Opencv 为什么我会遇到一个问题,告诉我将值设置为float,当我得到这个值时,我需要将它设置为integer?
我正试图保存一段摄像机的录音,我正在使用一个免费的课程,它说,我需要创建cv2.VideoWriter。 我尝试时遇到的问题是:Opencv 为什么我会遇到一个问题,告诉我将值设置为float,当我得到这个值时,我需要将它设置为integer?,opencv,python-3.7,Opencv,Python 3.7,我正试图保存一段摄像机的录音,我正在使用一个免费的课程,它说,我需要创建cv2.VideoWriter。 我尝试时遇到的问题是: Traceback (most recent call last): File ..., line 10, in <module> writer = cv2.VideoWriter(filename,cv2.VideoWriter_fourcc(*'DVIX'),20,(width,height)) TypeError: a float is re
Traceback (most recent call last):
File ..., line 10, in <module>
writer = cv2.VideoWriter(filename,cv2.VideoWriter_fourcc(*'DVIX'),20,(width,height))
TypeError: a float is required
我发现了问题,并将其更改为:
writer = cv2.VideoWriter("images/my_super_vid.mp4",cv2.VideoWriter_fourcc(*'DVIX'),float(20),(width,height))
甚至:
writer = cv2.VideoWriter("images/my_super_vid.mp4",cv2.VideoWriter_fourcc(*'DVIX'),20.0,(width,height))
但在这两次尝试中,我都得到了:
Traceback (most recent call last):
File "....", line 10, in <module>
writer = cv2.VideoWriter("images/my_super_vid.mp4",cv2.VideoWriter_fourcc(*'DVIX'),20.0,(width,height))
TypeError: integer argument expected, got float
它成功了。但现在我明白了:
qt.qpa.plugin: Could not find the Qt platform plugin "cocoa" in ""
此应用程序无法启动,因为无法初始化Qt平台插件。重新安装应用程序可能会解决此问题
当我试着用PyCharm运行它时
修复:只需从终端运行它。错误是指括号中同一行上的不同值。第一个值必须是一个浮点值,第二个值必须是一个int(反之亦然)试试这个mp4,
writer=cv2.VideoWriter(“images/my\u super\u vid.mp4”,0x7634706d,20,(width,height))
。同样的问题是:TypeError:需要一个浮点值Try,(int(width),int(height))
。它起作用了:),但是有没有办法知道哪个参数需要是float或int?因为在PyCharm中,参数说的是**args
,而不是实际的arg.。有没有办法知道哪个参数指的是哪个参数?好吧,我猜对了,它起了作用,但现在我得到了一个新问题,在帖子的问题部分编辑
writer = cv2.VideoWriter("images/my_super_vid.avi",cv2.VideoWriter_fourcc(*'XVID'),20, (int(width),int(height)))
qt.qpa.plugin: Could not find the Qt platform plugin "cocoa" in ""