From a615102947f35f7da449f69e71b91f7f2ece4364 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Mon, 22 Sep 2014 19:35:36 +0200 Subject: [PATCH 1/2] Fixed MSMF video capture initialization --- modules/highgui/src/cap_msmf.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/highgui/src/cap_msmf.cpp b/modules/highgui/src/cap_msmf.cpp index cc522e1e4..c2507e9d3 100644 --- a/modules/highgui/src/cap_msmf.cpp +++ b/modules/highgui/src/cap_msmf.cpp @@ -2445,11 +2445,12 @@ int videoDevice::findType(unsigned int size, unsigned int frameRate) fmt = vd_CaptureFormats.find(size); if( fmt != vd_CaptureFormats.end() ) FRM = fmt->second; - else if (FRM.empty()) - return -1; - else + else if(!vd_CaptureFormats.empty()) FRM = vd_CaptureFormats.rbegin()->second; + if (FRM.empty()) + return -1; + UINT64 frameRateMax = 0; SUBTYPEMap STMMax; if(frameRate == 0) { From 3603102c8939ee6bc223003011fa3800a4274f39 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Mon, 22 Sep 2014 19:38:04 +0200 Subject: [PATCH 2/2] Fixed assertion warning in MSMF frame grabber --- modules/highgui/src/cap_msmf.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/highgui/src/cap_msmf.cpp b/modules/highgui/src/cap_msmf.cpp index c2507e9d3..a8977a2fe 100644 --- a/modules/highgui/src/cap_msmf.cpp +++ b/modules/highgui/src/cap_msmf.cpp @@ -1462,7 +1462,6 @@ void ImageGrabber::stopGrabbing() HRESULT ImageGrabber::startGrabbing(void) { - _ComPtr pEvent = NULL; PROPVARIANT var; PropVariantInit(&var); HRESULT hr = ig_pSession->SetTopology(0, ig_pTopology); @@ -1470,6 +1469,7 @@ HRESULT ImageGrabber::startGrabbing(void) hr = ig_pSession->Start(&GUID_NULL, &var); for(;;) { + _ComPtr pEvent = NULL; HRESULT hrStatus = S_OK; MediaEventType met; if(!ig_pSession) break;