Learning OpenCV
Gary Bradski and Adrian Kaehler
Beijing · Cambridge · Farnham · Köln · Sebastopol · Taipei · Tokyo
FM-R4886-AT1.indd iFM-R4886-AT1.indd i 9/15/08 4:26:38 PM9/15/08 4:26:38 PM
Learning OpenCV
by Gary Bradski and Adrian Kaehler
Copyright © 2008 Gary Bradski and Adrian Kaehler. All rights reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions
are also available for most titles (safari.oreilly.com). For more information, contact our
corporate/institutional sales department: (800) 998-9938 or corporate@oreilly.com.
Editor:
Mike Loukides
Production Editor:
Rachel Monaghan
Production Services:
Newgen Publishing and
Data Services
Cover Designer:
Karen Montgomery
Interior Designer:
David Futato
Illustrator:
Robert Romano
Printing History:
September 2008: First Edition.
Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of
O’Reilly Media, Inc. Learning OpenCV, the image of a giant peacock moth, and related trade dress are
trademarks of O’Reilly Media, Inc.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as
trademarks. Where those designations appear in this book, and O’Reilly Media, Inc. was aware of a
trademark claim, the designations have been printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the publisher and authors assume
no responsibility for errors or omissions, or for damages resulting from the use of the information con-
tained herein.
This book uses Repkover,™ a durable and flexible lay-flat binding.
ISBN: 978-0-596-51613-0
[M]
FM-R4886-AT1.indd iiFM-R4886-AT1.indd ii 9/15/08 4:26:40 PM9/15/08 4:26:40 PM
iii
Preface ................................................................ ix
Overview1. ......................................................... 1
What Is OpenCV? 1
Who Uses OpenCV? 1
What Is Computer Vision? 2
The Origin of OpenCV 6
Downloading and Installing OpenCV 8
Getting the Latest OpenCV via CVS 10
More OpenCV Documentation 11
OpenCV Structure and Content 13
Portability 14
Exercises 15
Introduction to OpenCV2. ........................................... 16
Getting Started 16
First Program—Display a Picture 16
Second Program—AVI Video 18
Moving Around 19
A Simple Transformation 22
A Not-So-Simple Transformation 24
Input from a Camera 26
Writing to an AVI File 27
Onward 29
Exercises 29
Contents
FM-R4886-AT1.indd iiiFM-R4886-AT1.indd iii 9/15/08 4:26:40 PM9/15/08 4:26:40 PM