Mar 222018

OpenCV is an open-source framework for computer vision. It’s used for self-driving cars, surveillance, CCTV, traffic flow measurement, autonomous robots, license plate recognition, gesture recognition, and just about any other application where a computer needs to “see”.

You’ll have seen OpenCV in action whenever you’ve watched a surveillance scene in a film or documentary showing boxes being automatically drawn around moving people or cars on a computer screen.

OpenCV 3.3.0 runs well on a Raspberry Pi 3 using either the Pi camera module, USB webcam or USB video grabber and CCTV camera. Our examples run in Python 3. We have different code examples for the Pi camera and USB webcam/video grabber.

Here’s face recognition running on a Raspberry Pi 3 with the Raspberry Pi NoIR camera module

And here’s my CCTV system hooked up to the Raspberry Pi using a USB video grabber

This script looks for movement in the right of the image and saves time and date stamped photos of intruders to the Raspberry Pi’s micro SD card.

It would be quite easy to have it email the photo to you also.

There’s a full PDF guide with download links for our Python scripts here:

Here’s what each script does: – shows a live feed from the Pi camera on your Desktop – displays a box around any face found in the Pi camera feed – as above but records time stamped photos to SD card too. – Uses Mog2 background subtractor, takes a photo of large items on the left. – as above but with erosion and dilation filters too.

Also similar examples for USB webcam or USB video grabber, without the picam titles: – shows live vide feed from USB webcam or USB video grabber. – finds faces in the video feed and draws a box around them. – Uses Mog2 background subtractor to find intruders and cars on our CCTV camera.

By comparing and you can see exactly how to modify other OpenCV Python scripts for use with Raspberry Pi camera or USB webcam.


You can buy the OpenCV3 compatible USB video grabber we used, that will let you attach any video device with a composite output to your Pi, here:

 Posted by at 9:34 am

Sorry, the comment form is closed at this time.