summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/benchmark.c11
-rw-r--r--tools/gen-doc.c83
-rw-r--r--tools/grab-async.c2
-rw-r--r--tools/grab.c4
-rw-r--r--tools/gui/control.c30
-rw-r--r--tools/perf-overhead.c2
6 files changed, 112 insertions, 20 deletions
diff --git a/tools/benchmark.c b/tools/benchmark.c
index bff8b50..0939d78 100644
--- a/tools/benchmark.c
+++ b/tools/benchmark.c
@@ -100,7 +100,8 @@ grab_frames_sync (UcaCamera *camera, gpointer buffer, guint n_frames)
uca_camera_start_recording (camera, &error);
for (guint i = 0; i < n_frames; i++) {
- uca_camera_grab(camera, &buffer, &error);
+ if (!uca_camera_grab (camera, buffer, &error))
+ g_warning ("Data stream ended");
if (error != NULL) {
g_warning ("Error grabbing frame %02i/%i: `%s'", i, n_frames, error->message);
@@ -115,8 +116,12 @@ grab_frames_sync (UcaCamera *camera, gpointer buffer, guint n_frames)
static void
grab_callback (gpointer data, gpointer user_data)
{
+ static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
guint *n_acquired_frames = user_data;
+
+ g_static_mutex_lock (&mutex);
*n_acquired_frames += 1;
+ g_static_mutex_unlock (&mutex);
}
static void
@@ -136,7 +141,6 @@ grab_frames_async (UcaCamera *camera, gpointer buffer, guint n_frames)
;
uca_camera_stop_recording (camera, &error);
-
}
static void
@@ -204,6 +208,7 @@ benchmark (UcaCamera *camera)
g_print ("# Sensor size: %ix%i\n", sensor_width, sensor_height);
g_print ("# ROI size: %ix%i\n", roi_width, roi_height);
g_print ("# Exposure time: %fs\n", exposure);
+ g_print ("# Bits: %i\n", bits);
/* Synchronous frame acquisition */
g_print ("# %-10s%-10s%-10s%-16s%-16s\n", "type", "n_frames", "n_runs", "frames/s", "MiB/s");
@@ -250,7 +255,7 @@ main (int argc, char *argv[])
g_log_set_handler (NULL, G_LOG_LEVEL_MASK, log_handler, log_channel);
manager = uca_plugin_manager_new ();
- camera = uca_plugin_manager_get_camera (manager, argv[1], &error);
+ camera = uca_plugin_manager_get_camera (manager, argv[1], &error, NULL);
if (camera == NULL) {
g_error ("Initialization: %s", error->message);
diff --git a/tools/gen-doc.c b/tools/gen-doc.c
index f555a5f..d27bdd8 100644
--- a/tools/gen-doc.c
+++ b/tools/gen-doc.c
@@ -67,9 +67,9 @@ print_property_toc (GParamSpec **pspecs, guint n_props)
g_print ("<h2>Properties</h2><ul id=\"toc\">");
for (guint i = 0; i < n_props; i++) {
- GParamSpec *pspec = pspecs[i];
+ GParamSpec *pspec = pspecs[i];
const gchar *name = g_param_spec_get_name (pspec);
-
+
g_print ("<li><code><a href=#%s>\"%s\"</a></code></li>", name, name);
}
@@ -77,21 +77,90 @@ print_property_toc (GParamSpec **pspecs, guint n_props)
}
static void
+print_value_info (GParamSpec *pspec)
+{
+ gchar *default_value = NULL;
+ GString *range = g_string_new("");
+
+#define MAKE_RANGE(spec_type, fmt) \
+ { \
+ spec_type *spec = (spec_type *) pspec; \
+ g_string_printf (range, \
+ fmt" &#8804; <em>%s</em> &#8804; "fmt, \
+ spec->minimum, \
+ g_param_spec_get_name (pspec), \
+ spec->maximum); \
+ default_value = g_strdup_printf (fmt, spec->default_value); \
+ }
+
+ switch (pspec->value_type) {
+ case G_TYPE_BOOLEAN:
+ {
+ GParamSpecBoolean *spec = (GParamSpecBoolean *) pspec;
+ default_value = spec->default_value ? g_strdup ("<code>TRUE</code>") : g_strdup ("<code>FALSE</code>");
+ }
+ break;
+
+ case G_TYPE_UINT:
+ MAKE_RANGE (GParamSpecUInt, "%i");
+ break;
+
+ case G_TYPE_FLOAT:
+ MAKE_RANGE (GParamSpecFloat, "%.1e");
+ break;
+
+ case G_TYPE_DOUBLE:
+ MAKE_RANGE (GParamSpecDouble, "%.1e");
+ break;
+ }
+
+#undef MAKE_RANGE
+
+ if (g_type_is_a (pspec->value_type, G_TYPE_ENUM)) {
+ GParamSpecEnum *spec = (GParamSpecEnum *) pspec;
+
+ if (spec->enum_class->n_values > 0) {
+ g_string_printf (range, "<table><tr><th>Enum name</th><th>Value</th>");
+
+ for (guint i = 0; i < spec->enum_class->n_values; i++) {
+ GEnumValue *v = &spec->enum_class->values[i];
+ g_string_append_printf (range,
+ "<tr><td><code>%s</code></td><td>%i</td></tr>",
+ v->value_name, v->value);
+ }
+
+ g_string_append_printf (range, "</table>");
+ }
+ }
+
+ if (range->len > 0)
+ g_print ("<p>Possible values: %s</p>", range->str);
+
+ if (default_value != NULL) {
+ g_print ("<p>Default value: %s</p>", default_value);
+ g_free (default_value);
+ }
+
+ g_string_free (range, TRUE);
+}
+
+static void
print_property_descriptions (GParamSpec **pspecs, guint n_props)
{
g_print ("<h2>Details</h2><dl>");
for (guint i = 0; i < n_props; i++) {
- GParamSpec *pspec = pspecs[i];
+ GParamSpec *pspec = pspecs[i];
const gchar *name = g_param_spec_get_name (pspec);
g_print ("<dt id=\"%s\"><a href=\"#toc\">%s</a></dt>\n", name, name);
g_print ("<dd>");
- g_print ("<pre><code class=\"prop-type\">\"%s\" : %s : %s</code></pre>\n",
- name,
+ g_print ("<pre><code class=\"prop-type\">\"%s\" : %s : %s</code></pre>\n",
+ name,
g_type_name (pspec->value_type),
get_flags_description (pspec));
g_print ("<p>%s</p>\n", g_param_spec_get_blurb (pspec));
+ print_value_info (pspec);
g_print ("</dd>");
}
@@ -104,7 +173,7 @@ print_properties (UcaCamera *camera)
GObjectClass *oclass;
GParamSpec **pspecs;
guint n_props;
-
+
oclass = G_OBJECT_GET_CLASS (camera);
pspecs = g_object_class_list_properties (oclass, &n_props);
@@ -136,7 +205,7 @@ int main(int argc, char *argv[])
}
else {
name = argv[1];
- camera = uca_plugin_manager_get_camera (manager, name, &error);
+ camera = uca_plugin_manager_get_camera (manager, name, &error, NULL);
}
if (camera == NULL) {
diff --git a/tools/grab-async.c b/tools/grab-async.c
index 2c4bf04..00f2879 100644
--- a/tools/grab-async.c
+++ b/tools/grab-async.c
@@ -94,7 +94,7 @@ main(int argc, char *argv[])
}
manager = uca_plugin_manager_new ();
- camera = uca_plugin_manager_get_camera (manager, argv[1], &error);
+ camera = uca_plugin_manager_get_camera (manager, argv[1], &error, NULL);
if (camera == NULL) {
g_print("Error during initialization: %s\n", error->message);
diff --git a/tools/grab.c b/tools/grab.c
index 1518997..e8e91be 100644
--- a/tools/grab.c
+++ b/tools/grab.c
@@ -75,7 +75,7 @@ int main(int argc, char *argv[])
}
manager = uca_plugin_manager_new ();
- camera = uca_plugin_manager_get_camera (manager, argv[1], &error);
+ camera = uca_plugin_manager_get_camera (manager, argv[1], &error, NULL);
if (camera == NULL) {
g_print("Error during initialization: %s\n", error->message);
@@ -127,7 +127,7 @@ int main(int argc, char *argv[])
while (counter < 5) {
g_print(" grab frame ... ");
g_timer_start(timer);
- uca_camera_grab(camera, &buffer, &error);
+ uca_camera_grab(camera, buffer, &error);
if (error != NULL) {
g_print("\nError: %s\n", error->message);
diff --git a/tools/gui/control.c b/tools/gui/control.c
index f74e0f1..c177f07 100644
--- a/tools/gui/control.c
+++ b/tools/gui/control.c
@@ -135,6 +135,8 @@ update_pixbuf_dimensions (ThreadData *data)
if (data->pixbuf != NULL)
g_object_unref (data->pixbuf);
+ data->display_width = (gint) data->width * data->zoom_factor;
+ data->display_height = (gint) data->height * data->zoom_factor;
data->pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, data->display_width, data->display_height);
data->pixels = gdk_pixbuf_get_pixels (data->pixbuf);
gtk_image_set_from_pixbuf (GTK_IMAGE (data->image), data->pixbuf);
@@ -159,7 +161,8 @@ preview_frames (void *args)
gpointer buffer;
buffer = ring_buffer_get_current_pointer (data->buffer);
- uca_camera_grab (data->camera, &buffer, &error);
+ uca_camera_trigger (data->camera, &error);
+ uca_camera_grab (data->camera, buffer, &error);
if (error == NULL) {
convert_grayscale_to_rgb (data, buffer);
@@ -189,7 +192,7 @@ record_frames (gpointer args)
while (data->state == RECORDING) {
buffer = ring_buffer_get_current_pointer (data->buffer);
- uca_camera_grab (data->camera, &buffer, NULL);
+ uca_camera_grab (data->camera, buffer, NULL);
if (error == NULL) {
ring_buffer_proceed (data->buffer);
@@ -343,7 +346,7 @@ download_frames (ThreadData *data)
while (error == NULL) {
buffer = ring_buffer_get_current_pointer (data->buffer);
- uca_camera_grab (data->camera, &buffer, &error);
+ uca_camera_grab (data->camera, buffer, &error);
ring_buffer_proceed (data->buffer);
gdk_threads_enter ();
gtk_adjustment_set_value (data->download_adjustment, current_frame++);
@@ -415,13 +418,25 @@ on_zoom_changed (GtkComboBox *widget, ThreadData *data)
gtk_combo_box_get_active_iter (widget, &iter);
gtk_tree_model_get (model, &iter, FACTOR_COLUMN, &factor, -1);
- data->display_width = (gint) data->width * factor;
- data->display_height = (gint) data->height * factor;
data->zoom_factor = factor;
update_pixbuf_dimensions (data);
}
static void
+on_roi_width_changed (GObject *object, GParamSpec *pspec, ThreadData *data)
+{
+ g_object_get (object, "roi-width", &data->width, NULL);
+ update_pixbuf_dimensions (data);
+}
+
+static void
+on_roi_height_changed (GObject *object, GParamSpec *pspec, ThreadData *data)
+{
+ g_object_get (object, "roi-height", &data->height, NULL);
+ update_pixbuf_dimensions (data);
+}
+
+static void
create_main_window (GtkBuilder *builder, const gchar* camera_name)
{
static ThreadData td;
@@ -442,7 +457,7 @@ create_main_window (GtkBuilder *builder, const gchar* camera_name)
guint width, height;
GError *error = NULL;
- camera = uca_plugin_manager_get_camera (plugin_manager, camera_name, &error);
+ camera = uca_plugin_manager_get_camera (plugin_manager, camera_name, &error, NULL);
if ((camera == NULL) || (error != NULL)) {
g_error ("%s\n", error->message);
@@ -455,6 +470,9 @@ create_main_window (GtkBuilder *builder, const gchar* camera_name)
"sensor-bitdepth", &bits_per_sample,
NULL);
+ g_signal_connect (camera, "notify::roi-width", (GCallback) on_roi_width_changed, &td);
+ g_signal_connect (camera, "notify::roi-height", (GCallback) on_roi_height_changed, &td);
+
histogram_view = egg_histogram_view_new ();
property_tree_view = egg_property_tree_view_new (G_OBJECT (camera));
property_window = GTK_CONTAINER (gtk_builder_get_object (builder, "property-window"));
diff --git a/tools/perf-overhead.c b/tools/perf-overhead.c
index 6735e6f..7661dbc 100644
--- a/tools/perf-overhead.c
+++ b/tools/perf-overhead.c
@@ -163,7 +163,7 @@ main (int argc, char *argv[])
}
manager = uca_plugin_manager_new ();
- camera = uca_plugin_manager_get_camera (manager, argv[1], &error);
+ camera = uca_plugin_manager_get_camera (manager, argv[1], &error, NULL);
if (camera == NULL) {
g_print ("Error during initialization: %s\n", error->message);