OpenCV in Python, with multiprocessing and shared memory!
A collection of small codes for processing live video (like from a webcam) with OpenCV. Image data in memory (NumPy arrays) are shared by multiple processes using numpy-sharedmem Python module. Parallel processing workflow is implemented with MPipe.
Download and Install
First thing, you'll need OpenCV Python bindings on your system. Get it using YUM:
yum install opencv-python
aptitude install python-opencv
or Homebrew (on OS X):
brew tap homebrew/science brew install opencv
Okay, now get the project code:
git clone https://github.com/vmlaker/sherlock
cd sherlock make
For starters, let's test your OpenCV Python bindings.
This command shows live view from the first video device
/dev/video0) for a duration of 8 seconds:
The following cases demonstrate simplified motion detection. Each iteraton increases in complexity with cumulative changes intended to enhance performance.
Run one process:
Add parallel processing:
Add shared memory:
Processing algorithm is a run-of-the-mill foreground/background segmentation using scene average.
Consider profiling resource usage by running with
Objects in the video stream are detected using Haar feature-based
cascade classifiers. Active classifiers are listed in
src/util/cascade.py file. By default, these are
vanilla classifiers shipped with OpenCV distribution.
You can edit this file to activate (or deactivate) classifiers,
change search paths, add your own custom classifiers,
and configure global object detection parameters.
Run face detection serially:
Run face detection in parallel: