How to compile OpenCV on the Raspberry PI to use the Camera module using C++ for higher FPS
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo rpi-updat
$ sudo apt-get install build-essential cmake pkg-config
$ sudo apt-get install libjpeg8-dev libtiff4-dev libjasper-dev libpng12-dev libgtk2.0-dev libavcodec-dev libavformat-dev libswscale-dev libv4l-dev python2.7-dev
$ wget https://codeload.github.com/Itseez/opencv/zip/2.4.11
$ mv 2.4.11 opencv_2.4.11
$ unzip opencv_2.4.11 -d
$ cd opencv_2.4.11/opencv_2.4.11
$ mkdir build
$ cd build
$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_NEW_PYTHON_SUPPORT=ON ..
$ sudo make install
$sudo ldconfig
$ wget http://downloads.sourceforge.net/project/raspicam/raspicam-0.1.3.zip
$ unzip raspicam-0.1.3.zip -d raspicam-0.1.3
$ cd raspicam-0.1.3/raspicam-0.1.3
$ mkdir build
src/raspicam_cv.h
src/raspicam_cv.cpp
utils/raspicam_cv_test.cpp
We can now compile and install raspicam using the following command:
$ cd build
$ make
$ sudo make install
$ sudo ldconfig
If the compilation completed without error , you should find few executable files under the utils folder that you can use to test the camera : raspicam_test takes few photos and stors them in files and gives the FPS result :
$ ./raspicam_test
Usage (-help for help)
Connecting to camera
Connected to camera =00000000ea46d8e8 bufs=3686400
Capturing....
capturing ...30/100Saving image30.ppm
capturing ...60/100Saving image60.ppm
capturing ...90/100Saving image90.ppm
capturing ...95/100
Images saved in imagexx.ppm
4.05138 seconds for 100 frames : FPS 24.6829
As you can notice it reached abour 24 FPS .
There is also the executbale raspicam_cv_test to do the same test using openCV :
./raspicam_cv_test
Usage (-help for help)
Connecting to camera
Connected to camera =00000000ea46d8e8
Capturing
capturing ...95/100
Images saved in imagexx.jpg
6.5143 seconds for 100 frames : FPS = 15.3508
The code source of those files can be found under raspicam-0.1.3/utls/ folder .
Comments :