Computer Vision Technology Dave Bolme and Steve O Hara
Today we ll discuss... The OpenCV Computer Vision Library Python scripting for Computer Vision Python OpenCV bindings SciPy / Matlab-like Python capabilities Dave s very own PyVision library Matlab Image Processing Toolkit R biops package Others Matrox Imaging Library (MIL) ITK
OpenCV
OpenCV C Library Cross-platform Major Components Underlying Matrix Operations / Structures Computer Vision Lib High GUI Library Machine Learning Well supported, many examples in code OpenCV facedetect.exe sample
Sample OpenCV Code... void detect_and_draw_objects( IplImage* image, CvHaarClassifierCascade* cascade, int do_pyramids ) { IplImage* small_image = image; CvMemStorage* storage = cvcreatememstorage(0); CvSeq* faces; int i, scale = 1; High-level functions /* if the flag is specified, down-scale the input image to get a performance boost w/o loosing quality (perhaps) */ if( do_pyramids ) { small_image = cvcreateimage( cvsize(image->width/2,image->height/2), IPL_DEPTH_8U, 3 ); cvpyrdown( image, small_image, CV_GAUSSIAN_5x5 ); scale = 2; } /* use the fastest variant */ faces = cvhaardetectobjects( small_image, cascade, storage, 1.2, 2, CV_HAAR_DO_CANNY_PRUNING ); /* draw all the rectangles */ for( i = 0; i < faces->total; i++ ) { /* extract the rectanlges only */ CvRect face_rect = *(CvRect*)cvGetSeqElem( faces, i, 0 ); cvrectangle( image, cvpoint(face_rect.x*scale,face_rect.y*scale), cvpoint((face_rect.x+face_rect.width)*scale, (face_rect.y+face_rect.height)*scale), CV_RGB(255,0,0), 3 ); } if( small_image!= image ) cvreleaseimage( &small_image ); cvreleasememstorage( &storage ); } Drawing functions Explicit memory handling
Demonstration of some OpenCV Sample Programs included with Library.
Pros/Cons on OpenCV Pros: Performance / Compiled Code vs. Scripting Also note: Intel Performance Primitives, OpenCV on the Cell, other acceleration options Windows, Linux, MacOS Well supported, Yahoo group, tutorials, etc. Extensive library with broad applicability. Cons: All the normal stuff about coding in C, tracking down memory leaks, etc.
MatLab / Octave
MatLab Overview Used for many research projects. Open Source MatLab functions are available for many of the most important algorithms. See MATLAB Central File Exchange Easy to learn and use. Integrated plotting and visualization. Toolboxes for many common problems.
Matlab / Octive Pros Great prototyping / research language. Built in visualization tools. Has toolkits for computer vision. Good support and documentation. Cons Cost: $99 (Student) / $$$$$ (Other). May be much slower than C for some code. Poor general purpose language. Cannot build systems.
Python/PyVision
Python Very popular language for every thing. Increasingly popular for Machine Learning and Computer Vision. Matlab like syntax and numeric library (scipy) which includes much of the image processing toolkit and visualization tools. Full featured image library. Bindings to most open source Computer Vision and Machine Learning libraries.
PyVision Provides a conversion and simple interface to scipy and other python vision and ML libraries. Reads most image formats, videos, and webcams. Support for multiple image formats: PIL, opencv, scipy. Interfaces to PIL, scipy, opencv, libsvm. Image annotation, data logging, and statistical analysis. Basic CV support: Affine Transforms, Points, Rects, Normalization,... Face recognition algorithms.
Demonstration of some PyVision Capabilities
Pros/Cons on Python Approaches Pros Flexible, general-purpose, object-oriented scripting language Much faster for prototyping and experimentation Lots of other Python libraries Cons Less control over memory allocation May runs slower than a comparable C program. Not quite as easy as MatLab
R
R + biops Package R is an open source project for statistical computing. The biops package provides some image processing capabilities. Steve O Hara has used R + biops to train a blob classifier for surveillance-style IR imagery using Quadratic Discriminant Analysis.
Pros/Cons on Using R Pros If your work is statistics-heavy Nice output (plotting) Cons Available image/vision libraries are limited, so you ll be rolling-your-own for many things. No direct capture from video sources, AVIs, etc. Drawing images is slow...so trying to show results on video requires patience.
Other Libraries
Brief Mention of Other Libraries Matrox Imaging Library (MIL) Commercial/Industrial Package Focus on Machine Vision and Hardware Acceleration GPU s, FPGA s, custom image acquisition hardware... Not cheap. Yui Man has previous experience with MIL. Image Tool Kit (ITK) Very popular for medical imaging. Segmentation and registration. Open source (with python bindings)
Any Others?