VideoCapture错误:vidcap.Error:无法设置捕获分辨率

时间:2016-02-20 16:53:05

标签: python

from VideoCapture import Device

cam = Device()
cam.setResolution(320, 240)
cam.saveSnapshot('demo.jpg')

我在Windows Python2.7中使用VideoCapture。我不知道出了什么问题。如何解决这个问题。

Traceback (most recent call last):
  File "D:/ideaProject/python_workspace/webcap/webcap/test/vc.py", line 8, in <module>
    cam.setResolution(320, 240)
  File "D:\SoftWare\Python27\lib\VideoCapture.py", line 90, in setResolution
    self.dev.setresolution(width, height)
vidcap.Error: Cannot set capture resolution.

2 个答案:

答案 0 :(得分:0)

在深入了解VideoCapture.py之后,我找到了一个解决方案:

from VideoCapture import Device

cam = Device()
cam.getImage(timestamp=0).resize((320, 240)).save('demo.jpg', quality=80)

我可以获得合适的照片尺寸。也许我使用了错误的方法。

答案 1 :(得分:0)

我有一个问题,您的解决方案看起来更像是一种解决方法。我猜你没有改变你的相机的分辨率,你的代码所做的是使用你的相机拍摄原始图片,然后使用resize()函数来改变捕获的图片的大小。这意味着,你正在做的事情看起来像是先拍摄一张照片(没有你想要的分辨率),然后你去编辑拍摄的照片。如果我错了,我很感激你可以指出这一点,因为我也遇到了这个问题。

相关问题