3

What I want to do is take a source image which will contain a black-and-white chequered board of a known physical size and a known number of squares, and identify the boundaries of said board, as well as the angle from which it is being observed (assuming its perfectly flat) and from what distance.

If I can reliably identify the 4 corners of the board then I know how to calculate the angle and distance, so the task is more about identifying the chess board.

What I've tried so far is greyscaling the image and increasing the contrast so I end up with a stark black-and-white image (which to the eye contains blackness with just the white squares) - and while I can identify the boundaries of the board fine from a top-down perspective by measuring the frequency of changes from black->white->black, I'm not sure how to go about doing this for any angle.

Nominally I'm doing this with C#, but as far as actual answers go I'm happy for any code examples with a c-like syntax - more interested in the math and methodology for this one though.

James
  • 24,676
  • 13
  • 84
  • 130
PhonicUK
  • 13,486
  • 4
  • 43
  • 62
  • 2
    'How do I...' questions that need a whole algorithm as the response aren't really good fit for stackoverflow, but on the other hand there isn't a computer vision stackexchange yet... – James Sep 17 '12 at 11:15
  • A fairly 'loose' response would be perfectly fine. This is slightly more of a 'get me down the right track' kind of question rather than a 'what is the algo to do this?' - I'd then likely submit an answer myself with the actual algorithm once I have something. – PhonicUK Sep 17 '12 at 11:54
  • Would perhaps edged detection work here? There are a number of kernels which should have no problem finding edges that are angles. Just focus on the outermost edges. – Bill Sep 17 '12 at 15:27

1 Answers1

3

Finding a general 2d object inside a 3d world is often done with SIFT or SURF.

There are 2 steps:

  • find a manageable number of local features in the image (such as strong corners)
  • find a correlation between those points in your image and your search pattern

OpenCV has an implementation for that: Features2D + Homography to find a known object The Wikipedia article on surf also points out another c# implementation. Also see this Stackoverflow answer:


Now this is a pretty general method, and I do not know how well it will work with your checkerboard.

But there are specific approaches for chessboard patterns: such as the openCV function cvFindChessboardCorners (tutorial)

I never used it, but I found this description of the algorithm: (Source is in the file cvcalibinit.cpp )

  • Image binarization by thresholding to segment black and white squares
  • Find corners of the black squares:
    • Find contours of the boundaries of the black regions
    • Select contours of suitable shape
    • Approximate these contours with 4-vertex polygons
  • Among these select the quadrangles resembling calibration pattern squares
  • Extract corners of the selected quads, having at least one corner in vicinity
  • Group the corners of the selected quadrangles in lines according to calibration object size
Community
  • 1
  • 1
HugoRune
  • 13,157
  • 7
  • 69
  • 144