From 43829f61cb6ea65b55cc6a75c788a9cc0521217d Mon Sep 17 00:00:00 2001 From: Maria Date: Fri, 16 Aug 2013 17:28:43 +0200 Subject: Added Logarithmus. --- bin/gui/control.c | 48 +++- bin/gui/control.glade | 639 +++++++++++++++++++++++++++++++------------------- 2 files changed, 444 insertions(+), 243 deletions(-) (limited to 'bin/gui') diff --git a/bin/gui/control.c b/bin/gui/control.c index b895f91..69a2cda 100644 --- a/bin/gui/control.c +++ b/bin/gui/control.c @@ -59,6 +59,7 @@ typedef struct { GtkWidget *histogram_view; GtkToggleButton *histogram_button; + GtkToggleButton *log_button; GtkAdjustment *frame_slider; RingBuffer *buffer; @@ -83,9 +84,10 @@ down_scale (ThreadData *data, gpointer buffer) gdouble min; gdouble max; gdouble factor; + gdouble dval; guint8 *output; gint stride; - gint i = 0; + gint i = 0; egg_histogram_get_range (EGG_HISTOGRAM_VIEW (data->histogram_view), &min, &max); factor = 255.0 / (max - min); @@ -99,7 +101,13 @@ down_scale (ThreadData *data, gpointer buffer) gint offset = y * stride * data->width; for (gint x = 0; x < data->display_width; x++, offset += stride) { - gdouble dval = (input[offset] - min) * factor; + + if (gtk_toggle_button_get_active (data->log_button)) + { + dval = log((input[offset] - min) * factor); + } else { + dval = (input[offset] - min) * factor; + } guchar val = (guchar) CLAMP(dval, 0.0, 255.0); output[i++] = val; @@ -115,12 +123,19 @@ down_scale (ThreadData *data, gpointer buffer) gint offset = y * stride * data->width; for (gint x = 0; x < data->display_width; x++, offset += stride) { - gdouble dval = (input[offset] - min) * factor; + + if (gtk_toggle_button_get_active (data->log_button)) + { + dval = log((input[offset] - min) * factor); + } else { + dval = (input[offset] - min) * factor; + } guchar val = (guchar) CLAMP(dval, 0.0, 255.0); output[i++] = val; output[i++] = val; output[i++] = val; + } } } @@ -132,6 +147,7 @@ up_scale (ThreadData *data, gpointer buffer) gdouble min; gdouble max; gdouble factor; + gdouble dval; guint8 *output; gint i = 0; gint zoom; @@ -147,7 +163,13 @@ up_scale (ThreadData *data, gpointer buffer) for (gint y = 0; y < data->display_height; y++) { for (gint x = 0; x < data->display_width; x++) { gint offset = ((gint) (y / zoom) * data->width) + ((gint) (x / zoom)); - gdouble dval = (input[offset] - min) * factor; + + if (gtk_toggle_button_get_active (data->log_button)) + { + dval = log((input[offset] - min) * factor); + } else { + dval = (input[offset] - min) * factor; + } guchar val = (guchar) CLAMP(dval, 0.0, 255.0); output[i++] = val; @@ -162,7 +184,12 @@ up_scale (ThreadData *data, gpointer buffer) for (gint y = 0; y < data->display_height; y++) { for (gint x = 0; x < data->display_width; x++) { gint offset = ((gint) (y / zoom) * data->width) + ((gint) (x / zoom)); - gdouble dval = (input[offset] - min) * factor; + if (gtk_toggle_button_get_active (data->log_button)) + { + dval = log((input[offset] - min) * factor); + } else { + dval = (input[offset] - min) * factor; + } guchar val = (guchar) CLAMP(dval, 0.0, 255.0); output[i++] = val; @@ -215,8 +242,14 @@ get_statistics (ThreadData *data, gdouble *mean, gdouble *sigma, guint *_max, gu } } - *mean = sum / n; - *sigma = sqrt((squared_sum - sum*sum/n) / (n - 1)); + if (gtk_toggle_button_get_active (data->log_button)) + { + *mean = log(sum/n); + *sigma = log(sqrt((squared_sum - sum*sum/n) / (n - 1))); + } else { + *mean = sum / n; + *sigma = sqrt((squared_sum - sum*sum/n) / (n - 1)); + } *_min = min; *_max = max; } @@ -702,6 +735,7 @@ create_main_window (GtkBuilder *builder, const gchar* camera_name) td.record_button = GTK_WIDGET (gtk_builder_get_object (builder, "record-button")); td.download_button = GTK_WIDGET (gtk_builder_get_object (builder, "download-button")); td.histogram_button = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "histogram-checkbutton")); + td.log_button = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "logarithmus-checkbutton")); td.frame_slider = GTK_ADJUSTMENT (gtk_builder_get_object (builder, "frames-adjustment")); td.count = GTK_ADJUSTMENT (gtk_builder_get_object (builder, "acquisitions-adjustment")); diff --git a/bin/gui/control.glade b/bin/gui/control.glade index d4b663e..3467ed7 100644 --- a/bin/gui/control.glade +++ b/bin/gui/control.glade @@ -2,11 +2,9 @@ - - - - - + + 1 + 10 @@ -18,29 +16,269 @@ + + + + + + + + False + 6 + + + True + False + 2 + + + True + True + automatic + automatic + + + True + True + camera-types + False + 0 + + + Choose camera + + + + 0 + + + + + + + + + True + True + 0 + + + + + True + False + 6 + end + + + gtk-quit + False + True + True + True + True + + + + False + False + 0 + + + + + gtk-ok + False + True + True + True + True + + + False + False + 1 + + + + + False + True + 6 + 1 + + + + + + + 100 + 1 + 10 + 10 + + + False + 5 + normal + + + True + False + 2 + + + True + False + end + + + gtk-close + False + True + True + True + True + + + False + False + 0 + + + + + False + False + end + 0 + + + + + True + False + 10 + 6 + + + True + False + 0 + Downloading Frames … + + + False + False + 0 + + + + + True + False + download-adjustment + + + False + True + 1 + + + + + True + True + 1 + + + + + + download-close-button + + + + 100 + 0.01 + 10 + + + 1 + 10 + + + 65535 + 256 + 1 + 10 + + + 65535 + 1 + 10 + + + + + + + + + + + 400 % + 4 + + + 200 % + 2 + + + 100 % + 1 + + + 50 % + 0.5 + + + 25 % + 0.25 + + + + False Camera Control 1024 768 - + True + False True + False + False True + False _File True True + False gtk-new + False True + False True True @@ -48,7 +286,9 @@ gtk-open + False True + False True True @@ -56,7 +296,9 @@ gtk-save-as + False True + False True True @@ -64,15 +306,18 @@ True + False gtk-quit + False True + False True True - + @@ -81,16 +326,21 @@ + False True + False _Help True True + False gtk-about + False True + False True True @@ -102,15 +352,19 @@ False + True 0 True + False + False True + False Run True gtk-media-play @@ -122,7 +376,9 @@ + False True + False Record True gtk-media-record @@ -134,7 +390,9 @@ + False True + False Stop True gtk-media-stop @@ -146,7 +404,9 @@ + False True + False Download True network-receive @@ -159,6 +419,7 @@ False + True 1 @@ -178,10 +439,12 @@ True + False queue True + False gtk-missing-image @@ -196,6 +459,7 @@ True + False True @@ -204,10 +468,12 @@ True + False 12 True + False 0 Settings @@ -223,12 +489,14 @@ True + False 6 3 2 True + False 0 Exposure time: @@ -241,6 +509,7 @@ True + False 0 Acquire: @@ -255,27 +524,36 @@ True + False 6 True True + False + False + True + True exposure-adjustment 6 False + True 0 True + False 0 seconds + True + True 1 @@ -290,6 +568,7 @@ True + False 6 @@ -297,20 +576,28 @@ True 6 + False + False + True + True acquisitions-adjustment False + True 0 True + False 0 frames + True + True 1 @@ -326,6 +613,7 @@ Repeat + False True True False @@ -345,6 +633,7 @@ True False + False 6 @@ -352,19 +641,27 @@ True 6 + False + False + True + True False + True 0 True + False 0 times + True + True 1 @@ -381,12 +678,14 @@ False + True 1 True + False 0 0 6 @@ -404,6 +703,7 @@ True + False 0 12 @@ -416,6 +716,8 @@ + True + True 3 @@ -424,6 +726,7 @@ True + False Acquisition @@ -433,6 +736,7 @@ False + True 0 @@ -444,10 +748,12 @@ True + False 12 True + False 0 Histogram @@ -463,13 +769,16 @@ True + False 12 True + False True + False 0 Minimum: @@ -485,6 +794,10 @@ True True + False + False + True + True min-bin-value-adjustment @@ -497,6 +810,7 @@ True + False 0 Maximum: @@ -512,6 +826,10 @@ True True + False + False + True + True max-bin-value-adjustment @@ -535,6 +853,7 @@ Live Update + False True True False @@ -551,12 +870,15 @@ + True + True 1 True + False 12 2 2 @@ -565,6 +887,7 @@ True + False 0 Pixel counts: @@ -575,6 +898,7 @@ True + False 0 Distribution: @@ -587,44 +911,57 @@ True + False 6 True + False 0 µ = 0.0 + True + True 0 True + False 0 σ = 0.0 + True + True 1 True + False 0 min = 0 + True + True 2 True + False 0 max = 0 + True + True 3 @@ -640,6 +977,7 @@ True + False 0 0 @@ -650,6 +988,8 @@ + True + True 2 @@ -658,6 +998,7 @@ True + False Statistics @@ -667,6 +1008,7 @@ False + True 1 @@ -675,37 +1017,68 @@ True True - + True - 12 - 6 + False - + True - 0 - Zoom: + False + 12 + 6 + + + True + False + 0 + Zoom: + + + False + False + 0 + + + + + True + False + zoom-values + + + + 0 + + + + + False + False + 1 + + - False - False + True + True 0 - + + Logarithmus + False True - zoom-values - - - - 0 - - + True + False + 10 + 0 + True False False - 1 + 2 @@ -713,6 +1086,7 @@ True + False Preview @@ -744,6 +1118,7 @@ True + False Properties @@ -752,6 +1127,8 @@ + True + True 3 @@ -763,222 +1140,12 @@ + True + True 2 - - - - - - - - - - 400 % - 4 - - - 200 % - 2 - - - 100 % - 1 - - - 50 % - 0.5 - - - 25 % - 0.25 - - - - - 6 - - - True - 2 - - - True - True - automatic - automatic - - - True - True - camera-types - False - 0 - - - Choose camera - - - - 0 - - - - - - - - - 0 - - - - - True - 6 - end - - - gtk-quit - True - True - True - True - - - - False - False - 0 - - - - - gtk-ok - True - True - True - True - - - False - False - 1 - - - - - False - 6 - 1 - - - - - - - 65535 - 1 - 10 - - - 256 - 65535 - 1 - 10 - - - 1 - 10 - - - 5 - normal - - - True - 2 - - - True - 10 - 6 - - - True - 0 - Downloading Frames … - - - False - False - 0 - - - - - True - download-adjustment - - - False - 1 - - - - - 1 - - - - - True - end - - - gtk-close - True - True - True - True - - - False - False - 0 - - - - - False - False - end - 0 - - - - - - download-close-button - - - - 100 - 1 - 10 - 10 - - - 100 - 0.01 - 10 - - - 1 - 10 - -- cgit v1.2.3 From bbfec5e1eef0286df7315931238a9f588e265328 Mon Sep 17 00:00:00 2001 From: Maria Date: Thu, 19 Sep 2013 14:09:19 +0200 Subject: Added ROI. --- bin/gui/control.c | 124 ++++++++++++++++++++++++++++++++++++++------------ bin/gui/control.glade | 18 ++++++-- 2 files changed, 109 insertions(+), 33 deletions(-) (limited to 'bin/gui') diff --git a/bin/gui/control.c b/bin/gui/control.c index 69a2cda..504eb86 100644 --- a/bin/gui/control.c +++ b/bin/gui/control.c @@ -56,6 +56,10 @@ typedef struct { GtkWidget *download_close_button; GtkAdjustment *download_adjustment; GtkAdjustment *count; + GtkAdjustment *hadjustment, *vadjustment; + + GtkPaned *paned; + GtkRequisition child_requisition; GtkWidget *histogram_view; GtkToggleButton *histogram_button; @@ -65,6 +69,7 @@ typedef struct { RingBuffer *buffer; guchar *pixels; gint display_width, display_height; + gint page_width, page_height; gdouble zoom_factor; State state; guint n_recorded; @@ -76,7 +81,7 @@ typedef struct { } ThreadData; static UcaPluginManager *plugin_manager; -static gsize mem_size = 2048; +static gsize mem_size = 2048; static void down_scale (ThreadData *data, gpointer buffer) @@ -87,55 +92,80 @@ down_scale (ThreadData *data, gpointer buffer) gdouble dval; guint8 *output; gint stride; - gint i = 0; + gint i = 0; + gint start_wval; + gint start_hval; egg_histogram_get_range (EGG_HISTOGRAM_VIEW (data->histogram_view), &min, &max); factor = 255.0 / (max - min); output = data->pixels; stride = (gint) 1 / data->zoom_factor; + if (data->state == RUNNING) { + gint page_width = gtk_adjustment_get_page_size (GTK_ADJUSTMENT (data->hadjustment)); + gint page_height = gtk_adjustment_get_page_size (GTK_ADJUSTMENT (data->vadjustment)); + start_wval = gtk_adjustment_get_value (GTK_ADJUSTMENT (data->hadjustment)); + start_hval = gtk_adjustment_get_value (GTK_ADJUSTMENT (data->vadjustment)); + data->page_width = (page_width + start_wval); + data->page_height = (page_height + start_hval); + } else { + start_wval = 0; + start_hval = 0; + data->page_width = data->display_width; + data->page_height = data->display_height; + } + if (data->pixel_size == 1) { guint8 *input = (guint8 *) buffer; - for (gint y = 0; y < data->display_height; y++) { + for (gint y = 0; y < data->display_height; y++){ gint offset = y * stride * data->width; for (gint x = 0; x < data->display_width; x++, offset += stride) { - - if (gtk_toggle_button_get_active (data->log_button)) - { - dval = log((input[offset] - min) * factor); - } else { - dval = (input[offset] - min) * factor; + + if (y >= start_hval && y < data->page_height) { + if (x >= start_wval && x < data->page_width) { + + if (gtk_toggle_button_get_active (data->log_button)) + { + dval = log((input[offset] - min) * factor); + } else { + dval = (input[offset] - min) * factor; + } + } } guchar val = (guchar) CLAMP(dval, 0.0, 255.0); output[i++] = val; output[i++] = val; - output[i++] = val; + output[i++] = val; } } } else if (data->pixel_size == 2) { guint16 *input = (guint16 *) buffer; - for (gint y = 0; y < data->display_height; y++) { + for (gint y = 0; y < data->display_height; y++){ gint offset = y * stride * data->width; for (gint x = 0; x < data->display_width; x++, offset += stride) { - if (gtk_toggle_button_get_active (data->log_button)) - { - dval = log((input[offset] - min) * factor); - } else { - dval = (input[offset] - min) * factor; + if (y >= start_hval && y < data->page_height) { + if (x >= start_wval && x < data->page_width) { + + if (gtk_toggle_button_get_active (data->log_button)) + { + dval = log((input[offset] - min) * factor); + } else { + dval = (input[offset] - min) * factor; + } + } } guchar val = (guchar) CLAMP(dval, 0.0, 255.0); output[i++] = val; output[i++] = val; - output[i++] = val; - + output[i++] = val; } } } @@ -151,24 +181,45 @@ up_scale (ThreadData *data, gpointer buffer) guint8 *output; gint i = 0; gint zoom; + gint start_wval; + gint start_hval; egg_histogram_get_range (EGG_HISTOGRAM_VIEW (data->histogram_view), &min, &max); factor = 255.0 / (max - min); output = data->pixels; zoom = (gint) data->zoom_factor; + if (data->state == RUNNING) { + gint page_width = gtk_adjustment_get_page_size (GTK_ADJUSTMENT (data->hadjustment)); + gint page_height = gtk_adjustment_get_page_size (GTK_ADJUSTMENT (data->vadjustment)); + start_wval = gtk_adjustment_get_value (GTK_ADJUSTMENT (data->hadjustment)); + start_hval = gtk_adjustment_get_value (GTK_ADJUSTMENT (data->vadjustment)); + data->page_width = (page_width + start_wval); + data->page_height = (page_height + start_hval); + } else { + start_wval = 0; + start_hval = 0; + data->page_width = data->display_width; + data->page_height = data->display_height; + } + if (data->pixel_size == 1) { guint8 *input = (guint8 *) buffer; for (gint y = 0; y < data->display_height; y++) { for (gint x = 0; x < data->display_width; x++) { gint offset = ((gint) (y / zoom) * data->width) + ((gint) (x / zoom)); - - if (gtk_toggle_button_get_active (data->log_button)) - { - dval = log((input[offset] - min) * factor); - } else { - dval = (input[offset] - min) * factor; + + if (y >= start_hval && y < data->page_height) { + if (x >= start_wval && x < data->page_width) { + + if (gtk_toggle_button_get_active (data->log_button)) + { + dval = log((input[offset] - min) * factor); + } else { + dval = (input[offset] - min) * factor; + } + } } guchar val = (guchar) CLAMP(dval, 0.0, 255.0); @@ -184,17 +235,23 @@ up_scale (ThreadData *data, gpointer buffer) for (gint y = 0; y < data->display_height; y++) { for (gint x = 0; x < data->display_width; x++) { gint offset = ((gint) (y / zoom) * data->width) + ((gint) (x / zoom)); - if (gtk_toggle_button_get_active (data->log_button)) - { - dval = log((input[offset] - min) * factor); - } else { - dval = (input[offset] - min) * factor; + + if (y >= start_hval && y < data->page_height) { + if (x >= start_wval && x < data->page_width) { + + if (gtk_toggle_button_get_active (data->log_button)) + { + dval = log((input[offset] - min) * factor); + } else { + dval = (input[offset] - min) * factor; + } + } } guchar val = (guchar) CLAMP(dval, 0.0, 255.0); output[i++] = val; output[i++] = val; - output[i++] = val; + output[i++] = val; } } } @@ -308,6 +365,7 @@ update_pixbuf_dimensions (ThreadData *data) 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); @@ -351,6 +409,7 @@ preview_frames (void *args) gpointer buffer; buffer = ring_buffer_get_current_pointer (data->buffer); + uca_camera_trigger (data->camera, &error); uca_camera_grab (data->camera, buffer, &error); if (error == NULL) { @@ -739,6 +798,11 @@ create_main_window (GtkBuilder *builder, const gchar* camera_name) td.frame_slider = GTK_ADJUSTMENT (gtk_builder_get_object (builder, "frames-adjustment")); td.count = GTK_ADJUSTMENT (gtk_builder_get_object (builder, "acquisitions-adjustment")); + td.hadjustment = GTK_ADJUSTMENT (gtk_builder_get_object(builder, "adjustment1")); + td.vadjustment = GTK_ADJUSTMENT (gtk_builder_get_object(builder, "adjustment2")); + td.page_width = gtk_adjustment_get_page_size(GTK_ADJUSTMENT(td.hadjustment)); + td.page_height = gtk_adjustment_get_page_size(GTK_ADJUSTMENT(td.vadjustment)); + td.mean_label = GTK_LABEL (gtk_builder_get_object (builder, "mean-label")); td.sigma_label = GTK_LABEL (gtk_builder_get_object (builder, "sigma-label")); td.max_label = GTK_LABEL (gtk_builder_get_object (builder, "max-label")); diff --git a/bin/gui/control.glade b/bin/gui/control.glade index 3467ed7..e713371 100644 --- a/bin/gui/control.glade +++ b/bin/gui/control.glade @@ -6,6 +6,16 @@ 1 10 + + 100 + 1 + 10 + + + 100 + 1 + 10 + @@ -252,7 +262,7 @@ False Camera Control 1024 - 768 + 767 @@ -434,6 +444,8 @@ 480 True True + adjustment1 + adjustment2 automatic automatic @@ -452,8 +464,8 @@ - True - True + False + False -- cgit v1.2.3 From 081bbb4d5959c4999993fd2e2ce9298b9dfaa12c Mon Sep 17 00:00:00 2001 From: Maria Date: Thu, 19 Sep 2013 15:53:11 +0200 Subject: Fixed faster zoom. --- bin/gui/control.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'bin/gui') diff --git a/bin/gui/control.c b/bin/gui/control.c index 504eb86..069b825 100644 --- a/bin/gui/control.c +++ b/bin/gui/control.c @@ -588,7 +588,7 @@ on_start_button_clicked (GtkWidget *widget, ThreadData *data) } static void -on_stop_button_clicked (GtkWidget *widget, ThreadData *data) +on_stop_button_clicked (GtkWidget *widget, ThreadData *data, GtkAdjustment *adjustment) { GError *error = NULL; @@ -597,6 +597,8 @@ on_stop_button_clicked (GtkWidget *widget, ThreadData *data) set_tool_button_state (data); uca_camera_stop_recording (data->camera, &error); + on_frame_slider_changed (adjustment, data); + if (error != NULL) g_printerr ("Failed to stop: %s\n", error->message); -- cgit v1.2.3