Opencv undistortPoints断言失败

时间:2016-01-04 11:19:49

标签: c++ opencv

我正在尝试用opencv undistortPoints函数取消图像。我得到以下断言。

OpenCV错误:断言失败(src.isContinuous()&&(src.depth()== CV_32F || src.depth()== CV_64F)&&((src.rows == 1 && src.channels()== 2)|| src.cols * src.channels()== 2))在cv :: undistortPoints中,文件D:\ OpenCV \ 2.4.11 \ opencv \ sources \ modules \ imgproc \ src \ undistort.cpp,第394行

我无法确定为什么我会得到这个断言。这是代码:

    cv::Mat pixel_locations_src = cv::Mat(src.size(), CV_32FC2);

    for (int i = 0; i < src.size().height; i++) 
    {
        for (int j = 0; j < src.size().width; j++) 
        {
            pixel_locations_src.at<cv::Point2f>(i,j) = cv::Point2f(j,i);
        }
    }

    cv::Mat pixel_locations_dst = cv::Mat(src.size(), CV_32FC2);

    std::cout<<cameraMatrix<<std::endl;
    std::cout<<distCoeffs<<std::endl;

    cv::undistortPoints(pixel_locations_src, pixel_locations_dst, cameraMatrix, distCoeffs);

这是输入参数的样子:

pixel_locations_src是1920x1080矩阵。 cameraMatrix是3x3。 distCoeffs是8x1。

console output

感谢您的帮助。

1 个答案:

答案 0 :(得分:-1)

您必须进行适当的鱼眼校准,才能获得适当的失真系数。

如果您使用的是opencv的校准样本,请启用here(它们是opencv的一些配置)

然后使用新的失真系数再试一次。 (感谢Berak)

相关问题