最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

opencv2基于SURF特征提取實現(xiàn)兩張圖像拼接融合

 更新時間:2020年03月05日 13:39:28   作者:米姒翰  
這篇文章主要為大家詳細(xì)介紹了opencv2基于SURF特征提取實現(xiàn)兩張圖像拼接融合,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了opencv2實現(xiàn)兩張圖像拼接融合的具體代碼,供大家參考,具體內(nèi)容如下

要用到兩個文件,estimate.cpp和matcher.h(在有關(guān)魯棒匹配這篇博文中有)

estimate.cpp的頭文件也需要添加一些東西才行,以下是對的,已經(jīng)成功運行。

加了using namespace std;之后,cv::可以去掉了。

estimate.cpp:

#include <iostream>
#include <vector>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/calib3d/calib3d.hpp>
#include<opencv2/nonfree/nonfree.hpp>
#include<opencv2\legacy\legacy.hpp> 
#include "matcher.h"
using namespace std;
using namespace cv;
int main()
{
// Read input images讀入圖像
cv::Mat image1= cv::imread("parliament1.bmp",0);
cv::Mat image2= cv::imread("parliament2.bmp",0);
if (!image1.data || !image2.data)
return 0; 


  // Display the images顯示圖像
cv::namedWindow("Image 1");
cv::imshow("Image 1",image1);
cv::namedWindow("Image 2");
cv::imshow("Image 2",image2);


// Prepare the matcher準(zhǔn)備匹配
RobustMatcher rmatcher;
rmatcher.setConfidenceLevel(0.98);
rmatcher.setMinDistanceToEpipolar(1.0);
rmatcher.setRatio(0.65f);
cv::Ptr<cv::FeatureDetector> pfd= new cv::SurfFeatureDetector(10); 
rmatcher.setFeatureDetector(pfd);


// Match the two images
std::vector<cv::DMatch> matches;
std::vector<cv::KeyPoint> keypoints1, keypoints2;
cv::Mat fundemental= rmatcher.match(image1,image2,matches, keypoints1, keypoints2);


// draw the matches畫匹配結(jié)果
cv::Mat imageMatches;
cv::drawMatches(image1,keypoints1, // 1st image and its keypoints第一張圖像及其關(guān)鍵點
      image2,keypoints2, // 2nd image and its keypoints第二張圖像及其關(guān)鍵點
matches, // the matches匹配結(jié)果
imageMatches, // the image produced產(chǎn)生的圖像
cv::Scalar(255,255,255)); // color of the lines線的顏色
cv::namedWindow("Matches");
cv::imshow("Matches",imageMatches);

// Convert keypoints into Point2f將關(guān)鍵點轉(zhuǎn)換為Point2f
std::vector<cv::Point2f> points1, points2;
for (std::vector<cv::DMatch>::const_iterator it= matches.begin();
it!= matches.end(); ++it) {H


// Get the position of left keypoints得到左圖關(guān)鍵點位置
float x= keypoints1[it->queryIdx].pt.x;
float y= keypoints1[it->queryIdx].pt.y;
points1.push_back(cv::Point2f(x,y));
// Get the position of right keypoints得到右圖關(guān)鍵點位置
x= keypoints2[it->trainIdx].pt.x;
y= keypoints2[it->trainIdx].pt.y;
points2.push_back(cv::Point2f(x,y));
}


std::cout << points1.size() << " " << points2.size() << std::endl; 


// Find the homography between image 1 and image 2找到圖像1和圖像2之間的單應(yīng)性矩陣
std::vector<uchar> inliers(points1.size(),0);
cv::Mat homography= cv::findHomography(
cv::Mat(points1),cv::Mat(points2), // corresponding points對應(yīng)點
inliers, // outputed inliers matches 輸出內(nèi)點匹配
CV_RANSAC, // RANSAC method   RANSAC 方法
1.);  // max distance to reprojection point到對應(yīng)點的最大距離


// Draw the inlier points畫內(nèi)點
std::vector<cv::Point2f>::const_iterator itPts= points1.begin();
std::vector<uchar>::const_iterator itIn= inliers.begin();
while (itPts!=points1.end()) {


// draw a circle at each inlier location在每一個內(nèi)點畫一個圈
if (*itIn) 
 cv::circle(image1,*itPts,3,cv::Scalar(255,255,255),2);

++itPts;
++itIn;
}


itPts= points2.begin();
itIn= inliers.begin();
while (itPts!=points2.end()) {


// draw a circle at each inlier location在每一個內(nèi)點畫一個圈
if (*itIn) 
cv::circle(image2,*itPts,3,cv::Scalar(255,255,255),2);

++itPts;
++itIn;
}


  // Display the images with points顯示畫點的圖像
cv::namedWindow("Image 1 Homography Points");
cv::imshow("Image 1 Homography Points",image1);
cv::namedWindow("Image 2 Homography Points");
cv::imshow("Image 2 Homography Points",image2);


// Warp image 1 to image 2變形圖像1到圖像2
cv::Mat result;
cv::warpPerspective(image1, // input image輸入的圖像
result, // output image輸出的圖像
homography, // homography單應(yīng)性矩陣
cv::Size(2*image1.cols,image1.rows)); // size of output image輸出圖像的大小


// Copy image 1 on the first half of full image復(fù)制圖像1的上一部分
cv::Mat half(result,cv::Rect(0,0,image2.cols,image2.rows));
image2.copyTo(half);


  // Display the warp image顯示變形后圖像
cv::namedWindow("After warping");
cv::imshow("After warping",result);


cv::waitKey();
return 0;
}

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Qt中QPainter實現(xiàn)繪制文本功能的示例代碼

    Qt中QPainter實現(xiàn)繪制文本功能的示例代碼

    本文介紹了Qt中QPainter繪制文本的功能及實現(xiàn)動態(tài)文本效果的方法,文內(nèi)涵蓋drawText方法多種調(diào)用形式,QFont、QColor參數(shù)設(shè)置等,感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下
    2026-07-07
  • C++發(fā)郵件簡單實例詳解

    C++發(fā)郵件簡單實例詳解

    這篇文章主要為大家詳細(xì)介紹了C++發(fā)郵件的簡單實例,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-05-05
  • C語言實現(xiàn)學(xué)生學(xué)籍管理系統(tǒng)課程設(shè)計

    C語言實現(xiàn)學(xué)生學(xué)籍管理系統(tǒng)課程設(shè)計

    這篇文章主要為大家詳細(xì)介紹了C語言實現(xiàn)學(xué)生學(xué)籍管理系統(tǒng)課程設(shè)計,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-07-07
  • C/C++中字符串流詳解及其作用介紹

    C/C++中字符串流詳解及其作用介紹

    這篇文章主要介紹了C/C++中字符串流詳解及其作用,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2021-09-09
  • C++ 第三方庫 RabbitMq示例詳解

    C++ 第三方庫 RabbitMq示例詳解

    這篇文章主要介紹了C++ 第三方庫 RabbitMq示例詳解,本文通過實例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友參考下吧
    2025-04-04
  • 如何通過指針突破C++類的訪問權(quán)限

    如何通過指針突破C++類的訪問權(quán)限

    這篇文章主要介紹了通過指針突破C++類的訪問權(quán)限,本文通過實例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價值,需要的朋友可以參考下
    2020-02-02
  • C語言實現(xiàn)查詢自動售貨機中的商品價格【實例分享】

    C語言實現(xiàn)查詢自動售貨機中的商品價格【實例分享】

    本文主要介紹了C語言實現(xiàn)查詢自動售貨機中的商品價格的相關(guān)資料。具有很好的參考價值。下面跟著小編一起來看下吧
    2017-04-04
  • C語言MultiByteToWideChar和WideCharToMultiByte案例詳解

    C語言MultiByteToWideChar和WideCharToMultiByte案例詳解

    這篇文章主要介紹了C語言MultiByteToWideChar和WideCharToMultiByte案例詳解,本篇文章通過簡要的案例,講解了該項技術(shù)的了解與使用,以下就是詳細(xì)內(nèi)容,需要的朋友可以參考下
    2021-08-08
  • c++ 預(yù)處理的圖靈完備之引言

    c++ 預(yù)處理的圖靈完備之引言

    這篇文章主要介紹了c++ 預(yù)處理的圖靈完備之引言,需要的朋友可以參考下
    2017-07-07
  • C語言實現(xiàn)點菜系統(tǒng)

    C語言實現(xiàn)點菜系統(tǒng)

    這篇文章主要為大家詳細(xì)介紹了C語言實現(xiàn)點菜系統(tǒng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-06-06

最新評論

沂源县| 马关县| 齐河县| 西安市| 泽州县| 若尔盖县| 衡南县| 翁源县| 大宁县| 福海县| 浦县| 英吉沙县| 东乡县| 临邑县| 长白| 体育| 平利县| 榕江县| 绥阳县| 三门县| 秦皇岛市| 龙井市| 乌兰浩特市| 凤凰县| 霍山县| 赞皇县| 陈巴尔虎旗| 华亭县| 环江| 扬中市| 茂名市| 麻城市| 安新县| 东阿县| 昌乐县| 南郑县| 清水河县| 无棣县| 永安市| 遵化市| 革吉县|