我试图融合出的接缝,我刚刚拼接在一起使用搅拌机从OpenCV 3.2在cv::detail::MultiBandBlender
在#include "opencv2/stitching/detail/blenders.hpp"
中发现的图像。有没有很多的文档,甚至更少的编码示例,从我可以找到,但我设法找到一个很好的博客,帮助解释步骤here。
当我运行代码时,我得到以下error:/opencv/modules/core/src/copy.cpp:1176: error: (-215) top >= 0 && bottom >= 0 && left >= 0 && right >= 0 in function copyMakeBorder
下面是混合的代码(假设拼接、warpPerspective和单应性都是正确的)
//Mask of iamge to be combined so you can get resulting mask
Mat mask1(image1.size(), CV_8UC1, Scalar::all(255));
Mat mask2(image2.size(), CV_8UC1, Scalar::all(255));
Mat image1Updated, image2Updated;
//Warp the masks and the images to their new posistions so their are of all the same size to be overlayed and blended
warpPerspective(image1, image1Updated, (translation*homography), result.size(), INTER_LINEAR, BORDER_CONSTANT,(0));
warpPerspective(image2, image2Updated, translation, result.size(), INTER_LINEAR, BORDER_TRANSPARENT, (0));
warpPerspective(mask1, mask1, (translation*homography), result.size(), INTER_LINEAR, BORDER_CONSTANT,(0));
warpPerspective(mask2, mask2, translation, result.size(), INTER_LINEAR, BORDER_TRANSPARENT, (0));
//create blender
detail::MultiBandBlender blender(false, 5);
//feed images and the mask areas to blend
blender.feed(image1Updated, mask1, Point2f (0,0));
blender.feed(image2Updated, mask2, Point2f (0,0));
//prepare resulting size of image
blender.prepare(Rect(0, 0, result.size().width, result.size().height));
Mat result_s, result_mask;
//blend
blender.blend(result_s, result_mask);
当我尝试执行blender.feed
时发生错误
顺便说一句当为搅拌机制作遮罩时,遮罩应该是整个图像,还是只是在缝合期间彼此重叠的图像区域?
提前感谢任何帮助
编辑
我有它的工作,但现在得到这个结果混合成像。
这里是缝合图像没有混合参考。
任何想法如何改善?
2条答案
按热度按时间7uhlpewt1#
1.使用搅拌机.搅拌机前准备.饲料
1.重新设计你的面具(一半255和一半0)
0yycz8jy2#
这是旧的,但我发现了问题的原因,并会分享它的情况下,任何人都面临着同样的问题,问题是在warpPerspective方法,将有一点黑色像素接壤的扭曲图像,所以你必须转换
到
这将用最接近扭曲图像的像素替换扭曲图像周围的所有黑色区域。