Full warning message:
[ WARN:0] global C:\projects\opencv-python\opencv\modules\videoio\src\cap_msmf.cpp (674) SourceReaderCB::~SourceReaderCB terminating async callback
Code:
import numpy as np
import cv2
captureDevice = cv2.VideoCapture(0) #captureDevice = camera
while True:
ret, frame = captureDevice.read()
cv2.imshow('my frame', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
captureDevice.release()
cv2.destroyAllWindows()
Description:
When it runs, the my frame
windows appear and when I terminate the code, it gives me that warning message.
Python: 3.7.4
OpenCV (cv2): 4.1.2
OS: Windows 10
I don't know to fix this warning and why it gets me. Hope you help me in fixing and understanding that.
In addition, answers of this link didn't help me anyway.
Thanks in advance.
This seems to be a bug in MSMF backend of opencv. You can see more details in this issue.
I don't think this problem exists on Linux platforms. So I am providing the solution for windows.
For windows platform, you can change the backend to something else (most preferably DirectShow backend. For this, add to your VideoCapture
like below:
captureDevice = cv2.VideoCapture(0, cv2.CAP_DSHOW) #captureDevice = camera
This works for OpenCV>=3.4
.
A warning message is not an error!
But if that bothers you so much, you might try to disable MSMF by setting the following Environment Variable to 0
on Windows:
OPENCV_VIDEOIO_PRIORITY_MSMF
How to set the path and environment variables in Windows
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With