groundlight / framegrab

Library to easily grab frames from cameras or streams and do simple local analysis
MIT License
18 stars 0 forks source link

Not compatible with the Logitech Brio Webcam #26

Closed sunildkumar closed 4 months ago

sunildkumar commented 8 months ago

The framegrab library isn't compatible with the main camera on the Logitech Brio Webcam (https://www.logitech.com/en-us/products/webcams/brio-4k-hdr-webcam.960-001105.html). Framegrab discovers all three sensors on the webcam as valid cameras:

Found 3 cameras. Here are the configs for each camera:
{'input_type': 'generic_usb', 'options': {}, 'name': 'GENERIC_USB Camera - 1'}
{'input_type': 'generic_usb', 'options': {}, 'name': 'GENERIC_USB Camera - 2'}
{'input_type': 'generic_usb', 'options': {}, 'id': {'serial_number': 'EF65043D'}, 'name': 'GENERIC_USB Camera - EF65043D'}

Two are infrared-looking channels that technically work, but aren't very useful as they are black and white and very noisy.

The third is the main sensor, however trying to use this camera fails when we try to grab a frame from it:

[ WARN:0@13.205] global cap_v4l.cpp:1119 tryIoctl VIDEOIO(V4L2:/dev/video15): select() timeout.
[ WARN:0@23.215] global cap_v4l.cpp:1119 tryIoctl VIDEOIO(V4L2:/dev/video15): select() timeout.
Traceback (most recent call last):
  File "/home/sample-pi/getting_started/main.py", line 42, in <module>
    image_query = gl.ask_ml(detector=detector, image=image)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/groundlight/gl-py/lib/python3.11/site-packages/groundlight/client.py", line 434, in ask_ml
    iq = self.submit_image_query(
         ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/groundlight/gl-py/lib/python3.11/site-packages/groundlight/client.py", line 317, in submit_image_query
    image_bytesio: ByteStreamWrapper = parse_supported_image_types(image)
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/groundlight/gl-py/lib/python3.11/site-packages/groundlight/images.py", line 102, in parse_supported_image_types
    raise TypeError(
TypeError: Unsupported type for image. Must be PIL, numpy (H,W,3) BGR, or a JPEG as a filename (str), bytes, BytesIO, or BufferedReader.

I got this webcam working with cv2 here: https://github.com/sunildkumar/GrimeGuardian/blob/main/app/make_queries.py, but I'm not sure how to adapt this for the general solution here.

timmarkhuff commented 4 months ago

Fixed in https://github.com/groundlight/framegrab/pull/39