Using OpenCV with the Raspberry Pi camera

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.