|
|
|
@ -18,6 +18,7 @@ public: |
|
|
|
|
virtual ~CvCaptureCAM_XIMEA() { close(); } |
|
|
|
|
|
|
|
|
|
virtual bool open( int index ); |
|
|
|
|
bool open( const char* deviceName ); |
|
|
|
|
virtual void close(); |
|
|
|
|
virtual double getProperty(int) const; |
|
|
|
|
virtual bool setProperty(int, double); |
|
|
|
@ -26,6 +27,7 @@ public: |
|
|
|
|
virtual int getCaptureDomain() { return CV_CAP_XIAPI; } // Return the type of the capture object: CV_CAP_VFW, etc...
|
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
bool _open(); |
|
|
|
|
void init(); |
|
|
|
|
void errMsg(const char* msg, int errNum) const; |
|
|
|
|
void resetCvImage(); |
|
|
|
@ -51,6 +53,17 @@ CvCapture* cvCreateCameraCapture_XIMEA( int index ) |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
CvCapture* cvCreateCameraCapture_XIMEA( const char* serialNumber ) |
|
|
|
|
{ |
|
|
|
|
CvCaptureCAM_XIMEA* capture = new CvCaptureCAM_XIMEA; |
|
|
|
|
|
|
|
|
|
if( capture->open( serialNumber )) |
|
|
|
|
return capture; |
|
|
|
|
|
|
|
|
|
delete capture; |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/**********************************************************************************/ |
|
|
|
|
// Enumerate connected devices
|
|
|
|
|
void CvCaptureCAM_XIMEA::init() |
|
|
|
@ -75,13 +88,10 @@ void CvCaptureCAM_XIMEA::init() |
|
|
|
|
// Initialize camera input
|
|
|
|
|
bool CvCaptureCAM_XIMEA::open( int wIndex ) |
|
|
|
|
{ |
|
|
|
|
#define HandleXiResult(res) if (res!=XI_OK) goto error; |
|
|
|
|
|
|
|
|
|
int mvret = XI_OK; |
|
|
|
|
|
|
|
|
|
if(numDevices == 0) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
int mvret = XI_OK; |
|
|
|
|
if((mvret = xiOpenDevice( wIndex, &hmv)) != XI_OK) |
|
|
|
|
{ |
|
|
|
|
#if defined _WIN32 |
|
|
|
@ -97,12 +107,33 @@ bool CvCaptureCAM_XIMEA::open( int wIndex ) |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return _open(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool CvCaptureCAM_XIMEA::open( const char* serialNumber ) |
|
|
|
|
{ |
|
|
|
|
if(numDevices == 0) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
int mvret = XI_OK; |
|
|
|
|
if((mvret = xiOpenDeviceBy(XI_OPEN_BY_SN, serialNumber, &hmv)) != XI_OK) |
|
|
|
|
{ |
|
|
|
|
errMsg("Open XI_DEVICE failed", mvret); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return _open(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool CvCaptureCAM_XIMEA::_open() |
|
|
|
|
{ |
|
|
|
|
#define HandleXiResult(res) if (res!=XI_OK) goto error; |
|
|
|
|
int width = 0; |
|
|
|
|
int height = 0; |
|
|
|
|
int isColor = 0; |
|
|
|
|
|
|
|
|
|
// always use auto exposure/gain
|
|
|
|
|
mvret = xiSetParamInt( hmv, XI_PRM_AEAG, 1); |
|
|
|
|
int mvret = xiSetParamInt( hmv, XI_PRM_AEAG, 1); |
|
|
|
|
HandleXiResult(mvret); |
|
|
|
|
|
|
|
|
|
mvret = xiGetParamInt( hmv, XI_PRM_WIDTH, &width); |
|
|
|
|