Python cv2,无法抓取框架 [英] Python cv2, cant grab frame

查看:101
本文介绍了Python cv2,无法抓取框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始学习python.这是我的第一个代码.我尝试使用网络摄像头.出于某种原因,它给了我一个错误.代码

Im just starting to learn python. This is my first code. I tried using the webcam. For some reason it gives me an error. Code

import cv2, time

video = cv2.VideoCapture(0)
check, frame = video.read()

print(check)
print(frame)

cv2.imshow("vegans have big gay", frame)

cv2.waitKey(0)
video.release()

错误:

False
[ WARN:0] videoio(MSMF): OnReadSample() is called with error status: -1072875772
None
[ WARN:0] videoio(MSMF): async ReadSample() call is failed with error status: -1072875772
[ WARN:1] videoio(MSMF): can't grab frame. Error: -1072875772
Traceback (most recent call last):
  File "C:/Users/stasiek/PycharmProjects/pierwszy/capture.py", line 9, in <module>
    cv2.imshow("vegans have big gay", frame)
cv2.error: OpenCV(3.4.3) C:\projects\opencv-python\opencv\modules\highgui\src\window.cpp:356: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'cv::imshow'

推荐答案

试试这个

video = cv2.VideoCapture(0 + cv2.CAP_DSHOW)

代替

video = cv2.VideoCapture(0)

这篇关于Python cv2,无法抓取框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆