ofxCv icon indicating copy to clipboard operation
ofxCv copied to clipboard

bug? Calibration needs to use statics more

Open elliotwoods opened this issue 13 years ago • 2 comments

Currently it's really messy to use the features of calibration outside of the 'standard routine' e.g. i'm making a system where N cameras capture scenes At the time of capture a thread is started to perform the board finding, so each 'BoardFrame instance ends up with a vector<Point2f>, a success flag and a complete flag' blah blah blah i end with a spare set of recognised imagePoints and i sift through them blah blah blah i'm performing all the data handling (i.e. dealing with imagePoints) outside of the Calibrate class

it'd be great if Calibration's routines were generally static, and Calibration itself called these static functions as and when it needed them (to keep functionality the same as now, but also allow for assistance of calibration outside of a calibration instance)

e.g. bool findBoard(Mat img, vector<Point2f> &pointBuf) could call findBoard(Mat img, vector<Point2f> &pointBuf, cv::Size patternSize, CalibrationPattern)

also i think CalibrationPattern could be extended into a class which stores the squaresize, patternsize, pattern type

elliotwoods avatar Mar 07 '12 03:03 elliotwoods

this is my current workaround (create local instance and fill it up with data):

//----------
void CameraHead::calibrateIntrinsics(const vector<vector<Point2f> > & imagePoints) {
    ofxCv::Calibration calibration;
    calibration.imagePoints = imagePoints;
    calibration.setImageSize(this->imageSize);
    calibration.setPatternSize(boardFinder.getPatternSize());
    calibration.setSquareSize(boardFinder.getSquareSize());
    calibration.calibrate();
    this->intrinsics = calibration.getDistortedIntrinsics();
    this->distortion = calibration.getDistCoeffs();
}

i think this would be better as

//----------
void CameraHead::calibrateIntrinsics(const vector<vector<Point2f> > & imagePoints) {
    this->intrinsics = ofxCv::Calibration::calibrate(imagePoints, this->imageSize, calibrationBoard);

    //presumes intrinsics stores distortion coeffs, reprojection error

    //and that calibrationBoard is an instance of CalibrationBoard class
    //  which defines pattern size, type, spacing.
    //  and has method getObjectPoints()
}

elliotwoods avatar Mar 07 '12 03:03 elliotwoods

this sounds great. if you want to do this in a way that maintains the current API by wrapping static methods the way you describe, i would be glad to pull it.

if you're interested in doing this, make sure you submit it as a single PR with no extra changes/additions earmarked, so i can review and pull it quickly :)

kylemcdonald avatar Mar 07 '12 05:03 kylemcdonald