iOS Determine the corners of a Business Card in realtime

血红的双手。 提交于 2019-11-30 09:32:10

Read about Hough Transform. With it, you can detect lines. I would urge you to detect straight lines and then find four lines that are approximately at a right angle to each other and take the rectangle with the biggest area.

The steps would be:

  1. Edge detection using Sobel filter.
  2. Hough transform to find all straight lines in the image.
  3. Look at all parallel lines and then all lines 90 degrees to those parallel line pairs, to find possible rectangles.
  4. Pick the rectangle you like best. This could be by area, or by being best aligned to the phone, or you require that all edges are inside the visible camera image, or some other method.

Lastly: Computer Vision is hard... don't expect easy results.

Addendum

I should note that step 3 above is very simple, because the angle the lines take are simply one dimension of your Hough space. So parallel lines will have in this dimension equal values, and orthogonal lines will be shifted by pi or 90 degrees.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!