Pi Camera?

edited December 2016 in Raspberry PI

Hello! Has anyone been successful in using the Pi Camera with the capture library? I've been able to successfully run video examples following the steps outlined here: https://forum.processing.org/two/discussion/13485/how-to-use-processing-3-and-the-video-capture-library-on-raspberry-pi

When I run the GettingStartedCapture with a bit of modified code to work with the downloaded video lib, I get this:

Screen Shot 2016-08-23 at 22.09.06

I've verified that the camera is working by following this guide and capturing some still images.

Here is the code I'm using:

    import processing.video.*;

    Capture cam;

    void setup(){

      size(640,480);

      cam = new Capture(this);
      cam.start();

    }
    void draw(){
      if(cam.available() == true){
        cam.read();
    }

      image(cam,0,0, width, height);
    }

p.s. this is on a Raspberry Pi 3 Model B, Pi Camera v2, Raspbian Jessie p.p.s. a usb webcam works fine in YUV

Tagged:

Answers

  • Answer ✓

    After digging around a bit, I think this is being worked on: https://github.com/gohai/processing-glvideo/blob/master/examples/SimpleCapture/SimpleCapture.pde

    I'll try it out later on today...

  • wisof is correct. That works with my setup but I have been told that "texture.get() isn't working as it should", so I haven't yet been able to play with the captured video. All you can do at the moment on a Pi3 is display it unchanged.

  • I was foolishly attempting to view this over VNC. Viewing this over HDMI, the sketch works and I can switch from video0 and video1. Interestingly, I have an old webcam hooked up to video1. With the glvideo library, the pixels are rgb, with the processing.video.* they come in YUV.

    It is unfortunate that we can't access the pixels yet (I'll look into the source to see if I can help that at all) as I need to mess with them ;)

  • We just released version 1.1 of the GL Video library, which as support for the pixels array (@Englishman_in_Berlin). However this requires a change to Processing's OpenGL code, which is already in git, but not yet in a released version. So either wait for 3.2.2 (or 3.3?), or if you're in a hurry, compile the latest Processing from git and give it a shot. Compiling is surprisingly easy!

  • Please excuse my ignorance here, I have just bought a raspberry pi for the sole reason that it can now run Processing (relatively) easily. Unfortunately I am an absolute novice when it comes to using the linux terminal window, I have no idea what I am doing (google searches reveal that I am the only one. I must have been sick the day the entire world became experts at using "sudo". Whatever the hell that is).

    Anyway I am trying to use my Pi camera with processing and have followed the steps followed by Wisof above. Installing packages using sudo aptitude install gstreamer0.10-plugins-good didn't fix anything.

    Running the same code Wisof used above has now returned to telling me that "There are no capture devices connected to this computer", whereas before it had given me the "No such Gstreamer factory: v4l2src" error. Running the Simple Capture code for GLVideo now says that "GLVideo requires the P2D or P3D renderer".

    Attempting to add bcm2835_v4l2 to /etc/modules gives me a "Permission denied" error. What am I doing wrong here? This looks like it should have an easy enough fix but I have no clue.

    (On a side note; after installing Processing 3.2.1 on the raspberry pi I can only open it by going to the Processing folder in File Manager. Trying to open it with its automatically installed shortcuts gives me a "Invalid desktop entry file: 'usr/local/share/applications/processing.desktop'" error. Could this error explain anything? Again that flu I had on "Everyone Becomes a Linux Genius Day" means that searching for a solution has proven pointless for me. )

    The camera works, I used the raspistill and raspivid commands to prove that, but I just can't get anything from Processing yet.

    I have a pretty big installation coming up and it would be great to be able to use a camera with the Pi through Processing. Would a webcam work? What do I need to do to try out version 1.1?

    Thank you for your time and patience.

  • By the way I am using (well trying to) a v2 Pi Camera with a Raspberry Pi 3 Model B which is running Jessie. And Processing 3.2.1 obviously.

  • edited September 2016

    @yoink

    Edit /etc/modules like this: sudo nano /etc/modules.

    Your Simple Capture code contains size(320, 240, P2D)?

  • edited December 2016

    @gohai

    Is this solution supposed to support Processing 3.2.3 with all the same gear as @yoink is mentioning? Gives me:

    "(java:1365): GStreamer-WARNING **: Failed to load plugin '/home/pi/sketchbook/libraries/library1539864416009106957tmp/glvideo/library/linux-armv6hf/gstreamer-1.0/libgstencodebin.so': /home/pi/sketchbook/libraries/library1539864416009106957tmp/glvideo/library/linux-armv6hf/gstreamer-1.0/../libgstaudio-1.0.so.0: undefined symbol: gst_segment_is_equal

    Devices:"

    When running the SimpleCapture.pde sketch.

    Any help much appreciated.

  • @jonaseltes Which OS are you running?

  • import gohai.glvideo.*; 
    GLCapture video;
    
    void setup() {
        size(800, 480, P2D);
        video = new GLCapture(this, 0); 
        video.play(); }
    
    void draw() { 
      background(255, 255, 0);
      if (video.available()) { 
         video.read(); 
      } 
      image(video, 200, 240, 400, 240); 
    }
    
  • Hi @yoink , I have the same problem with my Raspberry Pi 3, have you fixed the PiCamera issue? if yes, thank you for help!

  • Hi @Yoink, and the rest.

    So maybe Im confused. I have been working on buying Pi hardware and learning about it. Im I mistaken or are you guys saying the Raspberry Pi Cameras (any) don't work to capture video frames (at any frame rate) from the Pi camera n Processing?

    Im hoping that it can be done. I am a student and would never have blown money on a pi camera if I had known this didnt work.

    If it does work, can someone PLEASE explain "how to use Pi camera with Processing for Video" IF IT DOESNT WORK: Can you please update the Support information because I am pretty sure MOST ANYONE will be thinking it works untill they buy hardware and try.

    Please, I am so grateful for processing and all the community libraries. Thankful to everyone who works to improve access to technology, etc. However, I must say I feel it seems extremely odd to not make explicitly clear that processing doesn't even support basic video capure from the default camera device.

    I am probably wrong and confused. I dont know. I am just trying to find out what actually works and Im tired and frustrated at the moment from this revelation.

    Again, Thank you all.

    P.S. Im sorry if this isnt well composed. Im very tired and need to run to class.

  • edited March 2017

    @Thumpr Short story: download the latest image with pre-installed Processing and put it onto an SD card. In Processing, run the Simple Capture example that comes with the GL Video library that is pre-installed also.

    Long story: the GL Video library was specifically made to have hardware-enabled video decoding on Raspbian, and to be able to use the Pi's camera. It works well for me, and most people that have tried using it (including Dan, who re-did an artwork that picks up colors from the camera with it).

    That is not to say that you might not trip over a bug when you try - but if you do: I am in need of you guys' help to figure out what's going on, when this happen, so please make sure your reports are detailed (e.g. including the OS), and be receptive to any discussion/follow up questions that arise out of your post (looking at @yoink @jonaseltes)...

  • edited March 2017

    @gohai Hi and thank you so much for the quick responses. The other image sounds like a good suggestion.

    For now I am using: Raspberry Pi Zero v1.3 with a 5MP pi camera installed (technically Arducam but same hardware I'm told). HDMI to led panel for display (also tried VNC for what its worth), basic USB keyboard/mouse, 150N WiFi, and using a well regulated 2.4 Amp power supply. I will probably pick up a Pi3 soon for the extra performance (when I have some extra $).

    OS **is the **1/11/17 build of rapian-jessie. I was updated **and **upgraded **via curl today(3/8/17). I also **ran sudo aptitude install gstreamer0.10-plugins-good and also added bcm2835_v4l2 to /etc/modules file then rebooted.(I should have taken specific note of the error prior to trying those changes, sorry). However, after making these changes and I got "No capture devices found" with an unmodified "SimpleCapture" example.

    Then I commented out GLCapture(this) and tried the other GLCapture(this, devices[0]) and with devices[1](just to see). When specifying devices[0] or [1], I get basically two messages. First I see "ArrayOutOfBoundsException:0". Then after the black window pops up I get 'The constructor "GLCapture(SimpleCapture,Class<devices[]>)" does not exist'.

    I will now try the image that has processing already included as suggested. That seems more promising. I just wanted to offer what user data I could before swapping to the other OS image. I will save this SD card as is on the side for now. Please let me know what I can do or try if it will help improve development and/or processing.

    Thanks again.

  • @Thumpr What is the output when you run the following in a terminal (on your described setup):

    ls -l /dev/video*
    
  • @gohai Ok, so I get not found doing the ls -l /dev/video*. I also noticed on bootup I get a FAIL error for "Start Load Kernel Modules".

    For what it's worth the camera is working with raspistill, etc.

    I have the processing 3.3 image flashed to an SD. I will give it a try and provide an update. I also got a loaner Pi3 but I need to free up an SD card for it before I can use it.

    Thanks again, (and sorry I wasn't able try sooner (school).)

  • @Thumpr I see. Let me explain:

    There are two ways of accessing pixels from the camera: there is a Raspberry Pi specific way (raspistill etc), which will only ever work with the firmware on the Pi and their closed-source driver - and there is a more generic way, where the camera appears just like any other capture device (like, say, a webcam).

    Processing makes use of the second path, partially because it's more future-proof, and partially because we don't have the resources for developing customizations for each and every ARM board that is out there.

    bcm2835_v4l2 is the name of the driver that makes the Pi camera work as a regular webcam. When you have this module loaded, but no /dev/video* device gets created, this can only mean that your third-party camera isn't actually compatible, at least not with the bcm2835_v4l2 driver.

    You might ask your vendor if there is a V4L, or V4L2 or Linux driver for this particular camera. But this is no bug that I could fix for you, I am afraid...

    If you don't need a video stream but merely still photos at regular intervals, then you could try to invoke raspistill from within Processing, and load the captured image from the file system with the image function. Hope this helps...

  • @gohai

    Ok, I just tried the image with Processing pre-installed and it IS Working.

    Thanks allot!

    Let me know what else you might like me to to to test the old one.

    I just realized I had a type "one" not "l" in 4l2 I had 412. Trying againg. will update

  • @Thumpr That explains it (if the v4l2 driver didn't get loaded).. Glad it works for you.

  • @gohai Ok, I feel stupid now lol. I had thought it was bcm2835_FourOneTwo not the letter "l". That makes me wonder if it could be part of the issue, meaning, maybe others are entering the same typo I did. Just a thought (it makes me feel better to think Im not the only one LoL).

    I now DO see /dev/video0 on the OLD Image I started with after fixing the Typo, AND the SimpleCapture now works on both the Jessie image that was upgraded and updated, and also obviously on the new Processing-pi image.

    Thanks again for all the awsomeness that u do, I hope my dumb typo was somehow helpful LOL sorry again man. Your the best.

Sign In or Register to comment.