From b5c90a21f289bb67c4806a8563d96fc674bba583 Mon Sep 17 00:00:00 2001 From: Volker Kaiser Date: Tue, 24 Apr 2012 08:53:21 +0200 Subject: pylon (basler) camera added --- cmake/FindPylon.cmake | 47 +++++++++++++++++++++++++++++++++++++++++++++++ cmake/FindYAT.cmake | 6 ++++++ 2 files changed, 53 insertions(+) create mode 100644 cmake/FindPylon.cmake create mode 100644 cmake/FindYAT.cmake (limited to 'cmake') diff --git a/cmake/FindPylon.cmake b/cmake/FindPylon.cmake new file mode 100644 index 0000000..f446df2 --- /dev/null +++ b/cmake/FindPylon.cmake @@ -0,0 +1,47 @@ + +# Try to find libpco.so +# +# Defines +# +# PCO_FOUND - system has libpco +# PCO_INCLUDE_DIRS - libpco include directory +# PCO_LIBRARIES - pco library + +find_package(YAT) + +find_package(PackageHandleStandardArgs) + +find_path(PYLON_DIRS include/pylon/PylonBase.h HINTS /opt/pylon ENV PYLON_ROOT) +set(GENICAM_ROOT ${PYLON_DIRS}/genicam) +set(PYLON_INCLUDE_DIRS ${PYLON_DIRS}/include ${GENICAM_ROOT}/library/CPP/include) + +# check for 32/64 bit +if (CMAKE_SIZEOF_VOID_P EQUAL 8) + set(PYLON_LIB_DIRS ${PYLON_DIRS}/lib64 ${PYLON_DIRS}/bin ${GENICAM_ROOT}/bin/Linux64_x64 + ${GENICAM_ROOT}/bin/Linux64_x64/GenApi/Generic) +else() + set(PYLON_LIB_DIRS ${PYLON_DIRS}/lib64 ${PYLON_DIRS}/bin ${GENICAM_ROOT}/bin/Linux32_i86 + ${GENICAM_ROOT}/bin/Linux32_i86/GenApi/Generic) +endif() + +find_library(PYLONBASE_LIB pylonbase PATHS ${PYLON_LIB_DIRS}) +find_library(PYLONUTILITY_LIB pylonutility PATHS ${PYLON_LIB_DIRS}) +find_library(PYLONGIGESUPP_LIB pylongigesupp PATHS ${PYLON_LIB_DIRS}) +find_library(GENAPI_LIB GenApi_gcc40_v2_1 PATHS ${PYLON_LIB_DIRS}) +find_library(GCBASE_LIB GCBase_gcc40_v2_1 PATHS ${PYLON_LIB_DIRS}) +set (PYLON_LIBS ${PYLONBASE_LIB} + ${PYLONUTILITY_LIB} + ${PYLONGIGESUPP_LIB} + ${GENAPI_LIB} + ${GCBASE_LIB} + ${YAT_LIB}) + +find_package_handle_standard_args(PYLON DEFAULT_MSG PYLON_LIBS PYLON_INCLUDE_DIRS) + +find_package(PkgConfig) +pkg_check_modules(BASLER_PYLON baslerpylon>=0.1.0 REQUIRED) +MESSAGE(LIBRARY_DIRS ${BASLER_PYLON_LIBRARY_DIRS}) +find_library(BASLERPYLON_LIB baslerpylon PATHS ${BASLER_PYLON_LIBRARY_DIRS}) + +#set (PYLON_LIBS ${PYLON_LIBS} ${BASLERPYLON_LIB}) + diff --git a/cmake/FindYAT.cmake b/cmake/FindYAT.cmake new file mode 100644 index 0000000..92da3c8 --- /dev/null +++ b/cmake/FindYAT.cmake @@ -0,0 +1,6 @@ + +find_package(PkgConfig) +pkg_check_modules(YAT yat>=1.7.7 REQUIRED) + +find_library(YAT_LIB yat ${YAT_LIBRARY_DIRS}) + -- cgit v1.2.3 From 38d6d18e83b0c33a18ef6f68c22c161d39abc449 Mon Sep 17 00:00:00 2001 From: Volker Kaiser Date: Tue, 8 May 2012 14:49:11 +0200 Subject: basler camera works --- CMakeLists.txt | 2 ++ cmake/FindPylon.cmake | 2 +- src/CMakeLists.txt | 7 ++++--- src/cameras/pylon_camera.cpp | 34 +++++++++++----------------------- src/cameras/uca-pylon-camera.c | 20 +++++++++++--------- src/cameras/uca-pylon-camera.h | 1 - test/grab_pylon.c | 3 ++- 7 files changed, 31 insertions(+), 38 deletions(-) (limited to 'cmake') diff --git a/CMakeLists.txt b/CMakeLists.txt index 91f0d14..c0685ba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required(VERSION 2.8) project(uca) +set(CMAKE_VERBOSE_MAKEFILE TRUE) + set(TARNAME "libuca") set(UCA_VERSION_MAJOR "0") set(UCA_VERSION_MINOR "6") diff --git a/cmake/FindPylon.cmake b/cmake/FindPylon.cmake index f446df2..142f432 100644 --- a/cmake/FindPylon.cmake +++ b/cmake/FindPylon.cmake @@ -43,5 +43,5 @@ pkg_check_modules(BASLER_PYLON baslerpylon>=0.1.0 REQUIRED) MESSAGE(LIBRARY_DIRS ${BASLER_PYLON_LIBRARY_DIRS}) find_library(BASLERPYLON_LIB baslerpylon PATHS ${BASLER_PYLON_LIBRARY_DIRS}) -#set (PYLON_LIBS ${PYLON_LIBS} ${BASLERPYLON_LIB}) +set (PYLON_LIBS ${PYLON_LIBS} ${BASLERPYLON_LIB}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5a3c014..9630a72 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -15,14 +15,14 @@ set(cameras) set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) # --- Find camera interfaces -#find_package(PCO) +find_package(PCO) find_package(PF) find_package(IPE) find_package(Pylon) # --- Find frame grabber interfaces -#find_package(FgLib5) -#find_package(ClSerMe4) +find_package(FgLib5) +find_package(ClSerMe4) # --- Miscellanous packages find_package(PkgConfig) @@ -101,6 +101,7 @@ if (PYLON_FOUND) set(uca_LIBS ${uca_LIBS} ${PYLON_LIBS}) 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 eafcf06..d27b6c4 100644 --- a/src/cameras/pylon_camera.cpp +++ b/src/cameras/pylon_camera.cpp @@ -8,24 +8,19 @@ namespace { GrabAPI::IGrabber* pGrabber = 0; - //yat::Mutex* pImageMutex = NULL; - //yat::Condition* pImageCondition = NULL; - //yat::Mutex pImageMutex; - //yat::Condition pImageCondition(pImageMutex); + yat::Mutex pImageMutex; + yat::Condition pImageCondition(pImageMutex); guint imageCounter = 0; guint currentImage = 0; GrabAPI::Image* image = NULL; void handle_image(GrabAPI::Image* newImage) { - //g_assert(pImageMutex); - //g_assert(pImageCondition); - //yat::MutexLock lock(pImageMutex); + yat::MutexLock lock(pImageMutex); delete image; image = newImage; imageCounter++; - std::cerr << "signal next image ready " << std::endl; - //pImageCondition.signal(); + pImageCondition.signal(); } void yat_exception_to_gerror(const yat::Exception& e, GError** error) @@ -70,13 +65,9 @@ namespace { void pylon_camera_new(const char* lib_path, const char* camera_ip, GError** error) { - g_assert(!pGrabber); try { - //pImageMutex = new yat::Mutex; - //pImageCondition = new yat::Condition(*pImageMutex); - yat::PlugInManager pm; std::pair pp = pm.load((std::string(lib_path) + "/libbaslerpylon.so").c_str()); @@ -91,7 +82,6 @@ void pylon_camera_new(const char* lib_path, const char* camera_ip, GError** erro pGrabber->initialize(); pGrabber->set_image_handler(GrabAPI::ImageHandlerCallback::instanciate(handle_image)); pGrabber->open(); - } catch (const yat::Exception& e) { yat_exception_to_gerror(e, error); @@ -146,6 +136,7 @@ void pylon_camera_get_sensor_size(guint* width, guint* height, GError** error) void pylon_camera_get_bit_depth(guint* depth, GError** error) { + std::cerr << __func__ << std::endl; g_assert(pGrabber); try { @@ -162,11 +153,10 @@ void pylon_camera_get_bit_depth(guint* depth, GError** error) void pylon_camera_start_acquision(GError** error) { g_assert(pGrabber); - //g_assert(pImageMutex); try { { - //yat::MutexLock lock(pImageMutex); + yat::MutexLock lock(pImageMutex); imageCounter = 0; currentImage = 0; } @@ -194,24 +184,22 @@ void pylon_camera_stop_acquision(GError** error) void pylon_camera_grab(gpointer *data, GError** error) { g_assert(pGrabber); - //g_assert(pImageMutex); - //g_assert(pImageCondition); - sleep(1); try { - //yat::MutexLock lock(pImageMutex); + yat::MutexLock lock(pImageMutex); g_assert(currentImage <= imageCounter); while (currentImage == imageCounter) { std::cerr << "wait for next image... " << currentImage << std::endl; - //pImageCondition.wait(); + pImageCondition.wait(); } - std::cerr << "grab next image " << currentImage << ", " << imageCounter << std::endl; + std::cerr << "grab next image " << currentImage << ", " << imageCounter + << "; width: " << image->width() << ", height: " << image->height() << std::endl; g_assert(currentImage < imageCounter); currentImage = imageCounter; - //memcpy(*data, image->base(), image->width() * image->height() * 2); + memcpy(*data, image->base(), image->width() * image->height() * 2); } catch (const yat::Exception& e) diff --git a/src/cameras/uca-pylon-camera.c b/src/cameras/uca-pylon-camera.c index 82380bc..1bc8ee2 100644 --- a/src/cameras/uca-pylon-camera.c +++ b/src/cameras/uca-pylon-camera.c @@ -77,8 +77,6 @@ static GParamSpec *pylon_properties[N_PROPERTIES] = { NULL, }; struct _UcaPylonCameraPrivate { - guint frame_width; - guint frame_height; guint bit_depth; gsize num_bytes; @@ -99,6 +97,11 @@ UcaPylonCamera *uca_pylon_camera_new(GError **error) return NULL; } + pylon_camera_get_sensor_size(&priv->width, &priv->height, error); + if (*error) { + g_print("Error when calling pylon_camera_get_sensor_size %s\n", (*error)->message); + return NULL; + } return camera; } @@ -115,7 +118,6 @@ static void uca_pylon_camera_start_recording(UcaCamera *camera, GError **error) static void uca_pylon_camera_stop_recording(UcaCamera *camera, GError **error) { g_return_if_fail(UCA_IS_PYLON_CAMERA(camera)); - UcaPylonCameraPrivate *priv = UCA_PYLON_CAMERA_GET_PRIVATE(camera); pylon_camera_stop_acquision(error); } @@ -125,14 +127,14 @@ static void uca_pylon_camera_grab(UcaCamera *camera, gpointer *data, GError **er UcaPylonCameraPrivate *priv = UCA_PYLON_CAMERA_GET_PRIVATE(camera); if (*data == NULL) { - *data = g_malloc0(priv->frame_width * priv->frame_height * priv->num_bytes); + *data = g_malloc0(priv->width * priv->height * priv->num_bytes); } pylon_camera_grab(data, error); } 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);*/ switch (property_id) { default: @@ -143,7 +145,7 @@ static void uca_pylon_camera_set_property(GObject *object, guint property_id, co static void uca_pylon_camera_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { - printf("pylon_get_property\n"); + fprintf(stderr, "pylon_get_property\n"); UcaPylonCameraPrivate *priv = UCA_PYLON_CAMERA_GET_PRIVATE(object); GError* error = NULL; @@ -152,13 +154,13 @@ static void uca_pylon_camera_get_property(GObject *object, guint property_id, GV case PROP_SENSOR_WIDTH: pylon_camera_get_sensor_size(&priv->width, &priv->height, &error); g_value_set_uint(value, priv->width); - printf("pylon_get_property sensor width %d\n", priv->width); + g_print("pylon_get_property sensor width %d\n", priv->width); break; case PROP_SENSOR_HEIGHT: pylon_camera_get_sensor_size(&priv->width, &priv->height, &error); g_value_set_uint(value, priv->height); - printf("pylon_get_property sensor height %d\n", priv->height); + g_print("pylon_get_property sensor height %d\n", priv->height); break; /* @@ -170,7 +172,7 @@ static void uca_pylon_camera_get_property(GObject *object, guint property_id, GV case PROP_SENSOR_BITDEPTH: pylon_camera_get_bit_depth(&priv->bit_depth, &error); g_value_set_uint(value, priv->bit_depth); - printf("pylon_get_property depth %d\n", priv->bit_depth); + g_print("pylon_get_property depth %d\n", priv->bit_depth); break; /* diff --git a/src/cameras/uca-pylon-camera.h b/src/cameras/uca-pylon-camera.h index 2f441dc..eebf63c 100644 --- a/src/cameras/uca-pylon-camera.h +++ b/src/cameras/uca-pylon-camera.h @@ -19,7 +19,6 @@ #define __UCA_PYLON_CAMERA_H #include - #include "uca-camera.h" G_BEGIN_DECLS diff --git a/test/grab_pylon.c b/test/grab_pylon.c index cb1e534..2f9b5a0 100644 --- a/test/grab_pylon.c +++ b/test/grab_pylon.c @@ -55,6 +55,7 @@ int main(int argc, char *argv[]) NULL); const int pixel_size = bits == 8 ? 1 : 2; + g_print("allocate buffer %u, %u, %d\n", width, height, pixel_size); gpointer buffer = g_malloc0(width * height * pixel_size); gchar filename[FILENAME_MAX]; @@ -65,7 +66,7 @@ int main(int argc, char *argv[]) uca_camera_start_recording(camera, &error); g_assert_no_error(error); - while (counter < 50) { + while (counter < 10) { g_print(" grab frame ... "); uca_camera_grab(camera, &buffer, &error); if (error != NULL) { -- cgit v1.2.3 From 0b5720d0414f7e9f196664677899e999179a49f6 Mon Sep 17 00:00:00 2001 From: Volker Kaiser Date: Wed, 1 Aug 2012 14:06:50 +0200 Subject: extracted pylon_camera C-wrapper into own project; enhanced cmake build for pylon cameras --- cmake/FindPylon.cmake | 55 +++----- src/CMakeLists.txt | 9 +- src/cameras/pylon_camera.cpp | 289 ----------------------------------------- src/cameras/pylon_camera.h | 32 ----- src/cameras/uca-pylon-camera.c | 2 +- test/CMakeLists.txt | 14 ++ 6 files changed, 39 insertions(+), 362 deletions(-) delete mode 100644 src/cameras/pylon_camera.cpp delete mode 100644 src/cameras/pylon_camera.h (limited to 'cmake') diff --git a/cmake/FindPylon.cmake b/cmake/FindPylon.cmake index 142f432..be3ce85 100644 --- a/cmake/FindPylon.cmake +++ b/cmake/FindPylon.cmake @@ -3,45 +3,30 @@ # # Defines # -# PCO_FOUND - system has libpco -# PCO_INCLUDE_DIRS - libpco include directory -# PCO_LIBRARIES - pco library +# PYLON_FOUND - system has libpco +# PYLON_INCLUDE_DIR - libpco include directory +# PYLON_LIB - pco library -find_package(YAT) +# check for environment variable PYLON_ROOT +message("DEFINED PYLON ROOT $ENV{PYLON_ROOT}") +if (NOT "$ENV{PYLON_ROOT}" STREQUAL "") + message("PYLON_ROOT=$ENV{PYLON_ROOT}") + set(ENV{LD_LIBRARY_PATH} "$ENV{LD_LIBRARY_PATH}:$ENV{PYLON_ROOT}/lib") + set(ENV{LD_LIBRARY_PATH} "$ENV{LD_LIBRARY_PATH};$ENV{PYLON_ROOT}/lib64") + set(ENV{LD_LIBRARY_PATH} "$ENV{LD_LIBRARY_PATH};$ENV{PYLON_ROOT}/genicam/bin/Linux64_x64") + set(ENV{LD_LIBRARY_PATH} "$ENV{LD_LIBRARY_PATH};$ENV{PYLON_ROOT}/genicam/bin/Linux32_i86") -find_package(PackageHandleStandardArgs) -find_path(PYLON_DIRS include/pylon/PylonBase.h HINTS /opt/pylon ENV PYLON_ROOT) -set(GENICAM_ROOT ${PYLON_DIRS}/genicam) -set(PYLON_INCLUDE_DIRS ${PYLON_DIRS}/include ${GENICAM_ROOT}/library/CPP/include) + find_package(YAT) + find_package(PackageHandleStandardArgs) -# check for 32/64 bit -if (CMAKE_SIZEOF_VOID_P EQUAL 8) - set(PYLON_LIB_DIRS ${PYLON_DIRS}/lib64 ${PYLON_DIRS}/bin ${GENICAM_ROOT}/bin/Linux64_x64 - ${GENICAM_ROOT}/bin/Linux64_x64/GenApi/Generic) -else() - set(PYLON_LIB_DIRS ${PYLON_DIRS}/lib64 ${PYLON_DIRS}/bin ${GENICAM_ROOT}/bin/Linux32_i86 - ${GENICAM_ROOT}/bin/Linux32_i86/GenApi/Generic) -endif() - -find_library(PYLONBASE_LIB pylonbase PATHS ${PYLON_LIB_DIRS}) -find_library(PYLONUTILITY_LIB pylonutility PATHS ${PYLON_LIB_DIRS}) -find_library(PYLONGIGESUPP_LIB pylongigesupp PATHS ${PYLON_LIB_DIRS}) -find_library(GENAPI_LIB GenApi_gcc40_v2_1 PATHS ${PYLON_LIB_DIRS}) -find_library(GCBASE_LIB GCBase_gcc40_v2_1 PATHS ${PYLON_LIB_DIRS}) -set (PYLON_LIBS ${PYLONBASE_LIB} - ${PYLONUTILITY_LIB} - ${PYLONGIGESUPP_LIB} - ${GENAPI_LIB} - ${GCBASE_LIB} - ${YAT_LIB}) + find_path(PYLON_INCLUDE_DIR libpyloncam/pylon_camera.h) + find_library(PYLON_LIB pyloncam) -find_package_handle_standard_args(PYLON DEFAULT_MSG PYLON_LIBS PYLON_INCLUDE_DIRS) + message("INCLUDE ${PYLON_INCLUDE_DIR}") -find_package(PkgConfig) -pkg_check_modules(BASLER_PYLON baslerpylon>=0.1.0 REQUIRED) -MESSAGE(LIBRARY_DIRS ${BASLER_PYLON_LIBRARY_DIRS}) -find_library(BASLERPYLON_LIB baslerpylon PATHS ${BASLER_PYLON_LIBRARY_DIRS}) - -set (PYLON_LIBS ${PYLON_LIBS} ${BASLERPYLON_LIB}) + find_package_handle_standard_args(PYLON DEFAULT_MSG PYLON_LIB PYLON_INCLUDE_DIR) +else() + message("Environment variable PYLON_ROOT not found! => unable to build pylon camera support") +endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 931ca9b..13d677a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -15,7 +15,7 @@ set(cameras) set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) # --- Find camera interfaces -#find_package(PCO) +find_package(PCO) find_package(PF) find_package(IPE) find_package(Pylon) @@ -96,13 +96,12 @@ if (PYLON_FOUND) option(HAVE_PYLON_CAMERA "Camera: Pylon based (Basler)" ON) if (HAVE_PYLON_CAMERA) - list(APPEND uca_SRCS cameras/uca-pylon-camera.c cameras/pylon_camera.cpp) + list(APPEND uca_SRCS cameras/uca-pylon-camera.c) list(APPEND uca_HDRS cameras/uca-pylon-camera.h) list(APPEND cameras "Pylon") - set(uca_LIBS ${uca_LIBS} ${PYLON_LIBS}) + set(uca_LIBS ${uca_LIBS} ${PYLON_LIB}) - include_directories(${PYLON_INCLUDE_DIRS}) - link_directories(/opt/pylon/lib64) + include_directories(${PYLON_INCLUDE_DIR}) endif() endif() diff --git a/src/cameras/pylon_camera.cpp b/src/cameras/pylon_camera.cpp deleted file mode 100644 index 094e3c8..0000000 --- a/src/cameras/pylon_camera.cpp +++ /dev/null @@ -1,289 +0,0 @@ - -#include "pylon_camera.h" -#include -#include -#include -#include - -namespace { - - GrabAPI::IGrabber* pGrabber = 0; - yat::Mutex pImageMutex; - yat::Condition pImageCondition(pImageMutex); - guint imageCounter = 0; - guint currentImage = 0; - GrabAPI::Image* image = NULL; - guint bytesPerPixel = 0; - - void handle_image(GrabAPI::Image* newImage) - { - yat::MutexLock lock(pImageMutex); - delete image; - image = newImage; - imageCounter++; - pImageCondition.signal(); - } - - void yat_exception_to_gerror(const yat::Exception& e, GError** error) - { - if (e.errors.size() == 2) - { - g_set_error(error, 0, 0, - "%s : %s : %s\n%s : %s : %s", - e.errors[0].reason.c_str(), - e.errors[0].desc.c_str(), - e.errors[0].origin.c_str(), - e.errors[1].reason.c_str(), - e.errors[1].desc.c_str(), - e.errors[1].origin.c_str()); - return; - } - if (e.errors.size() == 3) - { - g_set_error(error, 0, 0, - "%s : %s : %s\n%s : %s : %s\n%s : %s : %s", - e.errors[0].reason.c_str(), - e.errors[0].desc.c_str(), - e.errors[0].origin.c_str(), - e.errors[1].reason.c_str(), - e.errors[1].desc.c_str(), - e.errors[1].origin.c_str(), - e.errors[2].reason.c_str(), - e.errors[2].desc.c_str(), - e.errors[2].origin.c_str()); - return; - } - - g_set_error(error, 0, 0, - "%s : %s : %s", - e.errors[0].reason.c_str(), - e.errors[0].desc.c_str(), - e.errors[0].origin.c_str()); - } - -} - - -void pylon_camera_new(const char* lib_path, const char* camera_ip, GError** error) -{ - g_assert(!pGrabber); - try { - - yat::PlugInManager pm; - std::pair pp = - pm.load((std::string(lib_path) + "/libbaslerpylon.so").c_str()); - - yat::IPlugInObject* plugin_obj = 0; - pp.second->create(plugin_obj); - pGrabber = static_cast(plugin_obj); - - yat::PlugInPropValues values; - values["CameraIP"] = yat::Any(std::string(camera_ip)); - pGrabber->set_properties(values); - pGrabber->initialize(); - pGrabber->set_image_handler(GrabAPI::ImageHandlerCallback::instanciate(handle_image)); - pGrabber->open(); - } - catch (const yat::Exception& e) { - yat_exception_to_gerror(e, error); - } -} - -void pylon_camera_set_exposure_time(gdouble exp_time, GError** error) -{ - g_assert(pGrabber); - try - { - pGrabber->set_exposure_time(yat::Any(exp_time)); - } - catch (const yat::Exception& e) - { - yat_exception_to_gerror(e, error); - } -} - -void pylon_camera_get_exposure_time(gdouble* exp_time, GError** error) -{ - g_assert(pGrabber); - try - { - yat::Any exp_time_result; - pGrabber->get_exposure_time(exp_time_result); - *exp_time = yat::any_cast(exp_time_result); - } - catch (const yat::Exception& e) - { - yat_exception_to_gerror(e, error); - } -} - - -void pylon_camera_get_sensor_size(guint* width, guint* height, GError** error) -{ - g_assert(pGrabber); - try - { - yat::Any w, h; - pGrabber->get_sensor_width(w); - pGrabber->get_sensor_height(h); - *width = yat::any_cast(w); - *height = yat::any_cast(h); - } - catch (const yat::Exception& e) - { - yat_exception_to_gerror(e, error); - } -} - -void pylon_camera_get_bit_depth(guint* depth, GError** error) -{ - g_assert(pGrabber); - try - { - yat::Any bit_depth_result; - pGrabber->get_bit_depth(bit_depth_result); - *depth = yat::any_cast(bit_depth_result); - } - catch (const yat::Exception& e) - { - yat_exception_to_gerror(e, 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_get_gain(gint* gain, GError** error) -{ - g_assert(pGrabber); - try - { - yat::Any gain_result; - pGrabber->get_gain(gain_result); - *gain = yat::any_cast(gain_result); - } - catch (const yat::Exception& e) - { - yat_exception_to_gerror(e, error); - } -} - -void pylon_camera_set_gain(gint gain, GError** error) -{ - g_assert(pGrabber); - try - { - pGrabber->set_gain(yat::Any(gain)); - } - catch (const yat::Exception& e) - { - yat_exception_to_gerror(e, error); - } -} - -void pylon_camera_start_acquision(GError** error) -{ - g_assert(pGrabber); - guint bit_depth = 0; - pylon_camera_get_bit_depth(&bit_depth, error); - bytesPerPixel = 1; - if (bit_depth > 8) bytesPerPixel = 2; - if (bit_depth > 16) bytesPerPixel = 3; - if (bit_depth > 24) bytesPerPixel = 4; - try - { - { - yat::MutexLock lock(pImageMutex); - imageCounter = 0; - currentImage = 0; - } - pGrabber->start(); - } - catch (const yat::Exception& e) - { - yat_exception_to_gerror(e, error); - } -} - -void pylon_camera_stop_acquision(GError** error) -{ - g_assert(pGrabber); - try - { - pGrabber->stop(); - } - catch (const yat::Exception& e) - { - yat_exception_to_gerror(e, error); - } -} - -void pylon_camera_grab(gpointer *data, GError** error) -{ - g_assert(pGrabber); - try - { - yat::MutexLock lock(pImageMutex); - g_assert(currentImage <= imageCounter); - - while (currentImage == imageCounter) - { - std::cerr << "wait for next image... " << currentImage << std::endl; - pImageCondition.wait(); - } - - std::cerr << "grab next image " << currentImage << ", " << imageCounter - << "; width: " << image->width() / bytesPerPixel << ", height: " << image->height() << std::endl; - g_assert(currentImage < imageCounter); - currentImage = imageCounter; - memcpy(*data, image->base(), image->width() * image->height()); - - } - catch (const yat::Exception& e) - { - yat_exception_to_gerror(e, error); - } -} - -void pylon_camera_delete() -{ - if (!pGrabber) - return; - - pGrabber->close(); - pGrabber->uninitialize(); - delete pGrabber; -} - diff --git a/src/cameras/pylon_camera.h b/src/cameras/pylon_camera.h deleted file mode 100644 index 89b450b..0000000 --- a/src/cameras/pylon_camera.h +++ /dev/null @@ -1,32 +0,0 @@ - -#ifndef _PYLON_CAMERA_H_ -#define _PYLON_CAMERA_H_ - -#include - -G_BEGIN_DECLS - -void pylon_camera_new(const gchar* lib_path, const gchar* camera_ip, GError** error); - -void pylon_camera_set_exposure_time(gdouble exp_time, GError** error); -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_get_gain(gint* gain, GError** error); -void pylon_camera_set_gain(gint gain, GError** error); - -void pylon_camera_start_acquision(GError** error); -void pylon_camera_stop_acquision(GError** error); -void pylon_camera_grab(gpointer *data, GError** error); - -void pylon_camera_delete(); - -G_END_DECLS - -#endif - diff --git a/src/cameras/uca-pylon-camera.c b/src/cameras/uca-pylon-camera.c index 23aa1a3..6fef112 100644 --- a/src/cameras/uca-pylon-camera.c +++ b/src/cameras/uca-pylon-camera.c @@ -18,9 +18,9 @@ #include #include #include +#include #include "uca-camera.h" #include "uca-pylon-camera.h" -#include "pylon_camera.h" /*#define HANDLE_PYLON_ERROR(err) \ diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 873b85f..36a5fd3 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -33,6 +33,20 @@ include_directories( message("${CMAKE_CURRENT_SOURCE_DIR}") +if (HAVE_PYLON_CAMERA) + set(GENICAM_ROOT $ENV{PYLON_ROOT}/genicam) + # check for 32/64 bit + if (CMAKE_SIZEOF_VOID_P EQUAL 8) + set(PYLON_LIB_DIRS $ENV{PYLON_ROOT}/lib64 $ENV{PYLON_ROOT}/bin ${GENICAM_ROOT}/bin/Linux64_x64 + ${GENICAM_ROOT}/bin/Linux64_x64/GenApi/Generic) + else() + set(PYLON_LIB_DIRS $ENV{PYLON_ROOT}/lib64 $ENV{PYLON_ROOT}/bin ${GENICAM_ROOT}/bin/Linux32_i86 + ${GENICAM_ROOT}/bin/Linux32_i86/GenApi/Generic) + endif() + message("PYLON LIB DIRS ${PYLON_LIB_DIRS}") + link_directories(${PYLON_LIB_DIRS}) +endif() + add_executable(grab grab.c) add_executable(grab-async grab-async.c) -- cgit v1.2.3 From 6683a6e9a6fc0259d5e5dfd97279680e292d7938 Mon Sep 17 00:00:00 2001 From: Volker Kaiser Date: Wed, 1 Aug 2012 14:58:46 +0200 Subject: fixed pylon build --- cmake/FindPylon.cmake | 16 +++++++++------- src/CMakeLists.txt | 4 ++-- test/CMakeLists.txt | 1 - 3 files changed, 11 insertions(+), 10 deletions(-) (limited to 'cmake') diff --git a/cmake/FindPylon.cmake b/cmake/FindPylon.cmake index be3ce85..9c678bc 100644 --- a/cmake/FindPylon.cmake +++ b/cmake/FindPylon.cmake @@ -8,7 +8,9 @@ # PYLON_LIB - pco library # check for environment variable PYLON_ROOT -message("DEFINED PYLON ROOT $ENV{PYLON_ROOT}") +find_package(YAT) +find_package(PkgConfig) + if (NOT "$ENV{PYLON_ROOT}" STREQUAL "") message("PYLON_ROOT=$ENV{PYLON_ROOT}") set(ENV{LD_LIBRARY_PATH} "$ENV{LD_LIBRARY_PATH}:$ENV{PYLON_ROOT}/lib") @@ -16,16 +18,16 @@ if (NOT "$ENV{PYLON_ROOT}" STREQUAL "") set(ENV{LD_LIBRARY_PATH} "$ENV{LD_LIBRARY_PATH};$ENV{PYLON_ROOT}/genicam/bin/Linux64_x64") set(ENV{LD_LIBRARY_PATH} "$ENV{LD_LIBRARY_PATH};$ENV{PYLON_ROOT}/genicam/bin/Linux32_i86") + pkg_check_modules(LIBPYLONCAM pyloncam>=0.1 REQUIRED) - find_package(YAT) + find_library(YAT_LIB yat ${YAT_LIBRARY_DIRS}) find_package(PackageHandleStandardArgs) - find_path(PYLON_INCLUDE_DIR libpyloncam/pylon_camera.h) - find_library(PYLON_LIB pyloncam) - - message("INCLUDE ${PYLON_INCLUDE_DIR}") + find_package_handle_standard_args(PYLON DEFAULT_MSG LIBPYLONCAM_INCLUDEDIR LIBPYLONCAM_LIBRARIES) - find_package_handle_standard_args(PYLON DEFAULT_MSG PYLON_LIB PYLON_INCLUDE_DIR) + mark_as_advanced( + LIBPYLONCAM_INCLUDEDIR + LIBPYLONCAM_LIBRARIES) else() message("Environment variable PYLON_ROOT not found! => unable to build pylon camera support") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c114cce..9238106 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -98,9 +98,9 @@ if (PYLON_FOUND) list(APPEND uca_SRCS cameras/uca-pylon-camera.c) list(APPEND uca_HDRS cameras/uca-pylon-camera.h) list(APPEND cameras "Pylon") - set(uca_LIBS ${uca_LIBS} ${PYLON_LIB}) + set(uca_LIBS ${uca_LIBS} ${LIBPYLONCAM_LIBRARIES}) - include_directories(${PYLON_INCLUDE_DIR}) + include_directories(${LIBPYLONCAM_INCLUDEDIR}) endif() endif() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 5fb8133..4cd43ce 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -36,7 +36,6 @@ if (HAVE_PYLON_CAMERA) set(PYLON_LIB_DIRS $ENV{PYLON_ROOT}/lib64 $ENV{PYLON_ROOT}/bin ${GENICAM_ROOT}/bin/Linux32_i86 ${GENICAM_ROOT}/bin/Linux32_i86/GenApi/Generic) endif() - message("PYLON LIB DIRS ${PYLON_LIB_DIRS}") link_directories(${PYLON_LIB_DIRS}) endif() -- cgit v1.2.3 From c22c7e1254228c43cc56eecb03bd6ac171768a0d Mon Sep 17 00:00:00 2001 From: Volker Kaiser Date: Thu, 2 Aug 2012 10:22:28 +0200 Subject: use LIBPYLONCAM_OTHER_PREFIX to change prefix found with pkg-config --- cmake/FindPylon.cmake | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'cmake') diff --git a/cmake/FindPylon.cmake b/cmake/FindPylon.cmake index 9c678bc..a8b7182 100644 --- a/cmake/FindPylon.cmake +++ b/cmake/FindPylon.cmake @@ -10,6 +10,7 @@ # check for environment variable PYLON_ROOT find_package(YAT) find_package(PkgConfig) +find_package(PackageHandleStandardArgs) if (NOT "$ENV{PYLON_ROOT}" STREQUAL "") message("PYLON_ROOT=$ENV{PYLON_ROOT}") @@ -21,13 +22,18 @@ if (NOT "$ENV{PYLON_ROOT}" STREQUAL "") pkg_check_modules(LIBPYLONCAM pyloncam>=0.1 REQUIRED) find_library(YAT_LIB yat ${YAT_LIBRARY_DIRS}) - find_package(PackageHandleStandardArgs) find_package_handle_standard_args(PYLON DEFAULT_MSG LIBPYLONCAM_INCLUDEDIR LIBPYLONCAM_LIBRARIES) mark_as_advanced( LIBPYLONCAM_INCLUDEDIR LIBPYLONCAM_LIBRARIES) + if (DEFINED LIBPYLONCAM_OTHER_PREFIX) + string(REPLACE ${LIBPYLONCAM_PREFIX} ${LIBPYLONCAM_OTHER_PREFIX} + LIBPYLONCAM_INCLUDEDIR ${LIBPYLONCAM_INCLUDEDIR}) + string(REPLACE ${LIBPYLONCAM_PREFIX} ${LIBPYLONCAM_OTHER_PREFIX} + LIBPYLONCAM_LIBRARIES ${LIBPYLONCAM_LIBRARIES}) + endif() else() message("Environment variable PYLON_ROOT not found! => unable to build pylon camera support") -- cgit v1.2.3 From a48438344b1e36588ded72a2bb3ca5c309c3d656 Mon Sep 17 00:00:00 2001 From: Volker Kaiser Date: Thu, 2 Aug 2012 10:34:23 +0200 Subject: enhanced usage of LIBPYLONCAM_OTHER_PREFIX --- cmake/FindPylon.cmake | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'cmake') diff --git a/cmake/FindPylon.cmake b/cmake/FindPylon.cmake index a8b7182..fc9624b 100644 --- a/cmake/FindPylon.cmake +++ b/cmake/FindPylon.cmake @@ -14,20 +14,10 @@ find_package(PackageHandleStandardArgs) if (NOT "$ENV{PYLON_ROOT}" STREQUAL "") message("PYLON_ROOT=$ENV{PYLON_ROOT}") - set(ENV{LD_LIBRARY_PATH} "$ENV{LD_LIBRARY_PATH}:$ENV{PYLON_ROOT}/lib") - set(ENV{LD_LIBRARY_PATH} "$ENV{LD_LIBRARY_PATH};$ENV{PYLON_ROOT}/lib64") - set(ENV{LD_LIBRARY_PATH} "$ENV{LD_LIBRARY_PATH};$ENV{PYLON_ROOT}/genicam/bin/Linux64_x64") - set(ENV{LD_LIBRARY_PATH} "$ENV{LD_LIBRARY_PATH};$ENV{PYLON_ROOT}/genicam/bin/Linux32_i86") - - pkg_check_modules(LIBPYLONCAM pyloncam>=0.1 REQUIRED) find_library(YAT_LIB yat ${YAT_LIBRARY_DIRS}) - find_package_handle_standard_args(PYLON DEFAULT_MSG LIBPYLONCAM_INCLUDEDIR LIBPYLONCAM_LIBRARIES) - - mark_as_advanced( - LIBPYLONCAM_INCLUDEDIR - LIBPYLONCAM_LIBRARIES) + pkg_check_modules(LIBPYLONCAM pyloncam>=0.1 REQUIRED) if (DEFINED LIBPYLONCAM_OTHER_PREFIX) string(REPLACE ${LIBPYLONCAM_PREFIX} ${LIBPYLONCAM_OTHER_PREFIX} LIBPYLONCAM_INCLUDEDIR ${LIBPYLONCAM_INCLUDEDIR}) @@ -35,6 +25,12 @@ if (NOT "$ENV{PYLON_ROOT}" STREQUAL "") LIBPYLONCAM_LIBRARIES ${LIBPYLONCAM_LIBRARIES}) endif() + find_package_handle_standard_args(PYLON DEFAULT_MSG LIBPYLONCAM_INCLUDEDIR LIBPYLONCAM_LIBRARIES) + + mark_as_advanced( + LIBPYLONCAM_INCLUDEDIR + LIBPYLONCAM_LIBRARIES) + else() message("Environment variable PYLON_ROOT not found! => unable to build pylon camera support") endif() -- cgit v1.2.3 From 91daa3bdebd1fc1e368ff9fa2e99b4ea1131361e Mon Sep 17 00:00:00 2001 From: Volker Kaiser Date: Thu, 2 Aug 2012 11:44:17 +0200 Subject: using LIBDIR --- cmake/FindPylon.cmake | 5 ++++- src/CMakeLists.txt | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'cmake') diff --git a/cmake/FindPylon.cmake b/cmake/FindPylon.cmake index fc9624b..c1a4af1 100644 --- a/cmake/FindPylon.cmake +++ b/cmake/FindPylon.cmake @@ -23,13 +23,16 @@ if (NOT "$ENV{PYLON_ROOT}" STREQUAL "") LIBPYLONCAM_INCLUDEDIR ${LIBPYLONCAM_INCLUDEDIR}) string(REPLACE ${LIBPYLONCAM_PREFIX} ${LIBPYLONCAM_OTHER_PREFIX} LIBPYLONCAM_LIBRARIES ${LIBPYLONCAM_LIBRARIES}) + string(REPLACE ${LIBPYLONCAM_PREFIX} ${LIBPYLONCAM_OTHER_PREFIX} + LIBPYLONCAM_LIBDIR ${LIBPYLONCAM_LIBDIR}) endif() find_package_handle_standard_args(PYLON DEFAULT_MSG LIBPYLONCAM_INCLUDEDIR LIBPYLONCAM_LIBRARIES) mark_as_advanced( LIBPYLONCAM_INCLUDEDIR - LIBPYLONCAM_LIBRARIES) + LIBPYLONCAM_LIBRARIES + LIBPYLONCAM_LIBDIR) else() message("Environment variable PYLON_ROOT not found! => unable to build pylon camera support") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9238106..acba8a4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -101,6 +101,7 @@ if (PYLON_FOUND) set(uca_LIBS ${uca_LIBS} ${LIBPYLONCAM_LIBRARIES}) include_directories(${LIBPYLONCAM_INCLUDEDIR}) + link_directories(${LIBPYLONCAM_LIBDIR}) endif() endif() -- cgit v1.2.3 From c64797a677c3ec4869f0a143fbde654522e8b6d0 Mon Sep 17 00:00:00 2001 From: Volker Kaiser Date: Thu, 2 Aug 2012 12:43:25 +0200 Subject: propagating LIBPYLONCAM_LIBDIR to PARENT_SCOPE --- cmake/FindPylon.cmake | 1 + 1 file changed, 1 insertion(+) (limited to 'cmake') diff --git a/cmake/FindPylon.cmake b/cmake/FindPylon.cmake index c1a4af1..9820201 100644 --- a/cmake/FindPylon.cmake +++ b/cmake/FindPylon.cmake @@ -25,6 +25,7 @@ if (NOT "$ENV{PYLON_ROOT}" STREQUAL "") LIBPYLONCAM_LIBRARIES ${LIBPYLONCAM_LIBRARIES}) string(REPLACE ${LIBPYLONCAM_PREFIX} ${LIBPYLONCAM_OTHER_PREFIX} LIBPYLONCAM_LIBDIR ${LIBPYLONCAM_LIBDIR}) + set(LIBPYLONCAM_LIBDIR ${LIBPYLONCAM_LIBDIR} PARENT_SCOPE) endif() find_package_handle_standard_args(PYLON DEFAULT_MSG LIBPYLONCAM_INCLUDEDIR LIBPYLONCAM_LIBRARIES) -- cgit v1.2.3 From 859a6a6802e1891628af988a83a3e24b5b75c007 Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Thu, 9 Aug 2012 12:36:28 +0200 Subject: Drop REQUIRED flag from Basler dependencies If they are required, they cannot be built on machines without that dependency. --- cmake/FindPylon.cmake | 2 +- cmake/FindYAT.cmake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'cmake') diff --git a/cmake/FindPylon.cmake b/cmake/FindPylon.cmake index 9820201..01cee02 100644 --- a/cmake/FindPylon.cmake +++ b/cmake/FindPylon.cmake @@ -17,7 +17,7 @@ if (NOT "$ENV{PYLON_ROOT}" STREQUAL "") find_library(YAT_LIB yat ${YAT_LIBRARY_DIRS}) - pkg_check_modules(LIBPYLONCAM pyloncam>=0.1 REQUIRED) + pkg_check_modules(LIBPYLONCAM pyloncam>=0.1) if (DEFINED LIBPYLONCAM_OTHER_PREFIX) string(REPLACE ${LIBPYLONCAM_PREFIX} ${LIBPYLONCAM_OTHER_PREFIX} LIBPYLONCAM_INCLUDEDIR ${LIBPYLONCAM_INCLUDEDIR}) diff --git a/cmake/FindYAT.cmake b/cmake/FindYAT.cmake index 92da3c8..1f9a98b 100644 --- a/cmake/FindYAT.cmake +++ b/cmake/FindYAT.cmake @@ -1,6 +1,6 @@ find_package(PkgConfig) -pkg_check_modules(YAT yat>=1.7.7 REQUIRED) +pkg_check_modules(YAT yat>=1.7.7) find_library(YAT_LIB yat ${YAT_LIBRARY_DIRS}) -- cgit v1.2.3