March 6, 2023, 8:12am
Hello! I’ve been using OpenCV for a few weeks now, but I am new to this community. If this question was asked before, apologies in advance. Here goes:
Whenever I try to open the webcam with
video = cv2.VideoCapture(1),
I get these errors:
[ WARN:firstname.lastname@example.org] global D:\a\opencv-python\opencv-python\opencv\modules\videoio\src\cap_msmf.cpp (464) `anonymous-namespace'::SourceReaderCB::OnReadSample videoio(MSMF): OnReadSample() is called with error status: -1072873821
[ WARN:email@example.com] global D:\a\opencv-python\opencv-python\opencv\modules\videoio\src\cap_msmf.cpp (476) `anonymous-namespace'::SourceReaderCB::OnReadSample videoio(MSMF): async ReadSample() call is failed with error status: -1072873821
Mind you, using
video = cv2.VideoCapture(video_path) works perfectly, but now I have to use the webcam. However, I cannot do anything with these errors persisting. Any help is appreciated. Can post the code if needed. Thanks in advance!
March 7, 2023, 8:16am
try the DSHOW backend:
video = cv2.VideoCapture(1, CAP_DSHOW)
(by default on win, it is choosing the MSMF backend, which does not seem to work nicely for you)
March 17, 2023, 9:21am
video = cv2.VideoCapture(1, CAP_DSHOW)
This fixed my problem, thanks. The thread can be locked.
About msmf you can try :
Or on Python
os.environ[“OPENCV_VIDEOIO_MSMF_ENABLE_HW_TRANSFORMS”] = “0”
03:19AM - 29 Jun 20 UTC
10:08PM - 30 Jun 21 UTC
##### System information (version)
- OpenCV => 4.2
- Operating S
… ystem / Platform => Windows 64 Bit
- Compiler => Visual Studio 2017
- OpenCV => 4.3
- Operating System / Platform => Windows
- Compiler => :grey_question:
##### Detailed description
I am trying to open my Logitech HD Pro C910 USB webcam using OpenCV 4.3 in my Java app. If I use CAP_MSMF (or CAP_ANY), it takes **several minutes** for the camera to open up, delaying my application start time. CAP_DSHOW does not exhibit this behavior. The Python OpenCV bindings is also experiencing slow open times with CAP_MSMF.
I want to use MSMF for the GPU acceleration, but I can't use it with these startup times. Is there a way around this issue?
This issue does not show up when running my code on my Surface Pro 7 with its integrated webcam.
##### Steps to reproduce
Just call VideoCapture.open(0, CAP_MSMF) using certain webcams.
##### Issue submission checklist
- [X] I report the issue, it's not a question
OpenCV team works with answers.opencv.org, Stack Overflow and other communities
to discuss problems. Tickets with question without real issue statement will be
- [X] I checked the problem with documentation, FAQ, open issues,
answers.opencv.org, Stack Overflow, etc and have not found solution
Places to check:
* OpenCV documentation: https://docs.opencv.org
* FAQ page: https://github.com/opencv/opencv/wiki/FAQ
* OpenCV forum: https://answers.opencv.org
* OpenCV issue tracker: https://github.com/opencv/opencv/issues?q=is%3Aissue
* Stack Overflow branch: https://stackoverflow.com/questions/tagged/opencv
- [X] I updated to latest OpenCV version and the issue is still there
master branch for OpenCV 4.x and 3.4 branch for OpenCV 3.x releases.
OpenCV team supports only latest release for each branch.
The ticket is closed, if the problem is not reproduced with modern version.
- [x] There is reproducer code and related data files: videos, images, onnx, etc
The best reproducer -- test case for OpenCV that we can add to the library.
Recommendations for media files and binary files:
* Try to reproduce the issue with images and videos in opencv_extra repository
to reduce attachment size
* Use PNG for images, if you report some CV related bug, but not image reader
* Attach the image as archite to the ticket, if you report some reader issue.
Image hosting services compress images and it breaks the repro code.
* Provide ONNX file for some public model or ONNX file with with random weights,
if you report ONNX parsing or handling issue. Architecture details diagram
from netron tool can be very useful too. See https://lutzroeder.github.io/netron/