summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMihael Koep <koep@schneide.com>2015-03-17 11:22:18 +0100
committerMihael Koep <koep@schneide.com>2015-05-18 17:26:53 +0200
commitf2436c659242ccf0d5bb30a59b81cef8ee0aae99 (patch)
treefdcb4ea82b0b5398d2cf19988948fbd02d0547b7
parent8c75b713ed6b1551af89a6ec31062b00fa8218f1 (diff)
downloaduca-f2436c659242ccf0d5bb30a59b81cef8ee0aae99.tar.gz
uca-f2436c659242ccf0d5bb30a59b81cef8ee0aae99.tar.bz2
uca-f2436c659242ccf0d5bb30a59b81cef8ee0aae99.tar.xz
uca-f2436c659242ccf0d5bb30a59b81cef8ee0aae99.zip
Correct the ROI dimensions respecting the binning mode
Conflicts: plugins/dexela/changelog.txt
-rw-r--r--plugins/dexela/CMakeLists.txt2
-rw-r--r--plugins/dexela/changelog.txt4
-rw-r--r--plugins/dexela/uca-dexela-camera.c44
3 files changed, 42 insertions, 8 deletions
diff --git a/plugins/dexela/CMakeLists.txt b/plugins/dexela/CMakeLists.txt
index a62ee76..ba1ec2b 100644
--- a/plugins/dexela/CMakeLists.txt
+++ b/plugins/dexela/CMakeLists.txt
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 2.6)
project(ucadexela C)
-set(VERSION "1.3.2")
+set(VERSION "1.3.3")
find_package(DEXELA)
diff --git a/plugins/dexela/changelog.txt b/plugins/dexela/changelog.txt
index 5b44262..ea92265 100644
--- a/plugins/dexela/changelog.txt
+++ b/plugins/dexela/changelog.txt
@@ -1,3 +1,7 @@
+* Tue Mar 17 2015 Mihael Koep <mihael.koep@softwareschneiderei.de> 1.3.3-1
+- adjust the ROI depending on the binning
+* Wed Oct 8 2014 Mihael Koep <mihael.koep@softwareschneiderei.de> 1.3.2-2
+- new revision for libuca 1.6.0
* Tue Sep 16 2014 Mihael Koep <mihael.koep@softwareschneiderei.de> 1.3.2-1
- implement sensor pixel width and height properties
* Tue Sep 16 2014 Mihael Koep <mihael.koep@softwareschneiderei.de> 1.3.1-1
diff --git a/plugins/dexela/uca-dexela-camera.c b/plugins/dexela/uca-dexela-camera.c
index 378426a..3e22c06 100644
--- a/plugins/dexela/uca-dexela-camera.c
+++ b/plugins/dexela/uca-dexela-camera.c
@@ -166,6 +166,28 @@ static gboolean is_binning_allowed(UcaDexelaCameraPrivate *priv, guint binning)
return FALSE;
}
+static guint real_width(UcaDexelaCameraPrivate *priv)
+{
+ return priv->width / dexela_get_binning_mode_horizontal();
+}
+
+static guint real_height(UcaDexelaCameraPrivate *priv)
+{
+ return priv->height / dexela_get_binning_mode_vertical();
+}
+
+static void adjust_roi_width(UcaDexelaCameraPrivate *priv, guint requested_width)
+{
+ guint maxRoiWidth = real_width(priv) - priv->roi_x;
+ priv->roi_width = min(maxRoiWidth, requested_width);
+}
+
+static void adjust_roi_height(UcaDexelaCameraPrivate *priv, guint requested_height)
+{
+ guint maxRoiHeight = real_height(priv) - priv->roi_y;
+ priv->roi_height = min(maxRoiHeight, requested_height);
+}
+
static void uca_dexela_camera_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
{
UcaDexelaCameraPrivate *priv = UCA_DEXELA_CAMERA_GET_PRIVATE(object);
@@ -305,22 +327,28 @@ static void uca_dexela_camera_set_property(GObject *object, guint property_id, c
}
case PROP_ROI_X:
{
- priv->roi_x = g_value_get_uint(value);
+ guint maxRoiX = real_width(priv) - 1;
+ guint requestedRoiX = g_value_get_uint(value);
+ priv->roi_x = min(maxRoiX, requestedRoiX);
+ adjust_roi_width(priv, priv->roi_width);
break;
}
case PROP_ROI_Y:
{
- priv->roi_y = g_value_get_uint(value);
+ guint maxRoiY = real_height(priv) -1;
+ guint requestedRoiY = g_value_get_uint(value);
+ priv->roi_y = min(maxRoiY, requestedRoiY);
+ adjust_roi_height(priv, priv->roi_height);
break;
}
case PROP_ROI_WIDTH:
{
- priv->roi_width = g_value_get_uint(value);
+ adjust_roi_width(priv, g_value_get_uint(value));
break;
}
case PROP_ROI_HEIGHT:
{
- priv->roi_height = g_value_get_uint(value);
+ adjust_roi_height(priv, g_value_get_uint(value));
break;
}
case PROP_SENSOR_HORIZONTAL_BINNING:
@@ -331,6 +359,7 @@ static void uca_dexela_camera_set_property(GObject *object, guint property_id, c
return;
}
dexela_set_binning_mode(horizontalBinning, horizontalBinning);
+ adjust_roi_width(priv, priv->roi_width);
break;
}
case PROP_SENSOR_VERTICAL_BINNING:
@@ -341,6 +370,7 @@ static void uca_dexela_camera_set_property(GObject *object, guint property_id, c
return;
}
dexela_set_binning_mode(verticalBinning, verticalBinning);
+ adjust_roi_height(priv, priv->roi_height);
break;
}
case PROP_GAIN_MODE:
@@ -404,7 +434,7 @@ static gboolean uca_dexela_camera_grab(UcaCamera *camera, gpointer data, GError
// TODO: wait for a signal from uca_camera_trigger()
}
guchar* fullFrame = dexela_grab();
- apply_software_roi(fullFrame, priv->width, priv->num_bytes, data, priv->roi_x, priv->roi_y, priv->roi_width, priv->roi_height);
+ apply_software_roi(fullFrame, real_width(priv), priv->num_bytes, data, priv->roi_x, priv->roi_y, priv->roi_width, priv->roi_height);
return TRUE;
}
@@ -484,8 +514,8 @@ static gboolean setup_dexela(UcaDexelaCameraPrivate *priv)
priv->height = dexela_get_height();
priv->roi_x = 0;
priv->roi_y = 0;
- priv->roi_width = priv->width;
- priv->roi_height = priv->height;
+ priv->roi_width = real_width(priv);
+ priv->roi_height = real_height(priv);
priv->num_bytes = 2;
return TRUE;
}