stereoRectifyUncalibrated不良结果

问题描述

for (size_t i = 0; i < matches.size(); i++)
{
    if (matches[i].distance < 0.6 * matches[i+1].distance)
    {
        good_matches.push_back(matches[i]);
        pt1.push_back(keypoints1[matches[i].queryIdx].pt);
        pt2.push_back(keypoints2[matches[i].trainIdx].pt);

    }
}
std::vector<cv::Point2f> upt1;
std::vector<cv::Point2f> upt2;
cv::undistortPoints(pt1,upt1,cameraMatrix,distCoeffs);
cv::undistortPoints(pt2,upt2,distCoeffs);    
cv::Mat f = cv::findFundamentalMat(cv::Mat(upt1),cv::Mat(upt2),cv::FM_RANSAC,3,0.99);
std::vector<cv::Vec3f> lines1;

cv::computeCorrespondEpilines(cv::Mat(upt1),1,f,lines1);
for (auto iter = lines1.begin(); iter != lines1.end(); ++iter){
    cv::line(img2,cv::Point(0,-(*iter)[2] / (*iter)[1]),cv::Point(img2.cols,-((*iter)[2] + (*iter)[0] * img2.cols) / (*iter)[1]),cv::Scalar(255,255,255));
}


std::vector<cv::Vec3f> lines2;
cv::computeCorrespondEpilines(cv::Mat(upt2),2,lines2);
for (auto iter = lines2.begin(); iter != lines2.end(); ++iter){

    cv::line(img1,cv::Point(img1.cols,-((*iter)[2] + (*iter)[0] * img1.cols) / (*iter)[1]),255));
}
cv::Mat H1(4,4,img1.type());
cv::Mat H2(4,img2.type());
cv::stereoRectifyUncalibrated(upt1,img1.size(),H1,H2);

cv::Mat rectified1(img1.size(),img1.type());
cv::warpPerspective(img1,rectified1,img1.size());
cv::imwrite("rectified1.jpg",rectified1);

cv::Mat rectified2(img2.size(),img2.type());
cv::warpPerspective(img2,rectified2,H2,img2.size());
cv::imwrite("rectified2.jpg",rectified2);

opencv:4.0 ubuntu:20.04

pcameraMatrix和distCoeffs从calibrateCamera()获得。 上面的代码被部分省略。

结果图 [![在此处输入图片描述] [1]] [1]

左侧结果为灰色。问题是什么? 与其他图片一起运行的结果是相同的。 [1]:https://i.stack.imgur.com/HAJLa.jpg

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...