Using OpenCV with the Raspberry Pi camera
2015.11.21 created by Huangtao
Raspi-config
"Camera" and select "Enable"
Install Pi Camera:
===================
http://www.raspberrypi.org/archives/3890
Test Pi Camera:
===============
RASPISTILL-T 10000
Ok.
Https://github.com/robidouille/robidouille/tree/master/raspicam_cv
===================================================================
Prerequisites
First make sure CMake and git installed:
sudo apt-get install cmake git
You 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-dev
You need the Raspberry Pi Userland libraries:
Mkdir-p ~/git/raspberrypi
CD ~/git/raspberrypi
git clone https://github.com/raspberrypi/userland.git
CD Userland
./buildme
Build The Raspicam Library
Mkdir-p ~/git
CD ~/git
git clone https://github.com/robidouille/robidouille.git
CD ROBIDOUILLE/RASPICAM_CV
mkdir OBJS
Make
This would create:
libraspicamcv.a:a static Raspberry Cam library which provides an OPENCV like interface
Libraspicamcv.so:a Shared library of the above
RASPICAMTEST: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_CV
Link with the RASPICAMCV library
-l$ (HOME)/GIT/ROBIDOUILLE/RASPICAM_CV-LRASPICAMCV
Link with the Userland libraries:
-l$ (HOME)/git/raspberrypi/userland/build/lib-lmmal_core-lmmal-l Mmal_util-lvcos-lbcm_host
In your code add #include "RaspiCamCV.h" and replace:
Cvcapture-Raspicamcvcapture
Cvcreatecameracapture-Raspicamcvcreatecameracapture
Cvqueryframe-Raspicamcvqueryframe
Cvreleasecapture-Raspicamcvreleasecapture
Cvgetcaptureproperty-Raspicamcvgetcaptureproperty
Cvsetcaptureproperty does not currently work. Use the RaspiCamCvCreateCameraCapture2 method to specify width, height, framerate, bitrate and monochrome settings.
I use the this to:
===================
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.cpp
ok,success!
Some problem:
=============
Error while loading shared Libraries:libraspicamcv.so:cannot open Shared object file:no such file or directory
Use
sudo cp ~/git/robidouille/raspicam_cv/libraspicamcv.so/usr/lib
Using OpenCV with the Raspberry Pi camera