博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Using OpenCV with the Raspberry Pi camera
阅读量:5115 次
发布时间:2019-06-13

本文共 2645 字,大约阅读时间需要 8 分钟。

// 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

转载于:https://www.cnblogs.com/ht-beyond/p/4989751.html

你可能感兴趣的文章
【iOS越狱开发】如何将应用打包成.ipa文件
查看>>
[NOIP2013提高组] CODEVS 3287 火车运输(MST+LCA)
查看>>
Yii2 Lesson - 03 Forms in Yii
查看>>
Python IO模型
查看>>
Ugly Windows
查看>>
DataGridView的行的字体颜色变化
查看>>
Java再学习——关于ConcurrentHashMap
查看>>
如何处理Win10电脑黑屏后出现代码0xc0000225的错误?
查看>>
局域网内手机访问电脑网站注意几点
查看>>
[Serializable]的应用--注册码的生成,加密和验证
查看>>
Day19内容回顾
查看>>
第七次作业
查看>>
SpringBoot项目打包
查看>>
Linux操作系统 和 Windows操作系统 的区别
查看>>
《QQ欢乐斗地主》山寨版
查看>>
文件流的使用以及序列化和反序列化的方法使用
查看>>
Android-多线程AsyncTask
查看>>
第一个Spring冲刺周期团队进展报告
查看>>
红黑树 c++ 实现
查看>>
Android 获取网络链接类型
查看>>