簡體   English   中英

Opencv undistortPoints斷言失敗

[英]Opencv undistortPoints Assertion failed

我正在嘗試使用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。

控制台輸出

謝謝你的幫助。

您必須進行適當的魚眼校准,以獲得適當的失真系數。

如果您使用的是opencv的校准樣本,請在此處啟用它(它們是opencv的一些配置)

然后使用新的失真系數再試一次。 (感謝Berak)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM