summaryrefslogtreecommitdiffstats
path: root/src/cameras
diff options
context:
space:
mode:
Diffstat (limited to 'src/cameras')
-rw-r--r--src/cameras/pylon_camera.cpp35
-rw-r--r--src/cameras/pylon_camera.h3
-rw-r--r--src/cameras/uca-pylon-camera.c82
3 files changed, 99 insertions, 21 deletions
diff --git a/src/cameras/pylon_camera.cpp b/src/cameras/pylon_camera.cpp
index 71aede4..b73bc18 100644
--- a/src/cameras/pylon_camera.cpp
+++ b/src/cameras/pylon_camera.cpp
@@ -150,6 +150,41 @@ void pylon_camera_get_bit_depth(guint* depth, GError** error)
}
}
+void pylon_camera_get_roi(guint16* roi_x, guint16* roi_y, guint16* roi_width, guint16* roi_height, GError** error)
+{
+ g_assert(pGrabber);
+ g_assert(roi_x);
+ g_assert(roi_y);
+ g_assert(roi_width);
+ g_assert(roi_height);
+ try
+ {
+ GrabAPI::ROI roi = pGrabber->get_roi();
+ *roi_x = roi.x;
+ *roi_y = roi.y;
+ *roi_width = roi.width;
+ *roi_height = roi.height;
+ }
+ catch (const yat::Exception& e)
+ {
+ yat_exception_to_gerror(e, error);
+ }
+}
+
+void pylon_camera_set_roi(guint16 roi_x, guint16 roi_y, guint16 roi_width, guint16 roi_height, GError** error)
+{
+ g_assert(pGrabber);
+ try
+ {
+ GrabAPI::ROI roi(roi_x, roi_y, roi_width, roi_height);
+ pGrabber->set_roi(roi);
+ }
+ catch (const yat::Exception& e)
+ {
+ yat_exception_to_gerror(e, error);
+ }
+}
+
void pylon_camera_start_acquision(GError** error)
{
g_assert(pGrabber);
diff --git a/src/cameras/pylon_camera.h b/src/cameras/pylon_camera.h
index 8a474aa..f5c7cdc 100644
--- a/src/cameras/pylon_camera.h
+++ b/src/cameras/pylon_camera.h
@@ -14,6 +14,9 @@ void pylon_camera_get_exposure_time(gdouble* exp_time, GError** error);
void pylon_camera_get_sensor_size(guint* width, guint* height, GError** error);
void pylon_camera_get_bit_depth(guint* depth, GError** error);
+void pylon_camera_get_roi(guint16* roi_x, guint16* roi_y, guint16* roi_width, guint16* roi_height, GError** error);
+void pylon_camera_set_roi(guint16 roi_x, guint16 roi_y, guint16 roi_width, guint16 roi_height, GError** error);
+
void pylon_camera_start_acquision(GError** error);
void pylon_camera_stop_acquision(GError** error);
void pylon_camera_grab(gpointer *data, GError** error);
diff --git a/src/cameras/uca-pylon-camera.c b/src/cameras/uca-pylon-camera.c
index 1bc8ee2..c8fa073 100644
--- a/src/cameras/uca-pylon-camera.c
+++ b/src/cameras/uca-pylon-camera.c
@@ -50,11 +50,11 @@ GQuark uca_pylon_camera_error_quark()
}
enum {
- PROP_NAME = N_BASE_PROPERTIES,
- N_PROPERTIES
+ N_PROPERTIES = N_BASE_PROPERTIES
};
static gint base_overrideables[] = {
+ PROP_NAME,
PROP_SENSOR_WIDTH,
PROP_SENSOR_HEIGHT,
PROP_SENSOR_BITDEPTH,
@@ -63,10 +63,10 @@ static gint base_overrideables[] = {
// PROP_SENSOR_VERTICAL_BINNING,
// PROP_SENSOR_VERTICAL_BINNINGS,
// PROP_SENSOR_MAX_FRAME_RATE,
-// PROP_ROI_X,
-// PROP_ROI_Y,
-// PROP_ROI_WIDTH,
-// PROP_ROI_HEIGHT,
+ PROP_ROI_X,
+ PROP_ROI_Y,
+ PROP_ROI_WIDTH,
+ PROP_ROI_HEIGHT,
// PROP_HAS_STREAMING,
// PROP_HAS_CAMRAM_RECORDING,
0
@@ -82,9 +82,22 @@ struct _UcaPylonCameraPrivate {
guint width;
guint height;
+ guint16 roi_x, roi_y;
+ guint16 roi_width, roi_height;
};
+static void pylon_get_roi(GObject *object, GError** error)
+{
+ UcaPylonCameraPrivate *priv = UCA_PYLON_CAMERA_GET_PRIVATE(object);
+ pylon_camera_get_roi(&priv->roi_x, &priv->roi_y, &priv->roi_width, &priv->roi_height, error);
+}
+
+static void pylon_set_roi(GObject *object, GError** error)
+{
+ UcaPylonCameraPrivate *priv = UCA_PYLON_CAMERA_GET_PRIVATE(object);
+ pylon_camera_set_roi(priv->roi_x, priv->roi_y, priv->roi_width, priv->roi_height, error);
+}
UcaPylonCamera *uca_pylon_camera_new(GError **error)
{
@@ -134,9 +147,39 @@ static void uca_pylon_camera_grab(UcaCamera *camera, gpointer *data, GError **er
static void uca_pylon_camera_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
{
- /*UcaPylonCameraPrivate *priv = UCA_PYLON_CAMERA_GET_PRIVATE(object);*/
+ UcaPylonCameraPrivate *priv = UCA_PYLON_CAMERA_GET_PRIVATE(object);
+ GError* error = NULL;
switch (property_id) {
+
+ case PROP_ROI_X:
+ {
+ priv->roi_x = g_value_get_uint(value);
+ pylon_set_roi(object, &error);
+ }
+ break;
+
+ case PROP_ROI_Y:
+ {
+ priv->roi_y = g_value_get_uint(value);
+ pylon_set_roi(object, &error);
+ }
+ break;
+
+ case PROP_ROI_WIDTH:
+ {
+ priv->roi_width = g_value_get_uint(value);
+ pylon_set_roi(object, &error);
+ }
+ break;
+
+ case PROP_ROI_HEIGHT:
+ {
+ priv->roi_height = g_value_get_uint(value);
+ pylon_set_roi(object, &error);
+ }
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
return;
@@ -183,44 +226,41 @@ static void uca_pylon_camera_get_property(GObject *object, guint property_id, GV
case PROP_HAS_CAMRAM_RECORDING:
g_value_set_boolean(value, priv->camera_description->has_camram);
break;
+ */
case PROP_ROI_X:
{
- guint16 roi[4] = {0};
- guint err = pylon_get_roi(priv->pylon, roi);
- g_value_set_uint(value, roi[0]);
+ pylon_get_roi(object, &error);
+ g_value_set_uint(value, priv->roi_x);
}
break;
case PROP_ROI_Y:
{
- guint16 roi[4] = {0};
- guint err = pylon_get_roi(priv->pylon, roi);
- g_value_set_uint(value, roi[1]);
+ pylon_get_roi(object, &error);
+ g_value_set_uint(value, priv->roi_y);
}
break;
case PROP_ROI_WIDTH:
{
- guint16 roi[4] = {0};
- guint err = pylon_get_roi(priv->pylon, roi);
- g_value_set_uint(value, (roi[2] - roi[0]));
+ pylon_get_roi(object, &error);
+ g_value_set_uint(value, priv->roi_width);
}
break;
case PROP_ROI_HEIGHT:
{
- guint16 roi[4] = {0};
- guint err = pylon_get_roi(priv->pylon, roi);
- g_value_set_uint(value, (roi[3] - roi[1]));
+ pylon_get_roi(object, &error);
+ g_value_set_uint(value, priv->roi_height);
}
break;
-*/
+
case PROP_NAME:
{
//char *name = NULL;
//pylon_get_name(priv->pylon, &name);
- g_value_set_string(value, "TestName");
+ g_value_set_string(value, "Pylon Camera");
//free(name);
}
break;