I try to calibrate the Camera of a Smartphone with a console application because the speed of the Android example is very slow and It is hard to make proper Images.
The Console Application is inspired by a Book I found: OpenCV 2 Computer Vision: Application Programming Cookbook
Instead of a Chessboard like mentioned in the Book I take the Circle Grid from openCV which can be found in the "data" Folder.
Unfortunately when I use the "addChessboardPoints" Method I get the result of 0 successes and no Points are added into my Calibration. Here the Code:
int Calibrator::addChessboardPoints(const std::vector<std::string>& fileList, cv::Size& boardSize){
double onePerc = fileList.size() / 100.0f;
std::vector<cv::Point2f> imageCorners;
std::vector<cv::Point3f> objectCorners;
for(int i = 0; i < boardSize.height; i++){
for(int j = 0; j < boardSize.width; j++){
objectCorners.push_back(cv::Point3f(i, j, 0.0f));
}
}
cv::Mat image;
int successes = 0;
for(int i = 0; i < fileList.size(); i++){
double state = i+1.0f;
double progress = state / onePerc;
image = cv::imread(fileList[i], 0);
bool found = cv::findCirclesGrid(image, boardSize, imageCorners);
if(!found){
std::cout << "Progres: " << progress << "%" << std::endl;
continue;
}
cv::cornerSubPix(image, imageCorners, cv::Size(5,5), cv::Size(-1,-1),
cv::TermCriteria(cv::TermCriteria::MAX_ITER + cv::TermCriteria::EPS, 30, 0.1));
if(imageCorners.size() == boardSize.area()){
addPoints(imageCorners, objectCorners);
successes++;
}
std::cout << "Progress: " << progress << "%" << std::endl;
}
return successes;
}
The Images I took with my Camera can be looked up here. The boardSize
used here is cv::Size(5,4)
Does anyone know, what I did wrong?