Book Image

Android Application Programming with OpenCV 3

By : Joseph Howse
Book Image

Android Application Programming with OpenCV 3

By: Joseph Howse

Overview of this book

<p>Android Application Programming with OpenCV 3 is a practical, hands-on guide to computer vision and mobile app development. It shows how to capture, manipulate, and analyze images while building an application that combines photography and augmented reality. To help the reader become a well-rounded developer, the book covers OpenCV (a computer vision library), Android SDK (a mobile app framework), OpenGL ES (a 3D graphics framework), and even JNI (a Java/C++ interoperability layer).</p> <p>Now in its second edition, the book offers thoroughly reviewed code, instructions, and explanations. It is fully updated to support OpenCV 3 and Android 5, as well as earlier versions. Although it focuses on OpenCV's Java bindings, this edition adds an extensive chapter on JNI and C++, so that the reader is well primed to use OpenCV in other environments.</p>
Table of Contents (13 chapters)
Android Application Programming with OpenCV 3
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Porting the ARFilter to C++


We will port the ImageDetectionFilter class to C++. However, for the sake of limiting this project's scope, we will leave CameraProjectionAdapter and ARCubeRenderer as pure Java classes.

Once again, let's start with a header file, ImageDetectionFilter.hpp. This header uses types from OpenCV's core and features2d modules, plus the Standard Template Library's std::vector class. (The latter class is analogous to Java's ArrayList.) Accordingly, we can begin the header with the following code:

#ifndef IMAGE_DETECTION_FILTER
#define IMAGE_DETECTION_FILTER

#include <vector>

#include <opencv2/core/core.hpp>
#include <opencv2/features2d/features2d.hpp>

namespace secondsight {

The C++ version of ImageDetectionFilter has the same methods as the Java version. The arguments differ slightly, as we will still require the Java side to provide the reference image (for the constructor) and the projection matrix (for the apply method). Let's declare the C++ methods...