我正在使用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.
我怎样才能解决这个问题?
谢谢您,
阿巴斯