summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMihael Koep <koep@schneide.com>2014-04-09 12:09:54 +0200
committerMihael Koep <koep@schneide.com>2014-04-09 12:21:19 +0200
commit0e4338b82c6995f4b8647ec668a752b69085c052 (patch)
treed759a32cb099d286d0f6901d4a95387cc484622e
parent9136bc7ed3e057290bfd7d8a8beae424f1079182 (diff)
downloadlibuca-0e4338b82c6995f4b8647ec668a752b69085c052.tar.gz
libuca-0e4338b82c6995f4b8647ec668a752b69085c052.tar.bz2
libuca-0e4338b82c6995f4b8647ec668a752b69085c052.tar.xz
libuca-0e4338b82c6995f4b8647ec668a752b69085c052.zip
Make pylon plugin compatible with current libuca
-rw-r--r--cmake/FindPylon.cmake8
-rw-r--r--plugins/pylon/CMakeLists.txt10
-rw-r--r--plugins/pylon/changelog.txt4
-rw-r--r--plugins/pylon/uca-pylon-camera.c127
-rw-r--r--plugins/pylon/uca-pylon-camera.h2
5 files changed, 85 insertions, 66 deletions
diff --git a/cmake/FindPylon.cmake b/cmake/FindPylon.cmake
index d3f8879..e096bb4 100644
--- a/cmake/FindPylon.cmake
+++ b/cmake/FindPylon.cmake
@@ -1,11 +1,11 @@
-# Try to find libpco.so
+# Try to find libpylon.so
#
# Defines
#
-# PYLON_FOUND - system has libpco
-# PYLON_INCLUDE_DIR - libpco include directory
-# PYLON_LIB - pco library
+# PYLON_FOUND - system has libpylon
+# PYLON_INCLUDE_DIR - libpylon include directory
+# PYLON_LIB - pylon library
# check for environment variable PYLON_ROOT
find_package(YAT)
diff --git a/plugins/pylon/CMakeLists.txt b/plugins/pylon/CMakeLists.txt
index 7e573f1..3f8569c 100644
--- a/plugins/pylon/CMakeLists.txt
+++ b/plugins/pylon/CMakeLists.txt
@@ -1,13 +1,13 @@
cmake_minimum_required(VERSION 2.6)
project(ucapylon C)
-set(VERSION "1.0.0")
+set(VERSION "1.1.0")
find_package(Pylon)
if (PYLON_FOUND)
set(UCA_CAMERA_NAME "pylon")
+ set(PLUGIN_REVISION "1")
set(PLUGIN_VERSION ${VERSION})
- set(PLUGIN_REVISION "2")
set(PLUGIN_SUMMARY "Pylon plugin for libuca")
set(PLUGIN_CHANGELOG "${CMAKE_CURRENT_SOURCE_DIR}/changelog.txt")
set(PLUGIN_DESCRIPTION "Plugin for the Basler GigE CCD Camera.")
@@ -25,10 +25,10 @@ if (PYLON_FOUND)
create_enums(uca-pylon-enums
${CMAKE_CURRENT_SOURCE_DIR}/../../src/uca-enums
uca-pylon-camera.h)
-
+
add_library(ucapylon SHARED
- uca-pylon-enums.c
- uca-pylon-camera.c)
+ uca-pylon-camera.c
+ uca-pylon-enums.c)
target_link_libraries(ucapylon
${UCA_DEPS}
diff --git a/plugins/pylon/changelog.txt b/plugins/pylon/changelog.txt
index 78c6406..755233e 100644
--- a/plugins/pylon/changelog.txt
+++ b/plugins/pylon/changelog.txt
@@ -1,4 +1,6 @@
-* Tue Oct 15 2013 Mihael Koep <mihael.koep@softwareschneiderei.de> 1.0.0-2
+* Wed Apr 9 2014 Mihael Koep <mihael.koep@softwareschneiderei.de> 1.1.0-1
+- make compatible with current libuca
+* Tue Oct 15 2013 Mihael Koep <mihael.koep@softwareschneiderei.de> 1.0.2-2
- updated to libuca 1.3.0
* Tue Apr 23 2013 Vasili Kvockin <vasili.kvockin@softwareschneiderei.de> 1.0.0-1
- repackaged as part of libuca 1.*
diff --git a/plugins/pylon/uca-pylon-camera.c b/plugins/pylon/uca-pylon-camera.c
index 97c7d35..069d573 100644
--- a/plugins/pylon/uca-pylon-camera.c
+++ b/plugins/pylon/uca-pylon-camera.c
@@ -20,12 +20,17 @@
#include <string.h>
#include <libpyloncam/pylon_camera.h>
#include <gmodule.h>
+#include <gio/gio.h>
#include "uca-pylon-camera.h"
#include "uca-pylon-enums.h"
#define UCA_PYLON_CAMERA_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), UCA_TYPE_PYLON_CAMERA, UcaPylonCameraPrivate))
-G_DEFINE_TYPE(UcaPylonCamera, uca_pylon_camera, UCA_TYPE_CAMERA)
+static void uca_pylon_camera_initable_iface_init (GInitableIface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (UcaPylonCamera, uca_pylon_camera, UCA_TYPE_CAMERA,
+ G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE,
+ uca_pylon_camera_initable_iface_init))
#define PROP_GAIN_MIN 300
#define PROP_GAIN_MAX 400
@@ -50,7 +55,7 @@ enum {
PROP_ROI_HEIGHT_DEFAULT,
PROP_GAIN,
PROP_BALANCE_WHITE_AUTO,
- N_PROPERTIES
+ N_PROPERTIES
};
static gint base_overrideables[] = {
@@ -103,29 +108,6 @@ static void pylon_set_roi(GObject *object, GError** error)
pylon_camera_set_roi(priv->roi_x, priv->roi_y, priv->roi_width, priv->roi_height, error);
}
-UcaPylonCamera *uca_pylon_camera_new(GError **error)
-{
- UcaPylonCamera *camera = g_object_new(UCA_TYPE_PYLON_CAMERA, NULL);
- UcaPylonCameraPrivate *priv = UCA_PYLON_CAMERA_GET_PRIVATE(camera);
-
- gchar* pylon_camera_ip = getenv("PYLON_CAMERA_IP");
- if(!pylon_camera_ip) {
- g_error("no environment variable PYLON_CAMERA_IP found");
- }
-
- pylon_camera_new("/usr/local/lib64", pylon_camera_ip, error);
-
- if (*error != NULL)
- return NULL;
-
- pylon_camera_get_sensor_size(&priv->width, &priv->height, error);
-
- if (*error != NULL)
- return NULL;
-
- return camera;
-}
-
static void uca_pylon_camera_start_recording(UcaCamera *camera, GError **error)
{
g_return_if_fail(UCA_IS_PYLON_CAMERA(camera));
@@ -133,7 +115,6 @@ static void uca_pylon_camera_start_recording(UcaCamera *camera, GError **error)
priv->num_bytes = 2;
pylon_camera_start_acquision(error);
-
}
static void uca_pylon_camera_stop_recording(UcaCamera *camera, GError **error)
@@ -142,15 +123,16 @@ static void uca_pylon_camera_stop_recording(UcaCamera *camera, GError **error)
pylon_camera_stop_acquision(error);
}
-static void uca_pylon_camera_grab(UcaCamera *camera, gpointer *data, GError **error)
+static gboolean uca_pylon_camera_grab(UcaCamera *camera, gpointer data, GError **error)
{
- g_return_if_fail(UCA_IS_PYLON_CAMERA(camera));
+ g_return_val_if_fail(UCA_IS_PYLON_CAMERA(camera), FALSE);
UcaPylonCameraPrivate *priv = UCA_PYLON_CAMERA_GET_PRIVATE(camera);
- if (*data == NULL) {
- *data = g_malloc0(priv->roi_width * priv->roi_height * priv->num_bytes);
+ if (data == NULL) {
+ data = g_malloc0(priv->roi_width * priv->roi_height * priv->num_bytes);
}
- pylon_camera_grab(data, error);
+ pylon_camera_grab(&data, error);
+ return TRUE;
}
static void uca_pylon_camera_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
@@ -166,9 +148,9 @@ static void uca_pylon_camera_set_property(GObject *object, guint property_id, co
case PROP_TRIGGER_MODE:
break;
case PROP_BALANCE_WHITE_AUTO:
- {
- pylon_camera_set_int_attribute("BalanceWhiteAuto", g_value_get_enum(value), &error);
- }
+ {
+ pylon_camera_set_int_attribute("BalanceWhiteAuto", g_value_get_enum(value), &error);
+ }
break;
case PROP_ROI_X:
@@ -211,12 +193,12 @@ static void uca_pylon_camera_set_property(GObject *object, guint property_id, co
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
return;
}
-
+
if (error) {
if(error->message) {
- g_warning("failed to set property %d: %s", property_id, error->message);
+ g_warning("failed to set property %d: %s", property_id, error->message);
} else {
- g_warning("failed to set property %d", property_id);
+ g_warning("failed to set property %d", property_id);
}
}
}
@@ -228,13 +210,13 @@ static void uca_pylon_camera_get_property(GObject *object, guint property_id, GV
switch (property_id) {
case PROP_BALANCE_WHITE_AUTO:
- {
- gint enum_value = UCA_CAMERA_BALANCE_WHITE_OFF;
- pylon_camera_get_int_attribute("BalanceWhiteAuto", &enum_value, &error);
- UcaCameraBalanceWhiteAuto mode = enum_value;
- g_value_set_enum(value, mode);
- break;
- }
+ {
+ gint enum_value = UCA_CAMERA_BALANCE_WHITE_OFF;
+ pylon_camera_get_int_attribute("BalanceWhiteAuto", &enum_value, &error);
+ UcaCameraBalanceWhiteAuto mode = enum_value;
+ g_value_set_enum(value, mode);
+ break;
+ }
case PROP_SENSOR_WIDTH:
pylon_camera_get_sensor_size(&priv->width, &priv->height, &error);
g_value_set_uint(value, priv->width);
@@ -345,11 +327,11 @@ static void uca_pylon_camera_get_property(GObject *object, guint property_id, GV
break;
case PROP_NAME:
- {
- const gchar* name = NULL;
- pylon_camera_get_string_attribute("ModelName", &name, &error);
- g_value_set_string(value, name);
- }
+ {
+ const gchar* name = NULL;
+ pylon_camera_get_string_attribute("ModelName", &name, &error);
+ g_value_set_string(value, name);
+ }
break;
default:
@@ -358,9 +340,9 @@ static void uca_pylon_camera_get_property(GObject *object, guint property_id, GV
}
if (error) {
if(error->message) {
- g_warning("failed to get property %d: %s", property_id, error->message);
+ g_warning("failed to get property %d: %s", property_id, error->message);
} else {
- g_warning("failed to get property %d", property_id);
+ g_warning("failed to get property %d", property_id);
}
}
//g_debug("pylon_get_property end\n");
@@ -374,6 +356,42 @@ static void uca_pylon_camera_finalize(GObject *object)
G_OBJECT_CLASS(uca_pylon_camera_parent_class)->finalize(object);
}
+static gboolean uca_pylon_camera_initable_init(GInitable *initable, GCancellable *cancellable, GError **error)
+{
+ g_return_val_if_fail (UCA_IS_PYLON_CAMERA (initable), FALSE);
+
+ if (cancellable != NULL) {
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
+ "Cancellable initialization not supported");
+ return FALSE;
+ }
+
+ UcaPylonCameraPrivate *priv = UCA_PYLON_CAMERA_GET_PRIVATE(initable);
+
+ gchar* pylon_camera_ip = getenv("PYLON_CAMERA_IP");
+ if(!pylon_camera_ip) {
+ g_error("no environment variable PYLON_CAMERA_IP found");
+ }
+
+ pylon_camera_new("/usr/local/lib64", pylon_camera_ip, error);
+ if (*error != NULL) {
+ return FALSE;
+ }
+
+ pylon_camera_get_sensor_size(&priv->width, &priv->height, error);
+ if (*error != NULL) {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static void uca_pylon_camera_initable_iface_init(GInitableIface *iface)
+{
+ iface->init = uca_pylon_camera_initable_init;
+}
+
+
static void uca_pylon_camera_class_init(UcaPylonCameraClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
@@ -430,6 +448,7 @@ static void uca_pylon_camera_class_init(UcaPylonCameraClass *klass)
static void uca_pylon_camera_init(UcaPylonCamera *self)
{
+
self->priv = UCA_PYLON_CAMERA_GET_PRIVATE(self);
/* binnings */
@@ -440,8 +459,8 @@ static void uca_pylon_camera_init(UcaPylonCamera *self)
g_value_array_append(self->priv->binnings, &val);
}
-G_MODULE_EXPORT UcaCamera *
-uca_camera_impl_new (GError **error)
+G_MODULE_EXPORT GType
+uca_camera_get_type (void)
{
- return UCA_CAMERA(uca_pylon_camera_new(error));
+ return UCA_TYPE_PYLON_CAMERA;
}
diff --git a/plugins/pylon/uca-pylon-camera.h b/plugins/pylon/uca-pylon-camera.h
index ed95544..f3d7bb5 100644
--- a/plugins/pylon/uca-pylon-camera.h
+++ b/plugins/pylon/uca-pylon-camera.h
@@ -71,8 +71,6 @@ struct _UcaPylonCameraClass {
UcaCameraClass parent;
};
-UcaPylonCamera *uca_pylon_camera_new(GError **error);
-
GType uca_pylon_camera_get_type(void);
G_END_DECLS