0

A Python instructional video shows a simple example of cv2.VideoCapture(0) working, but on my PC it fails to open the camera and run. Here's the code:

import cv2

video = cv2.VideoCapture(0)

video.release()

The error message is here:

[ WARN:0@5.031] global D:\a\opencv-python\opencv-python\opencv\modules\videoio\src\cap_msmf.cpp (539) `anonymous-namespace'::SourceReaderCB::~SourceReaderCB terminating async callback
Cal-cium
  • 654
  • 12
  • 22
Bob H
  • 1
  • 1
    Also see https://stackoverflow.com/questions/60007427/cv2-warn0-global-cap-msmf-cpp-674-sourcereadercbsourcereadercb-termina and https://stackoverflow.com/questions/59596748/warn0-global-sourcereadercbsourcereadercb-terminating-async-callback-wa – Jeru Luke Apr 20 '22 at 17:10
  • that's merely a warning. where is the complete traceback? – Christoph Rackwitz Apr 20 '22 at 18:46

1 Answers1

0

I looked up the error and found the following post: CV2: "[ WARN:0] terminating async callback" when attempting to take a picture

Try adding cv2.CAP_DSHOW to your VideoCapture call, as per: https://stackoverflow.com/a/56839757/12131013

import cv2

video = cv2.VideoCapture(0, cv2.CAP_DSHOW)
video.release()
jared
  • 4,165
  • 1
  • 8
  • 31