缝合器类OpenCV

Stitcher class OpenCV

本文关键字:OpenCV      更新时间:2023-10-16

我有两个重叠面积约为25%的图像,但缝合失败。我该如何处理这个问题?

我尝试使用球体和冲浪,以及更改阈值。我还有其他选择吗?

Mat pano;
Stitcher stitcher = Stitcher::createDefault(try_use_gpu=false);
//Stitcher::Status status = stitcher.stitch(imgs, pano);
//stitcher.setWarper(new PlaneWarper());
stitcher.setWarper(new SphericalWarper());
stitcher.setFeaturesFinder(new detail::SurfFeaturesFinder(1000,3,4,3,4));
//stitcher.setFeaturesFinder(new detail::OrbFeaturesFinder());
stitcher.setRegistrationResol(0.1);
stitcher.setSeamEstimationResol(0.1);
stitcher.setCompositingResol(0.6);
stitcher.setPanoConfidenceThresh(1);
stitcher.setWaveCorrection(true);
stitcher.setWaveCorrectKind(detail::WAVE_CORRECT_HORIZ);
stitcher.setFeaturesMatcher(new detail::BestOf2NearestMatcher(false,0.3));
stitcher.setBundleAdjuster(new detail::BundleAdjusterRay());
tstart = clock();      
Stitcher::Status status = stitcher.stitch(imgs, pano);

25%的重叠绝对不够。40%会带来更好的结果,但仍然不够好。如果你想要很好的重叠,可以尝试60%到80%之间的重叠。重要的是,序列中要缝合在一起的下一个图像与上一个图像的中心区域重叠,因为存在/不应该有任何失真。例如,在80%重叠的情况下,不仅会发生这种情况,而且两张图像的中心区域也会非常靠近,所以你可以忽略失真,并在图像纹理质量允许的情况下找到大量匹配。我的建议是先看看库本身提供的样本。您可以在上找到最新版本https://github.com/Itseez/opencv/tree/master/samples/cpp/stitcher.cpp和https://github.com/Itseez/opencv/blob/master/samples/cpp/stitching_detailed.cpp.那么,深入挖掘源头本身也是件好事(https://github.com/Itseez/opencv/blob/master/modules/stitching/src/stitcher.cpp)也可以在OpenCV的参考手册中查找提供的文档(在线或以PDF格式下载)。