I am using "pygame" in python (the code below) to take an image with 4k resolution using Logitech Brio webcam.
# 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()
However, after running the code, I get this error:
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.
How can I solve this issue?
I appreciate any help in advance.
Thank you,
Abbas