Commit 0cd8684a authored by Andrey Kamaev's avatar Andrey Kamaev

Fix setting of FPS after frame width and height with DShow cameras

Issue #2114
parent 9e32c699
...@@ -3120,6 +3120,7 @@ protected: ...@@ -3120,6 +3120,7 @@ protected:
void init(); void init();
int index, width, height,fourcc; int index, width, height,fourcc;
int widthSet, heightSet;
IplImage* frame; IplImage* frame;
static videoInput VI; static videoInput VI;
}; };
...@@ -3138,6 +3139,7 @@ CvCaptureCAM_DShow::CvCaptureCAM_DShow() ...@@ -3138,6 +3139,7 @@ CvCaptureCAM_DShow::CvCaptureCAM_DShow()
index = -1; index = -1;
frame = 0; frame = 0;
width = height = fourcc = -1; width = height = fourcc = -1;
widthSet = heightSet = -1;
CoInitialize(0); CoInitialize(0);
} }
...@@ -3155,7 +3157,7 @@ void CvCaptureCAM_DShow::close() ...@@ -3155,7 +3157,7 @@ void CvCaptureCAM_DShow::close()
index = -1; index = -1;
cvReleaseImage(&frame); cvReleaseImage(&frame);
} }
width = height = -1; widthSet = heightSet = width = height = -1;
} }
// Initialize camera input // Initialize camera input
...@@ -3282,9 +3284,12 @@ bool CvCaptureCAM_DShow::setProperty( int property_id, double value ) ...@@ -3282,9 +3284,12 @@ bool CvCaptureCAM_DShow::setProperty( int property_id, double value )
{ {
VI.stopDevice(index); VI.stopDevice(index);
VI.setIdealFramerate(index,fps); VI.setIdealFramerate(index,fps);
if (widthSet > 0 && heightSet > 0)
VI.setupDevice(index, widthSet, heightSet);
else
VI.setupDevice(index); VI.setupDevice(index);
} }
break; return VI.isDeviceSetup(index);
} }
...@@ -3299,8 +3304,15 @@ bool CvCaptureCAM_DShow::setProperty( int property_id, double value ) ...@@ -3299,8 +3304,15 @@ bool CvCaptureCAM_DShow::setProperty( int property_id, double value )
VI.setIdealFramerate(index, fps); VI.setIdealFramerate(index, fps);
VI.setupDeviceFourcc(index, width, height, fourcc); VI.setupDeviceFourcc(index, width, height, fourcc);
} }
bool success = VI.isDeviceSetup(index);
if (success)
{
widthSet = width;
heightSet = height;
width = height = fourcc = -1; width = height = fourcc = -1;
return VI.isDeviceSetup(index); }
return success;
} }
return true; return true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment