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:

  1. 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 ...

Get Haskell Data Analysis Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.