gpt4 book ai didi

opencv - 使用鱼眼镜头undistortPoints时断言失败

转载 作者:行者123 更新时间:2023-12-02 17:47:45 36 4
gpt4 key购买 nike

我试图使从相机拍摄的鱼眼镜头图像不失真。我已经获得所需的相机参数。但是,当我运行以下代码时:

Mat cammatrix = cv::Mat::zeros(3,3, CV_64F);
cammatrix.at<double>(0,0) = 3.7089418826568277e+002;
cammatrix.at<double>(1,1) = 3.7179355652545451e+002;
cammatrix.at<double>(0,2) = 3.4450520804288089e+002;
cammatrix.at<double>(1,2) = 2.5859133287932718e+002;
cammatrix.at<double>(2,2) = 1.0;
std::vector<double> distortcoeff;
double tempdoub = -2.2022994789941803e+000;
distortcoeff.push_back(tempdoub);
tempdoub = 4.4652133910671958e+000;
distortcoeff.push_back(tempdoub);
tempdoub = 6.8050071879644780e-001;
distortcoeff.push_back(tempdoub);
tempdoub = -1.7697153575434696e+000;
distortcoeff.push_back(tempdoub);

// Process images here (optional)
Mat img_scene (current);

if(!img_scene.data )
{ std::cout<< " --(!) Error reading images " << std::endl; return -1; }
img_scene.convertTo(img_scene, CV_32FC2);
cv::fisheye::undistortPoints(img_scene, img_scene, cammatrix, distortcoeff);

我收到此错误:
OpenCV Error: Assertion failed (distorted.type() == CV_32FC2 || distorted.type() == CV_64FC2) in undistortPoints

不知道为什么会这样,因为在将它转换为CV_32FC2之前,我有.convertTo行。如果有人可以帮助我解决此错误,我将不胜感激!

最佳答案

给定undistortPoints()函数可获取未失真的像素位置,因为它是图像上当前的失真位置。即它对点而不是图像起作用。
使用fisheye::undistortImage获取图像。

关于opencv - 使用鱼眼镜头undistortPoints时断言失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31166105/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com