From 7e78b5d06ed7726892555a5c5bdb53d1974f9141 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Thu, 2 Oct 2014 11:48:47 +0200 Subject: [PATCH 1/3] Fixed selecting media type in DShow video capture. Set correct value of sample size when calling IAMStreamConfig::SetFormat function. For non-RGB media type it can be set to zero value. (See http://msdn.microsoft.com/en-us/library/windows/desktop/dd373477%28v=vs.85%29.aspx) --- modules/highgui/src/cap_dshow.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/highgui/src/cap_dshow.cpp b/modules/highgui/src/cap_dshow.cpp index c3c436c896..7888120538 100644 --- a/modules/highgui/src/cap_dshow.cpp +++ b/modules/highgui/src/cap_dshow.cpp @@ -2427,7 +2427,15 @@ static bool setSizeAndSubtype(videoDevice * VD, int attemptWidth, int attemptHei VD->pAmMediaType->subtype = mediatype; //buffer size - VD->pAmMediaType->lSampleSize = attemptWidth*attemptHeight*3; + if (mediatype == MEDIASUBTYPE_RGB24) + { + VD->pAmMediaType->lSampleSize = attemptWidth*attemptHeight*3; + } + else + { + // For compressed data, the value can be zero. + VD->pAmMediaType->lSampleSize = 0; + } //set fps if requested if( VD->requestedFrameTime != -1){ From 4b1bb702ce7577dc3d2231bcc0349db47f394cf7 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Thu, 2 Oct 2014 11:51:56 +0200 Subject: [PATCH 2/3] Fixed media type GUID for I420 format in DShow capture. FOURCC code bytes should be placed in the reverse order. --- modules/highgui/src/cap_dshow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/highgui/src/cap_dshow.cpp b/modules/highgui/src/cap_dshow.cpp index 7888120538..dfc0c43505 100644 --- a/modules/highgui/src/cap_dshow.cpp +++ b/modules/highgui/src/cap_dshow.cpp @@ -213,7 +213,7 @@ DEFINE_GUID(MEDIASUBTYPE_RGB24,0xe436eb7d,0x524f,0x11ce,0x9f,0x53,0x00,0x20,0xaf DEFINE_GUID(MEDIASUBTYPE_RGB32,0xe436eb7e,0x524f,0x11ce,0x9f,0x53,0x00,0x20,0xaf,0x0b,0xa7,0x70); DEFINE_GUID(MEDIASUBTYPE_RGB555,0xe436eb7c,0x524f,0x11ce,0x9f,0x53,0x00,0x20,0xaf,0x0b,0xa7,0x70); DEFINE_GUID(MEDIASUBTYPE_RGB565,0xe436eb7b,0x524f,0x11ce,0x9f,0x53,0x00,0x20,0xaf,0x0b,0xa7,0x70); -DEFINE_GUID(MEDIASUBTYPE_I420,0x49343230,0x0000,0x0010,0x80,0x00,0x00,0xaa,0x00,0x38,0x9b,0x71); +DEFINE_GUID(MEDIASUBTYPE_I420,0x30323449,0x0000,0x0010,0x80,0x00,0x00,0xaa,0x00,0x38,0x9b,0x71); DEFINE_GUID(MEDIASUBTYPE_UYVY,0x59565955,0x0000,0x0010,0x80,0x00,0x00,0xaa,0x00,0x38,0x9b,0x71); DEFINE_GUID(MEDIASUBTYPE_Y211,0x31313259,0x0000,0x0010,0x80,0x00,0x00,0xaa,0x00,0x38,0x9b,0x71); DEFINE_GUID(MEDIASUBTYPE_Y411,0x31313459,0x0000,0x0010,0x80,0x00,0x00,0xaa,0x00,0x38,0x9b,0x71); From 5c96021172fd1e3f0e845a29116d16924c5a2417 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Thu, 2 Oct 2014 17:51:10 +0200 Subject: [PATCH 3/3] Fixed getting CV_CAP_PROP_FOURCC property value Save selected FCC in order to return proper CV_CAP_PROP_FOURCC property value (currently FCC for RGB24 is always returned). --- modules/highgui/src/cap_dshow.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/highgui/src/cap_dshow.cpp b/modules/highgui/src/cap_dshow.cpp index dfc0c43505..6cc29443d7 100644 --- a/modules/highgui/src/cap_dshow.cpp +++ b/modules/highgui/src/cap_dshow.cpp @@ -2578,6 +2578,7 @@ int videoInput::start(int deviceID, videoDevice *VD){ if( setSizeAndSubtype(VD, VD->tryWidth, VD->tryHeight, VD->tryVideoType) ){ VD->setSize(VD->tryWidth, VD->tryHeight); + VD->videoType = VD->tryVideoType; foundSize = true; } else { // try specified size with all formats @@ -2588,6 +2589,7 @@ int videoInput::start(int deviceID, videoDevice *VD){ if(verbose)printf("SETUP: trying format %s @ %i by %i\n", guidStr, VD->tryWidth, VD->tryHeight); if( setSizeAndSubtype(VD, VD->tryWidth, VD->tryHeight, mediaSubtypes[i]) ){ VD->setSize(VD->tryWidth, VD->tryHeight); + VD->videoType = mediaSubtypes[i]; foundSize = true; break; }