繁体   English   中英

calibrateCamera opencv功能不起作用

[英]calibrateCamera opencv function does not work

我正在校准相机,以使图像不失真。 为了达到这个目标,我正在使用OpenCV库的校准摄像机功能。 因此,我使用棋盘在真实参考系统中获取点以提取点。 然后,我将这些点转换为带有mm的真实参考系统。 所以最后我得到两个点向量:棋盘交叉点向量和以毫米为单位的点向量。

最后,我尝试使用calibrateCamera函数校准摄像机,以获取我的校准参数。 校准摄像机功能定义如下:

calibrateCamera(pointsmm,points,Size(640,480),cameraMatrix,distCoeffs,rvec,tvec );  

点和点的定义如下:

vector<vector<Point2f>> points;
vector<vector<Point3f>> pointsmm;

和cameraMatrix,distCoeff,rvec,tvec作为

vector <float>

向量点的获取如下:

    vector <Point2f> temp;
    bool found = findChessboardCorners(md1,Size(nx,ny),temp);
    if (found){
        //cornerSubPix( md1_g, temp, Size(11,11), Size(-1,-1), TermCriteria( CV_TERMCRIT_EPS+CV_TERMCRIT_ITER, 30, 0.1 )); //(peggiora)
        points.push_back(temp); 
        vector<Point3f> temp2;
        for( int i = 0; i < ny; i++ )
            for( int j = 0; j < nx; j++ )
                temp2.push_back(Point3f(float((2*j + i % 2)*squaresize), float(i*squaresize), 220));
        pointsmm.push_back(temp2);
    }
    //nx and ny are the size of the image
    cv::drawChessboardCorners(md1, Size(nx,ny), Mat(temp), found);

对于我拥有的所有采集,都重复此操作,因此点和点的大小与采集数相对应。 向量的每个元素的大小与棋盘的预期大小相对应。

我画的棋盘还可以,点数对应。 另外我检查了pointsmm和points具有相同的大小。

当我在执行中调用校准函数时,出现以下错误:BridgeLibrary.dll中“ System.Runtime.InteropServices.SEHException”中未管理的异常外部组件引发了异常。 调试软件时,当我调用calibrateCamera函数时会抛出异常。

我正在使用CLI / C ++将wpf与c ++桥接。 我认为问题取决于我如何调用calibrateCamera函数。 我也尝试将向量rvec和tvec定义为向量,但是它不起作用。 我正在使用OpenCV 2.19版本。

您使用了正确的技巧。

我使用相同的方法为项目中的固定图案校准相机。

使用此链接可获得更多帮助:

http://docs.opencv.org/doc/tutorials/calib3d/camera_calibration_square_chess/camera_calibration_square_chess.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM