執行時顯示為灰色,是什么原因呢???
uj5u.com熱心網友回復:
單獨讀入圖片并顯示是正常的,執行 Stitcher::Status status = stitcher.stitch(imgs, pano);后就無法顯示?uj5u.com熱心網友回復:
代碼:#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/stitching/stitcher.hpp>
using namespace std;
using namespace cv;
bool try_use_gpu = true;
vector<Mat> imgs;
string result_name = "dst1.jpg";
int main(int argc, char * argv[])
{
Mat img1 = imread("1.jpg");
Mat img2 = imread("2.jpg");
imshow("p1", img1);
imshow("p2", img2);
if (img1.empty() || img2.empty())
{
cout << "Can't read image" << endl;
return -1;
}
imgs.push_back(img1);
imgs.push_back(img2);
Stitcher stitcher = Stitcher::createDefault(try_use_gpu);
// 使用stitch函式進行拼接
Mat pano;
Stitcher::Status status = stitcher.stitch(imgs, pano);
if (status != Stitcher::OK)
{
cout << "Can't stitch images, error code = " << int(status) << endl;
return -1;
}
imwrite(result_name, pano);
Mat pano2 = pano.clone();
// 顯示源影像,和結果影像
imshow("全景影像", img2);
waitKey(0);
return 0;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/170021.html
標籤:圖形處理/算法
