OpenCV 3.0 Computer Vision with Java
()
About this ebook
Daniel Lélis Baggio
Daniel Lelis Baggio started his work in computer vision through medical image processing at InCor (Instituto do Coracao - Heart Institute) in Sao Paulo, where he worked with intra-vascular ultrasound image segmentation. Since then, he has focused on GPGPU and ported the segmentation algorithm to work with NVIDIA's CUDA. He has also dived into six degrees of freedom head tracking with a natural user interface group through a project called ehci (http://code.google.com/p/ehci/). He now works for the Brazilian Air Force
Read more from Daniel Lélis Baggio
Mastering OpenCV with Practical Computer Vision Projects Rating: 0 out of 5 stars0 ratingsMastering OpenCV 3 - Second Edition Rating: 0 out of 5 stars0 ratings
Related to OpenCV 3.0 Computer Vision with Java
Related ebooks
Intel Galileo Essentials Rating: 0 out of 5 stars0 ratingsAndroid Application Programming with OpenCV Rating: 3 out of 5 stars3/5Learning ClojureScript Rating: 0 out of 5 stars0 ratingsRaspberry Pi 3 Projects for Java Programmers Rating: 0 out of 5 stars0 ratingsComputer Vision for the Web Rating: 0 out of 5 stars0 ratingsMastering BeagleBone Robotics Rating: 5 out of 5 stars5/5Instant MinGW Starter Rating: 0 out of 5 stars0 ratingsopenFrameworks Essentials Rating: 0 out of 5 stars0 ratingsMastering Android NDK Rating: 0 out of 5 stars0 ratingsApplication Development with Qt Creator - Second Edition Rating: 4 out of 5 stars4/5Mastering C# Concurrency Rating: 0 out of 5 stars0 ratingsWebSocket Essentials – Building Apps with HTML5 WebSockets Rating: 0 out of 5 stars0 ratingsPHP Programming Solutions Rating: 0 out of 5 stars0 ratingsNatural Language Processing with Java and LingPipe Cookbook Rating: 0 out of 5 stars0 ratingsShared Memory Application Programming: Concepts and Strategies in Multicore Application Programming Rating: 0 out of 5 stars0 ratingsBlockchain and IoT Complete Self-Assessment Guide Rating: 0 out of 5 stars0 ratingsWow! What a Ride!: A Quick Trip Through Early Semiconductor and Personal Computer Development Rating: 0 out of 5 stars0 ratingsSwift 2 Design Patterns Rating: 0 out of 5 stars0 ratingsParallel Processing for Artificial Intelligence 1 Rating: 5 out of 5 stars5/5Learning NHibernate 4 Rating: 0 out of 5 stars0 ratingsPro Spring Boot 2: An Authoritative Guide to Building Microservices, Web and Enterprise Applications, and Best Practices Rating: 0 out of 5 stars0 ratingsLighttpd Rating: 4 out of 5 stars4/5Deploying IP and MPLS QoS for Multiservice Networks: Theory and Practice Rating: 0 out of 5 stars0 ratingsJavaScript Unleashed: Harnessing the Power of Web Scripting Rating: 0 out of 5 stars0 ratingsRust for the IoT: Building Internet of Things Apps with Rust and Raspberry Pi Rating: 0 out of 5 stars0 ratingsGradle Effective Implementation Guide Rating: 3 out of 5 stars3/5Heterogeneous Computing with OpenCL 2.0 Rating: 0 out of 5 stars0 ratingsIntel Galileo Networking Cookbook Rating: 0 out of 5 stars0 ratingsGPU-based Parallel Implementation of Swarm Intelligence Algorithms Rating: 0 out of 5 stars0 ratings
Computers For You
101 Awesome Builds: Minecraft® Secrets from the World's Greatest Crafters Rating: 4 out of 5 stars4/5Standard Deviations: Flawed Assumptions, Tortured Data, and Other Ways to Lie with Statistics Rating: 4 out of 5 stars4/5Slenderman: Online Obsession, Mental Illness, and the Violent Crime of Two Midwestern Girls Rating: 4 out of 5 stars4/5The ChatGPT Millionaire Handbook: Make Money Online With the Power of AI Technology Rating: 0 out of 5 stars0 ratingsElon Musk Rating: 4 out of 5 stars4/5The Invisible Rainbow: A History of Electricity and Life Rating: 4 out of 5 stars4/5Procreate for Beginners: Introduction to Procreate for Drawing and Illustrating on the iPad Rating: 0 out of 5 stars0 ratingsUltimate Guide to Mastering Command Blocks!: Minecraft Keys to Unlocking Secret Commands Rating: 5 out of 5 stars5/5Master Builder Roblox: The Essential Guide Rating: 4 out of 5 stars4/5CompTIA IT Fundamentals (ITF+) Study Guide: Exam FC0-U61 Rating: 0 out of 5 stars0 ratingsMastering ChatGPT: 21 Prompts Templates for Effortless Writing Rating: 5 out of 5 stars5/5SQL QuickStart Guide: The Simplified Beginner's Guide to Managing, Analyzing, and Manipulating Data With SQL Rating: 4 out of 5 stars4/5User Friendly: How the Hidden Rules of Design Are Changing the Way We Live, Work, and Play Rating: 4 out of 5 stars4/5Grokking Algorithms: An illustrated guide for programmers and other curious people Rating: 4 out of 5 stars4/5Everybody Lies: Big Data, New Data, and What the Internet Can Tell Us About Who We Really Are Rating: 4 out of 5 stars4/5The Hacker Crackdown: Law and Disorder on the Electronic Frontier Rating: 4 out of 5 stars4/5GarageBand Basics: The Complete Guide to GarageBand: Music Rating: 0 out of 5 stars0 ratingsCompTIA Security+ Practice Questions Rating: 2 out of 5 stars2/5Alan Turing: The Enigma: The Book That Inspired the Film The Imitation Game - Updated Edition Rating: 4 out of 5 stars4/5Learning the Chess Openings Rating: 5 out of 5 stars5/5Storytelling with Data: Let's Practice! Rating: 4 out of 5 stars4/5CompTIA Security+ Get Certified Get Ahead: SY0-701 Study Guide Rating: 5 out of 5 stars5/5Deep Search: How to Explore the Internet More Effectively Rating: 5 out of 5 stars5/5AP® Computer Science Principles Crash Course Rating: 0 out of 5 stars0 ratings
Reviews for OpenCV 3.0 Computer Vision with Java
0 ratings0 reviews
Book preview
OpenCV 3.0 Computer Vision with Java - Daniel Lélis Baggio
Table of Contents
OpenCV 3.0 Computer Vision with Java
Credits
About the Author
Acknowledgment
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
Downloading the color images of this book
Errata
Piracy
Questions
1. Setting Up OpenCV for Java
Getting OpenCV for Java development
Building OpenCV from the source code
The Java OpenCV project in Eclipse
The NetBeans configuration
A Java OpenCV simple application
Building your project with Ant
The Java OpenCV Maven configuration
Creating a Windows Java OpenCV Maven project pointing to the Packt repository
Creating a Java OpenCV Maven project pointing to a local repository
Summary
2. Handling Matrices, Files, Cameras, and GUIs
Basic matrix manipulation
Pixel manipulation
Loading and displaying images from files
Displaying an image with Swing
Capturing a video from a camera
Video playback
Swing GUI's integration with OpenCV
Summary
3. Image Filters and Morphological Operators
Smoothing
Averaging
Gaussian
Median filtering
Bilateral filtering
Morphological operators
Flood filling
Image pyramids
Thresholding
Summary
4. Image Transforms
The Gradient and Sobel derivatives
The Laplace and Canny transforms
The line and circle Hough transforms
Geometric transforms – stretch, shrink, warp, and rotate
Discrete Fourier Transform and Discrete Cosine Transform
Integral images
Distance transforms
Histogram equalization
References
Summary
5. Object Detection Using Ada Boost and Haar Cascades
The boosting theory
AdaBoost
Cascade classifier detection and training
Detection
Training
References
Summary
6. Detecting Foreground and Background Regions and Depth with a Kinect Device
Background subtraction
Frame differencing
Averaging a background method
The mixture of Gaussians method
Contour finding
Kinect depth maps
The Kinect setup
The driver setup
The OpenCV Kinect support
The Kinect depth application
Summary
7. OpenCV on the Server Side
Setting up an OpenCV web application
Creating a Maven-based web application
Adding OpenCV dependencies
Running the web application
Importing the project to Eclipse
Mixed reality web applications
Image upload
Image processing
The response image
Summary
Index
OpenCV 3.0 Computer Vision with Java
OpenCV 3.0 Computer Vision with Java
Copyright © 2015 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: July 2015
Production reference: 1270715
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78328-397-2
www.packtpub.com
Credits
Author
Daniel Lélis Baggio
Reviewers
Ngoc Dao
Dileep Kumar Kotha
Domenico Luciani
Sebastian Montabone
Commissioning Editor
Kunal Parikh
Acquisition Editor
Harsha Bharwani
Content Development Editor
Nikhil Potdukhe
Technical Editor
Parag Topre
Copy Editors
Sarang Chari
Sonia Mathur
Swati Priya
Neha Vyas
Project Coordinator
Judie Jose
Proofreader
Safis Editing
Indexer
Monica Ajmera Mehta
Graphics
Disha Haria
Production Coordinator
Arvindkumar Gupta
Cover Work
Arvindkumar Gupta
About the Author
Daniel Lélis Baggio started his work in computer vision through medical image processing at Instituto do Coração (InCor), which is a heart institute in São Paulo, Brazil, where he worked with intravascular ultrasound (IVUS) image segmentation. After this, he focused on GPGPU and ported that algorithm to work with NVIDIA's CUDA. He also dived into the topic of six degrees of freedom (6DoF), head tracking through a project called EHCI (http://code.google.com/p/ehci/) with the Natural User Interface group.
He is also the author of Mastering OpenCV with Practical Computer Vision Projects, Packt Publishing.
Acknowledgment
I'd first like to thank God for all the opportunities He has given me as well as for giving me our happy family.
I'd certainly like to thank Professor Sergio Furuie for introducing me to this wonderful world of computer vision. I'd also like to thank Professor Carlos Henrique Forster for his courses on the subject.
A big thanks goes to all the reviewers of this book, who took their time to put constructive and interesting corrections to its contents.
I would also like to thank the people from Packt Publishing—especially Parag Topre, Nikhil Potdukhe, Sriram Neelakantan, Harsha Bharwani, Sageer Parkar, and Nadeem Bagban—without whom, this book would never have been finished. I would also like to thank them for their patience.
I would like to thank my parents, who brought me into this world and educated me. I also thank my brother for always being there for me.
I dedicate this book to my children, who will always be part of my heart.
I'd also like to thank my wife for supporting me day and night in our life's journey.
About the Reviewers
Ngoc Dao studied computer vision at the Computer Vision and Image Media Lab of the University of Tsukuba, Japan. He has created several high-speed and scalable image matching server systems using Scala, Akka, and MongoDB with OpenCV's Java binding. These systems can scale multiple machines and have successfully been used with many iOS and Android apps.
Other than computer vision, Ngoc is also interested in real-time distributed systems and web frameworks. He is the main author of Xitrum, which is an open source async and clustered web framework for Scala (http://xitrum-framework.github.io). He presented this framework at the Scala Matsuri 2014 conference in Tokyo (http://scalamatsuri.org/en/program/index.html).
I would like to thank Professor Yuichi Ohta, Professor Yoshinari Kameda, and Professor Kitahara Itaru at the University of Tsukuba. They taught me a lot about computer vision.
Dileep Kumar Kotha currently works as a senior software engineer at a telecom firm in Bangalore, India. He is an undergraduate in computer science from the National Institute of Technology, Rourkela, 2012 batch. He started working on image processing during his summer internship at the prestigious IIT Kharagpur and has continued working with OpenCV on Linux machines ever since. Currently, he successfully manages a blog on OpenCV for beginners, which you can find at http://opencvuser.blogspot.in/.
I would like to thank Packt Publishing for giving me the opportunity to review this book and Judie for bearing the delays in the completion of my reviews.
Domenico Luciani is a passionate 22-year-old programmer. He currently works as a software engineer for some companies and is studying computer science at the University of Palermo, Italy.
He is a computer vision enthusiast and loves security and often pentests too; he also takes part in bounty programs for many companies. He has worked with many technologies in the past, such as MongoDB, Node.js, PHP, PostgreSQL, and C. He makes many Node.js modules that he successfully publishes on the NPM website. He collaborated as a reviewer on a published BDD test using a JavaScript book. He studies the Go language (golang) just for fun.
He owns a Raspberry Pi. He loves writing code using vim and manages it with Git. He also writes tests and collaborates with various open source projects on the Web.
In his free time, he likes running and playing Parkour. You can find out more about him at http://dlion.it.
Sebastian Montabone is a computer engineer with a master's of science degree in computer vision. He has worked in areas, such as intelligent IP cameras for automated surveillance, data mining, 3D sensors, game development, and embedded devices.
He is the author of Beginning Digital Image Processing: Using Free Tools for Photographers, Apress. He has also written scientific articles and a computer vision video course OpenCV Computer Vision Application Programming, Packt Publishing.
You can visit his blog at www.samontab.com, where he shares his current projects with the world.
www.PacktPub.com
Support files, eBooks, discount offers, and more
For support files and downloads related to your book, please visit 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
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.
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
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 9 entirely free books. Simply use your login credentials for immediate access.
To all the readers, without whom this book would not have a reason for existing
Preface
Living in times when self-driving vehicles are becoming a reality might trigger curious minds as to how could computers' incipient vision works. Having a face recognized for access control, getting our pictures automatically organized by a subject or person, and having characters automatically recognized from paper scans are tasks that have become common in our lives. All these aforementioned actions have been enlisted in the so-called study area of computer vision.
As a scientific discipline, the theory behind systems that can extract information from images can be described as computer vision, and it has been adopted to extract valuable measurements from medical images, as well as to help humans delineate the boundaries of important image areas in the so-called semi-automatic procedures.
In the context of providing a simple-to-use computer vision infrastructure to help people rapidly build sophisticated vision applications, an open source library was created: OpenCV. It was designed for real-time applications and is written in C++, containing several hundred computer vision algorithms.
Although OpenCV had its debut alpha release back in January 1999, it was only in February 2013 that it officially supported desktop Java through bindings. As this is one of the most popular introductory teaching languages adopted in computer science departments as well as K-12 computer-related courses, it is important to have a good reference for how to build vision apps in a Java environment.
This book covers the basic OpenCV computer vision algorithms and their integration with Java. As the Swing GUI widget toolkit is widely adopted to build GUIs in Java, in this book, you will benefit from the chapters that deal with this topic as well as come to know how to set up your development environment that deals with native code bindings. Besides, operations such as stretching, shrinking, warping, and rotating, as well as finding edges, lines, and circles are all covered through interesting and practical sample projects in this book.
As the Kinect device has become a great tool for background segmentation, we have covered