2024-06-01 05:30:17 发布
网友
我现在使用的代码是:
from VideoCapture import Device cam = Device() cam.saveSnapshot('image.jpg')
使用py 2.7 引进了pygame和all以及videocapture 我在pycharm中得到了这个错误:
网络摄像头LED灯亮起,然后立即关闭。 或者帮助我使用其他代码和库,这些代码和库只能在windows上与Py2.7和pycharm配合使用!我只想保存图像,而不是显示它!在
你可能想降低你的PIL版本,看起来VideoCapture已经有一段时间没有更新了,仍然依赖于过时的PIL版本。在
pil2.x似乎有一个工作的fromstring方法:https://github.com/python-pillow/Pillow/blob/2.9.0/PIL/Image.py#L750
fromstring
否则,您可以尝试将VideoCapture.py中的第138行从im = Image.fromstring(...)改为{};希望这是唯一阻止它工作的东西。在
VideoCapture.py
im = Image.fromstring(...)
如果您使用的是pip,您可以使用pip uninstall Pillow卸载当前版本,然后使用pip install Pillow==2.9.0安装旧版本(Pillow是PIL的分支,PIL基本上是死的)。在
pip
pip uninstall Pillow
pip install Pillow==2.9.0
Pillow
打开文件C:\Python27\lib\VideoCapture.py,然后转到第138行。你应该有这样的东西:
C:\Python27\lib\VideoCapture.py
im = Image.fromstring('RGB', (width, height), buffer, 'raw', 'BGR', 0, -1)
将此行替换为:
你可能想降低你的PIL版本,看起来VideoCapture已经有一段时间没有更新了,仍然依赖于过时的PIL版本。在
pil2.x似乎有一个工作的
fromstring
方法:https://github.com/python-pillow/Pillow/blob/2.9.0/PIL/Image.py#L750否则,您可以尝试将};希望这是唯一阻止它工作的东西。在
VideoCapture.py
中的第138行从im = Image.fromstring(...)
改为{解决方案1:降低PIL
如果您使用的是
pip
,您可以使用pip uninstall Pillow
卸载当前版本,然后使用pip install Pillow==2.9.0
安装旧版本(Pillow
是PIL的分支,PIL基本上是死的)。在解决方案2:更新VideoCatpure
打开文件
C:\Python27\lib\VideoCapture.py
,然后转到第138行。你应该有这样的东西:将此行替换为:
^{2}$相关问题 更多 >
编程相关推荐