Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering OpenCV Android Application Programming

You're reading from   Mastering OpenCV Android Application Programming Master the art of implementing computer vision algorithms on Android platforms to build robust and efficient applications

Arrow left icon
Product type Paperback
Published in Jul 2015
Publisher
ISBN-13 9781783988204
Length 216 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Toc

The algorithm


In this section, let's look at the steps we will take to achieve our results. Our first task is to detect the paper from the background. For this, we will apply the k-means algorithm with two cluster centers. With the two cluster centers, we can detect which one of them represents the page and which one corresponds to the background, and create a binary image.

Now, we will use the cluster representing the paper and try to remove some noise and fill in some gaps with morphological opening and closing using a rectangular kernel.

Next, we will try to find the outer boundary of the page and use it to detect the corners. For this, we will detect the contours in the binary image and then identify the contour with the largest area.

Once we have the largest contour, we will detect the lines using a probabilistic Hough transformation. Then, we will join the lines and detect the corners.

Once we have the corners, we will detect which corner corresponds to which other corner, and then apply...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image