From cfdeec6fc8fabca7682c4c6fd2111b75fdfb527a Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Tue, 29 May 2012 16:27:41 +0200 Subject: Use ROI with (0,0) as starting coordinate --- src/cameras/uca-pco-camera.c | 55 ++++++++++++++++++++++++++++++++++++++++---- src/uca-camera.c | 12 +++++----- 2 files changed, 57 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/cameras/uca-pco-camera.c b/src/cameras/uca-pco-camera.c index fbbc613..852a4f9 100644 --- a/src/cameras/uca-pco-camera.c +++ b/src/cameras/uca-pco-camera.c @@ -540,6 +540,53 @@ static void uca_pco_camera_set_property(GObject *object, guint property_id, cons } break; + case PROP_ROI_X: + { + guint16 roi[4] = {0}; + pco_get_roi(priv->pco, roi); + + /* + * According to PCO specs, the image starts coordinates (1,1) + * rather than (0,0). Therefore we adjust the coordinates here. + */ + roi[0] = g_value_get_uint(value) + 1; + + if (pco_set_roi(priv->pco, roi) != PCO_NOERROR) + g_warning("Cannot set horizontal ROI position"); + } + break; + + case PROP_ROI_Y: + { + guint16 roi[4] = {0}; + pco_get_roi(priv->pco, roi); + roi[1] = g_value_get_uint(value) + 1; + + if (pco_set_roi(priv->pco, roi) != PCO_NOERROR) + g_warning("Cannot set vertical ROI position"); + } + break; + + case PROP_ROI_WIDTH: + { + guint16 roi[4] = {0}; + pco_get_roi(priv->pco, roi); + roi[2] = roi[0] + g_value_get_uint(value) - 1; + if (pco_set_roi(priv->pco, roi) != PCO_NOERROR) + g_warning("Cannot set ROI width"); + } + break; + + case PROP_ROI_HEIGHT: + { + guint16 roi[4] = {0}; + pco_get_roi(priv->pco, roi); + roi[3] = roi[1] + g_value_get_uint(value) - 1; + if (pco_set_roi(priv->pco, roi) != PCO_NOERROR) + g_warning("Cannot set ROI height"); + } + break; + case PROP_EXPOSURE_TIME: { const gdouble time = g_value_get_double(value); @@ -901,7 +948,7 @@ static void uca_pco_camera_get_property(GObject *object, guint property_id, GVal { guint16 roi[4] = {0}; pco_get_roi(priv->pco, roi); - g_value_set_uint(value, roi[0]); + g_value_set_uint(value, roi[0] - 1); } break; @@ -909,7 +956,7 @@ static void uca_pco_camera_get_property(GObject *object, guint property_id, GVal { guint16 roi[4] = {0}; pco_get_roi(priv->pco, roi); - g_value_set_uint(value, roi[1]); + g_value_set_uint(value, roi[1] - 1); } break; @@ -917,7 +964,7 @@ static void uca_pco_camera_get_property(GObject *object, guint property_id, GVal { guint16 roi[4] = {0}; pco_get_roi(priv->pco, roi); - g_value_set_uint(value, (roi[2] - roi[0])); + g_value_set_uint(value, (roi[2] - roi[0] + 1)); } break; @@ -925,7 +972,7 @@ static void uca_pco_camera_get_property(GObject *object, guint property_id, GVal { guint16 roi[4] = {0}; pco_get_roi(priv->pco, roi); - g_value_set_uint(value, (roi[3] - roi[1])); + g_value_set_uint(value, (roi[3] - roi[1] + 1)); } break; diff --git a/src/uca-camera.c b/src/uca-camera.c index ba7d912..dc7d8d7 100644 --- a/src/uca-camera.c +++ b/src/uca-camera.c @@ -254,29 +254,29 @@ static void uca_camera_class_init(UcaCameraClass *klass) g_param_spec_uint(uca_camera_props[PROP_ROI_X], "Horizontal coordinate", "Horizontal coordinate", - 1, G_MAXUINT, 1, - G_PARAM_READABLE); + 0, G_MAXUINT, 1, + G_PARAM_READWRITE); camera_properties[PROP_ROI_Y] = g_param_spec_uint(uca_camera_props[PROP_ROI_Y], "Vertical coordinate", "Vertical coordinate", - 1, G_MAXUINT, 1, - G_PARAM_READABLE); + 0, G_MAXUINT, 1, + G_PARAM_READWRITE); camera_properties[PROP_ROI_WIDTH] = g_param_spec_uint(uca_camera_props[PROP_ROI_WIDTH], "Width", "Width of the region of interest", 1, G_MAXUINT, 1, - G_PARAM_READABLE); + G_PARAM_READWRITE); camera_properties[PROP_ROI_HEIGHT] = g_param_spec_uint(uca_camera_props[PROP_ROI_HEIGHT], "Height", "Height of the region of interest", 1, G_MAXUINT, 1, - G_PARAM_READABLE); + G_PARAM_READWRITE); camera_properties[PROP_EXPOSURE_TIME] = g_param_spec_double(uca_camera_props[PROP_EXPOSURE_TIME], -- cgit v1.2.3