Commit 8bcd4b8b authored by Andreas Persson's avatar Andreas Persson

merge branch 'rt3067'

* rt3067:
  whitespace cleanup
  SyncCtrlOb: implement latency control
  Camera: fix deadlock when stopping acquisition
  Interface: add getCamera()
  Camera: refactor property management
  Camera: use SoftBufferCtrlObj
  split capabilities into separate files
  refuse to change pixel format when an acquisition is in progress
  USE_GIGE: add methods for getting/setting the packet size and the packet_delay
  USE_GIGE: add optional constructor arguments packet_size and packet_delay
  USE_GIGE: find cameras using serial numbers only
  USE_GIGE: implement handling of GigE image settings
  USE_GIGE: add helper methods for managing image settings
  introduce preprocessor macro USE_GIGE
  exception message whitespace fix
  set pixel format to MONO8 on startup
  Camera::_AcqThread: check if acquisition has been stopped _after_ retreiving the image buffer.
  use a thread for image acquisition
  remove unused members m_c_error, m_sync
parents 0b28f2d0 685945d6
......@@ -24,35 +24,43 @@
#include <stdlib.h>
#include <limits>
#include "HwBufferMgr.h"
#include "HwMaxImageSizeCallback.h"
#include "FlyCapture2.h"
using namespace std;
#ifdef USE_GIGE
typedef FlyCapture2::GigECamera Camera_t;
typedef FlyCapture2::GigEImageSettings ImageSettings_t;
typedef FlyCapture2::GigEImageSettingsInfo ImageSettingsInfo_t;
#else
typedef FlyCapture2::Camera Camera_t;
typedef FlyCapture2::Format7ImageSettings ImageSettings_t;
typedef FlyCapture2::Format7Info ImageSettingsInfo_t;
#endif
namespace lima
{
namespace PointGrey
{
/*******************************************************************
* \class Camera
* \brief object controlling the Point Grey camera via Pylon driver
* \brief object controlling the Point Grey camera via FlyCapture driver
*******************************************************************/
class VideoCtrlObj;
class SyncCtrlObj;
class Camera : public HwMaxImageSizeCallbackGen
{
friend class SyncCtrlObj;
DEB_CLASS_NAMESPC(DebModCamera, "Camera", "PointGrey");
friend class VideoCtrlObj;
public:
friend class Interface;
public:
enum Status {
Ready, Exposure, Readout, Latency, Fault
Ready, Exposure, Readout, Latency, Fault
};
Camera(const std::string& camera_ip, const int camera_serial_no = 0);
Camera(const int camera_serial,
const int packet_size = -1,
const int packet_delay = -1);
~Camera();
// hw interface
......@@ -61,27 +69,28 @@ class Camera : public HwMaxImageSizeCallbackGen
void stopAcq();
void getStatus(Camera::Status& status);
void reset(void);
// buffer control object
HwBufferCtrlObj* getBufferCtrlObj();
// detector info object
void getDetectorType(std::string& type);
void getDetectorModel(std::string& model);
void getDetectorImageSize(Size& size);
void getImageType(ImageType& type);
void setImageType(ImageType type);
// synch control object
void getTrigMode(TrigMode& mode);
void setTrigMode(TrigMode mode);
void setTrigMode(TrigMode mode);
void getExpTime(double& exp_time);
void setExpTime(double exp_time);
void getExpTimeRange(double& min_exp_time, double& max_exp_time) const;
void getLatTime(double& lat_time);
void setLatTime(double lat_time);
void getLatTimeRange(double& min_lat_time, double& max_lat_time) const;
void setExpTime(double exp_time);
void getExpTimeRange(double& min_exp_time, double& max_exp_time);
void getNbFrames(int& nb_frames);
void setNbFrames(int nb_frames);
void setNbFrames(int nb_frames);
void getNbHwAcquiredFrames(int &nb_acq_frames);
// roi control object
......@@ -94,57 +103,67 @@ class Camera : public HwMaxImageSizeCallbackGen
void getBin(Bin& bin);
void setBin(const Bin& bin);
// video control object
void getVideoMode(VideoMode& mode) const;
void setVideoMode(VideoMode mode);
// camera specific
void getPacketSize(int& packet_size);
void setPacketSize(int packet_size);
void getGain(double& gain);
void setGain(double gain);
void getPacketDelay(int& packet_delay);
void setPacketDelay(int packet_delay);
// camera specific
void getAutoExpTime(bool& auto_frame_rate) const;
void setAutoExpTime(bool auto_exp_time);
void getAutoGain(bool& auto_gain) const;
void setAutoGain(bool auto_gain);
protected:
void _getPropertyInfo(FlyCapture2::PropertyInfo *property_info);
void _getProperty(FlyCapture2::Property *property);
void _setProperty(FlyCapture2::Property *property);
private:
static void _newFrameCBK(FlyCapture2::Image* image, const void *data);
void _newFrame(FlyCapture2::Image *image);
SyncCtrlObj *m_sync;
VideoCtrlObj *m_video;
Camera::Status m_status;
int m_nb_frames;
int m_image_number;
bool m_continue_acq;
bool m_started;
FlyCapture2::Camera *m_camera;
FlyCapture2::CameraInfo m_camera_info;
FlyCapture2::Error m_error;
const FlyCapture2::Error m_c_error;
FlyCapture2::Format7Info m_fmt7_info;
FlyCapture2::Format7ImageSettings m_fmt7_image_settings;
FlyCapture2::Format7PacketInfo m_fmt7_packet_info;
FlyCapture2::Property m_frame_rate_property,
m_exp_time_property,
m_gain_property;
FlyCapture2::PropertyInfo m_frame_rate_property_info,
m_exp_time_property_info,
m_gain_property_info;
void getGain(double& gain);
void setGain(double gain);
void getGainRange(double& min_gain, double& max_gain);
void getFrameRate(double& frame_rate);
void setFrameRate(double frame_rate);
void getFrameRateRange(double& min_frame_rate, double& max_frame_rate);
void getAutoExpTime(bool& auto_frame_rate);
void setAutoExpTime(bool auto_exp_time);
void getAutoGain(bool& auto_gain);
void setAutoGain(bool auto_gain);
void getAutoFrameRate(bool& auto_frame_rate);
void setAutoFrameRate(bool auto_frame_rate);
protected:
// property management
void _getPropertyValue(FlyCapture2::PropertyType type, double& value);
void _setPropertyValue(FlyCapture2::PropertyType type, double value);
void _getPropertyRange(FlyCapture2::PropertyType type, double& min_value, double& max_value);
void _getPropertyAutoMode(FlyCapture2::PropertyType type, bool& auto_mode);
void _setPropertyAutoMode(FlyCapture2::PropertyType type, bool auto_mode);
void _getImageSettingsInfo();
void _applyImageSettings();
private:
class _AcqThread;
friend class _AcqThread;
void _setStatus(Camera::Status status, bool force);
void _stopAcq(bool internalFlag);
void _forcePGRY16Mode();
SoftBufferCtrlObj m_buffer_ctrl_obj;
Camera::Status m_status;
int m_nb_frames;
int m_image_number;
_AcqThread *m_acq_thread;
Cond m_cond;
volatile bool m_quit;
volatile bool m_acq_started;
volatile bool m_thread_running;
Camera_t *m_camera;
FlyCapture2::CameraInfo m_camera_info;
FlyCapture2::Error m_error;
ImageSettingsInfo_t m_image_settings_info;
ImageSettings_t m_image_settings;
};
} // namespace PointGrey
} // namespace lima
#endif // POINTGREYCAMERA_H
//###########################################################################
// This file is part of LImA, a Library for Image Acquisition
//
// Copyright (C) : 2009-2011
// European Synchrotron Radiation Facility
// BP 220, Grenoble 38043
// FRANCE
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// This software is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, see <http://www.gnu.org/licenses/>.
//###########################################################################
#ifndef POINTGREYDETINFOCTRLOBJ_H
#define POINTGREYDETINFOCTRLOBJ_H
#include "HwDetInfoCtrlObj.h"
namespace lima
{
namespace PointGrey
{
class Camera;
/*******************************************************************
* \class DetInfoCtrlObj
* \brief Control object providing PointGrey detector info interface
*******************************************************************/
class DetInfoCtrlObj : public HwDetInfoCtrlObj
{
DEB_CLASS_NAMESPC(DebModCamera, "DetInfoCtrlObj", "PointGrey");
public:
DetInfoCtrlObj(Camera& cam);
virtual ~DetInfoCtrlObj() {};
virtual void getMaxImageSize(Size& max_image_size);
virtual void getDetectorImageSize(Size& det_image_size);
virtual void getDefImageType(ImageType& def_image_type);
virtual void getCurrImageType(ImageType& curr_image_type);
virtual void setCurrImageType(ImageType curr_image_type);
virtual void getPixelSize(double& x_size, double &y_size);
virtual void getDetectorType(std::string& det_type);
virtual void getDetectorModel(std::string& det_model);
virtual void registerMaxImageSizeCallback(HwMaxImageSizeCallback& cb);
virtual void unregisterMaxImageSizeCallback(HwMaxImageSizeCallback& cb);
private:
Camera& m_cam;
};
} // namespace PointGrey
} // namespace lima
#endif // POINTGREYDETINFOCTRLOBJ_H
......@@ -23,163 +23,26 @@
#define POINTGREYINTERFACE_H
#include "HwInterface.h"
#include "PointGreyCamera.h"
namespace lima
{
namespace PointGrey
{
class Interface;
/*******************************************************************
* \class DetInfoCtrlObj
* \brief Control object providing PointGrey detector info interface
*******************************************************************/
class DetInfoCtrlObj : public HwDetInfoCtrlObj
{
DEB_CLASS_NAMESPC(DebModCamera, "DetInfoCtrlObj", "PointGrey");
public:
DetInfoCtrlObj(Camera& cam);
virtual ~DetInfoCtrlObj() {};
virtual void getMaxImageSize(Size& max_image_size);
virtual void getDetectorImageSize(Size& det_image_size);
virtual void getDefImageType(ImageType& def_image_type);
virtual void getCurrImageType(ImageType& curr_image_type);
virtual void setCurrImageType(ImageType curr_image_type);
virtual void getPixelSize(double& x_size,double &y_size);
virtual void getDetectorType(std::string& det_type);
virtual void getDetectorModel(std::string& det_model);
virtual void registerMaxImageSizeCallback(HwMaxImageSizeCallback& cb);
virtual void unregisterMaxImageSizeCallback(HwMaxImageSizeCallback& cb);
private:
Camera& m_cam;
};
/*******************************************************************
* \class SyncCtrlObj
* \brief Control object providing PointGrey synchronization interface
*******************************************************************/
class SyncCtrlObj : public HwSyncCtrlObj
{
DEB_CLASS_NAMESPC(DebModCamera, "SyncCtrlObj", "PointGrey");
public:
SyncCtrlObj(Camera& cam);
virtual ~SyncCtrlObj() {};
virtual bool checkTrigMode(TrigMode trig_mode);
virtual void setTrigMode(TrigMode trig_mode);
virtual void getTrigMode(TrigMode& trig_mode);
virtual void setExpTime(double exp_time);
virtual void getExpTime(double& exp_time);
virtual void setLatTime(double lat_time);
virtual void getLatTime(double& lat_time);
virtual void setNbHwFrames(int nb_frames);
virtual void getNbHwFrames(int& nb_frames);
virtual void getValidRanges(ValidRangesType& valid_ranges);
private:
Camera& m_cam;
};
/*******************************************************************
* \class RoiCtrlObj
* \brief Control object providing PointGrey Roi interface
*******************************************************************/
class RoiCtrlObj : public HwRoiCtrlObj
{
DEB_CLASS_NAMESPC(DebModCamera, "RoiCtrlObj", "PointGrey");
public:
RoiCtrlObj(Camera& cam);
virtual ~RoiCtrlObj() {};
virtual void setRoi(const Roi& set_roi);
virtual void getRoi(Roi& hw_roi);
virtual void checkRoi(const Roi& set_roi, Roi& hw_roi);
private:
Camera& m_cam;
};
/*******************************************************************
* \class BinCtrlObj
* \brief Control object providing PointGrey Bin interface
*******************************************************************/
class BinCtrlObj : public HwBinCtrlObj
{
DEB_CLASS_NAMESPC(DebModCamera, "BinCtrlObj", "PointGrey");
public:
BinCtrlObj(Camera& cam);
virtual ~BinCtrlObj() {}
virtual void setBin(const Bin& bin);
virtual void getBin(Bin& bin);
virtual void checkBin(Bin& bin);
private:
Camera& m_cam;
};
/*******************************************************************
* \class VideoCtrlObj
* \brief Control object providing PointGrey Video interface
*******************************************************************/
class VideoCtrlObj : public HwVideoCtrlObj
{
DEB_CLASS_NAMESPC(DebModCamera, "VideoCtrlObj", "PointGrey");
public:
VideoCtrlObj(Camera& cam);
virtual ~VideoCtrlObj() {};
virtual void getSupportedVideoMode(std::list<VideoMode> &aList) const;
virtual void getVideoMode(VideoMode&) const;
virtual void setVideoMode(VideoMode);
virtual void getLive(bool&) const;
virtual void setLive(bool);
virtual void getGain(double&) const;
virtual void setGain(double);
virtual void checkBin(Bin& bin){};
virtual void setBin(const Bin&){};
virtual void checkRoi(const Roi& set_roi, Roi& hw_roi){};
virtual void setRoi(const Roi&){};
private:
Camera& m_cam;
bool m_live;
};
class Camera;
class DetInfoCtrlObj;
class SyncCtrlObj;
/*******************************************************************
* \class Interface
* \brief PointGrey hardware interface
*******************************************************************/
class Interface : public HwInterface
{
DEB_CLASS_NAMESPC(DebModCamera, "PointGreyInterface", "PointGrey");
public:
public:
Interface(Camera& cam);
virtual ~Interface() {};
virtual ~Interface();
//- From HwInterface
virtual void getCapList(CapList&) const;
......@@ -190,23 +53,14 @@ class Interface : public HwInterface
virtual void getStatus(StatusType& status);
virtual int getNbHwAcquiredFrames();
//- PointGrey Specific
void getAutoExpTime(bool &auto_frame_rate) const;
void setAutoExpTime(bool auto_exp_time);
Camera& getCamera() { return m_cam; }
void getAutoGain(bool& auto_gain) const;
void setAutoGain(bool auto_gain);
private:
Camera& m_cam;
CapList m_cap_list;
DetInfoCtrlObj m_det_info;
SyncCtrlObj m_sync;
BinCtrlObj m_bin;
RoiCtrlObj m_roi;
VideoCtrlObj m_video;
private:
Camera& m_cam;
CapList m_cap_list;
DetInfoCtrlObj *m_det_info;
SyncCtrlObj *m_sync;
};
} // namespace PointGrey
} // namespace lima
......
//###########################################################################
// This file is part of LImA, a Library for Image Acquisition
//
// Copyright (C) : 2009-2011
// European Synchrotron Radiation Facility
// BP 220, Grenoble 38043
// FRANCE
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// This software is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, see <http://www.gnu.org/licenses/>.
//###########################################################################
#ifndef POINTGREYSYNCCTRLOBJ_H
#define POINTGREYSYNCCTRLOBJ_H
#include "HwSyncCtrlObj.h"
namespace lima
{
namespace PointGrey
{
class Camera;
/*******************************************************************
* \class SyncCtrlObj
* \brief Control object providing PointGrey synchronization interface
*******************************************************************/
class SyncCtrlObj : public HwSyncCtrlObj
{
DEB_CLASS_NAMESPC(DebModCamera, "SyncCtrlObj", "PointGrey");
public:
SyncCtrlObj(Camera& cam);
virtual ~SyncCtrlObj() {};
virtual bool checkTrigMode(TrigMode trig_mode);
virtual void setTrigMode(TrigMode trig_mode);
virtual void getTrigMode(TrigMode& trig_mode);
virtual void setExpTime(double exp_time);
virtual void getExpTime(double& exp_time);
virtual void setLatTime(double lat_time);
virtual void getLatTime(double& lat_time);
virtual void setNbHwFrames(int nb_frames);
virtual void getNbHwFrames(int& nb_frames);
virtual void getValidRanges(ValidRangesType& valid_ranges);
private:
void _adjustFrameRate();
Camera& m_cam;
double m_exp_time;
double m_lat_time;
double m_max_acq_period;
ValidRangesType m_valid_ranges;
};
} // namespace PointGrey
} // namespace lima
#endif // POINTGREYSYNCCTRLOBJ_H
......@@ -13,7 +13,7 @@ namespace PointGrey
Ready, Exposure, Readout, Latency,
};
Camera(const std::string& camera_ip, const int camera_serial_no = 0);
Camera(const int camera_serial, const int packet_size = -1, const int packet_delay = -1);
~Camera();
void prepareAcq();
......@@ -33,11 +33,7 @@ namespace PointGrey
void getExpTime(double& exp_time /Out/);
void setExpTime(double exp_time);
void getExpTimeRange(double& min_exp_time /Out/, double& max_exp_time /Out/) const;
void getLatTime(double& lat_time /Out/);
void setLatTime(double lat_time);
void getLatTimeRange(double& min_lat_time /Out/, double& max_lat_time /Out/) const;
void getExpTimeRange(double& min_exp_time /Out/, double& max_exp_time /Out/);
void getNbFrames(int& nb_frames /Out/);
void setNbFrames(int nb_frames);
......@@ -52,15 +48,31 @@ namespace PointGrey
void getBin(Bin& /Out/);
void setBin(const Bin&);
// -- video
void getGain(double& gain /Out/);
void setGain(double gain);
// -- camera specific
void getAutoExpTime(bool &auto_frame_rate /Out/) const;
// packet size control
void getPacketSize(int& packet_size /Out/);
void setPacketSize(int packet_size);
// packet delay control
void getPacketDelay(int& packet_delay /Out/);
void setPacketDelay(int packet_delay);
// exposure control
void getAutoExpTime(bool& auto_exp_time /Out/);
void setAutoExpTime(bool auto_exp_time);
void getAutoGain(bool& auto_gain /Out/) const;
void setAutoGain(bool auto_gain);
// gain control
void getGain(double& gain /Out/);
void setGain(double gain);
void getAutoGain(bool& auto_gain /Out/);
void setAutoGain(bool auto_gain);
void getGainRange(double& min_gain /Out/, double& max_gain /Out/);
// frame rate control
void getFrameRate(double& frame_rate /Out/);
void setFrameRate(double frame_rate);
void getAutoFrameRate(bool& auto_frame_rate /Out/);
void setAutoFrameRate(bool auto_frame_rate);
void getFrameRateRange(double& min_frame_rate /Out/, double& max_frame_rate /Out/);
};
};
......@@ -16,13 +16,109 @@ namespace PointGrey
virtual void startAcq();
virtual void stopAcq();
virtual void getStatus(StatusType& status /Out/);
virtual int getNbHwAcquiredFrames();
virtual int getNbHwAcquiredFrames();
//- camera specific
void getAutoExpTime(bool& auto_frame_rate /Out/) const;
void setAutoExpTime(bool auto_exp_time);
// -- camera specific
// packet size control
void getPacketSize(int& packet_size /Out/);
%MethodCode
sipCpp->getCamera().getPacketSize(a0);
%End
void setPacketSize(int packet_size);
%MethodCode
sipCpp->getCamera().setPacketSize(a0);
%End
// packet delay control
void getPacketDelay(int& packet_delay /Out/);
%MethodCode
sipCpp->getCamera().getPacketDelay(a0);
%End
void setPacketDelay(int packet_delay);
%MethodCode
sipCpp->getCamera().setPacketDelay(a0);
%End
// gain control
void getGain(double& gain /Out/);
%MethodCode
sipCpp->getCamera().getGain(a0);
%End
void setGain(double gain);
%MethodCode
sipCpp->getCamera().setGain(a0);
%End
void getAutoGain(bool& auto_gain /Out/);
%MethodCode
sipCpp->getCamera().getAutoGain(a0);
%End
void setAutoGain(bool auto_gain);
%MethodCode
sipCpp->getCamera().setAutoGain(a0);
%End
void getGainRange(double& min_gain /Out/, double& max_gain /Out/);
%MethodCode
sipCpp->getCamera().getGainRange(a0, a1);
%End
// exposure control
void getExpTime(double& exp_time /Out/);
%MethodCode
sipCpp->getCamera().getExpTime(a0);
%End
void setExpTime(double exp_time);
%MethodCode
sipCpp->getCamera().setExpTime(a0);
%End
void getAutoExpTime(bool& auto_exp_time /Out/);
%MethodCode
sipCpp->getCamera().getAutoExpTime(a0);
%End
void setAutoExpTime(bool auto_exp_time);
%MethodCode
sipCpp->getCamera().setAutoExpTime(a0);
%End
void getExpTimeRange(double& min_exp_time /Out/, double& max_exp_time /Out/);
%MethodCode
sipCpp->getCamera().getExpTimeRange(a0, a1);
%End
// frame rate control
void getFrameRate(double& frame_rate /Out/);
%MethodCode
sipCpp->getCamera().getFrameRate(a0);
%End
void setFrameRate(double frame_rate);
%MethodCode
sipCpp->getCamera().setFrameRate(a0);
%End
void getAutoFrameRate(bool& auto_frame_rate /Out/);
%MethodCode
sipCpp->getCamera().getAutoFrameRate(a0);
%End
void setAutoFrameRate(bool auto_frame_rate);
%MethodCode
sipCpp->getCamera().setAutoFrameRate(a0);
%End
void getFrameRateRange(double& min_frame_rate /Out/, double& max_frame_rate /Out/);
%MethodCode
sipCpp->getCamera().getFrameRateRange(a0, a1);
%End
void getAutoGain(bool& auto_gain /Out/) const;
void setAutoGain(bool auto_gain);
};
};
pointgrey-objs = PointGreyCamera.o PointGreyInterface.o
pointgrey-objs = PointGreyCamera.o \
PointGreyInterface.o \
PointGreyDetInfoCtrlObj.o \
PointGreySyncCtrlObj.o
SRCS = $(pointgrey-objs:.o=.cpp)
CXXFLAGS += -I../include -I../../../hardware/include -I../../../common/include \
-I/usr/include/flycapture \
-fPIC -g
-fPIC -g -DUSE_GIGE
all: PointGrey.o
......
This diff is collapsed.
//###########################################################################
// This file is part of LImA, a Library for Image Acquisition
//
// Copyright (C) : 2009-2011
// European Synchrotron Radiation Facility
// BP 220, Grenoble 38043
// FRANCE