pupil-labs / pyuvc

python binding to libuvc
Other
117 stars 51 forks source link

Windows 10 x64, Python 3.10.6 x64, pyuvc v 1.0: Can't open stream control - error: 'Operation not supported' #100

Open Raduq91 opened 3 months ago

Raduq91 commented 3 months ago

Windows 10 x64 Python 3.10.6 x64 (thonny-4.0.1-windows-portable) pyuvc v 1.0 libusbK-3.0.7.0-setup(same issue with libusbK-3.1.0.0-setup)

Followed instructions from here: https://github.com/pupil-labs/pyuvc/blob/master/WINDOWS_USER.md and installed pupil-labs-uvc, is there something else to do?

(and https://int80k.com/libuvc/ does not work for me: The connection has timed out)

code from examples:

import uvc

    devices = uvc.device_list()
    print("Available devices", devices)

    for device in devices:

        try:
            cap = uvc.Capture(device["uid"])
        except uvc.DeviceNotFoundError:
            continue

        print(f"{cap.name}")

        print("Available modes:")
        for mode in cap.available_modes:
            print(
                f"MODE: {mode.width} x {mode.height} @ {mode.fps} ({mode.format_name})"
            )

        print("Iterating over frame sizes and rates")
        for res in cap.frame_sizes:
            cap.frame_size = res
            for rate in cap.frame_rates:
                cap.frame_rate = rate
                print(f"RES/RATE: {res[0]} x {res[1]} @ {rate} Hz")

        cap.close()

output:

Available devices [{'name': 'RYS HFR USB2.0 Camera', 'manufacturer': 'RYS HFR USB2.0 Camera', 'serialNumber': 'unknown', 'idProduct': 5461, 'idVendor': 5546, 'device_address': 9, 'bus_number': 1, 'uid': '1:9'}]
RYS HFR USB2.0 Camera
Available modes:
MODE: 640 x 360 @ 330 (MJPG)
MODE: 1280 x 720 @ 120 (MJPG)
MODE: 1920 x 1080 @ 60 (MJPG)
Iterating over frame sizes and rates
RES/RATE: 640 x 360 @ 330 Hz
RES/RATE: 1280 x 720 @ 120 Hz
RES/RATE: 1920 x 1080 @ 60 Hz

import uvc

for device in uvc.device_list():

    cap = uvc.Capture(device["uid"])

    for mode in cap.available_modes:
        print(f"{cap.name} running at {mode}")
        try:
            cap.frame_mode = mode
        except uvc.InitError as err:
            print(f"{cap.name} mode selection - {err}")
            continue
        try:
            for x in range(10):
                frame = cap.get_frame_robust()
                print("frame gray mean", frame.gray.mean())
            # print(frame.img.mean())
        except uvc.InitError as err:
            print(f"{cap.name} getting frames - {err}")

    cap.close()

output:

RYS HFR USB2.0 Camera running at CameraMode(width=640, height=360, fps=330, format_native=7, format_name='MJPG', supported=True)
RYS HFR USB2.0 Camera getting frames - Can't open stream control - error: 'Operation not supported'
RYS HFR USB2.0 Camera running at CameraMode(width=1280, height=720, fps=120, format_native=7, format_name='MJPG', supported=True)
RYS HFR USB2.0 Camera getting frames - Can't open stream control - error: 'Operation not supported'
RYS HFR USB2.0 Camera running at CameraMode(width=1920, height=1080, fps=60, format_native=7, format_name='MJPG', supported=True)
RYS HFR USB2.0 Camera getting frames - Can't open stream control - error: 'Operation not supported'
saifwarraich commented 2 months ago

Facing the same issue.

Raduq91 commented 2 months ago

Additional info:

AMCAP Video Capture pin settings: image

( opencv 4.7.0.68 ) In Python if I use cv2.VideoCapture(0), there is video(640x360@60fps), but I can't change resolution. cv2.VideoCapture(0, cv2.CAP_DSHOW) is needed to change resolution(which will change fps too). (cv2.CAP_PROP_FRAME_WIDTH, 1280) # will have 120fps (cv2.CAP_PROP_FRAME_HEIGHT, 720)

Windows Camera app, in Video settings shows only "1080p 16:9 60fps" option

I used binary from this libuvc issue https://github.com/libuvc/libuvc/issues/12#issuecomment-1367972518 (I think this is the example file https://github.com/libuvc/libuvc/blob/master/src/example.c)

libuvc_mingw64>example.exe
UVC initialized
Device found
Device opened
DEVICE CONFIGURATION (15aa:1555/[none]) ---
Status: idle
VideoControl:
        bcdUVC: 0x0100
VideoStreaming(1):
        bEndpointAddress: 129
        Formats:
        MJPEGFormat(1)
                  bits per pixel: 0
                  GUID: 4d4a5047000000000000000000000000 (MJPG)
                  default frame: 1
                  aspect ratio: 0x0
                  interlace flags: 00
                  copy protect: 00
                        FrameDescriptor(1)
                          capabilities: 00
                          size: 640x360
                          bit rate: -608567296--3686400
                          max frame size: 460800
                          default interval: 1/330
                          interval[0]: 1/330
                        FrameDescriptor(2)
                          capabilities: 00
                          size: 1280x720
                          bit rate: 1769472000-1769472000
                          max frame size: 1843200
                          default interval: 1/120
                          interval[0]: 1/120
                        FrameDescriptor(3)
                          capabilities: 00
                          size: 1920x1080
                          bit rate: 1990656000-1990656000
                          max frame size: 4147200
                          default interval: 1/60
                          interval[0]: 1/60
                        StillFrameDescriptor
                          bEndPointAddress: 00
                          wWidth(1) = 640
                          wHeight(1) = 360
                          wWidth(2) = 1280
                          wHeight(2) = 720
                          wWidth(3) = 1920
                          wHeight(3) = 1080
END DEVICE CONFIGURATION

First format: (MJPG) 640x360 330fps
bmHint: 0001
bFormatIndex: 1
bFrameIndex: 1
dwFrameInterval: 30303
wKeyFrameRate: 0
wPFrameRate: 0
wCompQuality: 47
wCompWindowSize: 0
wDelay: 0
dwMaxVideoFrameSize: 460800
dwMaxPayloadTransferSize: 3072
bInterfaceNumber: 1
start_streaming: Not supported (-12)
Device closed
UVC exited
Raduq91 commented 2 months ago

Additional info: Partially working on Android with UVC using https://github.com/Peter-St/Android-UVC-Camera ( maybe relevant info: https://github.com/Peter-St/Android-UVC-Camera/issues/38 )

Changing resolution works but not the fps(the only choice is 330fps) 640x320@330 : fps looks 60 or more 1280x720@330fps: fps looks like 25-30 1920x1080@330fps: fps looks like 10-15

zzz9

xianzhuoliu commented 3 weeks ago

Has anyone solved this problem? I encountered the same issue.