From e5b5984f3c5bccb96d89449d2165b177b4f7aee3 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Wed, 27 Dec 2023 14:31:53 +0300 Subject: [PATCH] Reworked camera stream check to exclude non-video formats. --- modules/videoio/src/cap_msmf.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/modules/videoio/src/cap_msmf.cpp b/modules/videoio/src/cap_msmf.cpp index 4b234b8caeb2..6fbcd2aa02f5 100644 --- a/modules/videoio/src/cap_msmf.cpp +++ b/modules/videoio/src/cap_msmf.cpp @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -159,6 +160,11 @@ class ComPtr template inline T absDiff(T a, T b) { return a >= b ? a - b : b - a; } +// synonym for system MFVideoFormat_D16. D3DFMT_D16 = 80 +// added to fix builds with old MSVS and platform SDK +// see https://learn.microsoft.com/en-us/windows/win32/medfound/video-subtype-guids#luminance-and-depth-formats +DEFINE_MEDIATYPE_GUID( OCV_MFVideoFormat_D16, 80 ); + //================================================================================================== // Structure for collecting info about types of video which are supported by current video device @@ -350,9 +356,7 @@ struct MediaType } bool VideoIsAvailable() const { - return ((subType == MFVideoFormat_RGB32) || - (subType == MFVideoFormat_RGB24) || - (subType == MFVideoFormat_YUY2)); + return (subType != OCV_MFVideoFormat_D16); } };