google-coral/project-posenet

Excuse me,I want to ask how to input jpeg

XuTZ0912 opened this issue · 7 comments

mendel@deft-dog:~/project-posenet$ python3 pose_camera.py --jpeg
/home/mendel/project-posenet/gstreamer.py:15: PyGIWarning: Gst was imported without specifying a version first. Use gi.require_version('Gst', '1.0') before import to ensure that the right version gets loaded.
  from gi.repository import GLib, GObject, Gst, GstBase, GstVideo, Gtk
/home/mendel/project-posenet/gstreamer.py:15: PyGIWarning: GstBase was imported without specifying a version first. Use gi.require_version('GstBase', '1.0') before import to ensure that the right version gets loaded.
  from gi.repository import GLib, GObject, Gst, GstBase, GstVideo, Gtk
/home/mendel/project-posenet/gstreamer.py:15: PyGIWarning: GstVideo was imported without specifying a version first. Use gi.require_version('GstVideo', '1.0') before import to ensure that the right version gets loaded.
  from gi.repository import GLib, GObject, Gst, GstBase, GstVideo, Gtk
/home/mendel/project-posenet/gstreamer.py:15: PyGIWarning: Gtk was imported without specifying a version first. Use gi.require_version('Gtk', '3.0') before import to ensure that the right version gets loaded.
  from gi.repository import GLib, GObject, Gst, GstBase, GstVideo, Gtk
Loading model:  models/mobilenet/posenet_mobilenet_v1_075_481_641_quant_decoder_edgetpu.tflite
Gstreamer pipeline:  v4l2src device=/dev/video0 ! image/jpeg,width=640,height=480,framerate=30/1 ! decodebin ! videoflip video-direction=identity ! tee name=t
               t. ! queue max-size-buffers=1 leaky=downstream ! videoconvert ! freezer name=freezer ! rsvgoverlay name=overlay
                  ! videoconvert ! autovideosink
               t. ! queue max-size-buffers=1 leaky=downstream ! videoconvert ! videoscale ! video/x-raw,width=641,height=480 ! videobox name=box autocrop=true
                  ! video/x-raw,format=RGB,width=641,height=481 ! appsink name=appsink emit-signals=true max-buffers=1 drop=true

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)

if enter the directory

python3 pose_camera.py --jpeg /home/mendel/model/omodel/o32.jpeg
/home/mendel/project-posenet/gstreamer.py:15: PyGIWarning: Gst was imported without specifying a version first. Use gi.require_version('Gst', '1.0') before import to ensure that the right version gets loaded.
  from gi.repository import GLib, GObject, Gst, GstBase, GstVideo, Gtk
/home/mendel/project-posenet/gstreamer.py:15: PyGIWarning: GstBase was imported without specifying a version first. Use gi.require_version('GstBase', '1.0') before import to ensure that the right version gets loaded.
  from gi.repository import GLib, GObject, Gst, GstBase, GstVideo, Gtk
/home/mendel/project-posenet/gstreamer.py:15: PyGIWarning: GstVideo was imported without specifying a version first. Use gi.require_version('GstVideo', '1.0') before import to ensure that the right version gets loaded.
  from gi.repository import GLib, GObject, Gst, GstBase, GstVideo, Gtk
/home/mendel/project-posenet/gstreamer.py:15: PyGIWarning: Gtk was imported without specifying a version first. Use gi.require_version('Gtk', '3.0') before import to ensure that the right version gets loaded.
  from gi.repository import GLib, GObject, Gst, GstBase, GstVideo, Gtk
usage: pose_camera.py [-h] [--mirror] [--model MODEL]
                      [--res {480x360,640x480,1280x720}] [--videosrc VIDEOSRC]
                      [--h264] [--jpeg]
pose_camera.py: error: unrecognized arguments: /home/mendel/model/omodel/o32.jpeg

So, I want to ask the basic problem for this...Thank you!

@XuTZ0912 jpeg is true or false flag. when included it in the argument it would be True otherwise it is False.

The way to use is python3 pose_camera.py --jpeg

Which camera are you using? If USB camera can you share the output of v4l2-ctl --list-formats-ext --device /dev/video1

Feel free to reopen if they are any questions on this issue.

@hjonnala The help says

--jpeg                Use image/jpeg input

but how do you pass the image, if it is a boolean flag? If I use --videosrc I get a similar issue as #85

$ python3 pose_camera.py --jpeg --videosrc image.jpg
/path/to/project-posenet/gstreamer.py:15: PyGIWarning: Gst was imported without specifying a version first. Use gi.require_version('Gst', '1.0') before import to ensure that the right version gets loaded.
  from gi.repository import GLib, GObject, Gst, GstBase, GstVideo, Gtk
/path/to/project-posenet/gstreamer.py:15: PyGIWarning: GstBase was imported without specifying a version first. Use gi.require_version('GstBase', '1.0') before import to ensure that the right version gets loaded.
  from gi.repository import GLib, GObject, Gst, GstBase, GstVideo, Gtk
/path/to/project-posenet/gstreamer.py:15: PyGIWarning: GstVideo was imported without specifying a version first. Use gi.require_version('GstVideo', '1.0') before import to ensure that the right version gets loaded.
  from gi.repository import GLib, GObject, Gst, GstBase, GstVideo, Gtk
/path/to/project-posenet/gstreamer.py:15: PyGIWarning: Gtk was imported without specifying a version first. Use gi.require_version('Gtk', '3.0') before import to ensure that the right version gets loaded.
  from gi.repository import GLib, GObject, Gst, GstBase, GstVideo, Gtk
Loading model:  models/mobilenet/posenet_mobilenet_v1_075_481_641_quant_decoder_edgetpu.tflite
Gstreamer pipeline:  v4l2src device=/home/maiermic/Pictures/vlcsnap-2022-11-14-23h23m58s950.jpg ! image/jpeg,width=640,height=480,framerate=30/1 ! decodebin ! videoflip video-direction=identity ! tee name=t
               t. ! queue max-size-buffers=1 leaky=downstream ! videoconvert ! freezer name=freezer ! rsvgoverlay name=overlay
                  ! videoconvert ! autovideosink
               t. ! queue max-size-buffers=1 leaky=downstream ! videoconvert ! videoscale ! video/x-raw,width=641,height=480 ! videobox name=box autocrop=true
                  ! video/x-raw,format=RGB,width=641,height=481 ! appsink name=appsink emit-signals=true max-buffers=1 drop=true

Traceback (most recent call last):
  File "pose_camera.py", line 166, in <module>
    main()
  File "pose_camera.py", line 162, in main
    run(run_inference, render_overlay)
  File "pose_camera.py", line 122, in run
    gstreamer.run_pipeline(partial(inf_callback, engine), partial(render_callback, engine),
  File "/path/to/project-posenet/gstreamer.py", line 366, in run_pipeline
    pipeline.run()
  File "/path/to/project-posenet/gstreamer.py", line 74, in run
    sinkelement.set_property('sync', False)
AttributeError: 'NoneType' object has no attribute 'set_property'

Hi @maiermic for single image please try simple_pose.py.
jpeg flag is used to modify the gstreamer pipeline. It still required camera input as video source.

@hjonnala I'd like to get a drawing of the pose (e.g. like pose_camera.py). simple_pose.py only prints the coordinates.

@hjonnala I'd like to get a drawing of the pose (e.g. like pose_camera.py). simple_pose.py only prints the coordinates.

please try replacing the sinple_pose.py with the script at: https://github.com/hjonnala/snippets/blob/main/posenet/simple_pose.py

@hjonnala Thank you 👍