First time here? Check out the FAQ!

Ask Your Question
1

How can I get the raspberry Pi camera working with c++ on OpenCV3?

asked Jan 18 '17

j0h gravatar image

I was pleased to read about the addition of ARM support in the Opencv 3 change log, and decided to try installing OpenCV3.2 on my raspberry Pi. The installation appears to have been a success, and works with a USB web camera as one might expect. When I try to use the raspberry Pi camera however, it is less intuitive.

I tried installing some separate APIs for supporting the raspberry pi camera, but this did not pan out. I have tested the camera using separate python libraries (piCamera), and it is operational.

Im not exclusively looking for an OpenCV3 support library, but if anyone has done this type of thing and knows a library that has C++ support for the Raspberry Pi Camera, and works with opencv3, I would like to know.

Preview: (hide)

Comments

Have you try google and this?

LBerger gravatar imageLBerger (Jan 18 '17)edit

2 answers

Sort by » oldest newest most voted
1

answered Jan 24 '17

pklab gravatar image

To use the standard grabbing loop VideoCapture(0) with raspicam the Video4Linux driver is needed

On my website you can find an article about Install OpenCV-3.1 Python/C++ on Raspbian Jessie The article is for OpenCV 3.1.0 but the paragraph about Video4Linux should works

Preview: (hide)
0

answered Jan 24 '17

pi-null-mezon gravatar image

updated Jan 24 '17

Ok, one of the simplest solution was:

1) You should install netcat on the raspberry:

cmd >> sudo apt get install netcat;

2) After that, you should open tcp video stream from the raspberry (first select desired PORT_NUMBER, f.t.i. 8080):

cmd >> while true; do raspivid -t 0 -n -w 1280 -h 720 -fps 48 -ex fixedfps -b 3000000 -vf -sa -100 -o - | nc -l PORT_NUMBER; done

3) Now, from your opencv application you can open this stream (first check your Rasberry ip address YOUR-RPI-IP-ADDRESS):

...
cv::VideoCapture _cv;
if(_cv.open("tcp://YOUR-RPI-IP-ADDRESS:PORT_NUMBER")) { // change MACRO to the actual values!
   // Yhoo!
} else {
   std::cerr << "Can not open video source!";
}
...
Preview: (hide)

Question Tools

1 follower

Stats

Asked: Jan 18 '17

Seen: 6,730 times

Last updated: Jan 24 '17