CV2 Python VideoCapture(0) 意外参数 [英] CV2 Python VideoCapture(0) unexpected argument

查看:86
本文介绍了CV2 Python VideoCapture(0) 意外参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简短的 Python 脚本,可以打开网络摄像头并在本地网站上显示实时提要.我正在使用 PyCharm IDE,它提供更正并在出现语法错误时通知您.当我将一个参数传递给 VideoCapture 时,它​​会突出显示它并说意外的参数".

I have a short python script that will open the webcam and display a live feed on a local web site. I am using PyCharm IDE which offers corrections and notify's you in case of syntax error. When I pass an argument to VideoCapture it highlights it and says 'unexpected argument'.

self.video = cv2.VideoCapture(0)

self.video = cv2.VideoCapture(0)

这是在一个类中,'意外参数是由传递给 OpenCV 函数的 0 引起的.有什么办法可以解决这个问题吗?

This is in a class and the 'unexpected argument is caused by the 0 that is passed to the OpenCV function. Is there any way I can fix this?

顺便说一下,它按原样运行良好 - 当您运行它时,它按应有的方式运行.如果您删除零,错误就会消失,但它不再初始化网络摄像头.

By the way it works fine as is - when you run it, it works the way it should. If you remove the zero the error goes away but it no longer initializes the webcam.

推荐答案

除了修改不正确的绑定,您还可以通过添加 noinspection 注释来使 IDE 中的警告静音.

Instead of hacking in the incorrect bindings, you could also just silence the warning in the IDE, by adding a noinspection comment.

# noinspection PyArgumentList
cap = cv2.VideoCapture(filename)

这篇关于CV2 Python VideoCapture(0) 意外参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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