-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
VideoCapture with MSMF does not work when building with VIDEOIO_PLUGIN_LIST=all #23056
Copy link
Copy link
Closed
Closed
Copy link
Description
System Information
OpenCV version: 4.6.0, 4.7.0
Operating System / Platform: Windows 10
Compiler & compiler version: Visual Studio Community 2022
Detailed description
When building with VIDEOIO_PLUGIN_LIST=all, VideoCapture open(0, cv::CAP_MSMF) failed to capture images
Steps to reproduce
The file samples/cpp/example_cmake/example.cpp has been changed as followed
#include "opencv2/core.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/videoio.hpp"
#include <iostream>
using namespace cv;
using namespace std;
void drawText(Mat & image);
int main()
{
cout << "Built with OpenCV " << CV_VERSION << endl;
Mat image;
VideoCapture capture;
capture.open(0, cv::CAP_MSMF);
if(capture.isOpened())
{
cout << "Capture is opened" << endl;
for(;;)
{
capture >> image;
if(image.empty())
break;
drawText(image);
imshow("Sample", image);
if(waitKey(10) >= 0)
break;
}
}
else
{
cout << "No capture" << endl;
image = Mat::zeros(480, 640, CV_8UC1);
drawText(image);
imshow("Sample", image);
waitKey(0);
}
return 0;
}
void drawText(Mat & image)
{
putText(image, "Hello OpenCV",
Point(20, 50),
FONT_HERSHEY_COMPLEX, 1, // font face and scale
Scalar(255, 255, 255), // white
1, LINE_AA); // line thickness and type
}Build steps
git clone --branch 4.7.0 https://github.com/opencv/opencv.git
mkdir build
cd build
cmake.exe -G "Visual Studio 17" -DCMAKE_INSTALL_PREFIX=%CD%\..\install -DBUILD_SHARED_LIBS=ON -DBUILD_PERF_TESTS=OFF -DBUILD_TESTS=OFF -DBUILD_EXAMPLES=ON -DOPENCV_INSTALL_DATA_DIR_RELATIVE=%CD%\..\install -DINSTALL_CREATE_DISTRIB=ON -DBUILD_DOCS=OFF -DBUILD_opencv_python3=OFF -DBUILD_opencv_python2=OFF -DBUILD_opencv_java=OFF -DVIDEOIO_PLUGIN_LIST=all ../opencv
cmake.exe --build . --config Release --target install
%CD%\..\install\x64\vc17\samples\cpp\example_cpp_example.exeThe following configuration works
cmake.exe -G "Visual Studio 17" -DCMAKE_INSTALL_PREFIX=%CD%\..\install -DBUILD_SHARED_LIBS=ON -DBUILD_PERF_TESTS=OFF -DBUILD_TESTS=OFF -DBUILD_EXAMPLES=ON -DOPENCV_INSTALL_DATA_DIR_RELATIVE=%CD%\..\install -DINSTALL_CREATE_DISTRIB=ON -DBUILD_DOCS=OFF -DBUILD_opencv_python3=OFF -DBUILD_opencv_python2=OFF -DBUILD_opencv_java=OFF -DVIDEOIO_PLUGIN_LIST= ../opencvIssue submission checklist
- I report the issue, it's not a question
- I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
- I updated to the latest OpenCV version and the issue is still there
- There is reproducer code and related data files (videos, images, onnx, etc)
Reactions are currently unavailable