Improvements to cvFindChessboardCorners (Patch #545)


Added by Mitar M over 14 years ago. Updated almost 13 years ago.


Status:Open Start date:
Priority:Normal Due date:
Assignee:Vadim Pisarevsky % Done:

0%

Category:imgproc, video
Target version:-
Affected version: Operating System:
Difficulty: HW Platform:
Pull request:

Description

I made few improvements to cvFindChessboardCorners.

I had problems with chessboard in perspective, where dilation dilated quads in one direction more than in another. Because of this they have not connected properly together as they become too far apart. So I fixed icvFindQuadNeighbors to work also with such chessboard images.

For this I:
  • increased thresh_scale to 1.5 so that also corners which are apart for sqrt(2) (square diagonal) are matched
  • changed what is used as a base for threshold for corner candidates: now mean of all edge lengths (squared) of a current connected group of quads is used and not just of two quads (possible neighbors we are checking)
  • because of how threshold now operates (by mean) some corners/quads could be left out at the beginning which would later one be included as mean would expand with new quads
    • because of this I made around all this a loop which is repeated until no new corner/quads are added
  • there is a check for closest quad if there is some other corner closer than current one, in this case those two corners were not merged
    • this prevented to merge some proper corners because those other closest corner could be invalid for some other reasons and would later on not be used
    • because of this I changed this into a two pass process, where in the first pass such corners are not merged (to allow proper other closest corners to be matched), in the second pass this check is not done anymore, so that those invalid corners do not prevent valid ones to merge
  • because I increased radius of the area searched for neighboring corner candidates corners on the edge of the pattern could sometimes erroneously merge, this prevented later stages of chessboard finding algorithm to succeed
    • because of this I added additional check for corner candidates which checks if merging those two candidates would make a space between pattern's quads a triangle, and forbid such merge
    • this check is made by observation that between any two possible corners which are candidates for being merged (and their quads being marked as neighbors) there should be the shortest (alternative, before merging) path connecting those two corners along other edges of length at least four (if it even exists)
    • to assure the order in which this check is made (so that it prevents merge for corners which has the longest (thus less likely to be correct neighbor) distance between and not other corners in this (possible) triangle which could be correct ones) I made thresh_scale a variable which incrementally increases from 0.1 to 1.5 in a loop

In short, I changed algorithm to iteratively tries to improve what it has and not bailing out too soon. Implementation of this ideas could be probably improved a lot as currently it is quite brute-force approach blindly repeating things (it is still polynomial, but its degree increased a lot). But as calibration is not often time-critical I believe that successful matches are more important than failing fast by not matching (while match would be possible).

I am attaching a patch and images showing things described above.


corners1.png - Image original algorithm has problems finding chessboard (35.6 kB) Mitar M, 2010-08-26 09:29 pm

corners2.png - Skewed image of original image algorithm has problems finding chessboard, still problems because of the perspective, but less severe (40.1 kB) Mitar M, 2010-08-26 09:31 pm

distance1.png - Image shows how some corners are not connected because they are too far apart once image is dilated (15.3 kB) Mitar M, 2010-08-26 09:58 pm

triangles1.png - Invalid corners are merged on edges with larger search radius (15.2 kB) Mitar M, 2010-08-26 10:00 pm

triangles2.png - Invalid corners are merged on edges with larger search radius (15.8 kB) Mitar M, 2010-08-26 10:04 pm

cheesboard.patch - Patch for everything above (22 kB) Mitar M, 2010-08-27 12:47 am


Associated revisions

Revision 37568b26
Added by Marina Kolpakova about 12 years ago

Merge pull request #545 from cuda-geek:fix_lying_assertation

History

Updated by Mitar M over 14 years ago

Those images were made by turning of some of features of patched version so they might not be exactly the same as original OpenCV made versions but are close enough to show an example of what I am describing above.

Updated by Mitar M over 14 years ago

Replying to mitar:

increased thresh_scale to 1.5 so that also corners which are apart for sqrt(2) (square diagonal) are matched
I made thresh_scale a variable which incrementally increases from 0.1 to 1.5 in a loop

Miscalculated. Changed max thresh_scale to 2.0, what is ratio of maximal diagonal in a x 2a quad, squared (maximal for all quads is 4.0, 2.0^2^). Now the step is 0.25.

Updated by Vadim Pisarevsky over 14 years ago

  • Status deleted (Open)

Updated by Alexander Shishkov almost 13 years ago

  • Target version deleted ()

Updated by Alexander Shishkov almost 13 years ago

  • Status set to Open

Updated by Alexander Shishkov almost 13 years ago

  • Tracker changed from Feature to Patch
  • Priority changed from High to Normal
  • Target version deleted ()

Also available in: Atom PDF