A collection of object-oriented wrappers in Python wrappers for OpenCV.
OpenCV provides an enormous amount of useful utilities and functions related to computer vision, from matrix operations to face recognition. It comes with a set of bindings for Python generated by SWIG, but unfortunately these aren’t very Object Oriented, and can be tricky to use (users have to remember to release resources by hand, etc).
This is a still very incomplete set of objects that wrap common concepts in OpenCV into objects: Camera, Image, Window and so on. There are definitely tons of bugs, so beware. This project has been set up only as a way of representing the knowledge the authors have gathered about OpenCV and is not intended to be a complete set of OO wrappers for the library – but contributions of any kind are definitely welcome.
Make sure you have OpenCV and the Python bindings for it. If you have everything installed correctly, you should be able to run this successfully:
python -c 'import opencv; import opencv.highgui'
If this command generates any output, you need to have a look at your installation of OpenCV and the Python bindings. Make sure you’re using the correct version of Python, and that it is compatible with the bindings.
# Outputs the video coming from the first webcam found into the main window.
# See also @camera-display.py@.
from wrappers import *
camera = Camera(CV_CAP_ANY)
window = Window()
while True:
window.show(camera.frame())
if escape_pressed():
window.destroy()
break