I'm trying to calibrate a Leap Moion device via OpenCV's calibration libraries and a chessboard pattern, but it is not finding the chessboard corners.
I'm using a 9x6 chessboard pattern printed on a DIN A3 sheet which in turn is mounted on a large white desk. When I take a snapshot of the scene and pass the image directly into OpenCV's findChessboardCorners
function, nothing is found. I first thought, this is probably because of the large black vignetting effect in the Leap Motion's raw images. I read in the docs that a dark background is bad for the function and it probably won't work. So I figured out a way to "correct" this effect programatically, so that the edges get brighter (note: more light in the actual scene doesn't help at all). But it is still not detecting the corners.
Raw image
After vignetting correction
Here is some code
// img is the leap motion's raw image
leapMat.create(240, 640, CV_8UC1);
leapMat.data = const_cast<uchar*>(img.data());
// Vignetting correction
Mat leapMat_vig;
leapMat.copyTo(leapMat_vig);
for (int i = 0; i < leapMat_vig.rows; i++)
{
for (int j = 0; j < leapMat_vig.cols; j++)
{
double u = (double)(i - leapMat_vig.rows / 2) / leapMat_vig.rows;
double v = (double)(j - leapMat_vig.cols / 2) / leapMat_vig.cols;
double w = pow(u, 2) + pow(v, 2);
leapMat_vig.at<uchar>(i, j) += w * 2 * 255;
}
}
vector<Point2f> foundPoints;
// findChessboardCorners is not detecting my chessboard pattern
const auto found = findChessboardCorners(leapMat_vig, Size(6, 9), foundPoints, CALIB_CB_ADAPTIVE_THRESH + CALIB_CB_NORMALIZE_IMAGE + CALIB_CB_FAST_CHECK);
I also tried zooming in the image a little, but that still does not work.
Does anyone have an idea what I'm doing wrong or what I could improve?