Detecting faces and eyes through a camera stream
The camera is another source for real-time data. As frames come and go, we can perform powerful analysis using the OpenCV library.
In this recipe, we conduct facial detection through a live camera stream.
Getting ready
Install the OpenCV, SDL, and FTGL libraries for image manipulation and computer vision:
sudo apt-get install libopencv-dev libsdl1.2-dev ftgl-dev
Install an OpenCV library using cabal:
cabal install cv-combinators
How to do it…
Create a new source file, Main.hs
, and follow these steps:
Import the relevant libraries:
import AI.CV.ImageProcessors import qualified AI.CV.OpenCV.CV as CV import qualified Control.Processor as Processor import Control.Processor ((--<)) import AI.CV.OpenCV.Types (PImage) import AI.CV.OpenCV.CxCore (CvRect(..), CvSize(..)) import Prelude hiding (id) import Control.Arrow ((&&&), (***)) import Control.Category ((>>>), id)
Define the source of the camera stream. We will be using the built...