Android Application Programming with OpenCV
Format: PDF / Kindle (mobi) / ePub
- Set up OpenCV and an Android development environment on Windows, Mac, or Linux
- Capture and display real-time videos and still images
- Manipulate image data using OpenCV and Apache Commons Math
- Track objects and render 2D and 3D graphics on top of them
- Create a photo-capture and photo-sharing app that supports a variety of filters with a real-time preview feature
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.
What you will learn from this book
- Install OpenCV and an Android development environment on Windows, Mac, or Linux
- Capture, display, and save images
- Make images accessible to other apps via Android's MediaStore and Intent classes
- Integrate OpenCV events and views with Android's standard activity lifecycle and view hierarchy
- Learn how OpenCV uses matrices to store data about images, recognizable features in images, and camera characteristics
- Apply curves and other color transformations to simulate the look of old photos, movies, or video games
- Apply convolution filters that sharpen, blur, emboss, or darken edges and textures in an image
- Track real-world objects, especially printed images, in 2D and 3D space
- Extract camera data from Android SDK and use it to construct OpenCV and OpenGL projection matrices
- Render basic 3D graphics in OpenGL
destination pixel is affected by only a single input pixel. Next, we will examine a more flexible family of filters, which enable each destination pixel to be affected by a neighborhood of input pixels. Processing a neighborhood of pixels with convolution filters For a convolution filter, the channel values at each output pixel are a weighted average of the corresponding channel values in a neighborhood of input pixels. We can put the weights in a matrix, called a convolution matrix or kernel.
width = maxDimension; height = (int)(width / aspectRatio); } Mat dstROI = dst.submat(0, height, 0, width); Imgproc.resize(mReferenceImage, dstROI, dstROI.size(), 0.0, 0.0, Imgproc.INTER_AREA); return; } // Outline the found target in green. Core.line(dst, new Point(mSceneCorners.get(0, 0)), new Point(mSceneCorners.get(1, 0)), mLineColor, 4); Core.line(dst, new Point(mSceneCorners.get(1, 0)), new Point(mSceneCorners.get(2, 0)), mLineColor, 4); [ 86 ] www.it-ebooks.info Chapter 4 Core.line(dst,
filters. private static final String STATE_IMAGE_DETECTION_FILTER_INDEX = "imageDetectionFilterIndex"; private static final String STATE_CURVE_FILTER_INDEX = [ 87 ] www.it-ebooks.info Recognizing and Tracking Images "curveFilterIndex"; private static final String STATE_MIXER_FILTER_INDEX = "mixerFilterIndex"; private static final String STATE_CONVOLUTION_FILTER_INDEX = "convolutionFilterIndex"; // The filters. private Filter private Filter private Filter private Filter
open the Start menu and go to Control Panel | System. Click on the Advanced tab. Click on the Environment Variables button. Now, under System variables, select an existing environment variable, such as Path, and click on the Edit button. Alternatively, make a new environment variable by clicking on the New button. Edit the variable's name and value as needed. For example, if we want to add C:\androidsdk\platform-tools and C:\android-sdk\tools to Path, we should append
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