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](ftp://ftp.ylsh.ilc.edu.tw/upload/opencv/OpenCV.2.Computer.Vision.Application.Programming.Cookbook.pdf/)
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& fileList, cv::Size& boardSize){
double onePerc = fileList.size() / 100.0f;
std::vector imageCorners;
std::vector objectCorners;
calcBoardCornerPositions(boardSize, 13.40, objectCorners, ASYMCIRCLE);
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, cv::CALIB_CV_ASYMMETRIC_GRID);
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](https://www.dropbox.com/sh/4fubkv5z2aoceos/AAB_qWd4dVZTXy-WkePnJIUNa?dl=0). The `boardSize` used here is `cv::Size(11,4)`
Does anyone know, what I did wrong?
*UPDATE corrected BoardSize and findCirclesGrid flag. Problem still occurs.*
*UPDATE added calcBoardCornerPositions and usage in addChessboardPoints*
void Calibrator::calcBoardCornerPositions(cv::Size boardSize, float squareSize, std::vector& corners, PatternType flag){
//BoardSize is 11,4
switch(flag){
case CHESSBOARD:
case CIRCLEGRID:
for(int i = 0; i < boardSize.height; ++i)
for(int j = 0; j < boardSize.width; ++j)
corners.push_back(cv::Point3f(j*squareSize, i*squareSize, 0));
break;
case ASYMCIRCLE:
for(int i = 0; i < boardSize.height; ++i)
for(int j = 0; j < boardSize.width; ++i)
corners.push_back(cv::Point3f((2*j + i % 2) * squareSize, i*squareSize, 0));
break;
default:
break;
}
}
↧