diff options
author | Volker Kaiser <volker.kaiser@softwareschneiderei.de> | 2012-07-26 09:12:00 +0200 |
---|---|---|
committer | Volker Kaiser <volker.kaiser@softwareschneiderei.de> | 2012-07-26 15:36:43 +0200 |
commit | 67e3daeb2ad9d9835c4e19a1edd744cba92b83d1 (patch) | |
tree | 4a9c378753244c45d6d25054e3f23295195d1b1b /src | |
parent | 9395f3ed8c69c7873c187d8a93b4755b685b3c96 (diff) | |
download | uca-67e3daeb2ad9d9835c4e19a1edd744cba92b83d1.tar.gz uca-67e3daeb2ad9d9835c4e19a1edd744cba92b83d1.tar.bz2 uca-67e3daeb2ad9d9835c4e19a1edd744cba92b83d1.tar.xz uca-67e3daeb2ad9d9835c4e19a1edd744cba92b83d1.zip |
SCHNEIDE-255 (ROI support basler)
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 12 | ||||
-rw-r--r-- | src/cameras/pylon_camera.cpp | 35 | ||||
-rw-r--r-- | src/cameras/pylon_camera.h | 3 | ||||
-rw-r--r-- | src/cameras/uca-pylon-camera.c | 82 |
4 files changed, 105 insertions, 27 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 46bcfb2..931ca9b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -96,13 +96,13 @@ if (PYLON_FOUND) option(HAVE_PYLON_CAMERA "Camera: Pylon based (Basler)" ON) if (HAVE_PYLON_CAMERA) - set(uca_SRCS ${uca_SRCS} cameras/uca-pylon-camera.c cameras/pylon_camera.cpp) - set(uca_HDRS ${uca_HDRS} cameras/uca-pylon-camera.h) - set(uca_LIBS ${uca_LIBS} ${PYLON_LIBS}) - #list(APPEND cameras "Pylon") + list(APPEND uca_SRCS cameras/uca-pylon-camera.c cameras/pylon_camera.cpp) + list(APPEND uca_HDRS cameras/uca-pylon-camera.h) + list(APPEND cameras "Pylon") + set(uca_LIBS ${uca_LIBS} ${PYLON_LIBS}) - include_directories(${PYLON_INCLUDE_DIRS}) - link_directories(/opt/pylon/lib64) + include_directories(${PYLON_INCLUDE_DIRS}) + link_directories(/opt/pylon/lib64) endif() endif() 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; |