views:

752

answers:

3

Hi,

I am trying to find a good algorihtm that would detect corners in a image in a mobile phone. There are multiple algorithms to do that I am not sure which one will perform better in a memory and processor limited environment.

Specifically I am trying to find a sudoku grid in a picture taken using the camera of the phone. I am using C# and could not find any libraries that has basic image processing features. I implemented a Sobel filter to do edge detection and that is where I stand.

To make it clear the question is does anybody have any suggestions to use a specific algorithm or a library?

Thanks.

+1  A: 

I wouldn't say "corner detection" by itself is a very good way to do this. Take a step back and think about a photo of a sodoku grid, there are probably lots of assumptions you can make to simplify things.

For example, a sodoku grid always looks exactly the same:

  • White square
  • 9 x 9 regular grid

treating the image in the HSV colour space will allow you to look for high lightness areas (white-ish colours), RGB is a bit pants for most image-processing techniques.

thresholding the image should then reduce noise

Adjusting the image histogram first may also give you better results as it will probably whiten the grid (depends on the image though).

Then all you have to do is find a square. Because you know the grid is regular within it, you can divide the pixels up accordingly and OCR the squares with a number in.

:D

Andrew Bullock
Thanks for the answer. I used HSV but in a different way. I keep the dark areas assuming grid itself will be printed in black ink but your suggestion seems better. I probably also need to do a shear transformation before detecting squares. I took some test images in all of them grids are deformed and are trapeziums. Or maybe I can say that all disconnected white areas with certain sizes are grid.
Szere Dyeri
A: 

I have found OpenCV to be very useful in processing images, and I would score myself as a pretty average programmer.

Here's an example (in C++, but you could probably port it) that does corner detection in OpenCV.

Chris McCall
Hi Chris, I used OpenCV before but I am not aware of any port of it that would run in a mobile phone. Do you know any such thing? Maybe I can quickly play with it and try to compile it using windows mobile sdk. Thanks.
Szere Dyeri
+1  A: 

Since you are looking for a regular 9x9 grid consider the Hough transform. One way is to run an edge detector first, find all straight lines using the original Hough transform, and then try to figure out which of them form a grid. Or maybe you can come up with a clever way to parametrize the whole grid.

Dima
I thought about Hough transform but I was concerned about the complexity. I was thinking of finding points where vertical edges and horizontal edges intersects. But it also fails, when there is angled line. Maybe I can use Hough transform to first remove these kind of lines. Thanks.
Szere Dyeri
Actually, I think that finding corners is a good strategy. There are many corner detection operators. Harris operator is a popular one. http://en.wikipedia.org/wiki/Corner_detection
Dima