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 ...

Get OpenCV Android Programming By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.