中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當前位置: 首頁 > news >正文

電商設(shè)計網(wǎng)站模板搜索引擎優(yōu)化seo公司

電商設(shè)計網(wǎng)站模板,搜索引擎優(yōu)化seo公司,佛山購物網(wǎng)站建設(shè),做苗木的用什么網(wǎng)站一、介紹 圖像拼接. 二、分步實現(xiàn) 要實現(xiàn)圖像拼接,簡單來說有以下幾步: 對每幅圖進行特征點提取對對特征點進行匹配進行圖像配準把圖像拷貝到另一幅圖像的特定位置對重疊邊界進行特殊處理 PS:需要使用低版本的opencv,否則無法使…

一、介紹

? ? ?圖像拼接.

二、分步實現(xiàn)

? ? ?要實現(xiàn)圖像拼接,簡單來說有以下幾步:

  1. 對每幅圖進行特征點提取
  2. 對對特征點進行匹配
  3. 進行圖像配準
  4. 把圖像拷貝到另一幅圖像的特定位置
  5. 對重疊邊界進行特殊處理

? ? ?PS:需要使用低版本的opencv,否則無法使用特征角點提取算子。

#include "highgui/highgui.hpp"    
#include "opencv2/nonfree/nonfree.hpp"    
#include "opencv2/legacy/legacy.hpp"   
#include <iostream>  using namespace cv;
using namespace std;typedef struct
{Point2f left_top;Point2f left_bottom;Point2f right_top;Point2f right_bottom;
}four_corners_t;four_corners_t corners;void CalcCorners(const Mat& H, const Mat& src)
{// 左上角(0, 0, 1)double v2[3] = { 0, 0, 1 };double v1[3] = { 0 };Mat V2 = Mat(3, 1, CV_64FC1, v2);Mat V1 = Mat(3, 1, CV_64FC1, v1);V1 = H * V2;corners.left_top.x = v1[0] / v1[2];corners.left_top.y = v1[1] / v1[2];// 左下角(0, src.rows, 1)v2[0] = 0;v2[1] = src.rows;v2[2] = 1;V2 = Mat(3, 1, CV_64FC1, v2);V1 = Mat(3, 1, CV_64FC1, v1);V1 = H * V2;corners.left_bottom.x = v1[0] / v1[2];corners.left_bottom.y = v1[1] / v1[2];// 右上角(src.cols, 0, 1)v2[0] = src.cols;v2[1] = 0;v2[2] = 1;V2 = Mat(3, 1, CV_64FC1, v2);V1 = Mat(3, 1, CV_64FC1, v1);V1 = H * V2;corners.right_top.x = v1[0] / v1[2];corners.right_top.y = v1[1] / v1[2];// 右下角(src.cols, src.rows, 1)v2[0] = src.cols;v2[1] = src.rows;v2[2] = 1;V2 = Mat(3, 1, CV_64FC1, v2);V1 = Mat(3, 1, CV_64FC1, v1);V1 = H * V2;corners.right_bottom.x = v1[0] / v1[2];corners.right_bottom.y = v1[1] / v1[2];
}void OptimizeSeam(Mat& img1, Mat& trans, Mat& dst)
{int start = MIN(corners.left_top.x, corners.left_bottom.x);//開始位置,即重疊區(qū)域的左邊界  double processWidth = img1.cols - start; // 重疊區(qū)域的寬度  int rows = dst.rows;int cols = img1.cols; // 注意,是列數(shù)*通道數(shù)double alpha = 1; // img1中像素的權(quán)重  for (int i = 0; i < rows; i++){uchar* p = img1.ptr<uchar>(i);  // 獲取第i行的首地址uchar* t = trans.ptr<uchar>(i);uchar* d = dst.ptr<uchar>(i);for (int j = start; j < cols; j++){// 如果遇到圖像trans中無像素的黑點,則完全拷貝img1中的數(shù)據(jù)if (t[j * 3] == 0 && t[j * 3 + 1] == 0 && t[j * 3 + 2] == 0){alpha = 1;}else{// img1中像素的權(quán)重,與當前處理點距重疊區(qū)域左邊界的距離成正比,實驗證明,這種方法確實好  alpha = (processWidth - (j - start)) / processWidth;}d[j * 3] = p[j * 3] * alpha + t[j * 3] * (1 - alpha);d[j * 3 + 1] = p[j * 3 + 1] * alpha + t[j * 3 + 1] * (1 - alpha);d[j * 3 + 2] = p[j * 3 + 2] * alpha + t[j * 3 + 2] * (1 - alpha);}}
}int main(int argc, char* argv[])
{Mat image01 = imread("image2.png", 1); //右圖Mat image02 = imread("image1.png", 1); //左圖imshow("p2", image01);imshow("p1", image02);// 灰度圖轉(zhuǎn)換  Mat image1, image2;cvtColor(image01, image1, CV_RGB2GRAY);cvtColor(image02, image2, CV_RGB2GRAY);// 提取特征點SurfFeatureDetector Detector(2000);vector<KeyPoint> keyPoint1, keyPoint2;Detector.detect(image1, keyPoint1);Detector.detect(image2, keyPoint2);// 特征點描述SurfDescriptorExtractor Descriptor;Mat imageDesc1, imageDesc2;Descriptor.compute(image1, keyPoint1, imageDesc1);Descriptor.compute(image2, keyPoint2, imageDesc2);FlannBasedMatcher matcher;vector<vector<DMatch> > matchePoints;vector<Mat> train_desc(1, imageDesc1);matcher.add(train_desc);matcher.train();matcher.knnMatch(imageDesc2, matchePoints, 2);cout << "total match points: " << matchePoints.size() << endl;// Lowe's algorithm,獲取優(yōu)秀匹配點vector<DMatch> GoodMatchePoints;for (int i = 0; i < matchePoints.size(); i++){if (matchePoints[i][0].distance < 0.4 * matchePoints[i][1].distance){GoodMatchePoints.push_back(matchePoints[i][0]);}}// draw matchMat first_match;drawMatches(image02, keyPoint2, image01, keyPoint1, GoodMatchePoints, first_match);imshow("first_match ", first_match);vector<Point2f> imagePoints1, imagePoints2;for (int i = 0; i < GoodMatchePoints.size(); i++){imagePoints2.push_back(keyPoint2[GoodMatchePoints[i].queryIdx].pt);imagePoints1.push_back(keyPoint1[GoodMatchePoints[i].trainIdx].pt);}// 獲取圖像1到圖像2的投影映射矩陣 尺寸為3*3  Mat homo = findHomography(imagePoints1, imagePoints2, CV_RANSAC);cout << "變換矩陣為:\n" << homo << endl << endl; // 輸出映射矩陣      // 計算配準圖的四個頂點坐標CalcCorners(homo, image01);cout << "left_top:" << corners.left_top << endl;cout << "left_bottom:" << corners.left_bottom << endl;cout << "right_top:" << corners.right_top << endl;cout << "right_bottom:" << corners.right_bottom << endl;// 圖像配準  Mat imageTransform1, imageTransform2;warpPerspective(image01, imageTransform1, homo, Size(MAX(corners.right_top.x, corners.right_bottom.x), image02.rows));// warpPerspective(image01, imageTransform2, adjustMat*homo, Size(image02.cols*1.3, image02.rows*1.8));imshow("直接經(jīng)過透視矩陣變換", imageTransform1);// 創(chuàng)建拼接后的圖,需提前計算圖的大小int dst_width = imageTransform1.cols;  // 取最右點的長度為拼接圖的長度int dst_height = image02.rows;Mat dst(dst_height, dst_width, CV_8UC3);dst.setTo(0);imageTransform1.copyTo(dst(Rect(0, 0, imageTransform1.cols, imageTransform1.rows)));image02.copyTo(dst(Rect(0, 0, image02.cols, image02.rows)));imshow("b_dst", dst);// 優(yōu)化拼接處OptimizeSeam(image02, imageTransform1, dst);imshow("dst", dst);waitKey();return 0;
}

??

?

三、利用stitch實現(xiàn)

#include "opencv2/imgcodecs.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/stitching.hpp"
#include <iostream>using namespace std;
using namespace cv;int main(int argc, char* argv[])
{Mat img1 = imread("image1.png", cv::IMREAD_COLOR);Mat img2 = imread("image2.png", cv::IMREAD_COLOR);vector<Mat> imgs;imgs.push_back(img1);imgs.push_back(img2);Mat pano;Ptr<Stitcher> stitcher = Stitcher::create(Stitcher::PANORAMA);Stitcher::Status status = stitcher->stitch(imgs, pano);if (status != Stitcher::OK){cout << "Can't stitch images, error code = " << int(status) << endl;return EXIT_FAILURE;}string result_name = "result1.jpg";imwrite(result_name, pano);cout << "stitching completed successfully\n" << result_name << " saved!";return EXIT_SUCCESS;
}

http://www.risenshineclean.com/news/2463.html

相關(guān)文章:

  • 做很多網(wǎng)站省委副書記
  • 頂呱呱網(wǎng)站做的怎么樣?xùn)|莞網(wǎng)站推廣大全
  • 深圳專業(yè)手機網(wǎng)站建設(shè)重慶seo按天收費
  • 河北涿州網(wǎng)站建設(shè)黑科技推廣軟件
  • 前端做網(wǎng)站一般用什么框架中國十大搜索引擎網(wǎng)站
  • ps做旅游網(wǎng)站整合營銷方案
  • 公司網(wǎng)站怎么做能被別人搜索到個人網(wǎng)頁
  • 做微網(wǎng)站的第三方登錄界面百度推廣費用可以退嗎
  • 網(wǎng)站ui 特點建立免費網(wǎng)站
  • 保定網(wǎng)站seoseo外包優(yōu)化公司
  • 平面設(shè)計接單appseo內(nèi)部優(yōu)化包括哪些內(nèi)容
  • 做暖暖無碼網(wǎng)站國通快速建站
  • 寶安中心做網(wǎng)站網(wǎng)絡(luò)推廣seo教程
  • 企業(yè)網(wǎng)站開發(fā) metinfo網(wǎng)站搜索引擎優(yōu)化診斷
  • 備案 手機網(wǎng)站銷售管理怎么帶團隊
  • 谷歌做公司網(wǎng)站需要多少錢google關(guān)鍵詞推廣
  • 網(wǎng)站會員體系百度權(quán)重
  • 長春網(wǎng)站開發(fā)senluowx360搜索推廣官網(wǎng)
  • 渝北網(wǎng)站建設(shè)鄭州seo優(yōu)化外包公司
  • 成都市建設(shè)網(wǎng)站首頁地推的60種方法
  • 南寧網(wǎng)絡(luò)推廣建站建站平臺有哪些
  • seo職位要求寧波企業(yè)seo推廣
  • 企業(yè)網(wǎng)站網(wǎng)絡(luò)推廣百度安裝免費下載
  • 做網(wǎng)站宣傳語企業(yè)網(wǎng)絡(luò)營銷策劃書
  • 網(wǎng)站footer設(shè)計谷歌seo優(yōu)化中文章
  • 重慶江北區(qū)網(wǎng)站建設(shè)公司seo大全
  • 網(wǎng)站ip地址 a記錄鎮(zhèn)江百度關(guān)鍵詞優(yōu)化
  • 做自己的網(wǎng)站長沙百度開戶
  • 網(wǎng)站的首頁頁面布局怎么做seo優(yōu)化在線診斷
  • 做直播小視頻在線觀看網(wǎng)站百度推廣客服電話多少