OpenCV and Pi Camera Board

Congratulation !, you’ve got your new rasperry pi camera ! Isn’t-it cute ?
But after first try, you discover that it’s not an usb-webcam. 😦 Thus, OpenCV doesn’t work natively. (forget cvCaptureFromCAM for example and all your wonderful apps you’ve thought up !)

However, some nice apps (such as raspivid or raspistill) controls  the pi camera using MMAL functions.

The idea is to modify source code of such apps, use buffer memory of the camera to feed OpenCV image objects. Pretty easy (said like that).

WARNING : Many people have problem installing software (step 3 below). TO PREPARE YOUR RPI,  PLEASE FOLLOW STEP 2 and STEP 3 OF PREVIOUS ARTICLE (Magic Mirror) :

This could be done in 7 steps, because of 7 :

picture taken with Pi cam and displayed with opencv !
picture taken with Pi cam and displayed with opencv !

Enjoy !

14 thoughts on “OpenCV and Pi Camera Board”

  1. vwillcox said:

    As soon as the Camera Modules are back in stock, I am going to go through this code and tutorial! Thanks!

  2. Thank you!!! I shall try it out soon! 😀

  3. Remarkable grasp of the little Pi.
    Could you please direct your piercing gaze to the seeingwithsound dot com site, wherein The vOICe provides rudimentary sight replacement for a great variety of blindness.
    My quest is to enable The vOICe, or perhaps a useful portion of it, to run on the Pi.
    At present, the Rikomagic 4.2 Android stick is the favourite for experiments.
    The Pi has much lower price and lower power consumption, and could IMHO deliver a street- suitable, replaceable, wearable platform .

  4. This is brilliant – I got the camera and model A but was stuck on how to access the image data. Without your hard work documenting the steps I would be lost. Now for some OpenCV fun!

    Merci beaucoup!

  5. Thanks for the brillant tutorial! Is there a way to use this solution in a python script (e.g. in python call a function which starts the cam with opencv and gives me some analysed data back?)

  6. Thanks for your code and tutorial! Using your guide I was able to integrate facial recognition into my “SmartKegerator” Qt app that log pours from my kegerator! Source available here:

  7. This error is appeared after updated my raspberry pi

    /usr/bin/ld: CMakeFiles/camcv_0.dir/camcv_vid1.cpp.o: undefined reference to symbol ‘sem_init@@GLIBC_2.4’
    //lib/arm-linux-gnueabihf/ error adding symbols: DSO missing from command line
    collect2: ld returned 1 exit status
    CMakeFiles/camcv_0.dir/build.make:169: recipe for target ‘camcv_0’ failed
    make[2]: *** [camcv_0] Error 1
    CMakeFiles/Makefile2:63: recipe for target ‘CMakeFiles/camcv_0.dir/all’ failed
    make[1]: *** [CMakeFiles/camcv_0.dir/all] Error 2
    Makefile:75: recipe for target ‘all’ failed
    make: *** [all] Error 2

    Can you please help? thanks

  8. ravishankarkm said:

    Hi, I am facing a problem while installing facerec library in install face recognition API step 3.2. when i try to install it showing
    $sudo make
    /home/pi/libfacerec-0.04/src/lbp.cpp:In function ‘void cv :: elbp_(cv :: InputArray, cv:;OutputArray, int , int)’;


  9. I am kind of doing the same but with python and larger eyes. How exactly did you figure or calculate how the eyes should move. Did you use center as reference?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s