Android Application Programming With Opencv 3 Build Android Apps To Capture Manipulate and Track Objects in 2D and 3D 1St Edition Joseph Howse
Android Application Programming With Opencv 3 Build Android Apps To Capture Manipulate and Track Objects in 2D and 3D 1St Edition Joseph Howse
com
OR CLICK BUTTON
DOWLOAD NOW
More products digital (pdf, epub, mobi) instant
download maybe you interests ...
https://ebookmeta.com/product/beginning-android-programming-with-
android-studio-_unlocked-4th-edition-jerome-dimarzio/
https://ebookmeta.com/product/building-android-apps-in-python-
using-kivy-with-android-studio-with-pyjnius-plyer-and-
buildozer-1st-edition-ahmed-fawzy-mohamed-gad/
https://ebookmeta.com/product/head-first-android-development-a-
learners-guide-to-building-android-apps-with-kotlin-3rd-edition-
dawn-griffiths/
https://ebookmeta.com/product/android-studio-arctic-fox-
essentials-java-edition-developing-android-apps-using-android-
studio-2020-31-and-java-neil-smyth/
Learn Kotlin for Android Development: The Next
Generation Language for Modern Android Apps Programming
1st Edition Peter Späth
https://ebookmeta.com/product/learn-kotlin-for-android-
development-the-next-generation-language-for-modern-android-apps-
programming-1st-edition-peter-spath/
https://ebookmeta.com/product/android-studio-electric-eel-
essentials-kotlin-edition-developing-android-apps-using-android-
studio-2022-1-1-and-kotlin-neil-smyth/
https://ebookmeta.com/product/android-studio-electric-eel-
essentials-java-edition-developing-android-apps-using-android-
studio-2022-1-1-and-java-neil-smyth/
https://ebookmeta.com/product/learn-android-studio-3-with-kotlin-
efficient-android-app-development-1st-edition-ted-hagos/
https://ebookmeta.com/product/android-for-absolute-beginners-
getting-started-with-mobile-apps-development-using-the-android-
java-sdk-1st-edition-grant-allen/
www.it-ebooks.info
Android Application
Programming with OpenCV 3
Joseph Howse
BIRMINGHAM - MUMBAI
www.it-ebooks.info
Android Application Programming with OpenCV 3
All rights reserved. No part of this book may be reproduced, stored in a retrieval
system, or transmitted in any form or by any means, without the prior written
permission of the publisher, except in the case of brief quotations embedded in
critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy
of the information presented. However, the information contained in this book is
sold without warranty, either express or implied. Neither the author, nor Packt
Publishing, and its dealers and distributors will be held liable for any damages
caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the
companies and products mentioned in this book by the appropriate use of capitals.
However, Packt Publishing cannot guarantee the accuracy of this information.
ISBN 978-1-78528-538-7
www.packtpub.com
www.it-ebooks.info
Credits
Indexer
Commissioning Editor
Tejal Daruwale Soni
Veena Pagare
Production Coordinator
Acquisition Editor
Manu Joseph
Vivek Anantharaman
Cover Work
Content Development Editor
Manu Joseph
Parita Khedekar
Technical Editor
Ryan Kochery
www.it-ebooks.info
About the Author
Joseph Howse lives in Canada. During the cold winters, he grows a beard and his
four cats grow thick coats of fur. He combs the cats every day. Sometimes, the cats
pull his beard.
Joseph has authored OpenCV for Secret Agents, OpenCV Android Application
Programming, and OpenCV Computer Vision with Python. When he is not writing
books or grooming cats, Joseph provides consulting, training, and software
development services. His company is Nummist Media (http://nummist.com).
I dedicate my work to Sam, Jan, Bob, Bunny, and the cats, who have
been my lifelong guides and companions.
www.it-ebooks.info
About the Reviewers
Jared Burrows started working on Android development in 2011 when he got his
first smartphone. He learned Java quickly and started putting applications on Google
Play (the Android market). During this time, he was in a college and was interning at
Northrop Grumman; currently, he works there as a full-time software engineer.
As his programming skills have matured through the years, he has produced 1-2 new
apps each year and constantly remains active on websites such as StackOverflow,
developing a good reputation and helping others. When he bought a Google Glass
back in 2013, the first thing he created with an open source repository on GitHub
named OpenQuartz, and he has worked on implementing OpenCV into a few
example applications with Google Glass.
www.it-ebooks.info
Manav Kedia is a final-year undergraduate student of the department of Computer
Science and Engineering at the Indian Institute of Technology, Kharagpur. He has
interned with Adobe Research Labs, Bengaluru, and ETH Zurich previously. He is a
passionate programmer and software enthusiast. Android application development is
his forte among other things, in which he has bagged laurels from various hackathons
organized by IBM and Shephertz. He is proficient in programming languages such as
C++, Java, Python, AngularJS, and MySQL. He always ventures into new stuff. You
can reach him at [email protected].
I would like to thank the author for this brilliantly written book.
Reviewing this book was a great learning experience. I would
like to thank Milton Dsouza for coordinating with me throughout
the review. I would also like to thank my parents and friends for
supporting me in everything I do.
Yati Sagade is a programmer interested in, and working on, problems around
image analysis and computer vision. He has developed several computer vision
apps on the Android platform, including a work-in-progress "Air Piano" app named
Dirac, which along with his other projects can be found at https://github.com/
yati-sagade/.
www.it-ebooks.info
www.PacktPub.com
Did you know that Packt offers eBook versions of every book published, with PDF
and ePub files available? You can upgrade to the eBook version at www.PacktPub.com
and as a print book customer, you are entitled to a discount on the eBook copy. Get in
touch with us at [email protected] for more details.
https://www2.packtpub.com/books/subscription/packtlib
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital
book library. Here, you can search, access, and read Packt's entire library of books.
Why subscribe?
• Fully searchable across every book published by Packt
• Copy and paste, print, and bookmark content
• On demand and accessible via a web browser
www.it-ebooks.info
www.it-ebooks.info
Table of Contents
Preface iii
Chapter 1: Setting Up OpenCV 1
System requirements 2
Setting up a development environment 3
Getting prebuilt OpenCV4Android 5
Building OpenCV4Android from source 6
Building the OpenCV samples with Eclipse 8
Troubleshooting Eclipse projects 18
Troubleshooting the USB connection 21
Finding the documentation and help 23
Summary 23
Chapter 2: Working with Camera Frames 25
Designing our app – Second Sight 25
Creating the Eclipse project 28
Enabling camera and disk access in the manifest 33
Creating menu and string resources 36
Previewing and saving photos in CameraActivity 38
Deleting, editing, and sharing photos in LabActivity 51
Summary 55
Chapter 3: Applying Image Effects 57
Adding files to the project 57
Defining the Filter interface 60
Mixing color channels 60
Making subtle color shifts with curves 64
Mixing pixels with convolution filters 71
Adding the filters to CameraActivity 74
Summary 80
[i]
www.it-ebooks.info
Table of Contents
[ ii ]
www.it-ebooks.info
Preface
This book will show you how to use OpenCV in an Android app that displays a
camera feed, saves and shares photos, manipulates colors and edges, and tracks
real-world objects in 2D or 3D. Integration with OpenGL is also introduced so that
you can start building augmented reality (AR) apps that superimpose virtual 3D
scenes onto tracked objects in the camera feed.
Android is a mobile operating system that is mostly open source. For Java developers,
it offers a high-level application framework called Android SDK. Android apps are
modular insofar as they have standard, high-level interfaces to launch each other and
share data. Mobility, a high level of abstraction, and data sharing are great starting
points for a photo sharing app, similar to the one we will build.
Although OpenCV and Android provide a lot of high-level abstractions (and a lot of
open source code for curious users to browse), they are not necessarily easy to use
for newcomers. Setting up an appropriate development environment and translating
the libraries' broad functionality into application features are both daunting tasks.
This concise book helps us by placing an emphasis on a clean setup, clean application
design, and a simple understanding of each function's purpose.
The need for a book on this subject is particularly great because OpenCV's Java
and Android bindings are quite new and their documentation is not yet mature.
Little has been written about the steps for integrating OpenCV with Android's
standard camera, media, and graphics APIs. Surely, integration is a major part
of an app developer's work, so it is a major focus of this book.
[ iii ]
www.it-ebooks.info
Preface
By the end of our journey together, you will have a taste of the breadth of application
features that are made possible by integrating OpenCV with other Android libraries.
You will have your own small library of reusable classes that you can extend or modify
for your future computer vision projects. You will have a development environment
and the knowledge to use it, and you will be able to make more apps!
Chapter 2, Working with Camera Frames, shows how to integrate OpenCV into an
Android Java app that can preview, capture, save, and share photos.
Chapter 5, Combining Image Tracking with 3D Rendering, improves upon our previous
tracking technique by determining the target's position and rotation in real 3D
space. We expand our app so that it sets up an OpenGL 3D scene with the same
perspective as the Android device's real camera. Then, we draw a 3D cube atop
any tracked target.
Chapter 6, Mixing Java and C++ via JNI, demonstrates the use of Java Native Interface
(JNI) to call C++ functions from Java. We convert some of our application's filters
to C++ in order to learn about writing efficient, cross-platform code with OpenCV's
C++ interface.
[ iv ]
www.it-ebooks.info
Preface
You need a mobile device running Android 2.2 (Froyo) or greater, and it must have a
camera. Preferably, it should have two cameras, front and rear.
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:
"It will interface with the other apps on the device, via Android's MediaStore and
Intent classes."
When we wish to draw our attention to a particular part of a code block, the relevant
lines or items are set in bold:
android:label="@string/app_name"
android:screenOrientation="landscape">
<intent-filter>
[v]
www.it-ebooks.info
Preface
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: "These
steps should be repeated for all the native (C++) projects, which include OpenCV
Sample – face-detection and OpenCV Tutorial 2 - Mixed Processing."
Reader feedback
Feedback from our readers is always welcome. Let's 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.
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 get the most from your purchase.
[ vi ]
www.it-ebooks.info
Another random document with
no related content on Scribd:
NIKKINEN NYRKKEILEE
— No, no, ethän sinä vieläkään ikäloppu ole. Otahan käsineet, niin
koetamme kujeillessamme.
Kun yhä useampia koiria oli joutua pyörän jalkoihin, katsoi Nestori
kaupungin kadut hieman turvattomiksi ja ohjasi maantielle.
— Olipa milloin oli, mutta surkeaa se oli, niin että vieläkin ihan
itkettää. Minä muistan sen elämäni kaiken kuin eilisen päivän. Sinä
ilmoittauduit silloinkin tuohon köydenkiskontaan. Sinun piti muka,
koska muutkin kaupungin ukot, vieläpä viskaalitkin, tohtorit,
apteekkarit ja metsäherrat olivat ilmoittautuneet. Sinä et muka
iljennyt jäädä pois miesten muasta, kun olit tanakimpia ja
väkevimpiä köydenkiskojia kaupungissa.
— Alafakkihan se oli —
Meillä ei ole tietoa, missä kaukana tai kuinka lähellä Nestori kävi,
mutta kuulimme hänen palanneen iltayöstä, kiinnittäneen
»Jouhtenensa» laivalaituriin käydä kalkuttelemaan, juosseen
noutamassa kotoaan pensiinikanisterin, täyttäneen veneen säiliön
äärilleen ja menneen sitten maata kotiinsa.
<tb>