1

I have to write a camera-calibration an wanted to use python and opencv. The current problem I have is the following:

I have the code written down below:

import sys
import numpy as np
import cv2

image = cv2.imread(sys.argv[1])
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

ret = False
ret, corners = cv2.findChessboardCorners(image, (7,6), None)

print ret

okay so far so good, but it doesn't matter which image I am using my ret variable is turning False every single time, which basically means that there were no corners found.

There are some questions about this problem here on stack overflow but none of the solutions there would work for my problem. I tried using Images from 500x500 up to 8MP, I sharpened them afterwards, I even used the original Chessboards to get the corners. None of them worked.

Is there another way to get them or am I doing anything complete false from the ground up?

I also tried using the images without grayscale but the problem is the same.

Maroun
  • 94,125
  • 30
  • 188
  • 241
hGen
  • 2,235
  • 6
  • 23
  • 43
  • http://stackoverflow.com/questions/17665912/findchessboardcorners-fails-for-calibration-image – stark Nov 28 '14 at 13:40
  • As I said before i read nearly any article on stackoverflow about this failure, and I also used the calibration images of the tutorials you find on the net. In addition to that I am using the original printed opencv calibration pdf which is 10x7 – hGen Nov 28 '14 at 13:47

2 Answers2

2

Okay, I found out what the problem was.

The thing I didn't know before was that the dimensions you have to enter are original dimensions of the chessboard minus 1:

So if you have a 10 x 7 board, the dimensions to use are 9 x 6.

Maybe this will be helpful for other people having the same problem.

Update: Fixed a critical typo. Dimensions to use are 9 x 6, not 9 x 7.

SherylHohman
  • 16,580
  • 17
  • 88
  • 94
hGen
  • 2,235
  • 6
  • 23
  • 43
  • Did you mean 9x6? Or is only the first one subtracted? – ComputerScientist Feb 06 '17 at 18:49
  • It should be 9 x 6. Basically, you want to count the "inner" chessboard corners. "Intersections" at the edge of the chessboard do not count. The corners are defined as being the intersection of 4 chessboard squares. – SherylHohman Jun 03 '17 at 06:20
0

thanks hGen. your answer was really helpful. but in my case 9X6 worked (not 9X7).

cv::Mat imgClr = cv::imread( "05-00.png" );
cv::Mat imgGray;
cv::cvtColor( imgClr, imgGray, CV_BGR2GRAY );
cv::namedWindow( "Image", cv::WINDOW_NORMAL );
cv::imshow( "Image", imgGray );
cv::waitKey(0);

cv::Size board_sz = cv::Size(9, 6);
std::vector < cv::Point2f > corners;
bool found = cv::findChessboardCorners(imgGray, board_sz, corners, CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_NORMALIZE_IMAGE
                                       | CV_CALIB_CB_FAST_CHECK | CV_CALIB_CB_FILTER_QUADS );
if(found)
{
    cv::drawChessboardCorners(imgGray, board_sz, corners, found);
    cv::imshow( "Image", imgGray );
    cv::waitKey(0);
}