Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Calibration from Images results in 0 Successes

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?

Calibration from Images results in 0 Successes

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);
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. The boardSize used here is cv::Size(5,4)cv::Size(11,4)

Does anyone know, what I did wrong?

UPDATE corrected BoardSize and findCirclesGrid flag. Problem still occurs.

Calibration from Images results in 0 Successes

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));
    }
}
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. 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<cv::Point3f>& 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;
}

}

Calibration from Images results in 0 Successes

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;

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. 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<cv::Point3f>& 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;
}

}