videocapture::set not working (Bug #4270)
Description
Hi all,
I am having difficulty setting the frame size. I have tried usingcapture.set(CV_CAP_PROP_FRAME_WIDTH,1280);
capture.set(CV_CAP_PROP_FRAME_HEIGHT,720);
but it just doesn't change accordingly.
I have seen thread related to this (Bug #948) and i did exactly the same thing as Alexander Shishkov recommended but to no avail.
Can anyone help? Thanks
Related issues
duplicated by Bug #4290: videocapture::set not working | Cancelled | 2015-04-09 |
History
Updated by Frank Bauernöppel almost 10 years ago
GuoDong Goh wrote:
Hi all,
I am having difficulty setting the frame size. I have tried using
capture.set(CV_CAP_PROP_FRAME_WIDTH,1280);
capture.set(CV_CAP_PROP_FRAME_HEIGHT,720);
but it just doesn't change accordingly.I have seen thread related to this (Bug #948) and i did exactly the same thing as Alexander Shishkov recommended but to no avail.
Can anyone help? Thanks
I have the same issue here with Win 8.1 x64 and a Microsoft LifeCam (USB UVC device) and the latest OpenCV from master branch.
The capture.set
values provided will be cached internally and finally VD->streamConf->SetFormat
is called in file cap_dshow.cpp
which returns E_FAIL
. After finding and reading https://github.com/ofTheo/videoInput/issues/6 I added a few lines to correct lSampleSize in setSizeAndSubtype
:
1 if (mediatype == MEDIASUBTYPE_RGB24)
2 {
3 VD->pAmMediaType->lSampleSize = attemptWidth*attemptHeight*3;
4 }
5 else if (mediatype == MEDIASUBTYPE_YUY2)
6 {
7 VD->pAmMediaType->lSampleSize = attemptWidth*attemptHeight * 2;
8 }
9 else
Note that this is a workaround just for one mediatype. At least, YUY2 is the packed 4:2:2 YUV format recommended in the USB UVC Spec, so this fix should help for many USB cams. There are more mediatypes (e.g. various YUV formats) to fix. I suggest to calculate lSampleSize
from pVih->bmiHeader
where biBitcount
says 16 in my case. But, this probably needs lots of regression testing.
hth
Frank