Updated by Dmitry Retinskiy over 10 years ago
If I open a XIMA camera and set the downsampling, the retrieved capture frames will have the wrong dimensions.
<pre>
// Open the camera:
cv::VideoCapture cam;
cv::Mat bufferFrame;
int columns = 0;
cam.open(inputName);
cam.read(bufferFrame);
columns = bufferFrame.columns; // _Columns value is 2592_
cam.set(CV_CAP_PROP_XI_DATA_FORMAT, XI_RGB24 );
cam.set(CV_CAP_PROP_XI_DOWNSAMPLING, ximeaDefaultBinningMode);
// In the thread loop
cam.read(bufferFrame);
columns = bufferFrame.columns; // _Columns value is still 2592_
</pre>
Now, that seems to come from the fact that, in cap_ximea.cpp,
<pre>
void CvCaptureCAM_XIMEA::resetCvImage() // Called from CvCaptureCAM_XIMEA::retrieveFrame()
{
...
if( (int)image.width != width || (int)image.height != height || image.frm != (XI_IMG_FORMAT)format)
...
}
</pre>
the validation checks for the identity of the _image_ dimensions (which are the same, since they were updated by the internal CvCaptureCAM_XIMEA::grabFrame() call), but does not check for the identity of the _frame_ dimensions (which have not been changed, and need to).
An easy fix probably would be to add a check of the frame.cols and frame.rows in that condition line.
<pre>
// Open the camera:
cv::VideoCapture cam;
cv::Mat bufferFrame;
int columns = 0;
cam.open(inputName);
cam.read(bufferFrame);
columns = bufferFrame.columns; // _Columns value is 2592_
cam.set(CV_CAP_PROP_XI_DATA_FORMAT, XI_RGB24 );
cam.set(CV_CAP_PROP_XI_DOWNSAMPLING, ximeaDefaultBinningMode);
// In the thread loop
cam.read(bufferFrame);
columns = bufferFrame.columns; // _Columns value is still 2592_
</pre>
Now, that seems to come from the fact that, in cap_ximea.cpp,
<pre>
void CvCaptureCAM_XIMEA::resetCvImage() // Called from CvCaptureCAM_XIMEA::retrieveFrame()
{
...
if( (int)image.width != width || (int)image.height != height || image.frm != (XI_IMG_FORMAT)format)
...
}
</pre>
the validation checks for the identity of the _image_ dimensions (which are the same, since they were updated by the internal CvCaptureCAM_XIMEA::grabFrame() call), but does not check for the identity of the _frame_ dimensions (which have not been changed, and need to).
An easy fix probably would be to add a check of the frame.cols and frame.rows in that condition line.