google-coral / project-bodypix

BodyPix model demo application for Google Coral
Apache License 2.0
275 stars 52 forks source link

Gstreamer pipeline for USB camera /dev/video1 on coral dev board #2

Closed ashishkcap closed 2 years ago

ashishkcap commented 4 years ago

Hi, When I am trying to run bodypix using usb camera /dev/video1, sudo python3 bodypix_gl_imx.py --videosrc /dev/video1 getting the following error: v4l2src device=/dev/video1 ! video/x-raw,width=1920,height=1080,framerate=30/1 ! queue max-size-buffers=1 leaky=downstream ! identity ! glupload ! glvideoflip video-direction=identity ! tee name=t t. ! queue max-size-buffers=1 ! glfilterbin filter=glbox name=glbox ! video/x-raw,format=RGB,width=1024,height=768 ! queue max-size-buffers=1 ! inference name=inf ! agg. t. ! queue max-size-buffers=1 ! agg.

(bodypix_gl_imx.py:4401): Gtk-CRITICAL **: 13:02:37.321: _gtk_style_provider_private_get_settings: assertion 'GTK_IS_STYLE_PROVIDER_PRIVATE (provider)' failed

(bodypix_gl_imx.py:4401): Gtk-CRITICAL **: 13:02:37.321: _gtk_style_provider_private_get_settings: assertion 'GTK_IS_STYLE_PROVIDER_PRIVATE (provider)' failed

(bodypix_gl_imx.py:4401): Gtk-CRITICAL **: 13:02:37.321: _gtk_style_provider_private_get_settings: assertion 'GTK_IS_STYLE_PROVIDER_PRIVATE (provider)' failed Segmentation fault In https://coral.ai/docs/dev-board/camera/#using-an-hdmi-monitor example the usb camera gstreamer pipeline is v4l2src device=/dev/video1 ! video/x-raw,format=YUY2,width=800,height=600,framerate=20/1 ! glupload ! tee name=t t. ! queue ! glsvgoverlaysink name=glsink t. ! queue max-size-buffers=1 leaky=downstream ! glfilterbin filter=glbox ! video/x-raw,format=RGB,width=320,height=320 ! appsink name=appsink emit-signals=True max-buffers=1 drop=True sync=False

Can you modify the gstreamer pipeline for usb camera support? Thanks

mbrooksx commented 4 years ago

The pipeline works for USB cameras but I expect your camera doesn't have the capabilities for the default settings (raw @ 1920x1080). It looks like you changed the width and height arguments to this, can you use the default?

ashishkcap commented 4 years ago

I am using the default command sudo python3 bodypix_gl_imx.py --videosrc /dev/video1 Just added the --videosrc /dev/video1 to point to USB camera.

The camera doesnt support raw @1920x1080 30/1 v4l2-ctl --list-formats-ext --device /dev/video1

mbrooksx commented 4 years ago

Right I misread which example code you were using, 1920x1080 is the default for this one. Can you change the width and height arguments to dimensions supported by your camera?

ashishkcap commented 4 years ago

Hi, I tried using --width 800 --height 600 option supported by my camera, but still its not working. I guess the problem is the USB camera supports YUYV not raw format. The example https://coral.ai/docs/dev-board/camera/#using-an-hdmi-monitor the USB camera is working. I don't have much knowledge about GStreamer pipeline, maybe if we can use the same pipeline.

codyrushing commented 3 years ago

@ashishkcap I am experiencing the same when using a USB camera. When I run:

python3 bodypix_gl_imx.py --videosrc=/dev/video1 --width=1024 --height=768

I get this error:

Traceback (most recent call last):
  File "bodypix_gl_imx.py", line 890, in do_fixate_src_caps
    self.ensure_pads_found()
  File "bodypix_gl_imx.py", line 843, in ensure_pads_found
    feature = caps.get_features(0).get_nth(0)
AttributeError: 'NoneType' object has no attribute 'get_features'
Error: gst-stream-error-quark: Internal data stream error. (1): gstbasesrc.c(3055): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
streaming stopped, reason not-negotiated (-4)

As others mentioned above, this might have something to do with my camera using YUYV instead of raw format.

Other coral examples work fine with the USB camera on the Coral dev board, like this: https://coral.ai/docs/dev-board/camera/#run-the-face-detection-model-with-a-monitor

Does anyone know how to get this code base to work with a USB camera?

codyrushing commented 3 years ago

I'm stupid and I just realized there is a --jpeg command line option, which I didn't realize. My camera supports the JPEG format, so it works fine. This is with a Logitech C920

hjonnala commented 3 years ago

@ashishkcap are you still having the issues with USB camera?

hjonnala commented 2 years ago

closing due to inactivity.

google-coral-bot[bot] commented 2 years ago

Are you satisfied with the resolution of your issue? Yes No