社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Python

使用Logitech Brio网络摄像头和python中的“pygame”以4k分辨率拍摄照片

abbas • 6 年前 • 1323 次点击  

我正在使用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社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/55596