Book Image

Haskell Data Analysis cookbook

By : Nishant Shukla
Book Image

Haskell Data Analysis cookbook

By: Nishant Shukla

Overview of this book

Step-by-step recipes filled with practical code samples and engaging examples demonstrate Haskell in practice, and then the concepts behind the code. This book shows functional developers and analysts how to leverage their existing knowledge of Haskell specifically for high-quality data analysis. A good understanding of data sets and functional programming is assumed.
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...