Reader small image

You're reading from  OpenCV for Secret Agents

Product typeBook
Published inJan 2015
Reading LevelIntermediate
PublisherPackt
ISBN-139781783287376
Edition1st Edition
Languages
Right arrow
Author (1)
Joseph Howse
Joseph Howse
author image
Joseph Howse

Joseph Howse lives in a Canadian fishing village, where he chats with his cats, crafts his books, and nurtures an orchard of hardy fruit trees. He is President of Nummist Media Corporation, which exists to support his books and to provide mentoring and consulting services, with a specialty in computer vision. On average, in 2015-2022, Joseph has written 1.4 new books or new editions per year for Packt. He also writes fiction, including an upcoming novel about the lives of a group of young people in the last days of the Soviet Union.
Read more about Joseph Howse

Right arrow

Preface

Computer vision systems are deployed in the Arctic Ocean to spot icebergs at night. They are flown over the Amazon rainforest to create aerial maps of fires, blights, and illegal logging. They are set up in ports and airports worldwide to scan for suspects and contraband. They are sent to the depths of the Marianas Trench to guide autonomous submarines. They are used in operating rooms to help surgeons visualize the planned procedure and the patient's current condition. They are launched from battlefields as the steering systems of heat-seeking, anti-aircraft rockets.

We might seldom—or never—visit these places. However, stories often encourage us to imagine extreme environments and a person's dependence on tools in these unforgiving conditions. Perhaps fittingly, one of contemporary fiction's most popular characters is an almost ordinary man (handsome but not too handsome, clever but not too clever) who wears a suit, works for the British Government, always chooses the same drink, the same kind of woman, the same tone for delivering a pun, and is sent to do dangerous jobs with a peculiar collection of gadgets.

Bond. James Bond.

This book teaches seriously useful technologies and techniques with a healthy dose of inspiration from spy fiction. The Bond franchise is rich in ideas about detection, disguise, smart devices, image capture, and sometimes even computer vision specifically. With imagination, plus dedication of learning new skills, we can become the next generation of gadget makers to rival Bond's engineer, Q!

What this book covers

Chapter 1, Preparing for the Mission helps us to install OpenCV, a Python development environment, and an Android development environment on Windows, Mac, or Linux systems. In this chapter, we also install a Unity development environment on Windows or Mac.

Chapter 2, Searching for Luxury Accommodations Worldwide helps us to classify images of real estate based on color schemes. Are we outside a luxury dwelling or inside a Stalinist apartment? In this chapter, we use the classifier in a search engine that labels its image results.

Chapter 3, Training a Smart Alarm to Recognize the Villain and His Cat helps us to detect and recognize human faces and cat faces as a means of controlling an alarm. Has Ernst Stavro Blofeld returned with his blue-eyed Angora cat?

Chapter 4, Controlling a Phone App with Your Suave Gestures helps us to detect motion and recognize gestures as a means of controlling a guessing game on a smartphone. The phone knows why Bond is nodding even if no one else does.

Chapter 5, Equipping Your Car with a Rearview Camera and Hazard Detection helps us to detect car headlights, classify their color, estimate distances to them, and provide feedback to a driver. Is that car tailing us?

Chapter 6, Seeing a Heartbeat with a Motion Amplifying Camera helps us to amplify motion in live video, in real time, so that a person's heartbeat and breathing become clearly visible. See the passion!

Chapter 7, Creating a Physics Simulation Based on a Pen and Paper Sketch helps us to draw a ball-in-a-maze puzzle on paper and see it come to life as a physics simulation on a smartphone. Physics and timing are everything!

What you need for this book

This book supports several operating systems as development environments, including Windows XP or a later version, Mac OS X 10.6 or a later version, Debian Wheezy, Raspbian, Ubuntu 12.04 or a later version, Linux Mint 13 or a later version, Fedora 18 or a later version, CentOS 7 or a later version, and openSUSE 13.1 or a later version.

The book contains six projects with the following requirements:

  • Four of these six projects run on Windows, Mac, or Linux and require a webcam. Optionally, these projects can use Raspberry Pi or another single-board computer that runs Linux.

  • One project runs on Android 2.2 or a later version and requires a front-facing camera (which most Android devices have).

  • One project runs on Android 2.3 or a later version and requires a rear-facing camera and gravity sensor (which most Android devices have). For development, it requires a Windows or Mac machine and approximately $75 worth of game development software.

Setup instructions for all required libraries and tools are covered in the book. Optional setup instructions for Raspberry Pi are also included.

Who this book is for

This book is for tinkerers (and spies) who want to make computer vision a practical and fun part of their lifestyle. You should already be comfortable with 2D graphic concepts, object-oriented languages, GUIs, networking, and command line. This book does not assume experience with any specific libraries or platforms. Detailed instructions cover everything from setting up the development environment to deploying finished apps.

A desire to learn multiple technologies and techniques and to integrate them is highly beneficial! This book will help you branch out to understand several types of systems and application domains where computer vision is relevant, and it will help you to apply several approaches to detect, recognize, track, and augment faces, objects, and motions.

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "You can edit /etc/modules to check whether bcm2835-v4l2 is already listed there."

A block of code is set as follows:

set PYINSTALLER=C:\PyInstaller\pyinstaller.py

REM Remove any previous build of the app.
rmdir build /s /q
rmdir dist /s /q

REM Train the classifier.
python HistogramClassifier.py

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

<activity
 android:name="com.nummist.goldgesture.CameraActivity"
 android:label="@string/app_name"
 android:screenOrientation="landscape"
 android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
 <intent-filter>
 <action android:name="android.intent.action.MAIN" />
 <category android:name=
 "android.intent.category.LAUNCHER" />
 </intent-filter>
</activity>

Any command-line input or output is written as follows:

$ echo "bcm2835-v4l2" | sudo tee -a /etc/modules

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Click on the link for Bing Search API (not any variant such as Bing Search API – Web Results Only)."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail , and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you. The latest and updated example code for this book is also available from the author's website at http://nummist.com/opencv/.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the ErrataSubmissionForm link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at , and we will do our best to address the problem. You can also contact the author directly at or you can check his website, http://nummist.com/opencv/, for answers to common questions about this book.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
OpenCV for Secret Agents
Published in: Jan 2015Publisher: PacktISBN-13: 9781783287376
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Joseph Howse

Joseph Howse lives in a Canadian fishing village, where he chats with his cats, crafts his books, and nurtures an orchard of hardy fruit trees. He is President of Nummist Media Corporation, which exists to support his books and to provide mentoring and consulting services, with a specialty in computer vision. On average, in 2015-2022, Joseph has written 1.4 new books or new editions per year for Packt. He also writes fiction, including an upcoming novel about the lives of a group of young people in the last days of the Soviet Union.
Read more about Joseph Howse