Book Image

Haskell Data Analysis Cookbook

By : Nishant Shukla
Book Image

Haskell Data Analysis Cookbook

By: Nishant Shukla

Overview of this book

Table of Contents (19 chapters)
Haskell Data Analysis Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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 (PImage)
    import AI.CV.OpenCV.CxCore (CvRect(..), CvSize(..))
    import Prelude hiding (id)
    import Control.Arrow ((&&&), (***))
    import Control.Category ((>>>), id)
  2. Define the source of the camera stream. We will be using the built...