@@ -18,6 +18,7 @@ class CvCaptureCAM_XIMEA : public CvCapture
18
18
virtual ~CvCaptureCAM_XIMEA () { close (); }
19
19
20
20
virtual bool open ( int index );
21
+ bool open ( const char * deviceName );
21
22
virtual void close ();
22
23
virtual double getProperty (int ) const ;
23
24
virtual bool setProperty (int , double );
@@ -26,6 +27,7 @@ class CvCaptureCAM_XIMEA : public CvCapture
26
27
virtual int getCaptureDomain () { return CV_CAP_XIAPI; } // Return the type of the capture object: CV_CAP_VFW, etc...
27
28
28
29
private:
30
+ bool _open ();
29
31
void init ();
30
32
void errMsg (const char * msg, int errNum) const ;
31
33
void resetCvImage ();
@@ -51,6 +53,17 @@ CvCapture* cvCreateCameraCapture_XIMEA( int index )
51
53
return 0 ;
52
54
}
53
55
56
+ CvCapture* cvCreateCameraCapture_XIMEA ( const char * serialNumber )
57
+ {
58
+ CvCaptureCAM_XIMEA* capture = new CvCaptureCAM_XIMEA;
59
+
60
+ if ( capture->open ( serialNumber ))
61
+ return capture;
62
+
63
+ delete capture;
64
+ return 0 ;
65
+ }
66
+
54
67
/* *********************************************************************************/
55
68
// Enumerate connected devices
56
69
void CvCaptureCAM_XIMEA::init ()
@@ -75,13 +88,10 @@ void CvCaptureCAM_XIMEA::init()
75
88
// Initialize camera input
76
89
bool CvCaptureCAM_XIMEA::open ( int wIndex )
77
90
{
78
- #define HandleXiResult (res ) if (res!=XI_OK) goto error;
79
-
80
- int mvret = XI_OK;
81
-
82
91
if (numDevices == 0 )
83
92
return false ;
84
93
94
+ int mvret = XI_OK;
85
95
if ((mvret = xiOpenDevice ( wIndex, &hmv)) != XI_OK)
86
96
{
87
97
#if defined _WIN32
@@ -97,12 +107,33 @@ bool CvCaptureCAM_XIMEA::open( int wIndex )
97
107
#endif
98
108
}
99
109
110
+ return _open ();
111
+ }
112
+
113
+ bool CvCaptureCAM_XIMEA::open ( const char * serialNumber )
114
+ {
115
+ if (numDevices == 0 )
116
+ return false ;
117
+
118
+ int mvret = XI_OK;
119
+ if ((mvret = xiOpenDeviceBy (XI_OPEN_BY_SN, serialNumber, &hmv)) != XI_OK)
120
+ {
121
+ errMsg (" Open XI_DEVICE failed" , mvret);
122
+ return false ;
123
+ }
124
+
125
+ return _open ();
126
+ }
127
+
128
+ bool CvCaptureCAM_XIMEA::_open ()
129
+ {
130
+ #define HandleXiResult (res ) if (res!=XI_OK) goto error;
100
131
int width = 0 ;
101
132
int height = 0 ;
102
133
int isColor = 0 ;
103
134
104
135
// always use auto exposure/gain
105
- mvret = xiSetParamInt ( hmv, XI_PRM_AEAG, 1 );
136
+ int mvret = xiSetParamInt ( hmv, XI_PRM_AEAG, 1 );
106
137
HandleXiResult (mvret);
107
138
108
139
mvret = xiGetParamInt ( hmv, XI_PRM_WIDTH, &width);
0 commit comments