// Using OpenCV with the Raspberry Pi camera
// 2015.11.21 created by Huangtaoraspi-config
“camera” and select “enable”install Pi Camera:
===================http://www.raspberrypi.org/archives/3890test Pi Camera:=============== raspistill -t 10000ok.https://github.com/robidouille/robidouille/tree/master/raspicam_cv
===================================================================PrerequisitesFirst make sure you have cmake and git installed: sudo apt-get install cmake gitYou might also need gcc/g++ in case it's not already installed, along with some other libraries: sudo apt-get install gcc g++ libx11-dev libxt-dev libxext-dev libgraphicsmagick1-dev libcv-dev libhighgui-devYou need the raspberry pi userland libraries:
mkdir -p ~/git/raspberrypi cd ~/git/raspberrypi git clone https://github.com/raspberrypi/userland.git cd userland ./buildmeBuild the raspicam library
mkdir -p ~/git cd ~/git git clone https://github.com/robidouille/robidouille.git cd robidouille/raspicam_cv mkdir objs makeThis will create:libraspicamcv.a: A static raspberry cam library which provides an opencv like interfacelibraspicamcv.so: A shared library of the aboveraspicamtest: A small test app which uses the static library. Execute with ./raspicamtest. Press Esc to exit.Using the static library
Add the include path -I$(HOME)/git/robidouille/raspicam_cvLink with the raspicamcv library -L$(HOME)/git/robidouille/raspicam_cv -lraspicamcvLink with the userland libraries: -L$(HOME)/git/raspberrypi/userland/build/lib -lmmal_core -lmmal -l mmal_util -lvcos -lbcm_hostIn your code add #include "RaspiCamCV.h" and replace:
CvCapture -> RaspiCamCvCapture cvCreateCameraCapture -> raspiCamCvCreateCameraCapture cvQueryFrame -> raspiCamCvQueryFrame cvReleaseCapture -> raspiCamCvReleaseCapture cvGetCaptureProperty -> raspiCamCvGetCapturePropertycvSetCaptureProperty does not currently work. Use the raspiCamCvCreateCameraCapture2 method to specify width, height, framerate, bitrate and monochrome settings. I use in this way:===================e.g.#include <opencv2/opencv.hpp>#include "RaspiCamCV.h"...g++ `pkg-config --cflags opencv` `pkg-config --libs opencv` -I/root/git/robidouille/raspicam_cv
-L/root/git/robidouille/raspicam_cv -lraspicamcv -L/root/git/raspberrypi/userland/build/lib -lmmal_core -lmmal -l mmal_util -lvcos -lbcm_host -o main main.cppok,success!
some problem:=============error while loading shared libraries: libraspicamcv.so: cannot open shared object file: No such file or directoryuse: sudo cp ~/git/robidouille/raspicam_cv/libraspicamcv.so /usr/lib