Using OpenCV with the Raspberry Pi camera

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

时间: 2025-01-31 04:45:07

Using OpenCV with the Raspberry Pi camera的相关文章

Raspberry Pi NOOBS setup

NOOBS SETUP To get started with Raspberry Pi you need an operating system. NOOBS (New Out Of the Box Software) is an easy operating system install manager for the Raspberry Pi. HOW TO GET AND INSTALL NOOBS BUY A PREINSTALLED SD CARD The easiest way t

Roomblock: a Platform for Learning ROS Navigation With Roomba, Raspberry Pi and RPLIDAR(转)

What is this? "Roomblock" is a robot platform consists of a Roomba, a Raspberry Pi 2, a laser sensor(RPLIDAR) and a mobile battery. The mounting frame can be made by 3D printers. ROS navigation system enable to make a map of rooms and use it to

用树莓派Raspberry Pi和Micro:bit做一个自拍器

在这个项目中,我们将使用Python来构建一个由Micro:bit触发树莓派Raspberry Pi和相机模块的自拍器.这是开始使用硬件和简单文本编程的好方法. 我们将学习: 如何设置Raspberry Pi相机 如何在Micro:bit和Raspberry Pi上使用输入和输出引脚 用Python代码控制GPIO引脚 用Python代码控制相机模块 材料: 带有SD卡和常规外围设备的Raspberry Pi Raspberry Pi camera module Micro:bit USB A

在Raspberry Pi上安装openni2_camera

在上一篇文章--在Raspberry Pi上安装ROS Package 中,我加入了openni2_camera和openni2_launch,你如果按照我的步骤一步一步来,编译到某一步骤,肯定会碰到编译错误的,哈哈,所以我在上一篇文章末尾留了一句"预知后事如何,请听下回分解". 上一篇文章中需要安装的 Package 需要依赖 OpenCV 和 OpenNi2,凡是涉及到图像,肯定是依赖 OpenCV的,openni2_camera还要依赖OpenNi2. rosdep没有解决好这两

基于树莓派(Raspberry Pi)平台的智能家居实现(一)----继电器模块,DHT11模块

前言:    ??其实做这个智能家居系统我还是因为学校的毕业设计,距离上篇文章发布已经过去了20多天了,之前想着只是做一个烟雾报警,然后通过Zabbix进行报警,但是通过这20多天的设计,我发现实现报警的功能其实除了邮件,还有短信.微信.甚至电话.但是因为各种原因,比如.....钱0.0,哈哈哈,因此我计划用企业微信进行一个报警,然后貌似通过普通微信进行一个简单的交互(interactive),还是不错的选择,并且做出来的效果也很棒.??最后想说的是:"基于树莓派(Raspberry Pi)平台

从零开始搭建Raspberry Pi机器视觉编程环境

从零开始搭建Raspberry Pi机器视觉编程环境 本文主要包括如下内容: 安装Raspbian系统 连接和设置网络 安装中文支持 用电脑控制树莓派 通过SSH远程登录树莓派命令行界面 安装VNC远程登录树莓派图形桌面 通过串口连接树莓派 安装OpenCV及相关开发包 一键备份树莓派SD卡 1 安装Raspbian系统 拿到树莓派后第一件事当然是装系统.安装树莓派系统所需配置: 1个输出5V,>700mA(通常选择1A或2A)的USB电源适配器 1根micro USB线(安卓线) 1张拷贝好系

raspberry pi 机器人

从小对机器人非常感兴趣,正好身边有一个raspberry pi,平时就当Linux的服务器练练命令行,写写脚本.这次打算把raspberry pi的强大的GPIO都利用起来,做个小机器人. 首先从网上买了机器人相关的配件,主要是驱动机器人移动的电机.L298N电机驱动板.HC-SR04超声波距离探测传感器.机器人车身等配件.用来制作机器人的是raspberry pi B+.此型号一共有40个GPIO口,足以满足入门型机器人的制作要求. 以下是我连接L298N电机驱动板和HC-SR04距离传感器的

Raspberry Pi 摄像头模块应用程序文档翻译

http://dreamcolor.net/archives/raspicam-documentation.html —————————————————————————————————————————————————————————————————————— Raspberry Pi 摄像头模块应用程序文档翻译 更新日志: 2014 年 3 月 24 日更新:根据 2013 年 12 月更新的文档,对原译文进行扩展翻译.翻译完毕. 2014 年 3 月 4 日更新:根据 2013 年 12 月更

VNC connect to raspberry pi under ubuntu desktop environment

1 使用Remmina Remote Desktop ubuntu 14.04自带一款远程桌面叫作 Remmina Remote Desktop 利用它即可方便打开已经开启VNC server的raspberry pi 如图,已经新建好了一个raspberry的链接. 新建服务链接 填写链接name 选择链接所使用protocol,注意要选VNC 填写server的地址 填写登录user name以及password 如图: 2 使用SSL/SSH VNC Viewer 下载vnc viewer