|
@@ -1,25 +1,60 @@
|
|
|
#include <ufo/ufo.h>
|
|
|
-#include <stdio.h>
|
|
|
+#include <stdlib.h>
|
|
|
#include "piv-scheduler.h"
|
|
|
#include "piv-nodes.h"
|
|
|
#include "piv-ufo-base.h"
|
|
|
|
|
|
-int main (void)
|
|
|
+static void
|
|
|
+check_error (GError *error)
|
|
|
+{
|
|
|
+ if (error != NULL) {
|
|
|
+ g_print ("Error reading configuration: %s\n", error->message);
|
|
|
+ exit (1);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+int
|
|
|
+main (int argc, char *argv[])
|
|
|
{
|
|
|
struct piv_nodes piv;
|
|
|
struct piv_ufo_base piv_base;
|
|
|
+ GOptionContext *context;
|
|
|
+ GKeyFile *key_file;
|
|
|
+ GError *error = NULL;
|
|
|
+ static gchar *key_file_name = NULL;
|
|
|
+
|
|
|
+ static GOptionEntry entries[] = {
|
|
|
+ { "config", 'c', 0, G_OPTION_ARG_STRING, &key_file_name, "Configuration file name (default piv.cfg)", "FILE" },
|
|
|
+ { NULL }
|
|
|
+ };
|
|
|
|
|
|
#if !(GLIB_CHECK_VERSION (2, 36, 0))
|
|
|
g_type_init ();
|
|
|
#endif
|
|
|
|
|
|
+ context = g_option_context_new (NULL);
|
|
|
+ g_option_context_add_main_entries (context, entries, NULL);
|
|
|
+
|
|
|
+ if (!g_option_context_parse (context, &argc, &argv, &error)) {
|
|
|
+ g_print ("Failed parsing arguments: %s\n", error->message);
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!key_file_name)
|
|
|
+ key_file_name = "piv.cfg";
|
|
|
+
|
|
|
piv_ufo_base_init(&piv_base);
|
|
|
piv_nodes_init(&piv, &piv_base);
|
|
|
+
|
|
|
if (piv_base.error)
|
|
|
- printf("Error %s\n", piv_base.error->message);
|
|
|
+ g_print ("Error %s\n", piv_base.error->message);
|
|
|
|
|
|
- /* This file include all the configurations that can be passed to the
|
|
|
- * plugins */
|
|
|
+ key_file = g_key_file_new ();
|
|
|
+
|
|
|
+ if (!g_key_file_load_from_file (key_file, key_file_name, G_KEY_FILE_NONE, &error)) {
|
|
|
+ g_print ("Error loading `%s': %s", key_file_name, error->message);
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
|
|
|
/*********************/
|
|
|
/* CONFIGURATION *****/
|
|
@@ -27,7 +62,49 @@ int main (void)
|
|
|
UfoTaskNode *global_reader;
|
|
|
global_reader = ufo_plugin_manager_get_task (piv_base.manager, "read", &piv_base.error);
|
|
|
|
|
|
-#include "config.h"
|
|
|
+ gchar *input_path = g_key_file_get_string (key_file, "input", "path", &error);
|
|
|
+ check_error (error);
|
|
|
+
|
|
|
+ guint scale = (guint) g_key_file_get_integer (key_file, "input", "scale", &error);
|
|
|
+ check_error (error);
|
|
|
+
|
|
|
+ g_object_set (G_OBJECT (global_reader), "path", input_path, NULL);
|
|
|
+ g_object_set (G_OBJECT (piv.writer), "filename", "res%i.tif", NULL);
|
|
|
+ g_object_set (G_OBJECT (piv.ringwriter), "filename", "results", NULL);
|
|
|
+
|
|
|
+ g_object_set (G_OBJECT (piv.denoise), "matrix_size",
|
|
|
+ g_key_file_get_integer (key_file, "input", "matrix_size", &error) / scale, NULL);
|
|
|
+ check_error (error);
|
|
|
+
|
|
|
+ g_object_set (G_OBJECT (piv.contrast), "remove_high",
|
|
|
+ g_key_file_get_boolean (key_file, "input", "remove_high_intensity_pixels", &error), NULL);
|
|
|
+ check_error (error);
|
|
|
+
|
|
|
+ guint ring_start = ((guint) g_key_file_get_integer (key_file, "ring", "start", &error)) / scale;
|
|
|
+ check_error (error);
|
|
|
+
|
|
|
+ guint ring_end = ((guint) g_key_file_get_integer (key_file, "ring", "end", &error)) / scale;
|
|
|
+ check_error (error);
|
|
|
+
|
|
|
+ guint ring_step = ((guint) g_key_file_get_integer (key_file, "ring", "step", &error)) / scale;
|
|
|
+ check_error (error);
|
|
|
+
|
|
|
+ g_object_set (G_OBJECT (piv.ring_pattern),
|
|
|
+ "ring_start", ring_start,
|
|
|
+ "ring_end", ring_end,
|
|
|
+ "ring_step", ring_step, NULL);
|
|
|
+
|
|
|
+ g_object_set (G_OBJECT (piv.ring_pattern), "ring_thickness",
|
|
|
+ g_key_file_get_integer (key_file, "ring", "thickness", &error) / scale, NULL);
|
|
|
+ check_error (error);
|
|
|
+
|
|
|
+ g_object_set (G_OBJECT (piv.ring_pattern), "width",
|
|
|
+ g_key_file_get_integer (key_file, "ring", "width", &error) / scale, NULL);
|
|
|
+ check_error (error);
|
|
|
+
|
|
|
+ g_object_set (G_OBJECT (piv.ring_pattern), "height",
|
|
|
+ g_key_file_get_integer (key_file, "ring", "height", &error) / scale, NULL);
|
|
|
+ check_error (error);
|
|
|
|
|
|
g_object_set (G_OBJECT (piv.ringwriter), "scale", scale, NULL);
|
|
|
|
|
@@ -40,12 +117,46 @@ int main (void)
|
|
|
g_object_set (G_OBJECT (piv.dump_ring), "scale", scale, NULL);
|
|
|
|
|
|
/* Does not need user configuration */
|
|
|
- unsigned number_of_rings = (ring_end - ring_start) / ring_step + 1;
|
|
|
- g_object_set (G_OBJECT (piv.duplicater), "dup_count", number_of_rings,
|
|
|
- NULL);
|
|
|
+ guint number_of_rings = (ring_end - ring_start) / ring_step + 1;
|
|
|
+ g_object_set (G_OBJECT (piv.duplicater), "dup_count", number_of_rings, NULL);
|
|
|
g_object_set (G_OBJECT (piv.concatenate_result), "ring_count", number_of_rings, NULL);
|
|
|
g_object_set (G_OBJECT (piv.loop_ringfft), "loop", 1, NULL);
|
|
|
- g_object_set (G_OBJECT (piv.loop_ringfft), "dup_count", number_of_images, NULL);
|
|
|
+
|
|
|
+ g_object_set (G_OBJECT (piv.loop_ringfft), "dup_count",
|
|
|
+ g_key_file_get_integer (key_file, "input", "num_images", &error), NULL);
|
|
|
+ check_error (error);
|
|
|
+
|
|
|
+ g_object_set (G_OBJECT (piv.concatenate_result), "max_count",
|
|
|
+ g_key_file_get_integer (key_file, "ring", "max_count", &error), NULL);
|
|
|
+ check_error (error);
|
|
|
+
|
|
|
+ g_object_set (G_OBJECT (piv.filter_particle), "min",
|
|
|
+ g_key_file_get_double (key_file, "filter", "min", &error), NULL);
|
|
|
+ check_error (error);
|
|
|
+
|
|
|
+ g_object_set (G_OBJECT (piv.filter_particle), "threshold",
|
|
|
+ g_key_file_get_double (key_file, "filter", "threshold", &error), NULL);
|
|
|
+ check_error (error);
|
|
|
+
|
|
|
+ g_object_set (G_OBJECT (piv.get_dup_circ), "threshold",
|
|
|
+ g_key_file_get_double (key_file, "dup", "threshold", &error) / scale, NULL);
|
|
|
+ check_error (error);
|
|
|
+
|
|
|
+ g_object_set (G_OBJECT (piv.remove_circle), "threshold",
|
|
|
+ g_key_file_get_double (key_file, "remove", "threshold", &error) / scale, NULL);
|
|
|
+ check_error (error);
|
|
|
+
|
|
|
+ g_object_set (G_OBJECT (piv.multi_search), "radii_range",
|
|
|
+ g_key_file_get_integer (key_file, "radii", "range", &error) / scale, NULL);
|
|
|
+ check_error (error);
|
|
|
+
|
|
|
+ g_object_set (G_OBJECT (piv.multi_search), "threshold",
|
|
|
+ g_key_file_get_double (key_file, "radii", "threshold", &error), NULL);
|
|
|
+ check_error (error);
|
|
|
+
|
|
|
+ g_object_set (G_OBJECT (piv.multi_search), "displacement",
|
|
|
+ g_key_file_get_integer (key_file, "radii", "displacement", &error) / scale, NULL);
|
|
|
+ check_error (error);
|
|
|
|
|
|
/*********************/
|
|
|
/* GRAPH SETUP *******/
|
|
@@ -57,10 +168,13 @@ int main (void)
|
|
|
g_print("Main : No GPUs found\n");
|
|
|
return 1;
|
|
|
}
|
|
|
+
|
|
|
g_print("Main : Connecting nodes %p\n", it->data);
|
|
|
piv_nodes_set_gpu(&piv, it->data);
|
|
|
piv_nodes = g_list_append(piv_nodes, &piv);
|
|
|
- piv_ufo_base_connect(&piv_base, &piv, scale, dump_ring_to_image, global_reader);
|
|
|
+ piv_ufo_base_connect (&piv_base, &piv, scale,
|
|
|
+ g_key_file_get_boolean (key_file, "output", "dump_ring_to_image", &error), global_reader);
|
|
|
+ check_error (error);
|
|
|
|
|
|
// Graph expansion for usage of multiple GPUs. Uncomment lines when UFO
|
|
|
// supports calling plug-ins on demand
|
|
@@ -81,9 +195,13 @@ int main (void)
|
|
|
/*********************/
|
|
|
|
|
|
piv_ufo_base_unref(&piv_base);
|
|
|
+
|
|
|
for (it = piv_nodes; it; it = it->next)
|
|
|
piv_nodes_unref(it->data);
|
|
|
+
|
|
|
g_object_unref (global_reader);
|
|
|
+ g_option_context_free (context);
|
|
|
+ g_key_file_free (key_file);
|
|
|
|
|
|
return 0;
|
|
|
}
|