pupil-labs / pyuvc

python binding to libuvc
Other
117 stars 51 forks source link

uvc:Could not init 'White Balance temperature blue'! #87

Open RolandThsive opened 2 years ago

RolandThsive commented 2 years ago

Hello,

I recently tried using this library for controlling my OBSBOT TINY CAMERA but I cannot use it because every time I try to run the example code provided, it throws this error - Look below, All the prerequisite conditions for using this library has been followed perfectly, Please advise what could this error mean.

[{'name': 'unknown', 'manufacturer': 'unknown', 'serialNumber': 'unknown', 'idProduct': 28799, 'idVendor': 1226, 'device_address': 2, 'bus_number': 1, 'uid': '1:2'}, {'name': 'unknown', 'manufacturer': 'unknown', 'serialNumber': 'unknown', 'idProduct': 28799, 'idVendor': 1226, 'device_address': 2, 'bus_number': 1, 'uid': '1:2'}, {'name': 'OBSBOT Tiny', 'manufacturer': 'Remo Tech Co., Ltd.', 'serialNumber': 'unknown', 'idProduct': 65264, 'idVendor': 28208, 'device_address': 11, 'bus_number': 1, 'uid': '1:11'}] ERROR:uvc:Could not init 'White Balance temperature blue'! Error: range() arg 3 must not be zero ERROR:uvc:Could not init 'White Balance temperature red'! Error: range() arg 3 must not be zero [(640, 360, 60), (640, 360, 30), (640, 360, 24), (640, 360, 20), (640, 360, 15), (960, 540, 60), (960, 540, 30), (960, 540, 24), (960, 540, 20), (960, 540, 15), (1280, 720, 60), (1280, 720, 30), (1280, 720, 24), (1280, 720, 20), (1280, 720, 15), (1920, 1080, 30), (1920, 1080, 24), (1920, 1080, 20), (1920, 1080, 15)] 0 Traceback (most recent call last): File "C:\Users\user\Desktop\test3.py", line 21, in frame = cap.get_frame_robust() File "uvc.pyx", line 572, in uvc.Capture.get_frame_robust File "uvc.pyx", line 588, in uvc.Capture.get_frame File "uvc.pyx", line 544, in uvc.Capture._start uvc.InitError

papr commented 2 years ago

Hi @RolandThsive Although the white balance temp messages are logged as "errors", they are not the cause for the failed init. To debug this issue further, could you please add the following two lines to the beginning of the example script and share the additionally generated logs?

import os
os.environ["LIBUSB_DEBUG"] = "3"
RolandThsive commented 2 years ago

Hello, @papr

I have added the two lines, The output remains the same,

[{'name': 'unknown', 'manufacturer': 'unknown', 'serialNumber': 'unknown', 'idProduct': 28799, 'idVendor': 1226, 'device_address': 2, 'bus_number': 1, 'uid': '1:2'}, {'name': 'unknown', 'manufacturer': 'unknown', 'serialNumber': 'unknown', 'idProduct': 28799, 'idVendor': 1226, 'device_address': 2, 'bus_number': 1, 'uid': '1:2'}, {'name': 'OBSBOT Tiny', 'manufacturer': 'Remo Tech Co., Ltd.', 'serialNumber': 'unknown', 'idProduct': 65264, 'idVendor': 28208, 'device_address': 11, 'bus_number': 1, 'uid': '1:11'}] ERROR:uvc:Could not init 'White Balance temperature blue'! Error: range() arg 3 must not be zero ERROR:uvc:Could not init 'White Balance temperature red'! Error: range() arg 3 must not be zero [(640, 360, 60), (640, 360, 30), (640, 360, 24), (640, 360, 20), (640, 360, 15), (960, 540, 60), (960, 540, 30), (960, 540, 24), (960, 540, 20), (960, 540, 15), (1280, 720, 60), (1280, 720, 30), (1280, 720, 24), (1280, 720, 20), (1280, 720, 15), (1920, 1080, 30), (1920, 1080, 24), (1920, 1080, 20), (1920, 1080, 15)] 0 Traceback (most recent call last): File "C:\Users\user\Desktop\test3.py", line 24, in frame = cap.get_frame_robust() File "uvc.pyx", line 572, in uvc.Capture.get_frame_robust File "uvc.pyx", line 588, in uvc.Capture.get_frame File "uvc.pyx", line 544, in uvc.Capture._start uvc.InitError

papr commented 2 years ago

This is unfortunate. Would you be able to test the code and camera on a Linux machine?

My best guess is that the camera is not fulfilling all hardware requirements:

1) UVC compatible (see specification here: http://www.cajunbot.com/wiki/images/8/85/USB_Video_Class_1.1.pdf) (Chapters below refer to this document) 2) Support Video Interface Class Code 0x0E CC_VIDEO (see A.1) 3) Support Video Subclass Code 0x02 SC_VIDEOSTREAMING (see A.2) 4) Support for the UVC_VS_FRAME_MJPEG (0x07) video streaming interface descriptor subtype (A.6) 5) Support UVC_FRAME_FORMAT_COMPRESSED frame format

RolandThsive commented 2 years ago

Hello @papr , So I got hold of a linux machine, I installed whatever was required, Apparently after installing all the dependencies for the library i am getting the module uvc not found error, which is weird, can you please help me out I have no idea what is missing. Heres the error,

Traceback (most recent call last): File "ex.py", line 2, in import uvc ModuleNotFoundError: No module named 'uvc'

I followed the linux dependencies part here - https://github.com/pupil-labs/pyuvc

papr commented 2 years ago

Hi, this looks like pyuvc itself was not yet build:

pip install git+https://github.com/pupil-labs/pyuvc
RolandThsive commented 2 years ago

Hello,

SO there is apparently a problem with building the uvc module only in linux

Collecting git+https://github.com/pupil-labs/pyuvc Cloning https://github.com/pupil-labs/pyuvc to /tmp/pip-req-build-ccyaublm Running command git clone --filter=blob:none --quiet https://github.com/pupil-labs/pyuvc /tmp/pip-req-build-ccyaublm Resolved https://github.com/pupil-labs/pyuvc to commit 430d2e674f6e41dbf5919fc4b4824c3a2ace36e1 Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... done Collecting numpy Using cached numpy-1.22.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (16.9 MB) Building wheels for collected packages: uvc Building wheel for uvc (pyproject.toml) ... error error: subprocess-exited-with-error

× Building wheel for uvc (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [51 lines of output] running bdist_wheel running build running build_ext building 'uvc' extension creating build creating build/temp.linux-x86_64-cpython-38 x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/tmp/pip-build-env-_w2gjzmh/overlay/lib/python3.8/site-packages/numpy/core/include -I/usr/include/python3.8 -c uvc.c -o build/temp.linux-x86_64-cpython-38/uvc.o In file included from /tmp/pip-build-env-_w2gjzmh/overlay/lib/python3.8/site-packages/numpy/core/include/numpy/ndarraytypes.h:1960, from /tmp/pip-build-env-_w2gjzmh/overlay/lib/python3.8/site-packages/numpy/core/include/numpy/ndarrayobject.h:12, from /tmp/pip-build-env-_w2gjzmh/overlay/lib/python3.8/site-packages/numpy/core/include/numpy/arrayobject.h:5, from uvc.c:731: /tmp/pip-build-env-_w2gjzmh/overlay/lib/python3.8/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp] 17 | #warning "Using deprecated NumPy API, disable it with " \ | ^~~ uvc.c: In function ‘pyx_f_3uvc_7Capturestart’: uvc.c:15854:20: error: too many arguments to function ‘uvc_stream_start’ 15854 | pyx_v_status = uvc_stream_start(pyx_v_self->strmh, NULL, NULL, pyx_v_self->_bandwidth_factor, 0); | ^~~~ In file included from uvc.c:728: /usr/local/include/libuvc/libuvc.h:637:13: note: declared here 637 | uvc_error_t uvc_stream_start(uvc_stream_handle_t *strmh, | ^~~~ uvc.c: In function ‘pyx_pf_3uvc_7Capture_8get_frame’: uvc.c:16956:42: warning: comparison of integer expressions of different signedness: ‘uint32_t’ {aka ‘unsigned int’} and ‘int’ [-Wsign-compare] 16956 | pyx_t_7 = ((pyx_v_uvc_frame->width == pyx_v_j_width) != 0); | ^~ uvc.c:16962:43: warning: comparison of integer expressions of different signedness: ‘uint32_t’ {aka ‘unsigned int’} and ‘int’ [-Wsign-compare] 16962 | pyx_t_7 = ((pyx_v_uvc_frame->height == __pyx_v_j_height) != 0); | ^~ uvc.c: In function ‘pyx_f_3uvc_7Captureenumerate_controls’: uvc.c:17138:26: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] 17138 | pyx_v_input_terminal = uvc_get_input_terminals(pyx_v_self->devh); | ^ uvc.c:17147:27: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] 17147 | pyx_v_output_terminal = uvc_get_output_terminals(pyx_v_self->devh); | ^ uvc.c:17156:27: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] 17156 | pyx_v_processing_unit = uvc_get_processing_units(pyx_v_self->devh); | ^ uvc.c:17165:26: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] 17165 | pyx_v_extension_unit = uvc_get_extension_units(pyx_v_self->devh); | ^ uvc.c: In function ‘__pyx_f_3uvc_7Captureenumerate_formats’: uvc.c:17740:23: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] 17740 | pyx_v_format_desc = uvc_get_format_descs(pyx_v_self->devh); | ^ At top level: uvc.c:20227:13: warning: ‘pyx_f_3uvc_on_status_update’ defined but not used [-Wunused-function] 20227 | static void pyx_f_3uvc_on_status_update(CYTHON_UNUSED enum uvc_status_class pyx_v_status_class, CYTHON_UNUSED int __pyx_v_event, CYTHON_UNUSED int pyx_v_selector, CYTHON_UNUSED enum uvc_status_attribute pyx_v_status_attribute, CYTHON_UNUSED void *pyx_v_data, CYTHON_UNUSED size_t pyx_v_data_len, CYTHON_UNUSED void *pyx_v_user_ptr) { | ^~~~~~~~~ error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1 [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for uvc Failed to build uvc ERROR: Could not build wheels for uvc, which is required to install pyproject.toml-based projects

papr commented 2 years ago

uvc.c:15854:20: error: too many arguments to function ‘uvc_stream_start’ 15854 | pyx_v_status = uvc_stream_start(pyx_v_self->strmh, NULL, NULL, __pyx_v_self->_bandwidth_factor, 0);

Based on this message, it looks like pyuvc is not building against the pupil labs libuvc that you should have built in the previous dependency installation. Please check if there is another libuvc installed on that system that might be causing the conflict. Specifcally, check if the libuvc-dev package is installed.