python - 使用 Logitech Brio 网络摄像头和 python 中的“pygame”以 4k 分辨率拍照的问题
问题描述
我在 python 中使用“pygame”(下面的代码)使用 Logitech Brio 网络摄像头拍摄 4k 分辨率的图像。
# take picture using pygame
import time
import cv2
import pygame
import pygame.camera
from pygame.locals import *
start_time = time.time()
pygame.init()
pygame.camera.init()
cam = pygame.camera.Camera(0,(4096, 2160))
cam.start()
image = cam.get_image()
path = 'C:/Users/aatefi2/Downloads/robot_images/'
imageName = str(time.strftime("%Y_%m_%d_%H_%M_%S")) + '.jpg'
pygame.image.save(image, str(path) + imageName)
elapsed_time = time.time() - start_time
print (elapsed_time)
cam.stop()
但是,运行代码后,我收到此错误:
runfile('C:/Users/aatefi2/Downloads/robotic arm/kortex-master/kortex-master/api_python/examples/Webcam_take_picture.py', wdir='C:/Users/aatefi2/Downloads/robotic arm/kortex-master/kortex-master/api_python/examples')
Traceback (most recent call last):
File "<ipython-input-16-0e9a77e64eb6>", line 1, in <module>
runfile('C:/Users/aatefi2/Downloads/robotic arm/kortex-master/kortex-master/api_python/examples/Webcam_take_picture.py', wdir='C:/Users/aatefi2/Downloads/robotic arm/kortex-master/kortex-master/api_python/examples')
File "C:\Users\aatefi2\AppData\Local\Continuum\anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
execfile(filename, namespace)
File "C:\Users\aatefi2\AppData\Local\Continuum\anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/aatefi2/Downloads/robotic arm/kortex-master/kortex-master/api_python/examples/Webcam_take_picture.py", line 51, in <module>
cam = pygame.camera.Camera(0,(4096, 2160))
File "C:\Users\aatefi2\AppData\Local\Continuum\anaconda3\lib\site-packages\pygame\_camera_vidcapture.py", line 60, in __init__
self.dev.setresolution(width, height)
Error: Cannot set capture resolution.
我该如何解决这个问题?
我提前感谢任何帮助。
谢谢,
阿巴斯
解决方案
推荐阅读
- python - Pandas 取下面的行值
- python - Python 函数的空括号
- python - 如何从 ndarray 帧中访问单个像素阵列,或者是否有更好的方法来存储帧并访问它们?
- dart - 无法在 dart 项目中运行 genhtml
- c++ - 是否可以将数组元素与没有循环的硬编码初始化列表进行比较?
- ios - 如何在第二次从 iOS 的 xamarin 表单中的菜单按钮进入票务列表后使票务列表清晰?
- python - 从 Flask 的蓝图中删除全局应用程序引用
- c# - 由于 DateTime.AddSeconds,查找上一个蜡烛不起作用
- npm - 将 Google Cloud Functions 与 registry.npmjs.org 以外的注册表一起使用
- javascript - 将应用程序从 Angular 8 更新到 Angular 9 时出错