User avatar
Raspberry Pi Certified Educator
Raspberry Pi Certified Educator
Posts: 569
Joined: Sat Nov 02, 2013 2:06 pm

OpenCV and Computer Vision Help

Fri Oct 12, 2018 10:50 am


So I am working on Computer Vision with my Raspberry Pi3 based robot and wondered before I start asking Python OpenCV related questions here, should I ask elsewhere - if so where?
I have looked for a suitable Forum on the subject and have asked questions on Stack Exchange and Stack Overflow but don't seem to get a lot of response. Indeed my question on the Raspberry Pi Stack Exchange got moved to Stack Overflow because it wasn't Raspberry Pi related :-(

I am having some success in testing using downloaded images and video footage but now I am trying to use the onboard PiCamera I am encountering some problems. My hunch is that it has something to do with the difference in image properties (resolution etc).

If the answer to my first question is ask away then I'll post my code and problems.

Raspberry Pi Certified Educator. Main Hardware - Raspberry Pi 1 model B revision 2, Raspberry Pi 2 model B, Pi Camera

User avatar
Posts: 711
Joined: Tue Aug 01, 2017 10:06 am

Re: OpenCV and Computer Vision Help

Fri Oct 12, 2018 10:50 pm

post on this forum as there is lots of people using OpenCV on RPi on this forum and your likely to get your questions answered.

The first minute of this video will show you how to use the stream of images from PiCam with OpenCV on RPi

User avatar
Posts: 289
Joined: Mon Nov 12, 2012 10:22 pm
Contact: Website

Re: OpenCV and Computer Vision Help

Sat Oct 13, 2018 6:02 am

The Pi camera modules are quite good, and do have a v4l2 driver available that makes it easy to open in the OpenCV api.
For robotics, the mjpeg codec will be the cleanest option, but keep an eye on the resolution versus frame-rate relationship of the hardware.

Utilities to calibrate camera settings:
sudo apt-get install v4l2ucp v4l2-ctl

#list supported camera codecs (choose one that does not burden pi cpu/gpu):
v4l2-ctl --list-formats-ext

#as per: ... om-webcam/
VideoCapture webcam;;
webcam.set(CV_CAP_PROP_FOURCC ,CV_FOURCC('M', 'J', 'P', 'G') );
webcam.set(CV_CAP_PROP_FRAME_WIDTH ,1920);
webcam.set(CV_CAP_PROP_FRAME_HEIGHT ,1080);

#although the pi GPU can hardware decode MJPG at 1080p30 ... I am uncertain if the regular deb package build will support it.

note these constants are sometimes cv version, driver and platform dependent. Also, OpenCV is best used in an C++ program (with a modern nvidia CUDA capable gpu for processing large data-sets), as the bindings for other languages are usually in various stages of deprecation in the wrappers.

"Learning OpenCV" is a great introduction to the library: ... 0596516134

Remember that raw-resolution and optics choices can often save a lot of computing overhead. ;-)

Best regards,

Return to “Automation, sensing and robotics”