码迷,mamicode.com
首页 > Web开发 > 详细

Using OpenCV with the Raspberry Pi camera

时间:2015-11-23 22:04:20      阅读:310      评论:0      收藏:0      [点我收藏+]

标签:

// 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 you have 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 will 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 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.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

标签:

原文地址:http://www.cnblogs.com/ht-beyond/p/4989751.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!