OpenProcessing on Raspberry Pi

edited October 2016 in Raspberry PI

To start simple, I would like to have this sketch run on my raspberry pi:

/**
 *  Please note that the code for interfacing with Capture devices
 *  will change in future releases of this library. This is just a
 *  filler till something more permanent becomes available.
 *
 *  For use with the Raspberry Pi camera, make sure the camera is
 *  enabled in the Raspberry Pi Configuration tool and add the line
 *  "bcm2835_v4l2" (without quotation marks) to the file
 *  /etc/modules. After a restart you should be able to see the
 *  camera device as /dev/video0.
 */

import gohai.glvideo.*;
GLCapture video;

void setup() {
  size(320, 240, P2D);
  // this will use the first recognized camera
  video = new GLCapture(this, 0);
  video.play();
}

void draw() {
  background(0);
  if (video.available()) {
    video.read();
  }
  image(video, 0, 0, width, height);
}

It is taken directly from https://github.com/gohai/processing-glvideo/blob/master/examples/SimpleCapture/SimpleCapture.pde

I can re-install my OS to have a clean slate if needed, I am only using this for one project.

Errors I run into frequently relate to java and Gstreamer:

(java:8424): GStreamer-WARNING **: Failed to load plugin '/home/pi/sketchbook/libraries/glvideo/library/linux-armv6hf/gstreamer-1.0/libgstalsa.so': /home/pi/sketchbook/libraries/glvideo/library/linux-armv6hf/gstreamer-1.0/libgstalsa.so: symbol snd_pcm_get_chmap, version ALSA_0.9 not defined in file libasound.so.2 with link time reference

(java:8424): GStreamer-WARNING **: Failed to load plugin '/home/pi/sketchbook/libraries/glvideo/library/linux-armv6hf/gstreamer-1.0/libgstvideo4linux2.so': /lib/arm-linux-gnueabihf/libc.so.6: version `GLIBC_2.17' not found (required by /home/pi/sketchbook/libraries/glvideo/library/linux-armv6hf/gstreamer-1.0/libgstvideo4linux2.so)

(java:8424): GStreamer-WARNING **: Failed to load plugin '/home/pi/sketchbook/libraries/glvideo/library/linux-armv6hf/gstreamer-1.0/libgstlibav.so': /lib/arm-linux-gnueabihf/libc.so.6: version `GLIBC_2.17' not found (required by /home/pi/sketchbook/libraries/glvideo/library/linux-armv6hf/gstreamer-1.0/libgstlibav.so) Could not parse pipeline v4l2src device=/dev/video0 ! glupload name=glup ! glcolorconvert ! capsfilter name=filter ! fakesink name=vsink: no element "v4l2src"

The only thing I've been able to succeed at is this instruction https://raspberrypi.org/documentation/usage/webcams/README.md

I understand a decent amount, but I'm no expert at this stuff.

Thanks, Bonem

Tagged:

Answers

  • Hi @Bonem, Interesting to hear about this... what's the OS/distribution you're running on the Pi that gives those errors?

    It will definitely work with the current image of Raspbian + Processing, but I'd love to figure out what's going on here.

  • Hey @gohai, thank you for replying!

    When I turn the pi on it mentions Raspbian GNU/Linux 7.

    I think my problem is there are steps I need to take to prepare my raspberry pi. Steps like updating the java and gstreamer libraries, and steps to enable my webcam. The thing is, I have tried everything I could find but it still does not work in the end.

    What do you suggest?

  • @Bonem That's a very old version of Raspbian - I'd suggest you copy any files you want to keep of your SD card and install a current version. You could try this image that has Processing pre-installed, if you want to.

  • edited October 2016

    Ok, I will do that right now. Thank you

  • @Gohai,

    I did as you suggested, updated processing, updated the GL Video library, ran the sketch, and it gave me these errors:

    RunnableTask.run(): A caught exception occured on thread main-Display-.x11_:0.0-2-EDT-1: RunnableTask[enqueued true[executed false, flushed false], tTotal 2 ms, tExec 0 ms, tQueue 2 ms, attachment null, throwable java.lang.RuntimeException: Waited 5000ms for: <1066a9d, 695d57>[count 1, qsz 0, owner <main-FPSAWTAnimator#00-Timer0>] - <main-Display-.x11_:0.0-2-EDT-1>] java.lang.RuntimeException: Waited 5000ms for: <1066a9d, 695d57>[count 1, qsz 0, owner <main-FPSAWTAnimator#00-Timer0>] - <main-Display-.x11_:0.0-2-EDT-1> at jogamp.common.util.locks.RecursiveLockImpl01Unfairish.lock(RecursiveLockImpl01Unfairish.java:198) at jogamp.newt.WindowImpl.getLocationOnScreen(WindowImpl.java:1159) at jogamp.newt.driver.x11.X11UnderlayTracker.windowMoved(X11UnderlayTracker.java:141) at jogamp.newt.WindowImpl.consumeWindowEvent(WindowImpl.java:4386) at jogamp.newt.WindowImpl.sendWindowEvent(WindowImpl.java:4317) at jogamp.newt.WindowImpl.positionChanged(WindowImpl.java:4558) at jogamp.newt.WindowImpl.sizePosMaxInsetsVisibleChanged(WindowImpl.java:4865) at jogamp.newt.driver.x11.DisplayDriver.DispatchMessages0(Native Method) at jogamp.newt.driver.x11.DisplayDriver.dispatchMessagesNative(DisplayDriver.java:112) at jogamp.newt.WindowImpl.waitForVisible(WindowImpl.java:4449) at jogamp.newt.WindowImpl.waitForVisible(WindowImpl.java:4443) at jogamp.newt.WindowImpl.createNative(WindowImpl.java:777) at jogamp.newt.WindowImpl.setVisibleActionImpl(WindowImpl.java:1248) at jogamp.newt.WindowImpl$VisibleAction.run(WindowImpl.java:1318) at com.jogamp.common.util.RunnableTask.run(RunnableTask.java:127) at jogamp.newt.DefaultEDTUtil$NEDT.run(DefaultEDTUtil.java:375) DefaultEDT.run(): Caught exception occured on thread main-Display-.x11_:0.0-2-EDT-1: RunnableTask[enqueued false[executed true, flushed false], tTotal 15605 ms, tExec 15603 ms, tQueue 2 ms, attachment null, throwable java.lang.RuntimeException: Waited 5000ms for: <1066a9d, 695d57>[count 1, qsz 0, owner <main-FPSAWTAnimator#00-Timer0>] - <main-Display-.x11_:0.0-2-EDT-1>] java.lang.RuntimeException: Waited 5000ms for: <1066a9d, 695d57>[count 1, qsz 0, owner <main-FPSAWTAnimator#00-Timer0>] - <main-Display-.x11_:0.0-2-EDT-1> at jogamp.common.util.locks.RecursiveLockImpl01Unfairish.lock(RecursiveLockImpl01Unfairish.java:198) at jogamp.newt.WindowImpl.getLocationOnScreen(WindowImpl.java:1159) at jogamp.newt.driver.x11.X11UnderlayTracker.windowMoved(X11UnderlayTracker.java:141) at jogamp.newt.WindowImpl.consumeWindowEvent(WindowImpl.java:4386) at jogamp.newt.WindowImpl.sendWindowEvent(WindowImpl.java:4317) at jogamp.newt.WindowImpl.positionChanged(WindowImpl.java:4558) at jogamp.newt.WindowImpl.sizePosMaxInsetsVisibleChanged(WindowImpl.java:4865) at jogamp.newt.driver.x11.DisplayDriver.DispatchMessages0(Native Method) at jogamp.newt.driver.x11.DisplayDriver.dispatchMessagesNative(DisplayDriver.java:112) at jogamp.newt.WindowImpl.waitForVisible(WindowImpl.java:4449) at jogamp.newt.WindowImpl.waitForVisible(WindowImpl.java:4443) at jogamp.newt.WindowImpl.createNative(WindowImpl.java:777) at jogamp.newt.WindowImpl.setVisibleActionImpl(WindowImpl.java:1248) at jogamp.newt.WindowImpl$VisibleAction.run(WindowImpl.java:1318) at com.jogamp.common.util.RunnableTask.run(RunnableTask.java:127) at jogamp.newt.DefaultEDTUtil$NEDT.run(DefaultEDTUtil.java:375) GLVideo: glcolorconvertelement0: Failed to convert video buffer Debugging information: gstglcolorconvertelement.c(220): gst_gl_color_convert_element_prepare_output_buffer (): /GstPipeline:pipeline0/GstGLColorConvertElement:glcolorconvertelement0 GLVideo: v4l2src0: Internal data flow error. Debugging information: gstbasesrc.c(2948): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: streaming task paused, reason error (-5) EGLDisplayUtil.EGLDisplays: Shutdown (open: 1) EGLDisplayUtil: Open EGL Display Connections: 1 EGLDisplayUtil: Open[0]: 0x1: EGLDisplayRef[0x1: refCnt 2]

  • @Bonem (That's with a current Raspbian release, right?) What Raspberry Pi model & camera are you trying this with?

    I'll try my best to reproduce this here...

  • edited October 2016

    I believe these two commands will update Raspbian, so I will run them now:

    sudo apt-get update

    sudo apt-get dist-upgrade

    I'm trying not to do anything extra, only what you say to do. That way there is no mistake that I am making...

  • edited October 2016

    @Gohai

    After updating the error is now this:

    Setting 'Run Sketches on Display' preference to display 1

    GLVideo: v4l2src0: Cannot identify device '/dev/video0'.

    Debugging information: v4l2_calls.c(606): gst_v4l2_open (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: system error: No such file or directory

    GLVideo: v4l2src0: Cannot identify device '/dev/video0'.

    Debugging information: v4l2_calls.c(606): gst_v4l2_open (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: system error: No such file or directory

    FIXED - I had the USB camera unplugged when I ran the sketch and received these errors.

  • @Bonem What camera are you trying this with? The Raspberry Pi camera, or a USB-attached one?

    If it's the former, make sure you've enabled its v4l2 driver like explained in the example's header:

    /*
     *  For use with the Raspberry Pi camera, make sure the camera is
     *  enabled in the Raspberry Pi Configuration tool and add the line
     *  "bcm2835_v4l2" (without quotation marks) to the file
     *  /etc/modules. After a restart you should be able to see the
     *  camera device as /dev/video0.
     */
    
  • edited October 2016

    @Gohai

    I am using a USB-attached, still not working :(

  • @Bonem

    Not working as in: the same error ("No such file or directory") as you posted above? If this is the case, and you're not seeing a video0 when you do a ls -l /dev, then your camera most likely not supported by Linux.

  • edited October 2016

    @Gohai

    Here are the new errors:

    GLVideo: glcolorconvertelement0: Failed to convert video buffer

    Debugging information: gstglcolorconvertelement.c(220): gst_gl_color_convert_element_prepare_output_buffer ():

    /GstPipeline:pipeline0/GstGLColorConvertElement:glcolorconvertelement0

    GLVideo: v4l2src0: Internal data flow error.

    Debugging information: gstbasesrc.c(2948): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: streaming task paused, reason error (-5)

    EGLDisplayUtil.EGLDisplays: Shutdown (open: 1)

    EGLDisplayUtil: Open EGL Display Connections: 1

    EGLDisplayUtil: Open[0]: 0x1: EGLDisplayRef[0x1: refCnt 2]

  • @Bonem

    This must be a bug in the library - please open an issue at https://github.com/gohai/processing-video with all relevant informations.

Sign In or Register to comment.