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
OpenCV Android Programming By Example

You're reading from   OpenCV Android Programming By Example Leverage OpenCV to develop vision-aware and intelligent Android applications.

Arrow left icon
Product type Paperback
Published in Dec 2015
Publisher
ISBN-13 9781783550593
Length 202 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Toc

Rigid perspective correction

Our first trial to do perspective correction will be a rigid one. We will follow these steps:

  1. Convert the input image to grayscale.
  2. Use the Canny edge detector to get the edge image.
  3. Detect the lines in the edge image using the probabilistic Hough transform.
  4. Find the bounding lines of the object of interest.
  5. Estimate the bounding rectangle of the object of interest; hence the name rigid because the object doesn't need to have parallel opposite sides, but we will enforce this by using a rectangular estimation to the quadrilateral object.
  6. Build a list of the rectangle's four corners.
  7. Impose a correspondence between the rectangle corners and screen corners.
  8. Use the correspondence to get a perspective transformation matrix.
  9. Apply the transformation matrix to the input image to get the corrected perspective of the object of interest.

UI definitions

We will add an additional menu item to start the perspective correction process. Go to the res/menu/soft_scanner.xml...

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