OpenCV detect corners

I'm using OpenCV on the iPhone. I want to find a Sudoku in a photo. I started with some Gaussian Blur, Adaptive Threshold, Inverting the image and Dilate. Then I did some findContour and drawContour to isolate the Sudoku grid. Then I've used the Hough Transform to find lines and what I need to do now is find the corners of the grid. The Sudoku photo may be taken in an angle so I need to find the corners so I can crop and warp the image correctly.

This is how two different photos may look. One is pretty straight and one in an angle:

Probabilistic Hough

http://img96.imageshack.us/i/skrmavbild20110424kl101.png/

http://img846.imageshack.us/i/skrmavbild20110424kl101.png/

(Standard Hough comes in a comment. I can't post more than two links)

So, what would be the best approach to find those corners? And which of the two transform is easiest to use?

Best Regards Linus


Why not use OpenCV's corner detection? Take a look at cvCornerHarris().

Alternatively, take a look at cvGoodFeaturesToTrack(). It's the Swiss Army Knife of feature detection and can be configured to use the Harris corner detector (among others).


I suggest the following approach. First, find all intersections of lines. It is helpful to sepparate lines into "horisontal" and "vertical" by angle (ie find two major directions of lines). Then find the convex hull of acquired points. Now you have corners and some points on the boundaries. You can remove the latter by analysing the angle between neighbour points in the convex hull. Corners will have the angle about 90 degrees and points on the boundaries - about 180 degrees.


Have you looked at this blog post outlining how to make a Soduko solver for the iPhone using OpenCV?

http://sudokugrab.blogspot.com/2009/07/how-does-it-all-work.html

链接地址: http://www.djcxy.com/p/79590.html

上一篇: 在HoughLines(opencv)之前Canny有什么用处?

下一篇: OpenCV检测角落