google-coral / project-teachable

Example Project: Teachable Machine
https://coral.withgoogle.com/projects/teachable-machine/
Apache License 2.0
26 stars 15 forks source link

Running without an attached monitor #6

Closed robotastic closed 4 years ago

robotastic commented 5 years ago

I am trying to get a headless version up and running. If I connect over VNC, I am able to start things up and it works great. However, if I set it to run automatically using rc.local, I get the error below. I tested this by SSHing to it. I have done a chmod on run.sh. I am using a RPi4 and the prebuilt image from here.

pi@raspberrypi:~/project-teachable $ su pi run.sh 
Password: 
Initialize UI.
Detected Raspberry Pi.
Initialize Model...
INFO: Initialized TensorFlow Lite runtime.
W :67] Minimum runtime version required by package (2) is lower than expected (10).
W :67] Minimum runtime version required by package (2) is lower than expected (10).
Start Pipeline.
Gstreamer pipeline:  v4l2src device=/dev/video0 ! video/x-raw,width=640,height=480,framerate=30/1 ! queue max-size-buffers=1 leaky=downstream  ! tee name=t
            t. ! queue max-size-buffers=1 leaky=downstream ! videoconvert ! videoscale ! video/x-raw,format=RGB,width=320,height=180 ! appsink name=appsink sync=false emit-signals=true max-buffers=1 drop=true
            t. ! queue max-size-buffers=1 leaky=downstream ! videoconvert
               ! rsvgoverlay name=overlay ! videoconvert ! autovideosink

Error: gst-resource-error-quark: GStreamer encountered a general resource error. (1): gstkmssink.c(1530): gst_kms_sink_show_frame (): /GstPipeline:pipeline0/GstAutoVideoSink:autovideosink0/GstKMSSink:autovideosink0-actual-sink-kms:
drmModeSetPlane failed: Permission denied (-13)

Same command run through a VNC connection:

su pi ./run.sh 
Password: 
Initialize UI.
Detected Raspberry Pi.
Initialize Model...
INFO: Initialized TensorFlow Lite runtime.
W :67] Minimum runtime version required by package (2) is lower than expected (10).
W :67] Minimum runtime version required by package (2) is lower than expected (10).
Start Pipeline.
Gstreamer pipeline:  v4l2src device=/dev/video0 ! video/x-raw,width=640,height=480,framerate=30/1 ! queue max-size-buffers=1 leaky=downstream  ! tee name=t
            t. ! queue max-size-buffers=1 leaky=downstream ! videoconvert ! videoscale ! video/x-raw,format=RGB,width=320,height=180 ! appsink name=appsink sync=false emit-signals=true max-buffers=1 drop=true
            t. ! queue max-size-buffers=1 leaky=downstream ! videoconvert
               ! rsvgoverlay name=overlay ! videoconvert ! autovideosink

fps 1000.0; #examples: 0; Class      --
fps 21.5; #examples: 0; Class      --
robotastic commented 5 years ago

It looks like removing ! autovideosink from gstreamer.py solves that issue, but then you lose the preview window when you do have a monitor attached. There is probably a more flexible approach... I am just not sure what it is. Probably detecting if a monitor is attached and then configuring the pipeline appropriately.