diff options
| author | Volker Kaiser <volker.kaiser@softwareschneiderei.de> | 2012-05-08 14:49:11 +0200 | 
|---|---|---|
| committer | Volker Kaiser <volker.kaiser@softwareschneiderei.de> | 2012-07-26 15:36:43 +0200 | 
| commit | 38d6d18e83b0c33a18ef6f68c22c161d39abc449 (patch) | |
| tree | 4c21f9374a8ce66834b8869a051315d8b6b304e1 /src | |
| parent | b5c90a21f289bb67c4806a8563d96fc674bba583 (diff) | |
| download | libuca-38d6d18e83b0c33a18ef6f68c22c161d39abc449.tar.gz libuca-38d6d18e83b0c33a18ef6f68c22c161d39abc449.tar.bz2 libuca-38d6d18e83b0c33a18ef6f68c22c161d39abc449.tar.xz libuca-38d6d18e83b0c33a18ef6f68c22c161d39abc449.zip  | |
basler camera works
Diffstat (limited to 'src')
| -rw-r--r-- | src/CMakeLists.txt | 7 | ||||
| -rw-r--r-- | src/cameras/pylon_camera.cpp | 34 | ||||
| -rw-r--r-- | src/cameras/uca-pylon-camera.c | 20 | ||||
| -rw-r--r-- | src/cameras/uca-pylon-camera.h | 1 | 
4 files changed, 26 insertions, 36 deletions
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<yat::IPlugInInfo*, yat::IPlugInFactory*> 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 <glib-object.h> -  #include "uca-camera.h"  G_BEGIN_DECLS  | 
