diff options
author | Matthias Vogelgesang <matthias.vogelgesang@kit.edu> | 2012-07-11 14:34:02 +0200 |
---|---|---|
committer | Matthias Vogelgesang <matthias.vogelgesang@gmail.com> | 2012-07-11 15:35:30 +0200 |
commit | a76a2cc8d881b239e7f07a3b04a15bb66d4aa1f8 (patch) | |
tree | edf07aa0208938e3b8ec9083a9e0cb38818dfa17 | |
parent | 6c5ffb341a917fcc7dd2bf499f5951d1ccbb656e (diff) | |
download | libuca-a76a2cc8d881b239e7f07a3b04a15bb66d4aa1f8.tar.gz libuca-a76a2cc8d881b239e7f07a3b04a15bb66d4aa1f8.tar.bz2 libuca-a76a2cc8d881b239e7f07a3b04a15bb66d4aa1f8.tar.xz libuca-a76a2cc8d881b239e7f07a3b04a15bb66d4aa1f8.zip |
Scale automatically and fix some warnings with UFO
-rw-r--r-- | src/cameras/uca-ufo-camera.c | 3 | ||||
-rw-r--r-- | test/control.c | 52 | ||||
-rw-r--r-- | test/grab.c | 2 |
3 files changed, 30 insertions, 27 deletions
diff --git a/src/cameras/uca-ufo-camera.c b/src/cameras/uca-ufo-camera.c index ec7dae1..63faaf8 100644 --- a/src/cameras/uca-ufo-camera.c +++ b/src/cameras/uca-ufo-camera.c @@ -74,6 +74,7 @@ static gint base_overrideables[] = { PROP_ROI_HEIGHT_MULTIPLIER, PROP_HAS_STREAMING, PROP_HAS_CAMRAM_RECORDING, + PROP_TRIGGER_MODE, 0, }; @@ -285,6 +286,8 @@ static void uca_ufo_camera_get_property(GObject *object, guint property_id, GVal case PROP_NAME: g_value_set_string(value, "Ufo Camera w/ CMOSIS CMV2000"); break; + case PROP_TRIGGER_MODE: + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); break; diff --git a/test/control.c b/test/control.c index aa79c67..1e07eb5 100644 --- a/test/control.c +++ b/test/control.c @@ -61,7 +61,7 @@ enum { }; -void convert_8bit_to_rgb(guchar *output, guchar *input, int width, int height) +static void convert_8bit_to_rgb(guchar *output, guchar *input, int width, int height) { for (int i = 0, j = 0; i < width*height; i++) { output[j++] = input[i]; @@ -70,34 +70,33 @@ void convert_8bit_to_rgb(guchar *output, guchar *input, int width, int height) } } -void convert_16bit_to_rgb(guchar *output, guchar *input, int width, int height, float scale) +static void convert_16bit_to_rgb(guchar *output, guchar *input, int width, int height) { guint16 *in = (guint16 *) input; - for (int i = 0, j = 0; i < width*height; i++) { - guchar val = (guint8) ((in[i]/scale)*256.0f); - output[j++] = val; - output[j++] = val; - output[j++] = val; + guint16 min = G_MAXUINT16, max = 0; + gfloat spread = 0.0f; + + for (int i = 0; i < width * height; i++) { + guint16 v = in[i]; + if (v < min) + min = v; + if (v > max) + max = v; } -} -void reallocate_buffers(ThreadData *td, int width, int height) -{ - const size_t num_bytes = width * height * td->pixel_size; - - g_object_unref(td->pixbuf); - g_free(td->buffer); - - td->pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, width, height); - td->buffer = (guchar *) g_malloc(num_bytes); - td->width = width; - td->height = height; - td->pixels = gdk_pixbuf_get_pixels(td->pixbuf); - gtk_image_set_from_pixbuf(GTK_IMAGE(td->image), td->pixbuf); - memset(td->buffer, 0, num_bytes); + spread = (gfloat) max - min; + + if (spread > 0.0f) { + for (int i = 0, j = 0; i < width*height; i++) { + guchar val = (guint8) (((in[i] - min) / spread) * 255.0f); + output[j++] = val; + output[j++] = val; + output[j++] = val; + } + } } -void *grab_thread(void *args) +static void *grab_thread(void *args) { ThreadData *data = (ThreadData *) args; gchar filename[FILENAME_MAX] = {0,}; @@ -117,8 +116,9 @@ void *grab_thread(void *args) * just do nothing if it is an already displayed one. */ if (data->pixel_size == 1) convert_8bit_to_rgb(data->pixels, data->buffer, data->width, data->height); - else if (data->pixel_size == 2) - convert_16bit_to_rgb(data->pixels, data->buffer, data->width, data->height, data->scale); + else if (data->pixel_size == 2) { + convert_16bit_to_rgb(data->pixels, data->buffer, data->width, data->height); + } gdk_threads_enter(); gdk_flush(); @@ -232,7 +232,7 @@ static void create_main_window(GtkBuilder *builder, const gchar* camera_name) GdkPixbuf *pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, td.width, td.height); gtk_image_set_from_pixbuf(GTK_IMAGE(image), pixbuf); - td.pixel_size = bits_per_sample == 16 ? 2 : 1; + td.pixel_size = bits_per_sample > 8 ? 2 : 1; td.image = image; td.pixbuf = pixbuf; td.buffer = (guchar *) g_malloc(td.pixel_size * td.width * td.height); diff --git a/test/grab.c b/test/grab.c index e34cf1a..a4d4aa3 100644 --- a/test/grab.c +++ b/test/grab.c @@ -79,7 +79,7 @@ int main(int argc, char *argv[]) NULL); g_object_set(G_OBJECT(camera), - "exposure-time", 0.1, + "exposure-time", 0.001, "roi-x0", 0, "roi-y0", 0, "roi-width", 1000, |