国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C > 正文

OpenCV實現多圖像拼接成一張大圖

2020-01-26 13:34:20
字體:
來源:轉載
供稿:網友

本文實例為大家分享了OpenCV實現多圖像拼接成大圖的具體代碼,供大家參考,具體內容如下

開始嘗試merge函數,具體如下:

定義四個矩陣A,B,C,D。得到矩陣combine。

#include<iostream>#include <core/core.hpp>#include <opencv2/imgproc/imgproc.hpp>#include <opencv2/highgui/highgui.hpp>using namespace std;using namespace cv;int main(){ cv::Mat a = (cv::Mat_<int>(2,2)<<1,2,3,4); cv::Mat b = (cv::Mat_<int>(2,2)<<5,6,7,8); cv::Mat c = (cv::Mat_<int>(2,2)<<9,10,11,12); cv::Mat d = (cv::Mat_<int>(2,2)<<13,14,15,16); std::vector<cv::Mat> v1; v1.push_back(a); v1.push_back(b); v1.push_back(c); v1.push_back(d); cv::Mat combine; cv::merge(v1, combine); cout << "combine=" <<combine<< endl; cout<<"Size of combine:"<<combine.size()<<endl;  system("pause"); return 0;}

結果如下:

顯然,不是我們需要的結果。

嘗試hconcat和vconcat函數,這兩個函數opencv本身并沒有。

詳細介紹參見hconcatvconcat

具體實現如下:

#include <iostream>#include <core/core.hpp>#include <opencv2/imgproc/imgproc.hpp>#include <opencv2/highgui/highgui.hpp>using namespace std;using namespace cv;int main(){ cv::Mat a = (cv::Mat_<int>(2,2)<<1,2,3,4); cv::Mat b = (cv::Mat_<int>(2,2)<<5,6,7,8); cv::Mat c = (cv::Mat_<int>(2,2)<<9,10,11,12); cv::Mat d = (cv::Mat_<int>(2,2)<<13,14,15,16); Mat combine,combine1,combine2; hconcat(a,b,combine1); hconcat(c,d,combine2); vconcat(combine1,combine2,combine); //namedWindow("Combine",CV_WINDOW_AUTOSIZE); //imshow("Combine",combine); cout<<"Combine=:"<<combine<<endl; system("pause"); return 0;}

結果:

圖像拼接實現

#include <iostream>#include <core/core.hpp>#include <opencv2/imgproc/imgproc.hpp>#include <opencv2/highgui/highgui.hpp>using namespace std;using namespace cv;int main(){ //cv::Mat a = (cv::Mat_<int>(2,2)<<1,2,3,4); //cv::Mat b = (cv::Mat_<int>(2,2)<<5,6,7,8); //cv::Mat c = (cv::Mat_<int>(2,2)<<9,10,11,12); //cv::Mat d = (cv::Mat_<int>(2,2)<<13,14,15,16); Mat combine,combine1,combine2; Mat a=imread("1.jpg"); Mat b=imread("2.jpg"); Mat c=imread("3.jpg"); Mat d=imread("4.jpg"); hconcat(a,b,combine1); hconcat(c,d,combine2); vconcat(combine1,combine2,combine); namedWindow("Combine",CV_WINDOW_AUTOSIZE); imshow("Combine",combine); waitKey(0); //cout<<"Combine=:"<<combine<<endl; system("pause"); return 0;}

圖像結果顯示如下:

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 英吉沙县| 青岛市| 桂阳县| 息烽县| 建阳市| 高清| 明星| 陆河县| 晴隆县| 平定县| 霞浦县| 龙陵县| 宁明县| 陆丰市| 嘉义县| 武鸣县| 磐安县| 丽江市| 隆子县| 贺州市| 永靖县| 襄垣县| 台南县| 儋州市| 内黄县| 曲水县| 林芝县| 色达县| 玛沁县| 三亚市| 襄樊市| 镇坪县| 乌兰浩特市| 政和县| 正宁县| 张家港市| 玉门市| 页游| 赞皇县| 称多县| 邹城市|