Unexpected solution to a detection problem

Before leaving for vacations I was fighting a very curious issue with my chessboard detection algorithm.  All my tests were done with pictures of chessboards that occupied most of the image.  The tests where very positive even for outside picture and under different lighting.  But when I tried to run the algorithm on a picture taken from a distance;  That is, that contained a “small” (because of perspective) chessboard; it failed to even detect the presence of the chessboard.

Thinking that the problem was in the findChessboardCorners function, I went to debug opencv.  One of the things I notice about the chessboard process is that it initially does a thresholding of the image.  I further noticed that this initial step depended on a histogram equalization.  Since this process depends on the overall values of the image pixels, I thought that the fact that my test images contained mainly snow (white pixels) was the culprit of the problem.  I went to gimp and started to darken the image.  To my surprise the darkening did not work as I expected.  It did increase the amount of sub-squares that were being found, but it did not detect the chessboard.

Finally, after some trial and error, I discovered that if I surround the chessboard with a thick black square (always careful to leave some white between the square and the chessboard), the algorithm would always detect the square (no matter how small it was)

This image is a part of a larger image.  I put it here to show the way that I encapsulated the chessboard image in a black square.  Notice that there is still a bit of white between the chessboard and the black square.

I am now going to create two chessboard images.  They will have different color codes and therefore different numbers. Both will have a black border to enhance detection.  The idea is to try to make an algorithm that will automatically group images depending on their chessboard code.  I will also try to add code that corrects various camera distortions.

Advertisement

About joelgranados

I'm fascinated with how technology and science impact our reality and am drawn to leverage them in order to increase the potential of human activity.
This entry was posted in opencv, PhD. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s