Assuming 2 cameras (also gives the error if only one camera):
C:\Users\Dave\data\Code\Python\VideoCapture>python3 test.py
Found camera 0
Found camera 1
C:\Users\Dave\data\Code\Python\VideoCapture>python3 test.py
Found camera 0
[ WARN:0] terminating async callback
Found camera 1
[ WARN:0] terminating async callback
import cv2
def countCameras():
"""Returns count of found cameras (not opened yet).
Brute force - just tries them all till it fails."""
camCount = 0
while True:
cam = cv2.VideoCapture(camCount)
if cam.isOpened():
print("Found camera", camCount)
cam.release()
camCount += 1
else:
return camCount
countCameras()
Windows 10 Pro
x64
cv2.__version__ == '4.1.0'
This is a bug in OpenCV in MSMF backend: https://github.com/opencv/opencv/issues/13255
You could try setx OPENCV_VIDEOIO_PRIORITY_MSMF 0 before running your script. However, there's nothing I can do in this repo to fix the issue.
Had this issue on opencv4*, 3.4.4
When installed opencv 3.4.2.16 the warning disappeared
Most helpful comment
This is a bug in OpenCV in MSMF backend: https://github.com/opencv/opencv/issues/13255
You could try
setx OPENCV_VIDEOIO_PRIORITY_MSMF 0before running your script. However, there's nothing I can do in this repo to fix the issue.