mirror of
https://github.com/opencv/opencv.git
synced 2024-11-28 21:20:18 +08:00
videoio: ximea - allow opening capture by serial number
This commit is contained in:
parent
1d4a29f149
commit
01acb08c7b
@ -354,7 +354,11 @@ CV_IMPL CvCapture * cvCreateFileCaptureWithPreference (const char * filename, in
|
||||
TRY_OPEN(result, cvCreateFileCapture_OpenNI2 (filename))
|
||||
if (apiPreference) break;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_XIMEA
|
||||
case CAP_XIAPI:
|
||||
TRY_OPEN(result, cvCreateCameraCapture_XIMEA(filename))
|
||||
if (apiPreference) break;
|
||||
#endif
|
||||
case CAP_IMAGES:
|
||||
TRY_OPEN(result, cvCreateFileCapture_Images (filename))
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -126,6 +126,7 @@ CvCapture* cvCreateFileCapture_OpenNI( const char* filename );
|
||||
CvCapture* cvCreateFileCapture_OpenNI2( const char* filename );
|
||||
CvCapture* cvCreateCameraCapture_Android( int index );
|
||||
CvCapture* cvCreateCameraCapture_XIMEA( int index );
|
||||
CvCapture* cvCreateCameraCapture_XIMEA( const char* serialNumber );
|
||||
CvCapture* cvCreateCameraCapture_AVFoundation(int index);
|
||||
CvCapture* cvCreateCameraCapture_Aravis( int index );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user