Android Application Programming with OpenCV
By Joseph Howse
3/5
()
About this ebook
Take a smartphone from your pocket, and within a few seconds, you can snap a photo, manipulate it, and share it with the world. You have just achieved mass production of image data. With a computer vision library such as OpenCV, you can analyze and transform copious amounts of image data in real time on a mobile device. The upshot to this is that you, as developers, can provide mobile users with many new kinds of images, constantly highlighting certain visual features that are of artistic or practical interest. Android is a convenient platform for such experiments because it uses a high-level language (Java), it provides standardized interfaces for sharing image data between applications, and it is mostly open source, so everyone can study its implementation.
Android Application Programming with OpenCV is a practical, hands-on guide that covers the fundamental tasks of computer vision—capturing, filtering, and analyzing images-with step-by-step instructions for writing both an application and reusable library classes.
Android Application Programming with OpenCV looks at OpenCV's Java bindings for Android and dispels mysteries such as which version of these bindings to use, how to integrate with standard Android functionality for layout, event handling, and data sharing, and how to integrate with OpenGL for rendering. By following the clear, concise, and modular examples provided in this book, you will develop an application that previews, captures, and shares photos with special effects based on color manipulation, edge detection, image tracking, and 3D rendering.
Beneath the application layer, you will develop a small but extensible library that you can reuse in your future projects. This library will include filters for selectively modifying an image based on edge detection, 2D and 3D image trackers, and adapters to convert the Android system's camera specifications into OpenCV and OpenGL projection matrices. If you want a quick start in computer vision for Android, then this is the book for you.
By the end of Android Application Programming with OpenCV, you will have developed a computer vision application that integrates OpenCV, Android SDK, and OpenGL.
ApproachA step-by-step tutorial to help you master computer vision and mobile app development.
Who this book is forThis book is for Java developers who are new to computer vision and who would like to learn about how it is used in relation to application development. It is assumed that you have previous experience in Java, but not necessarily Android. A basic understanding of image data (for example pixels and color channels) would be helpful too. You are expected to have a mobile device running Android 2.2 (Froyo) or greater and it must have a camera.
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 from Joseph Howse
Python Game Programming By Example: A pragmatic guide for developing your own games with Python Rating: 1 out of 5 stars1/5OpenCV for Secret Agents Rating: 0 out of 5 stars0 ratingsOpenCV 3 Blueprints Rating: 0 out of 5 stars0 ratingsiOS Application Development with OpenCV 3 Rating: 0 out of 5 stars0 ratings
Related to Android Application Programming with OpenCV
Related ebooks
OpenCV Android Programming By Example: Leverage OpenCV to develop vision-aware and intelligent Android applications. Rating: 0 out of 5 stars0 ratingsMastering OpenCV 3 - Second Edition Rating: 0 out of 5 stars0 ratingsMastering Android NDK Rating: 0 out of 5 stars0 ratingsAndroid Studio Cookbook: Design, test, and debug your apps using Android Studio Rating: 4 out of 5 stars4/5Asynchronous Android Rating: 4 out of 5 stars4/5Learning Android Application Testing Rating: 0 out of 5 stars0 ratingsAndroid Wireless Application Development Vol I Android Essentials 3rd Edition Rating: 0 out of 5 stars0 ratingsAndroid NDK: Beginner's Guide - Second Edition Rating: 0 out of 5 stars0 ratingsKotlin at a Glance: Use of Lambdas and higher-order functions to write more concise, clean, reusable, and simple code Rating: 0 out of 5 stars0 ratingsAndroid Studio Development Essentials Rating: 5 out of 5 stars5/5OpenGL Data Visualization Cookbook Rating: 0 out of 5 stars0 ratingsAndroid Native Development Kit Cookbook Rating: 0 out of 5 stars0 ratingsAndroid Studio Electric Eel Essentials - Java Edition: Developing Android Apps Using Android Studio 2022.1.1 and Java Rating: 0 out of 5 stars0 ratingsSDL Game Development Rating: 0 out of 5 stars0 ratingsOpenCV with Python Blueprints: Design and develop advanced computer vision projects using OpenCV with Python Rating: 0 out of 5 stars0 ratingsApplication Development with Qt Creator - Second Edition Rating: 4 out of 5 stars4/5Computer Vision for the Web: Unleash the power of the Computer Vision algorithms in JavaScript to develop vision-enabled web content Rating: 0 out of 5 stars0 ratingsOpenCV By Example Rating: 0 out of 5 stars0 ratingsOpenCL Programming by Example Rating: 0 out of 5 stars0 ratingsJetpack Compose 1.7 Essentials: Developing Android Apps with Jetpack Compose 1.7, Android Studio, and Kotlin Rating: 0 out of 5 stars0 ratingsAndroid High Performance Programming Rating: 0 out of 5 stars0 ratings50 C# Concepts Every Developer Should Know Rating: 0 out of 5 stars0 ratingsAndroid Design Patterns and Best Practice Rating: 5 out of 5 stars5/5Programming Kotlin Applications: Building Mobile and Server-Side Applications with Kotlin Rating: 0 out of 5 stars0 ratingsBeginning Android Programming with Android Studio Rating: 0 out of 5 stars0 ratingsMy First Mobile App for Students: A comprehensive guide to Android app development for beginners (English Edition) Rating: 0 out of 5 stars0 ratingsOpenSceneGraph 3.0 Beginner's Guide Rating: 0 out of 5 stars0 ratings
Applications & Software For You
The Beginner's Guide to Procreate Dreams: How to Create and Animate Your Stories on the iPad Rating: 0 out of 5 stars0 ratingsCanva Tips and Tricks Beyond The Limits Rating: 3 out of 5 stars3/52022 Adobe® Premiere Pro Guide For Filmmakers and YouTubers Rating: 5 out of 5 stars5/5Learn to Code. Get a Job. The Ultimate Guide to Learning and Getting Hired as a Developer. Rating: 5 out of 5 stars5/5GarageBand For Dummies Rating: 5 out of 5 stars5/5Blender All-in-One For Dummies Rating: 0 out of 5 stars0 ratingsExcel : The Ultimate Comprehensive Step-By-Step Guide to the Basics of Excel Programming: 1 Rating: 5 out of 5 stars5/580 Ways to Use ChatGPT in the Classroom Rating: 5 out of 5 stars5/5Tableau Your Data!: Fast and Easy Visual Analysis with Tableau Software Rating: 4 out of 5 stars4/5Canva For Dummies Rating: 5 out of 5 stars5/5The Designer’s Guide to Figma: Master Prototyping, Collaboration, Handoff, and Workflow Rating: 3 out of 5 stars3/5The Basics of User Experience Design by Interaction Design Foundation Rating: 4 out of 5 stars4/5Python Projects for Everyone Rating: 0 out of 5 stars0 ratingsMastering YouTube Automation: The Ultimate Guide to Creating a Successful Faceless Channel Rating: 0 out of 5 stars0 ratingsAnimation for Beginners: Getting Started with Animation Filmmaking Rating: 4 out of 5 stars4/52025 Procreate and Procreate Dreams: A Complete Guide to Digital Art and Animation on iPad Rating: 0 out of 5 stars0 ratingsLogic Pro X For Dummies Rating: 0 out of 5 stars0 ratingsThe Most Concise Step-By-Step Guide To ChatGPT Ever Rating: 3 out of 5 stars3/5Photoshop - Stupid. Simple. Photoshop: A Noobie's Guide to Using Photoshop TODAY Rating: 3 out of 5 stars3/5Adobe Illustrator CC For Dummies Rating: 5 out of 5 stars5/5Design for Hackers: Reverse Engineering Beauty Rating: 4 out of 5 stars4/5Skulls & Anatomy: Copyright Free Vintage Illustrations for Artists & Designers Rating: 1 out of 5 stars1/5Six Figure Blogging In 3 Months Rating: 3 out of 5 stars3/5
Reviews for Android Application Programming with OpenCV
2 ratings0 reviews
Book preview
Android Application Programming with OpenCV - Joseph Howse
Table of Contents
Android Application Programming with OpenCV
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers and more
Why Subscribe?
Free Access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Setting Up OpenCV
System requirements
Setting up a development environment
Getting a ready-made development environment – Tegra Android Development Pack (TAPD)
Assembling a development environment piece-by-piece
Getting the prebuilt OpenCV4Android
Building OpenCV4Android from source
Building the OpenCV samples with Eclipse
Finding documentation and help
Summary
2. Working with Camera Frames
Designing our app – Second Sight
Creating the Eclipse project
Enabling camera and disk access in the manifest
Creating menu and string resources
Previewing and saving photos in CameraActivity
Deleting, editing, and sharing photos in LabActivity
Summary
3. Applying Image Effects
Adding files to the project
Defining the Filter interface
Mixing color channels
Making subtle color shifts with curves
Processing a neighborhood of pixels with convolution filters
Adding the filters to CameraActivity
Summary
4. Recognizing and Tracking Images
Adding files to the project
Understanding image tracking
Writing an image tracking filter
Adding the tracker filters to CameraActivity
Summary
5. Combining Image Tracking with 3D Rendering
Adding files to the project
Defining the ARFilter interface
Building projection matrices in CameraProjectionAdapter
Modifying ImageDetectionFilter for 3D tracking
Rendering the cube in ARCubeRenderer
Adding 3D tracking and rendering to CameraActivity
Learning more about 3D graphics on Android
Summary
Index
Android Application Programming with OpenCV
Android Application Programming with OpenCV
Copyright © 2013 Packt Publishing
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.
First published: September 2013
Production Reference: 1180913
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-84969-520-6
www.packtpub.com
Cover Image by Ankita Jha (<[email protected]>)
Credits
Author
Joseph Howse
Reviewers
Karan Kedar Balkar
Rohit Bhat
Viral Parekh
Acquisition Editors
Nikhil Karkal
Kartikey Pandey
Commissioning Editor
Harsha Bharwani
Technical Editors
Jinesh Kampani
Manal Pednekar
Project Coordinator
Amigya Khurana
Proofreader
Amy Guest
Indexer
Rekha Nair
Graphics
Ronak Dhruv
Production Coordinator
Conidon Miranda
Cover Work
Conidon Miranda
About the Author
Joseph Howse might be at home right now, sitting on a sofa and writing a book, or he might have dashed away with a suitcase full of books, cameras, and computers. He is equipped to see the world
or at least to do his work in computer vision.
He is a software developer at Ad-Dispatch (Canada), where he makes augmented reality games for iOS and Android. Thanks to computer vision, the games can make use of real-world props such as a child's drawings, toys, or blanket-forts.
He also provides training and consulting services. He is currently consulting at Market Beat (El Salvador) on an embedded systems project that uses OpenCV for face recognition.
He holds three masters degrees in Computer Science, International Development Studies, and Business Administration (Dalhousie University, Canada). His research has been published by ISMAR (International Symposium on Mixed and Augmented Realities), and he would love to meet you there if you go.
Android Application Programming with OpenCV is Joe's second book with Packt. His first book, OpenCV Computer Vision with Python, includes an introduction to face tracking and depth cameras (for example, Kinect) on Windows, Mac, and Linux.
Joe likes cats, kittens, oceans, and seas. Felines and saline water sustain him. He lives with his multi-species family in Halifax, on Canada's Atlantic coast.
I am able to write—and to enjoy writing—because I am constantly encouraged by the memory of Sam and by the companionship of Mom, Dad, and the cats. They are my fundamentals.
I am indebted to my editors and reviewers for guiding this book to completion. Their professionalism, courtesy, good judgment, and passion for books are much appreciated.
About the Reviewers
Karan Kedar Balkar has been working as an independent Android application developer since the past four years. Born and brought up in Mumbai, he holds a bachelor degree in Computer Engineering. He has written over 50 programming tutorials on his personal blog (http://karanbalkar.com), covering popular technologies and frameworks.
At present, he is working as a software engineer. He has been trained on various technologies including Java, Oracle, and .NET. Apart from being passionate about technology, he loves to write poems and travel to different places. He likes listening to music and enjoys playing the guitar.
Firstly, I would like to thank my parents for their constant support and encouragement. I would also like to thank my friends Srivatsan Iyer, Ajit Pillai, and Prasaanth Neelakandan for always inspiring and motivating me.
I would like to express my deepest gratitude to Packt Publishing for giving me a chance to be a part of the reviewing process.
Rohit Bhat is a Computer Science graduate from BITS Pilani, India, currently working as a Software Specialist in a leading Big Data Analytics firm. He has done projects in a variety of fields of technology encompassing Data Mining, Android Development, Open CV, Swarm Intelligence, Workflow Automation, and Video Conferencing platform. He loves to keep himself abreast of the latest technology and can always be found ready for a discussion on any topic under the sun. He is also interested in reading, startup, economics, and current affairs. He likes to write and is a freelance blogger in his spare time.
He is currently writing a book for Packt on Bonita Open Solution, a technology which he has used extensively for Workflow Automation and Business Process Modeling.
Viral Parekh is a young graduate of Computer Science. He is a skilled mobile application developer. He has a grip on the various open source libraries such as OpenCV, OpenNI (Open Natural Interaction), FFmpeg, and video4linux. He is keen to work in the field of Human computer Interaction and Augmented reality.
www.PacktPub.com
Support files, eBooks, discount offers and more
You might want to visit www.PacktPub.com for support files and downloads related to your book.
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
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
Support files, eBooks, discount offers and morehttp://PacktLib.PacktPub.com
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across 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 web browser
Free Access for Packt account holders
If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access.
Preface
This book will show you how to use OpenCV's Java bindings 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 on tracked objects in