2014/11/18 Leave a comment
Detecting objects in images has been used in many applications: auto tagging pictures (e.g. Facebook, Phototime), counting the number of people in a street(e.g. Placemeter), classifying pictures, … And even in Bistro, a device to feed cats.
This post is a small introduction to OpenCV an open source computer vision library using scala.
The OpenCV library provides several features to manipulate images(apply filters, transformation), detect faces and recognize faces in images.
In this post, we are going to implement two small scala programs:
- read an image and run the Haar cascade classifier to detect the faces in the image
- use the webcam and detect faces in real time
To detect faces, we are using the Haar Feature-based Cascade Classifier which is a classifier to detect objects in an image. You can find a good introduction on the openCV website and on the Facial Recognition youtube video by Tom Neumark
Note that detecting faces and recognizing faces(who?) are two different problems and use two different approaches. In this post we are going to only look at face detection.
You can fetch the code used in this post on github:
git clone https://github.com/chimpler/blog-scala-javacv.git
Detecting faces in an image
In this section we are going to detect the faces in the skyfall movie cast picture below by using a Haar Cascade classifier:
We start by reading the image using opencv:
Read more of this post