diff options
author | Matthias Vogelgesang <matthias.vogelgesang@ipe.fzk.de> | 2011-03-09 12:25:11 +0100 |
---|---|---|
committer | Matthias Vogelgesang <matthias.vogelgesang@ipe.fzk.de> | 2011-03-09 12:25:11 +0100 |
commit | 432d6083dd9cbe50579780c88206733776898e9d (patch) | |
tree | dad91a6469dfbe7d39cf946b57244fed602743ec | |
parent | cd7590bac56800586c4aadef077d1effe03b00c4 (diff) | |
download | uca-432d6083dd9cbe50579780c88206733776898e9d.tar.gz uca-432d6083dd9cbe50579780c88206733776898e9d.tar.bz2 uca-432d6083dd9cbe50579780c88206733776898e9d.tar.xz uca-432d6083dd9cbe50579780c88206733776898e9d.zip |
Set correct exposure. Use µs for all time-related units.
-rw-r--r-- | src/cameras/pf.c | 12 | ||||
-rw-r--r-- | src/uca.c | 8 | ||||
-rw-r--r-- | test/control.c | 43 |
3 files changed, 32 insertions, 31 deletions
diff --git a/src/cameras/pf.c b/src/cameras/pf.c index 65b7b6c..d32f62f 100644 --- a/src/cameras/pf.c +++ b/src/cameras/pf.c @@ -97,7 +97,7 @@ static uint32_t uca_pf_set_property(struct uca_camera_t *cam, enum uca_property_ if (pfDevice_SetProperty(0, t, &value) < 0) return UCA_ERR_PROP_VALUE_OUT_OF_RANGE; - cam->frame_height = *((uint32_t *) data); + cam->frame_height = value.value.i; break; case UCA_PROP_X_OFFSET: @@ -111,10 +111,10 @@ static uint32_t uca_pf_set_property(struct uca_camera_t *cam, enum uca_property_ break; case UCA_PROP_EXPOSURE: - if (grabber->set_property(grabber, FG_EXPOSURE, (uint32_t *) data) != UCA_NO_ERROR) - return UCA_ERR_PROP_VALUE_OUT_OF_RANGE; - - value.value.f = (float) *((uint32_t *) data); + /* I haven't found a specification but it looks like PF uses milli + * seconds. We also by-pass the frame grabber... */ + value.type = PF_FLOAT; + value.value.f = (float) *((uint32_t *) data) / 1000.0; if (pfDevice_SetProperty(0, t, &value) < 0) return UCA_ERR_PROP_VALUE_OUT_OF_RANGE; break; @@ -145,7 +145,7 @@ static uint32_t uca_pf_get_property(struct uca_camera_t *cam, enum uca_property_ break; case PF_FLOAT: - set_void(data, uint32_t, (uint32_t) floor(value.value.f+0.5)); + set_void(data, uint32_t, (uint32_t) floor((value.value.f * 1000.0)+0.5)); break; case PF_STRING: @@ -54,11 +54,11 @@ static struct uca_property_t property_map[UCA_PROP_LAST+1] = { { "Image.Offset.y.Max", uca_pixel, uca_uint32t, uca_read }, { "Image.Bitdepth", uca_bits, uca_uint32t, uca_read}, { "Time.Exposure", uca_us, uca_uint32t, uca_readwrite }, - { "Time.Exposure.Min", uca_ns, uca_uint32t, uca_read }, - { "Time.Exposure.Max", uca_ms, uca_uint32t, uca_read }, + { "Time.Exposure.Min", uca_us, uca_uint32t, uca_read }, + { "Time.Exposure.Max", uca_us, uca_uint32t, uca_read }, { "Time.Delay", uca_us, uca_uint32t, uca_readwrite }, - { "Time.Delay.Min", uca_ns, uca_uint32t, uca_read }, - { "Time.Delay.Max", uca_ms, uca_uint32t, uca_read }, + { "Time.Delay.Min", uca_us, uca_uint32t, uca_read }, + { "Time.Delay.Max", uca_us, uca_uint32t, uca_read }, { "Time.Framerate", uca_fps, uca_uint32t, uca_read }, { "Temperature.Sensor", uca_dc, uca_uint32t, uca_read }, { "Temperature.Camera", uca_dc, uca_uint32t, uca_read }, diff --git a/test/control.c b/test/control.c index 1eb7e0f..a8c7079 100644 --- a/test/control.c +++ b/test/control.c @@ -5,9 +5,9 @@ #include "uca.h" #include "uca-cam.h" -struct ThreadData { +typedef struct { guchar *buffer, *pixels; - gboolean run; + gboolean running; GtkWidget *image; GdkPixbuf *pixbuf; int width; @@ -15,12 +15,12 @@ struct ThreadData { int bits; struct uca_camera_t *cam; struct uca_t *uca; -}; +} ThreadData ; -struct ValueCellData { - struct ThreadData *thread_data; +typedef struct { + ThreadData *thread_data; GtkTreeStore *tree_store; -}; +} ValueCellData; enum { COLUMN_NAME = 0, @@ -63,17 +63,18 @@ static gboolean delete_event(GtkWidget *widget, GdkEvent *event, gpointer data) static void destroy(GtkWidget *widget, gpointer data) { - struct uca_t *uca = (struct uca_t *) data; - uca_destroy(uca); - gtk_main_quit (); + ThreadData *td = (ThreadData *) data; + td->running = FALSE; + uca_destroy(td->uca); + gtk_main_quit(); } void *grab_thread(void *args) { - struct ThreadData *data = (struct ThreadData *) args; + ThreadData *data = (ThreadData *) args; struct uca_camera_t *cam = data->cam; - while (data->run) { + while (data->running) { cam->grab(cam, (char *) data->buffer); if (data->bits == 8) convert_8bit_to_rgb(data->pixels, data->buffer, data->width, data->height); @@ -92,9 +93,9 @@ void *grab_thread(void *args) static void on_toolbutton_run_clicked(GtkWidget *widget, gpointer args) { - struct ThreadData *data = (struct ThreadData *) args; + ThreadData *data = (ThreadData *) args; GError *error = NULL; - data->run = TRUE; + data->running = TRUE; data->cam->start_recording(data->cam); if (!g_thread_create(grab_thread, data, FALSE, &error)) { g_printerr("Failed to create thread: %s\n", error->message); @@ -104,16 +105,16 @@ static void on_toolbutton_run_clicked(GtkWidget *widget, gpointer args) static void on_toolbutton_stop_clicked(GtkWidget *widget, gpointer args) { - struct ThreadData *data = (struct ThreadData *) args; - data->run = FALSE; + ThreadData *data = (ThreadData *) args; + data->running = FALSE; data->cam->stop_recording(data->cam); } static void on_valuecell_edited(GtkCellRendererText *renderer, gchar *path, gchar *new_text, gpointer data) { - struct ValueCellData *value_data = (struct ValueCellData *) data; + ValueCellData *value_data = (ValueCellData *) data; - if (value_data->thread_data->run) + if (value_data->thread_data->running) return; GtkTreeModel *tree_model = GTK_TREE_MODEL(value_data->tree_store); @@ -310,7 +311,7 @@ int main(int argc, char *argv[]) /* start grabbing and thread */ int pixel_size = bits_per_sample == 8 ? 1 : 2; - struct ThreadData td; + ThreadData td; uca_cam_alloc(cam, 20); td.image = image; td.pixbuf = pixbuf; @@ -321,12 +322,13 @@ int main(int argc, char *argv[]) td.bits = bits_per_sample; td.cam = cam; td.uca = uca; + td.running = FALSE; g_signal_connect(window, "delete-event", G_CALLBACK (delete_event), NULL); g_signal_connect(window, "destroy", - G_CALLBACK (destroy), uca); + G_CALLBACK (destroy), &td); g_signal_connect(GTK_WIDGET(gtk_builder_get_object(builder, "toolbutton_run")), "clicked", G_CALLBACK(on_toolbutton_run_clicked), &td); @@ -334,8 +336,7 @@ int main(int argc, char *argv[]) g_signal_connect(GTK_WIDGET(gtk_builder_get_object(builder, "toolbutton_stop")), "clicked", G_CALLBACK(on_toolbutton_stop_clicked), &td); - - struct ValueCellData value_cell_data; + ValueCellData value_cell_data; value_cell_data.thread_data = &td; value_cell_data.tree_store = tree_store; |