Android Application Programming With Opencv Joseph Howse Download
Android Application Programming With Opencv Joseph Howse Download
https://ebookbell.com/product/android-application-programming-
with-opencv-joseph-howse-50654022
https://ebookbell.com/product/android-application-programming-with-
opencv-3-build-android-apps-to-capture-manipulate-and-track-objects-
in-2d-and-3d-joseph-howse-5476342
https://ebookbell.com/product/android-application-programming-with-
opencv-1st-edition-joseph-howse-38215670
https://ebookbell.com/product/android-application-programming-with-
opencv-3-build-android-apps-to-capture-manipulate-and-track-objects-
in-2d-and-3d-1st-edition-joseph-howse-50195958
https://ebookbell.com/product/android-application-development-
programming-with-the-google-sdk-1st-edition-rick-rogers-2483424
Programming With Mobile Applications Android Ios And Windows Phone 7
1st Thomas J Duffy
https://ebookbell.com/product/programming-with-mobile-applications-
android-ios-and-windows-phone-7-1st-thomas-j-duffy-4981184
https://ebookbell.com/product/reactive-programming-in-kotlin-design-
and-build-nonblocking-asynchronous-kotlin-applications-with-rxkotlin-
reactorkotlin-android-and-spring-rivu-chakraborty-6855722
Kotlin Programming Cookbook Explore More Than 100 Recipes That Show
How To Build Robust Mobile And Web Applications With Kotlin Spring
Boot And Android Aanand Shekhar Roy
https://ebookbell.com/product/kotlin-programming-cookbook-explore-
more-than-100-recipes-that-show-how-to-build-robust-mobile-and-web-
applications-with-kotlin-spring-boot-and-android-aanand-shekhar-
roy-11063710
https://ebookbell.com/product/learning-android-application-
programming-for-the-kindle-fire-a-handson-guide-to-building-your-
first-android-application-lauren-darcey-5474226
https://ebookbell.com/product/mastering-opencv-android-application-
programming-salil-kapur-42918618
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.
Livery Place
35 Livery Street
ISBN 978-1-84969-520-6
www.packtpub.com
Cover Image by Ankita Jha (<[email protected]>)
Credits
Author
Joseph Howse
Reviewers
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.
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.
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.
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.
http://PacktLib.PacktPub.com
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 the camera feed.
The need for a book on this subject is particularly great because the
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 an 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.
By the end of our journey together, you will have a taste of the breadth of
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!
What this book covers
Chapter 1, Setting Up OpenCV, covers the steps to setting up OpenCV
and an Android development environment, including Eclipse and Android
SDK.
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. Also, it should preferably come with the Google Play Store app
because OpenCV uses Google Play Store to manage installation and
upgrades of shared libraries.
Random documents with unrelated
content Scribd suggests to you:
Everything that I read with Harry, or that I talk over with him, has
new meaning for me, or a new force.
Why are we so careful to avoid pain? If it was a necessary part of
the highest mortal experience, how can we ask that it may be left
out from ours? And yet, on every new occasion, we strive to put
from us the offered cross. Even while we say, "Thy will be done!" an
inward hope entreats that will to be merciful. Such remonstrances
with myself rose in me as I read. They did not prevent me from
feeling a thrill of dread as this warning passed over my lips:—"Who
shall say how soon God may draw us from our easy speculations and
theories of suffering, to the practical experience of it? Who can tell
how soon we may be called to the fiery trial?" I turned involuntarily
to Harry. He, too, had heard a summons in these words. I read in his
eyes the answer that came from his steady breast,—"My Father, I
am here!" I felt my spirit lifted with the closing words,—"If we suffer
with him, we shall also reign with him"; but there was no change in
Harry's clear, prepared look. I have never known a faith so implicit as
his. He does not ask after threats or promises; he only listens for
commands.
When the services were over, Hans came forward to say good-bye to
the Doctor and Harry. He took a hand of each, and stood looking
from one to the other.
"We cannot spare you, Harry Dudley. We shall miss you, Doctor.
Harry, when you are ready to set up your farm, come and take a
look round you here again. We are good people, and love you. There
will be land near in the market before long. Sooner should you have
it than old Rasey. Think of it; we can talk things over, evenings."
"You shall have your turn," he said to his boys, who were waiting,
one on either side of him. "I am an old man, and leave-taking comes
hard. Youth has many chances more."
He gave his benediction, repeated a little rhyming German couplet,—
a charm, perhaps, for a good journey,—and then turned away
sturdily, went slowly out of the door and down the steps, leaving
Karl and Fritz to say their words of farewell. Karl spoke for both.
What Fritz had in his heart to say he could not utter, for the tears
would have come with it.
At a quarter before twelve Harry brought down the russet knapsack,
—brought down the little flower-press,—brought down the long
umbrella.
He transferred from the over-full knapsack to his own some
packages of flowers. The flower-press would not enter either
knapsack. The Doctor had it strapped on outside his. I watched
these little arrangements, glad of the time they took. Harry helped
the Doctor on with his pack. I would have done the same for Harry,
but he was too quick for me. I adjusted the strap from which the
green tin case hung, that I might do something for him.
Doctor Borrow took a serious leave of my mother,—for this, at least,
was a final one. But Harry would not have it so. The tears were
gathering in her eyes. "You will see us again," he said, confidently.
The Doctor shook his head. "You have made us too happy here for
us not to wish that it might be so."
But my mother accepted Harry's assurance.
They looked round for Tabitha. She appeared from my mother's
room, the door of which had been a little open. Both thanked her
cordially for her kind cares. She gave them her good wishes,
affectionately and solemnly, and disappeared again.
"I shall not bid you good-bye," said the Doctor, yet taking my hand.
"Only till the nineteenth," said Harry, clasping it as soon as the
Doctor relinquished it. "Till the eighteenth," I mean; "till the
eighteenth," he repeated, urgently.
"Till the eighteenth," I answered.
The Doctor mounted the blue spectacles. This was the last act of
preparation. The minute-hand was close upon the appointed
moment.
At the first stroke of twelve, they were on their way. I followed,
slowly, as if the reluctance of my steps could hold back theirs. The
gate closed behind them. The Doctor took at once his travelling gait
and trudged straight on; but Harry turned and gave a glance to the
house, to the barn, to the little patch of flowers,—to all the objects
with which the week had made him familiar. Then his look fell upon
me, who was waiting for it. He searched my face intently for an
instant, and then, with a smile which made light of all but happy
presentiments, waved me adieu, and hastened on to overtake the
Doctor.
I was glad it was not a working-day,—glad that I could go in and sit
down by my mother, to talk over with her, or, silent, to think over
with her, the scenes which had animated our little room, and which
were still to animate it. Harry's parting look stayed with me. I felt all
my gain, and had no more sense of loss. Can we ever really lose
what we have ever really possessed?
Evening.
I have been over to Blanty's. I should have gone yesterday, but it
rained heavily from early morning until after dark. Such days I
consider yours. I had been anxious about Blanty since Sunday, and
not altogether without reason. He has had a threatening of fever. I
hope it will prove a false alarm. I found him sitting at his door,
already better,—but still a good deal cast down, for he was never ill
in his life before. He had been wishing for me, and would have sent
to me, if I had not gone. He could hardly let me come away, but
pressed me to stay one hour longer, one half hour, one quarter. But I
had some things to attend to at home, and, as he did not really
need me, I bade him good-bye resolutely, promising to go to him
again next Monday. I cannot well go sooner.
If I had stayed, I should have missed a visit from Frederic Harvey.
When I came within sight of our gate, on the way back, a horseman
was waiting at it, looking up the road, as if watching for me. He
darted forward, on my appearance,—stopped short, when close
beside me,—dismounted, and greeted me with a warmth which I
blamed myself for finding it hard to return. He did not blame me,
apparently. Perhaps he ascribes the want he may feel in my manner
to New-England reserve; or perhaps he feels no want. He is so
assured of the value of his regard, that he takes full reciprocity for
granted. The docile horse, at a sign, turned and walked along beside
us to the gate, followed us along the path to the house, and took his
quiet stand before the door when we went in.
Frederic Harvey, having paid his respects to my mother, seated
himself in the great arm-chair, which now seems to be always
claiming the Doctor, and which this new, slender occupant filled very
inadequately.
"I stayed in New York three weeks too long," he exclaimed, after
looking about him a little—for traces of Harry, it seemed. "Time goes
so fast there! But I thought, from one of my sister's letters, that
Dudley was to go back to World's End after he left you. Is he
changed? Oh, but you cannot tell. You never knew him till now. I
need not have asked, at any rate. He is not one to change. While I
knew him, he was only more himself with every year."
"It is two years since you met, is it not?"
"Yes; but what are two years to men who were children together?
We shall take things up just where we laid them down. Ours is the
older friendship. I shall always have the advantage of you there. But
you and he must have got along very well together. Your notions
agree with his better than mine do. It does not matter. Friendship
goes by fate, I believe. He may hold what opinions he likes, for me;
and so may you."
"I believe that on some important subjects my opinions differ very
much from yours."—I am determined to stand square with Frederic
Harvey.
"In regard to our institutions, you mean? I know, that, spoken or
unspoken, hatred of them is carried in the heart of every New-
Englander. It is sometimes suppressed through politeness or from
interest, but I never saw a Northerner who was good for anything, in
whom it did not break out on the first provocation. I like as well to
have it fairly understood in the outset. I have had a letter from Harry
in answer to one of mine. It is explicit on this point."
I had no doubt it was very explicit. Frederic's eye meeting mine, he
caught my thought, and we had a good laugh together, which made
us better friends.
"The Northerners are brought up in their set of prejudices, as we in
ours. I can judge of the force of theirs by that of my own. I only
wish there was the same unanimity among us. We are a house
divided against itself."
And Frederic's face darkened,—perhaps with the recollection of the
rupture of old ties in Shaler's case,—or rather, as it seemed, with the
rankling of some later, nearer pain. He turned quickly away from the
intrusive thought, whatever it was. He does not like the unpleasant
side of things.
"At any rate, because Harry Dudley and I are to be adverse, it does
not follow that we are to be estranged. I cannot forget our school-
days,—our walks on the boulevards and the quays,—our rides in the
Bois,—our journeys together, when we were like brothers. I was
never so happy as in those days, when I had not a care or a duty in
the world."
He had the air, with his twenty-one years, of a weary man-of-the-
world. There was no affectation in it. Unless report have done him
injustice, the last two years have put a gulf between him and that
time.
I reminded him of the conversation between him and his sister, in
which they spoke of Harry Dudley before I knew who Harry Dudley
was. He remembered it, and returned very readily to the subject of
it. He related many incidents of the tour in Brittany, and spoke
warmly of the pleasure of travelling with a companion who is alive to
everything of interest in every sort. He said his travels in Germany,
and even in Italy, had hardly left with him so lively and enduring
impressions as this little journey into Brittany; for there he had gone
to the heart of things.
"I must see him again. We must meet once more as we used to
meet. We must have one good clasp of the hand; we must, at least,
say a kind good-bye to the old friendship. If, hereafter, we find
ourselves opposed in public life, I shall deal him the worst I can, but
with openness and loyalty like his own, and doing him more justice
in my heart, perhaps, than he will do me."
Frederic Harvey inquired anxiously where Harry was to be found,
and I was obliged to tell him of our intended meeting. I was afraid
he would propose to go with me. He was on the point of doing so,
but refrained, seeing that I was not expecting such a suggestion.
We could easily have arranged to meet at Quickster, which is about
the same distance from him that it is from me. But a ride of twenty
miles, most of them slow ones, beside a man with whom you are not
in full sympathy, is a trial. I did not feel called upon to undergo it for
him. When he took leave of me, he again seemed about to propose
something, and I felt it was this plan which was so natural; but he
was again withheld, by pride or by delicacy. Either feeling I could
sympathize with, and I was more touched by this reserve than by all
his friendly advances; but I hardened my heart. He mounted his
horse. I saw him go slowly down the path to the road, stoop from
the saddle to open the gate,—pass out. And then I was seized with
sudden compunction. I heard the slow step of his horse, receding as
if reluctantly, and ready to be checked at a hint. I ran to the gate.
Frederic was just turning away, as if he had been looking back,
expecting to see me; but in the same instant he gave an intimation
to his horse, and was out of the reach of my repentance.
"I liked him." With Harry these words mean a great deal. Could
Harry ever have liked him, if he had not been worthy to be liked?
How sad his look was, when he spoke of his happy boyish days!—
happier than these only because they were blameless. Was not this
regret itself an earnest of the power of return? He had good blood in
him. He is Charles Shaler's cousin. He has a weak, shallow mother,—
a father whose good qualities and whose faults are overlaid with the
same worldly varnish impartially. He feels the need of other
influences, and clings to Harry. He comes to me instinctively seeking
something he has not in his home. My mother has always judged
him more kindly than I have. If he had been a poor outcast child, I
should have felt his coming to me so frankly and so persistently to
be a sign I was to do something for him. Is there a greater need
than that of sympathy and honest counsel? I have been selfish, but
this pain is punishment enough. I feel a remorse surely out of
proportion to my sin. I do not prevent his going to meet Harry by
not asking him to go with me. He is not one to give up his wish; and
in this case there is no reason that he should. He will arrive; I am
sure of it. And I will atone, at least in part. I will ask him to join me
on the ride home.
Old Jasper has told me stories of Frederic Harvey's good-
heartedness in childhood: tells them to me, indeed, every time he
sees me. I remember one in particular, of the pretty little boy in his
foreign dress, and speaking his foreign language, carrying his own
breakfast one morning to the cabin where the old man lay sick; and
another of his taking away part of her load from a feeble woman;
and another of his falling on a driver and wresting from him the whip
with which he was lashing a fainting boy. But Jasper has only these
early stories to tell of him; and what different ones are current now!
In dear old New England the child is father of the man. There the
lovely infancy is the sure promise of the noble maturity. But where
justice is illegal! where mercy is a criminal indulgence! where youth
is disciplined to selfishness, and the man's first duty is to deny
himself his virtues! If the nephew of Augustus had lived, would he
indeed have been Marcellus? Heu pietas! Heu prisca fides!—these
might have been mourned, though Octavia had not wept her son.
When I touched the handle of the door, it was turned from the
inside. Dr. Borrow seized my hand, clasping it, not in greeting, but
like one who clings for succor. He searched my face with ardently
questioning look, as if I might have brought him mercy or reprieve.
He saw that I had not. A spasm passed over his face. His mouth
opened to speak, with voiceless effort. He motioned me to lead
where he was to go. We went down-stairs, and he followed me, as I
had followed Brompton, along the entry, across the yard, through
the barn. He glanced towards the tree and then took his way to the
shed. I did not enter with him.
When he came back to me, he was very pale, but his expression was
soft and tender as I had never known it. We went in again together,
and stood there side by side.
Brompton spoke from without. "There is one thing I have not told
you, Dr. Borrow."
The Doctor turned to him patiently.
"There was an inquest held early this morning."
Dr. Borrow lifted his hand to ward off more.
"Let me take my child and go!"
The Doctor looked towards Orphy. Again I had almost wronged him
in my thought. "Come, my lad," he said, kindly; "you and I must
take care of him home."
Orphy left his place of watch. He came and stood close beside the
Doctor, devoting his allegiance; tears gathered in the eyes that the
soul looked through once more; the mouth retook its own pathetic
smile.
I knew that Harry Dudley must lie in Massachusetts ground, but I
could not look my last so soon. Dr. Borrow saw my intention and
prevented it. He took my hand affectionately, yet as holding me from
him.
"Do not come. I am better off without you. I must battle this out
alone."
Then, a moment after, as feeling he had amends to make,—
"You have known him a few weeks. Think what I have lost,—the
child, the boy, the man! All my hopes were in him,—I did not myself
know how wholly!"
And beyond this anguish lay other, that he would have put off till its
time, but it pressed forward.
"Colvil, you are going home. You go to be consoled. What am I
going to?"
On the side-street, the swift tread of horses and the roll of rapid
wheels. A wagon stopped before the gate. What a joy Charles
Shaler's coming was to have been to us!
He was prepared. He came forward erect and stern. He saluted us
gravely in passing, went in and stood beside the bier. He remained
gazing intently for a little time,—then, laying his hand lightly on the
sacred forehead, raised his look to heaven. He came out composed
as he had entered.
Shaler spoke apart with Brompton, and returned to us.
"You would leave this place as soon as possible?" he said to Dr.
Borrow.
"Yes."
I had meant to combat the Doctor's desire that I should leave him,—
not for my own sake, but because I thought he would need me; but
I submitted now. Shaler would assume every care, and I saw that
Dr. Borrow yielded himself up implicitly.
It is over. Over with the last meeting, the last parting. Over with that
career in which I was to have lived, oh, how much more than in my
Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.
ebookbell.com