Manual perspective correction

One more option that we can include is making use of the device's touchscreen and making the user select the corners of the object of interest manually. This option could come in handy if there is too much background noise and the automatic perspective correction didn't give the desired results.

The steps that we will follow are very similar to what we have seen in the Flexible perspective correction section:

  1. Let the user select the four corners of the object of interest.
  2. Find the object centroid.
  3. Sort the select corners according to the object centroid.
  4. Impose a correspondence between the sorted corners and screen corners.
  5. Use the correspondence to get a perspective transformation matrix.
  6. Apply the transformation matrix ...

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.