pupil-labs / pyuvc

python binding to libuvc
Other
117 stars 51 forks source link

AttributeError @uvc_bindings.pyx #95

Open anmorick opened 8 months ago

anmorick commented 8 months ago

Hi All. I meet a problem when I run at python3. Here is my erre message. it said uvc_bindings.pyx having AttributeError. But I saw it , it seems correctly as normal. Traceback (most recent call last): File "cc.py", line 12, in cap.frame_mode = (1280, 960, 30) File "uvc_bindings.pyx", line 941, in uvc_bindings.Capture.frame_mode.set File "uvc_bindings.pyx", line 629, in uvc_bindings.Capture._configure_stream AttributeError: 'tuple' object has no attribute 'format_native'

uvc_bindings.pyx.txt Many thank. All

Rick

psarahdactyl commented 1 week ago

I am having this problem too on my raspberry pi. my code is just:

import uvc
import numpy as np
from PIL import Image

# Setup GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(LED_PIN, GPIO.OUT)
GPIO.setup(SENSOR_PIN, GPIO.IN)

# Initialize Camera
cap = uvc.Capture(uvc.device_list()[0]['uid'])
cap.frame_mode = (640, 400, 7)

and my error message is:

  File "/home/sak/Documents/audiotrope_raspberry_pi/led_camera_sensor_trigger_threaded.py", line 23, in <module>
    cap.frame_mode = (640, 400, 7)
  File "uvc_bindings.pyx", line 931, in uvc_bindings.Capture.frame_mode.__set__
  File "uvc_bindings.pyx", line 625, in uvc_bindings.Capture._configure_stream
AttributeError: 'tuple' object has no attribute 'format_native'

when I go through the modes in a loop as in the example in https://github.com/pupil-labs/pyuvc/blob/master/examples/access_100_frames.py I get this output:

 CameraMode(width=320, height=200, fps=10, format_native=7, format_name='MJPG', supported=True)
 CameraMode(width=320, height=200, fps=15, format_native=7, format_name='MJPG', supported=True)
 CameraMode(width=320, height=200, fps=20, format_native=7, format_name='MJPG', supported=True)
 CameraMode(width=320, height=200, fps=30, format_native=7, format_name='MJPG', supported=True)
 CameraMode(width=320, height=200, fps=60, format_native=7, format_name='MJPG', supported=True)
 CameraMode(width=320, height=200, fps=120, format_native=7, format_name='MJPG', supported=True)
 CameraMode(width=320, height=240, fps=10, format_native=7, format_name='MJPG', supported=True)
 CameraMode(width=320, height=240, fps=15, format_native=7, format_name='MJPG', supported=True)
 CameraMode(width=320, height=240, fps=20, format_native=7, format_name='MJPG', supported=True)
 CameraMode(width=320, height=240, fps=30, format_native=7, format_name='MJPG', supported=True)
 CameraMode(width=320, height=240, fps=60, format_native=7, format_name='MJPG', supported=True)
 CameraMode(width=320, height=240, fps=120, format_native=7, format_name='MJPG', supported=True)
 CameraMode(width=640, height=360, fps=10, format_native=7, format_name='MJPG', supported=True)
 CameraMode(width=640, height=360, fps=20, format_native=7, format_name='MJPG', supported=True)
 CameraMode(width=640, height=360, fps=30, format_native=7, format_name='MJPG', supported=True)
 CameraMode(width=640, height=360, fps=60, format_native=7, format_name='MJPG', supported=True)
 CameraMode(width=640, height=360, fps=120, format_native=7, format_name='MJPG', supported=True)
 CameraMode(width=640, height=400, fps=10, format_native=7, format_name='MJPG', supported=True)
 CameraMode(width=640, height=400, fps=15, format_native=7, format_name='MJPG', supported=True)
 CameraMode(width=640, height=400, fps=20, format_native=7, format_name='MJPG', supported=True)
 CameraMode(width=640, height=400, fps=30, format_native=7, format_name='MJPG', supported=True)
 CameraMode(width=640, height=400, fps=60, format_native=7, format_name='MJPG', supported=True)
 CameraMode(width=640, height=400, fps=120, format_native=7, format_name='MJPG', supported=True)
 CameraMode(width=640, height=480, fps=10, format_native=7, format_name='MJPG', supported=True)
 CameraMode(width=640, height=480, fps=15, format_native=7, format_name='MJPG', supported=True)
 CameraMode(width=640, height=480, fps=20, format_native=7, format_name='MJPG', supported=True)
 CameraMode(width=640, height=480, fps=30, format_native=7, format_name='MJPG', supported=True)
 CameraMode(width=640, height=480, fps=60, format_native=7, format_name='MJPG', supported=True)
 CameraMode(width=640, height=480, fps=120, format_native=7, format_name='MJPG', supported=True)
 CameraMode(width=800, height=600, fps=10, format_native=7, format_name='MJPG', supported=True)
 CameraMode(width=800, height=600, fps=15, format_native=7, format_name='MJPG', supported=True)
 CameraMode(width=800, height=600, fps=20, format_native=7, format_name='MJPG', supported=True)
 CameraMode(width=800, height=600, fps=30, format_native=7, format_name='MJPG', supported=True)
 CameraMode(width=800, height=600, fps=60, format_native=7, format_name='MJPG', supported=True)
 CameraMode(width=800, height=600, fps=120, format_native=7, format_name='MJPG', supported=True)
 CameraMode(width=1280, height=720, fps=10, format_native=7, format_name='MJPG', supported=True)
 CameraMode(width=1280, height=720, fps=15, format_native=7, format_name='MJPG', supported=True)
 CameraMode(width=1280, height=720, fps=20, format_native=7, format_name='MJPG', supported=True)
 CameraMode(width=1280, height=720, fps=30, format_native=7, format_name='MJPG', supported=True)
 CameraMode(width=1280, height=720, fps=60, format_native=7, format_name='MJPG', supported=True)
 CameraMode(width=1280, height=720, fps=120, format_native=7, format_name='MJPG', supported=True)
 CameraMode(width=1280, height=800, fps=10, format_native=7, format_name='MJPG', supported=True)
 CameraMode(width=1280, height=800, fps=15, format_native=7, format_name='MJPG', supported=True)
 CameraMode(width=1280, height=800, fps=30, format_native=7, format_name='MJPG', supported=True)
 CameraMode(width=1280, height=800, fps=120, format_native=7, format_name='MJPG', supported=True)

so I am pretty sure this function should work. please help if possible! thanks!