【发布时间】:2015-09-22 13:52:31
【问题描述】:
我需要在 C++ 中使用 OpenCV 拼接一些图像,所以我编写了以下代码:
#include <opencv2/opencv.hpp>
#include <opencv2/stitching.hpp>
#include <cstdio>
#include <vector>
void main()
{
std::vector<cv::Mat> vImg;
cv::Mat rImg;
vImg.push_back(cv::imread("./stitching_img/S1.png"));
vImg.push_back(cv::imread("./stitching_img/S2.png"));
vImg.push_back(cv::imread("./stitching_img/S3.png"));
cv::Stitcher stitcher = cv::Stitcher::createDefault();
unsigned long AAtime = 0, BBtime = 0;
AAtime = cv::getTickCount();
cv::Stitcher::Status status = stitcher.stitch(vImg, rImg);
BBtime = cv::getTickCount();
printf("%.2lf sec \n", (BBtime - AAtime) / cv::getTickFrequency());
if (cv::Stitcher::OK == status)
cv::imshow("Stitching Result", rImg);
else
std::printf("Stitching fail.");
cv::waitKey(0);
}
不幸的是,它总是在以下文件上显示“拼接失败” -- http://imgur.com/a/32ZNS 而它在这些文件上工作 -- http://imgur.com/a/ve5sY
我做错了什么?我该如何解决?
提前致谢。
【问题讨论】: