2011-08-12 01:59:30 +08:00
|
|
|
#include "precomp.hpp"
|
|
|
|
|
2014-09-09 23:22:20 +08:00
|
|
|
#ifdef WIN32
|
2011-08-12 01:59:30 +08:00
|
|
|
#include "xiApi.h"
|
2014-09-09 23:22:20 +08:00
|
|
|
#else
|
|
|
|
#include <m3api/xiApi.h>
|
|
|
|
#endif
|
2011-08-12 01:59:30 +08:00
|
|
|
|
|
|
|
/**********************************************************************************/
|
|
|
|
|
|
|
|
class CvCaptureCAM_XIMEA : public CvCapture
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CvCaptureCAM_XIMEA() { init(); }
|
|
|
|
virtual ~CvCaptureCAM_XIMEA() { close(); }
|
|
|
|
|
|
|
|
virtual bool open( int index );
|
|
|
|
virtual void close();
|
2014-12-11 01:17:35 +08:00
|
|
|
virtual double getProperty(int) const;
|
2011-08-12 01:59:30 +08:00
|
|
|
virtual bool setProperty(int, double);
|
|
|
|
virtual bool grabFrame();
|
|
|
|
virtual IplImage* retrieveFrame(int);
|
2012-06-26 19:47:49 +08:00
|
|
|
virtual int getCaptureDomain() { return CV_CAP_XIAPI; } // Return the type of the capture object: CV_CAP_VFW, etc...
|
2011-08-12 01:59:30 +08:00
|
|
|
|
2013-06-12 01:17:31 +08:00
|
|
|
private:
|
2012-06-26 19:47:49 +08:00
|
|
|
void init();
|
|
|
|
void errMsg(const char* msg, int errNum);
|
2013-06-12 01:17:31 +08:00
|
|
|
void resetCvImage();
|
|
|
|
int getBpp();
|
2011-08-12 01:59:30 +08:00
|
|
|
IplImage* frame;
|
|
|
|
|
2012-06-26 19:47:49 +08:00
|
|
|
HANDLE hmv;
|
|
|
|
DWORD numDevices;
|
|
|
|
int timeout;
|
2013-06-12 01:17:31 +08:00
|
|
|
XI_IMG image;
|
2011-08-12 01:59:30 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/**********************************************************************************/
|
|
|
|
|
|
|
|
CvCapture* cvCreateCameraCapture_XIMEA( int index )
|
|
|
|
{
|
2013-06-12 01:17:31 +08:00
|
|
|
CvCaptureCAM_XIMEA* capture = new CvCaptureCAM_XIMEA;
|
2011-08-12 01:59:30 +08:00
|
|
|
|
|
|
|
if( capture->open( index ))
|
|
|
|
return capture;
|
|
|
|
|
2012-06-26 19:47:49 +08:00
|
|
|
delete capture;
|
2011-08-12 01:59:30 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************************/
|
|
|
|
// Enumerate connected devices
|
|
|
|
void CvCaptureCAM_XIMEA::init()
|
|
|
|
{
|
2015-04-04 03:49:50 +08:00
|
|
|
#if defined WIN32 || defined _WIN32
|
2012-06-26 19:47:49 +08:00
|
|
|
xiGetNumberDevices( &numDevices);
|
2015-04-04 03:49:50 +08:00
|
|
|
#else
|
|
|
|
// try second re-enumeration if first one fails
|
|
|
|
if (xiGetNumberDevices( &numDevices) != XI_OK)
|
|
|
|
{
|
|
|
|
xiGetNumberDevices( &numDevices);
|
|
|
|
}
|
|
|
|
#endif
|
2012-06-26 19:47:49 +08:00
|
|
|
hmv = NULL;
|
2013-07-09 04:33:39 +08:00
|
|
|
frame = NULL;
|
|
|
|
timeout = 0;
|
2012-06-26 19:47:49 +08:00
|
|
|
memset(&image, 0, sizeof(XI_IMG));
|
2011-08-12 01:59:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************************/
|
|
|
|
// Initialize camera input
|
|
|
|
bool CvCaptureCAM_XIMEA::open( int wIndex )
|
|
|
|
{
|
2013-11-20 04:51:47 +08:00
|
|
|
#define HandleXiResult(res) if (res!=XI_OK) goto error;
|
|
|
|
|
2012-06-26 19:47:49 +08:00
|
|
|
int mvret = XI_OK;
|
|
|
|
|
2013-11-20 04:51:47 +08:00
|
|
|
if(numDevices == 0)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if((mvret = xiOpenDevice( wIndex, &hmv)) != XI_OK)
|
2013-07-09 04:33:39 +08:00
|
|
|
{
|
2015-04-04 03:49:50 +08:00
|
|
|
#if defined WIN32 || defined _WIN32
|
2013-11-20 04:51:47 +08:00
|
|
|
errMsg("Open XI_DEVICE failed", mvret);
|
|
|
|
return false;
|
2015-04-04 03:49:50 +08:00
|
|
|
#else
|
|
|
|
// try opening second time if first fails
|
|
|
|
if((mvret = xiOpenDevice( wIndex, &hmv)) != XI_OK)
|
|
|
|
{
|
|
|
|
errMsg("Open XI_DEVICE failed", mvret);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
#endif
|
2013-07-09 04:33:39 +08:00
|
|
|
}
|
2013-11-20 04:51:47 +08:00
|
|
|
|
|
|
|
int width = 0;
|
|
|
|
int height = 0;
|
|
|
|
int isColor = 0;
|
|
|
|
|
|
|
|
// always use auto exposure/gain
|
|
|
|
mvret = xiSetParamInt( hmv, XI_PRM_AEAG, 1);
|
|
|
|
HandleXiResult(mvret);
|
|
|
|
|
|
|
|
mvret = xiGetParamInt( hmv, XI_PRM_WIDTH, &width);
|
|
|
|
HandleXiResult(mvret);
|
|
|
|
|
|
|
|
mvret = xiGetParamInt( hmv, XI_PRM_HEIGHT, &height);
|
|
|
|
HandleXiResult(mvret);
|
|
|
|
|
|
|
|
mvret = xiGetParamInt(hmv, XI_PRM_IMAGE_IS_COLOR, &isColor);
|
|
|
|
HandleXiResult(mvret);
|
|
|
|
|
|
|
|
if(isColor) // for color cameras
|
2013-07-09 04:33:39 +08:00
|
|
|
{
|
2013-11-20 04:51:47 +08:00
|
|
|
// default image format RGB24
|
|
|
|
mvret = xiSetParamInt( hmv, XI_PRM_IMAGE_DATA_FORMAT, XI_RGB24);
|
|
|
|
HandleXiResult(mvret);
|
|
|
|
|
|
|
|
// always use auto white balance for color cameras
|
|
|
|
mvret = xiSetParamInt( hmv, XI_PRM_AUTO_WB, 1);
|
|
|
|
HandleXiResult(mvret);
|
|
|
|
|
|
|
|
// allocate frame buffer for RGB24 image
|
|
|
|
frame = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 3);
|
2013-07-09 04:33:39 +08:00
|
|
|
}
|
2013-11-20 04:51:47 +08:00
|
|
|
else // for mono cameras
|
2012-06-26 19:47:49 +08:00
|
|
|
{
|
2013-11-20 04:51:47 +08:00
|
|
|
// default image format MONO8
|
|
|
|
mvret = xiSetParamInt( hmv, XI_PRM_IMAGE_DATA_FORMAT, XI_MONO8);
|
|
|
|
HandleXiResult(mvret);
|
|
|
|
|
|
|
|
// allocate frame buffer for MONO8 image
|
|
|
|
frame = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
//default capture timeout 10s
|
|
|
|
timeout = 10000;
|
|
|
|
|
|
|
|
mvret = xiStartAcquisition(hmv);
|
|
|
|
if(mvret != XI_OK)
|
|
|
|
{
|
|
|
|
errMsg("StartAcquisition XI_DEVICE failed", mvret);
|
|
|
|
goto error;
|
2012-06-26 19:47:49 +08:00
|
|
|
}
|
|
|
|
return true;
|
2013-11-20 04:51:47 +08:00
|
|
|
|
|
|
|
error:
|
|
|
|
errMsg("Open XI_DEVICE failed", mvret);
|
|
|
|
xiCloseDevice(hmv);
|
|
|
|
hmv = NULL;
|
|
|
|
return false;
|
2011-08-12 01:59:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************************/
|
|
|
|
|
|
|
|
void CvCaptureCAM_XIMEA::close()
|
|
|
|
{
|
2013-06-12 01:17:31 +08:00
|
|
|
if(frame)
|
|
|
|
cvReleaseImage(&frame);
|
2013-08-21 20:44:09 +08:00
|
|
|
|
2013-07-09 04:33:39 +08:00
|
|
|
if(hmv)
|
|
|
|
{
|
|
|
|
xiStopAcquisition(hmv);
|
|
|
|
xiCloseDevice(hmv);
|
|
|
|
}
|
2013-06-12 01:17:31 +08:00
|
|
|
hmv = NULL;
|
2011-08-12 01:59:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************************/
|
|
|
|
|
|
|
|
bool CvCaptureCAM_XIMEA::grabFrame()
|
|
|
|
{
|
2013-06-12 01:17:31 +08:00
|
|
|
memset(&image, 0, sizeof(XI_IMG));
|
2012-06-26 19:47:49 +08:00
|
|
|
image.size = sizeof(XI_IMG);
|
|
|
|
int mvret = xiGetImage( hmv, timeout, &image);
|
|
|
|
|
2014-09-09 23:22:20 +08:00
|
|
|
if(mvret == XI_ACQUISITION_STOPED)
|
2012-06-26 19:47:49 +08:00
|
|
|
{
|
|
|
|
xiStartAcquisition(hmv);
|
|
|
|
mvret = xiGetImage(hmv, timeout, &image);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(mvret != XI_OK)
|
|
|
|
{
|
|
|
|
errMsg("Error during GetImage", mvret);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-08-12 01:59:30 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************************/
|
|
|
|
|
|
|
|
IplImage* CvCaptureCAM_XIMEA::retrieveFrame(int)
|
|
|
|
{
|
2012-06-26 19:47:49 +08:00
|
|
|
// update cvImage after format has changed
|
2013-06-12 01:17:31 +08:00
|
|
|
resetCvImage();
|
2013-08-21 20:44:09 +08:00
|
|
|
|
2012-06-26 19:47:49 +08:00
|
|
|
// copy pixel data
|
|
|
|
switch( image.frm)
|
|
|
|
{
|
2013-08-21 20:44:09 +08:00
|
|
|
case XI_MONO8 :
|
2013-06-12 01:17:31 +08:00
|
|
|
case XI_RAW8 : memcpy( frame->imageData, image.bp, image.width*image.height); break;
|
|
|
|
case XI_MONO16 :
|
|
|
|
case XI_RAW16 : memcpy( frame->imageData, image.bp, image.width*image.height*sizeof(WORD)); break;
|
|
|
|
case XI_RGB24 :
|
|
|
|
case XI_RGB_PLANAR : memcpy( frame->imageData, image.bp, image.width*image.height*3); break;
|
|
|
|
case XI_RGB32 : memcpy( frame->imageData, image.bp, image.width*image.height*4); break;
|
2012-06-26 19:47:49 +08:00
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
return frame;
|
2011-08-12 01:59:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************************/
|
|
|
|
|
2013-06-12 01:17:31 +08:00
|
|
|
void CvCaptureCAM_XIMEA::resetCvImage()
|
|
|
|
{
|
|
|
|
int width = 0, height = 0, format = 0;
|
|
|
|
xiGetParamInt( hmv, XI_PRM_WIDTH, &width);
|
|
|
|
xiGetParamInt( hmv, XI_PRM_HEIGHT, &height);
|
|
|
|
xiGetParamInt( hmv, XI_PRM_IMAGE_DATA_FORMAT, &format);
|
|
|
|
|
2015-02-02 21:59:52 +08:00
|
|
|
if( (int)image.width != frame->width || (int)image.height != frame->height || image.frm != (XI_IMG_FORMAT)format)
|
2013-06-12 01:17:31 +08:00
|
|
|
{
|
|
|
|
if(frame) cvReleaseImage(&frame);
|
|
|
|
frame = NULL;
|
|
|
|
|
|
|
|
switch( image.frm)
|
|
|
|
{
|
|
|
|
case XI_MONO8 :
|
|
|
|
case XI_RAW8 : frame = cvCreateImage(cvSize( image.width, image.height), IPL_DEPTH_8U, 1); break;
|
2013-08-21 20:44:09 +08:00
|
|
|
case XI_MONO16 :
|
2013-06-12 01:17:31 +08:00
|
|
|
case XI_RAW16 : frame = cvCreateImage(cvSize( image.width, image.height), IPL_DEPTH_16U, 1); break;
|
2013-08-21 20:44:09 +08:00
|
|
|
case XI_RGB24 :
|
2013-06-12 01:17:31 +08:00
|
|
|
case XI_RGB_PLANAR : frame = cvCreateImage(cvSize( image.width, image.height), IPL_DEPTH_8U, 3); break;
|
|
|
|
case XI_RGB32 : frame = cvCreateImage(cvSize( image.width, image.height), IPL_DEPTH_8U, 4); break;
|
|
|
|
default :
|
|
|
|
return;
|
|
|
|
}
|
2013-08-21 20:44:09 +08:00
|
|
|
}
|
2013-06-12 01:17:31 +08:00
|
|
|
cvZero(frame);
|
|
|
|
}
|
|
|
|
/**********************************************************************************/
|
|
|
|
|
2014-12-11 01:17:35 +08:00
|
|
|
double CvCaptureCAM_XIMEA::getProperty( int property_id ) const
|
2011-08-12 01:59:30 +08:00
|
|
|
{
|
2012-06-26 19:47:49 +08:00
|
|
|
if(hmv == NULL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
int ival = 0;
|
|
|
|
float fval = 0;
|
|
|
|
|
|
|
|
switch( property_id )
|
|
|
|
{
|
|
|
|
// OCV parameters
|
|
|
|
case CV_CAP_PROP_POS_FRAMES : return (double) image.nframe;
|
|
|
|
case CV_CAP_PROP_FRAME_WIDTH : xiGetParamInt( hmv, XI_PRM_WIDTH, &ival); return ival;
|
|
|
|
case CV_CAP_PROP_FRAME_HEIGHT : xiGetParamInt( hmv, XI_PRM_HEIGHT, &ival); return ival;
|
|
|
|
case CV_CAP_PROP_FPS : xiGetParamFloat( hmv, XI_PRM_FRAMERATE, &fval); return fval;
|
|
|
|
case CV_CAP_PROP_GAIN : xiGetParamFloat( hmv, XI_PRM_GAIN, &fval); return fval;
|
|
|
|
case CV_CAP_PROP_EXPOSURE : xiGetParamInt( hmv, XI_PRM_EXPOSURE, &ival); return ival;
|
|
|
|
|
|
|
|
// XIMEA camera properties
|
|
|
|
case CV_CAP_PROP_XI_DOWNSAMPLING : xiGetParamInt( hmv, XI_PRM_DOWNSAMPLING, &ival); return ival;
|
|
|
|
case CV_CAP_PROP_XI_DATA_FORMAT : xiGetParamInt( hmv, XI_PRM_IMAGE_DATA_FORMAT, &ival); return ival;
|
|
|
|
case CV_CAP_PROP_XI_OFFSET_X : xiGetParamInt( hmv, XI_PRM_OFFSET_X, &ival); return ival;
|
|
|
|
case CV_CAP_PROP_XI_OFFSET_Y : xiGetParamInt( hmv, XI_PRM_OFFSET_Y, &ival); return ival;
|
|
|
|
case CV_CAP_PROP_XI_TRG_SOURCE : xiGetParamInt( hmv, XI_PRM_TRG_SOURCE, &ival); return ival;
|
|
|
|
case CV_CAP_PROP_XI_GPI_SELECTOR : xiGetParamInt( hmv, XI_PRM_GPI_SELECTOR, &ival); return ival;
|
|
|
|
case CV_CAP_PROP_XI_GPI_MODE : xiGetParamInt( hmv, XI_PRM_GPI_MODE, &ival); return ival;
|
|
|
|
case CV_CAP_PROP_XI_GPI_LEVEL : xiGetParamInt( hmv, XI_PRM_GPI_LEVEL, &ival); return ival;
|
|
|
|
case CV_CAP_PROP_XI_GPO_SELECTOR : xiGetParamInt( hmv, XI_PRM_GPO_SELECTOR, &ival); return ival;
|
|
|
|
case CV_CAP_PROP_XI_GPO_MODE : xiGetParamInt( hmv, XI_PRM_GPO_MODE, &ival); return ival;
|
|
|
|
case CV_CAP_PROP_XI_LED_SELECTOR : xiGetParamInt( hmv, XI_PRM_LED_SELECTOR, &ival); return ival;
|
|
|
|
case CV_CAP_PROP_XI_LED_MODE : xiGetParamInt( hmv, XI_PRM_LED_MODE, &ival); return ival;
|
|
|
|
case CV_CAP_PROP_XI_AUTO_WB : xiGetParamInt( hmv, XI_PRM_AUTO_WB, &ival); return ival;
|
|
|
|
case CV_CAP_PROP_XI_AEAG : xiGetParamInt( hmv, XI_PRM_AEAG, &ival); return ival;
|
|
|
|
case CV_CAP_PROP_XI_EXP_PRIORITY : xiGetParamFloat( hmv, XI_PRM_EXP_PRIORITY, &fval); return fval;
|
2015-02-07 05:48:37 +08:00
|
|
|
case CV_CAP_PROP_XI_AE_MAX_LIMIT : xiGetParamInt( hmv, XI_PRM_AE_MAX_LIMIT, &ival); return ival;
|
2012-06-26 19:47:49 +08:00
|
|
|
case CV_CAP_PROP_XI_AG_MAX_LIMIT : xiGetParamFloat( hmv, XI_PRM_AG_MAX_LIMIT, &fval); return fval;
|
|
|
|
case CV_CAP_PROP_XI_AEAG_LEVEL : xiGetParamInt( hmv, XI_PRM_AEAG_LEVEL, &ival); return ival;
|
|
|
|
case CV_CAP_PROP_XI_TIMEOUT : return timeout;
|
|
|
|
|
|
|
|
}
|
|
|
|
return 0;
|
2011-08-12 01:59:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************************/
|
|
|
|
|
|
|
|
bool CvCaptureCAM_XIMEA::setProperty( int property_id, double value )
|
2012-06-26 19:47:49 +08:00
|
|
|
{
|
|
|
|
int ival = (int) value;
|
|
|
|
float fval = (float) value;
|
|
|
|
|
|
|
|
int mvret = XI_OK;
|
|
|
|
|
|
|
|
switch(property_id)
|
|
|
|
{
|
|
|
|
// OCV parameters
|
2013-06-12 01:17:31 +08:00
|
|
|
case CV_CAP_PROP_FRAME_WIDTH : mvret = xiSetParamInt( hmv, XI_PRM_WIDTH, ival); break;
|
|
|
|
case CV_CAP_PROP_FRAME_HEIGHT : mvret = xiSetParamInt( hmv, XI_PRM_HEIGHT, ival); break;
|
2011-08-12 01:59:30 +08:00
|
|
|
case CV_CAP_PROP_FPS : mvret = xiSetParamFloat( hmv, XI_PRM_FRAMERATE, fval); break;
|
2012-06-26 19:47:49 +08:00
|
|
|
case CV_CAP_PROP_GAIN : mvret = xiSetParamFloat( hmv, XI_PRM_GAIN, fval); break;
|
|
|
|
case CV_CAP_PROP_EXPOSURE : mvret = xiSetParamInt( hmv, XI_PRM_EXPOSURE, ival); break;
|
|
|
|
// XIMEA camera properties
|
|
|
|
case CV_CAP_PROP_XI_DOWNSAMPLING : mvret = xiSetParamInt( hmv, XI_PRM_DOWNSAMPLING, ival); break;
|
2013-06-12 01:17:31 +08:00
|
|
|
case CV_CAP_PROP_XI_DATA_FORMAT : mvret = xiSetParamInt( hmv, XI_PRM_IMAGE_DATA_FORMAT, ival); break;
|
2012-06-26 19:47:49 +08:00
|
|
|
case CV_CAP_PROP_XI_OFFSET_X : mvret = xiSetParamInt( hmv, XI_PRM_OFFSET_X, ival); break;
|
|
|
|
case CV_CAP_PROP_XI_OFFSET_Y : mvret = xiSetParamInt( hmv, XI_PRM_OFFSET_Y, ival); break;
|
|
|
|
case CV_CAP_PROP_XI_TRG_SOURCE : mvret = xiSetParamInt( hmv, XI_PRM_TRG_SOURCE, ival); break;
|
|
|
|
case CV_CAP_PROP_XI_GPI_SELECTOR : mvret = xiSetParamInt( hmv, XI_PRM_GPI_SELECTOR, ival); break;
|
2015-02-07 05:48:37 +08:00
|
|
|
case CV_CAP_PROP_XI_TRG_SOFTWARE : mvret = xiSetParamInt( hmv, XI_PRM_TRG_SOFTWARE, 1); break;
|
2012-06-26 19:47:49 +08:00
|
|
|
case CV_CAP_PROP_XI_GPI_MODE : mvret = xiSetParamInt( hmv, XI_PRM_GPI_MODE, ival); break;
|
|
|
|
case CV_CAP_PROP_XI_GPI_LEVEL : mvret = xiSetParamInt( hmv, XI_PRM_GPI_LEVEL, ival); break;
|
|
|
|
case CV_CAP_PROP_XI_GPO_SELECTOR : mvret = xiSetParamInt( hmv, XI_PRM_GPO_SELECTOR, ival); break;
|
|
|
|
case CV_CAP_PROP_XI_GPO_MODE : mvret = xiSetParamInt( hmv, XI_PRM_GPO_MODE, ival); break;
|
|
|
|
case CV_CAP_PROP_XI_LED_SELECTOR : mvret = xiSetParamInt( hmv, XI_PRM_LED_SELECTOR, ival); break;
|
|
|
|
case CV_CAP_PROP_XI_LED_MODE : mvret = xiSetParamInt( hmv, XI_PRM_LED_MODE, ival); break;
|
|
|
|
case CV_CAP_PROP_XI_AUTO_WB : mvret = xiSetParamInt( hmv, XI_PRM_AUTO_WB, ival); break;
|
2015-02-07 05:48:37 +08:00
|
|
|
case CV_CAP_PROP_XI_MANUAL_WB : mvret = xiSetParamInt( hmv, XI_PRM_MANUAL_WB, ival); break;
|
2012-06-26 19:47:49 +08:00
|
|
|
case CV_CAP_PROP_XI_AEAG : mvret = xiSetParamInt( hmv, XI_PRM_AEAG, ival); break;
|
|
|
|
case CV_CAP_PROP_XI_EXP_PRIORITY : mvret = xiSetParamFloat( hmv, XI_PRM_EXP_PRIORITY, fval); break;
|
2015-02-07 05:48:37 +08:00
|
|
|
case CV_CAP_PROP_XI_AE_MAX_LIMIT : mvret = xiSetParamInt( hmv, XI_PRM_AE_MAX_LIMIT, ival); break;
|
2012-06-26 19:47:49 +08:00
|
|
|
case CV_CAP_PROP_XI_AG_MAX_LIMIT : mvret = xiSetParamFloat( hmv, XI_PRM_AG_MAX_LIMIT, fval); break;
|
|
|
|
case CV_CAP_PROP_XI_AEAG_LEVEL : mvret = xiSetParamInt( hmv, XI_PRM_AEAG_LEVEL, ival); break;
|
|
|
|
case CV_CAP_PROP_XI_TIMEOUT : timeout = ival; break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(mvret != XI_OK)
|
|
|
|
{
|
|
|
|
errMsg("Set parameter error", mvret);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return true;
|
|
|
|
|
2011-08-12 01:59:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************************/
|
|
|
|
|
2012-06-26 19:47:49 +08:00
|
|
|
void CvCaptureCAM_XIMEA::errMsg(const char* msg, int errNum)
|
2011-08-12 01:59:30 +08:00
|
|
|
{
|
2012-06-26 19:47:49 +08:00
|
|
|
#if defined WIN32 || defined _WIN32
|
2013-06-12 01:17:31 +08:00
|
|
|
char buf[512]="";
|
2012-06-26 19:47:49 +08:00
|
|
|
sprintf( buf, "%s : %d\n", msg, errNum);
|
|
|
|
OutputDebugString(buf);
|
|
|
|
#else
|
|
|
|
fprintf(stderr, "%s : %d\n", msg, errNum);
|
|
|
|
#endif
|
2011-08-12 01:59:30 +08:00
|
|
|
}
|
|
|
|
|
2013-06-12 01:17:31 +08:00
|
|
|
/**********************************************************************************/
|
|
|
|
|
|
|
|
int CvCaptureCAM_XIMEA::getBpp()
|
|
|
|
{
|
|
|
|
switch( image.frm)
|
|
|
|
{
|
|
|
|
case XI_MONO8 :
|
|
|
|
case XI_RAW8 : return 1;
|
2013-08-21 20:44:09 +08:00
|
|
|
case XI_MONO16 :
|
2013-06-12 01:17:31 +08:00
|
|
|
case XI_RAW16 : return 2;
|
2013-08-21 20:44:09 +08:00
|
|
|
case XI_RGB24 :
|
2013-06-12 01:17:31 +08:00
|
|
|
case XI_RGB_PLANAR : return 3;
|
|
|
|
case XI_RGB32 : return 4;
|
|
|
|
default :
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-21 20:44:09 +08:00
|
|
|
/**********************************************************************************/
|