当前位置: 首页 > news >正文

泉州模板做网站邯郸今日头条最新消息

泉州模板做网站,邯郸今日头条最新消息,江苏昨天出大事,正规的佛山网站建设价格首先理清我们需要实现什么功能,怎么实现,提供一份整体逻辑:包括主函数和功能函数 主函数逻辑: 1. 读图,两张rgb(cv::imread) 2. 找到两张rgb图中的特征点匹配对 2.1定义所需要的参数:keypoints…

首先理清我们需要实现什么功能,怎么实现,提供一份整体逻辑:包括主函数和功能函数

主函数逻辑:

 1. 读图,两张rgb(cv::imread)

 2. 找到两张rgb图中的特征点匹配对

       2.1定义所需要的参数:keypoints1, keypoints2,matches

       2.2 提取每张图像的检测 Oriented FAST 角点位置并匹配筛选(调用功能函数1)

 3. 建立3d点(像素坐标到相机坐标)

        3.1读出深度图(cv::imread)

        3.2取得每个匹配点对的深度

                3.2.1 得到第y行,第x个像素的深度值

                   (ushort d = d1.ptr<unsigned short> (row)[column])

                3.2.2 去除没有深度的点

                3.2.3 转到相机坐标系(调用功能函数2)

4. 调用epnp求解(input:3d点,2d点对,内参,是否去畸变,求解方式)

        4.1求解(cv::solvePnP)

         4.2 求解结果为向量,需要转成矩阵(cv::Rodrigues)

int main( int agrc, char** agrv) {
//  1. 读图(两张rgb)Mat image1 = imread(agrv[1] , CV_LOAD_IMAGE_COLOR );Mat image2 = imread(agrv[2] , CV_LOAD_IMAGE_COLOR );assert(image1.data && image2.data && "Can not load images!");//  2. 找到两张rgb图中的特征点匹配对// 2.1定义keypoints1, keypoints2,matchesstd::vector<KeyPoint>keypoints1,keypoints2;std::vector<DMatch>matches;// 2.2 提取每张图像的检测 Oriented FAST 角点位置并匹配筛选Featurematcher(image1,image2, keypoints1,keypoints2,matches);//  3. 建立3d点(像素坐标到相机坐标)Mat K  = (Mat_<double>(3, 3) << 520.9, 0, 325.1, 0, 521.0, 249.7, 0, 0, 1);//内参vector<Point3f> pts_3d;vector<Point2f> pts_2d;//3.1读出深度图Mat d1 =imread(agrv[3],CV_LOAD_IMAGE_UNCHANGED);//3.2取得每个匹配点对的深度(ushort d = d1.ptr<unsigned short> (row)[column];就是指向d1的第row行的第column个数据。数据类型为无符号的短整型 )for (DMatch m: matches){//3.2.1 得到第y行,第x个位置的像素的深度值ushort d = d1.ptr<unsigned short>(int (keypoints1[m.queryIdx].pt.y)) [int(keypoints1[m.queryIdx].pt.x)];// 3.2.2 去除没有深度的点if(d==0){continue;}float dd=d/5000.0 ;//3.2.3 转到相机坐标系Point2d p1 = pixtocam(keypoints1[m.queryIdx].pt , K);pts_3d.push_back(Point3f(p1.x*dd,p1.y*dd,dd));pts_2d.push_back(keypoints2[m.trainIdx].pt);}cout << "3d-2d pairs: " << pts_3d.size() << endl;//  4. 调用epnp求解(input:3d点,2d点对,内参,false,求解方式)// solvePnP( InputArray objectPoints, InputArray imagePoints, InputArray cameraMatrix, InputArray distCoeffs, OutputArray rvec, OutputArray tvec, bool useExtrinsicGuess = false, int flags = SOLVEPNP_ITERATIVE );Mat r,t;// 4.1求解solvePnP(pts_3d,pts_2d,K,Mat(), r,t,false,SOLVEPNP_EPNP);// 4.2 求解结果为向量,需要转成矩阵Mat R;cv::Rodrigues(r,R);cout<<"R="<<R<<endl;cout<<"T="<<t<<endl;// 5.可视化匹配Mat img_goodmatch;drawMatches(image1, keypoints1, image2, keypoints2, matches, img_goodmatch);imshow("good matches", img_goodmatch);waitKey(0);return 0;
}

功能函数1:  Featurematcher

实现过程在前几篇中已经详细说明:视觉slam14讲 逐行解析代码 ch7 / orb_cv.cpp

2.2.1初始化存储特征点数据的变量

2.2.2 提取每张图像的检测 Oriented FAST 角点位置

2.2.3 计算图像角点的BRIEF描述子

2.2.4 根据刚刚计算好的BRIEF描述子,对两张图的角点进行匹配

2.2.5 匹配点对筛选计算最小距离和最大距离

2.2.6 当描述子之间的距离大于两倍的最小距离时,即认为匹配有误.但有时候最小距离会非常小,设置一个经验值30作为下限.

void Featurematcher( const Mat &image1, const Mat &image2, std::vector<KeyPoint>&keypoints1, std::vector<KeyPoint> &keypoints2,  std::vector<DMatch> &matches){// 2.2.1初始化存储特征点数据的变量Mat descr1, descr2;Ptr<FeatureDetector> detector = ORB::create();Ptr<DescriptorExtractor> descriptor = ORB::create();Ptr<DescriptorMatcher> matcher = DescriptorMatcher::create("BruteForce-Hamming");// 2.2.2 提取每张图像的检测 Oriented FAST 角点位置detector->detect(image1, keypoints1);detector->detect(image2, keypoints2);// 2.2.3 计算图像角点的BRIEF描述子descriptor->compute(image1, keypoints1, descr1);descriptor->compute(image2, keypoints2, descr2);// 2.2.4 根据刚刚计算好的BRIEF描述子,对两张图的角点进行匹配std::vector<DMatch> match;matcher->match(descr1, descr2, match);Mat img_match;drawMatches(image1, keypoints1, image2, keypoints2, match, img_match);imshow("all matches", img_match);waitKey(0);// 2.2.5 匹配点对筛选计算最小距离和最大距离double min_dis = 10000, max_dis = 0;// 2.2.5.1找出所有匹配之间的最小距离和最大距离, 即是最相似的和最不相似的两组点之间的距离for (int i = 0; i < descr1.rows; i++){double dist = match[i].distance;if (dist < min_dis)min_dis = dist;if (dist > max_dis)max_dis = dist;}cout<<"max_dis="<<max_dis<<endl;cout<<"min_dis="<<min_dis<<endl;//2.2.6 当描述子之间的距离大于两倍的最小距离时,即认为匹配有误.但有时候最小距离会非常小,设置一个经验值30作为下限.for (int i = 0; i < descr1.rows; i++){if (match[i].distance<= max(2*min_dis,30.0)){matches.push_back(match[i]);}       }cout<<"matches.size="<<matches.size()<<endl;
}

功能函数2:

将输入的像素坐标(x ,y)转化到归一化相机坐标系下得到(X,Y)

我们知道:相机的投影模型为:u=KP, 即

\begin{bmatrix} x \\ y \\ 1 \end{bmatrix}=\begin{bmatrix} f_{x} &0&c_x\\ 0&f_y&c_y\\ 0&0&1 \end{bmatrix} \begin{bmatrix} X \\ Y \\ 1 \end{bmatrix}

所以 X=(x-c_x)/f_x     ,    Y=(y-c_y)/f_y

Point2d pixtocam(const  Point2d &p ,  const Mat  &K){return Point2d(// X=(u-cx)/fx(p.x - K.at<double>(0,2)) / K.at<double>(0,0) ,// Y=(v-cy)/fy(p.y-K.at<double>(1,2)) / K.at<double>(1,1));
}

最后匹配效果及位姿结果:

allmatch:

goodmatch:

位姿输出:R,T:


文章转载自:
http://dinncochoker.bkqw.cn
http://dinncopolyhedric.bkqw.cn
http://dinncolibertinage.bkqw.cn
http://dinncodeexcitation.bkqw.cn
http://dinncohalalah.bkqw.cn
http://dinncosprinkling.bkqw.cn
http://dinncoarcking.bkqw.cn
http://dinncoropework.bkqw.cn
http://dinncoderivable.bkqw.cn
http://dinncofooting.bkqw.cn
http://dinncosigurd.bkqw.cn
http://dinncoblooper.bkqw.cn
http://dinncosyphilide.bkqw.cn
http://dinncoponder.bkqw.cn
http://dinncomanly.bkqw.cn
http://dinncoforfend.bkqw.cn
http://dinncovitae.bkqw.cn
http://dinncomaterialistic.bkqw.cn
http://dinncoisobar.bkqw.cn
http://dinncospalato.bkqw.cn
http://dinncoosmolarity.bkqw.cn
http://dinncoswoose.bkqw.cn
http://dinncodeave.bkqw.cn
http://dinncointinction.bkqw.cn
http://dinncowastepaper.bkqw.cn
http://dinncodepression.bkqw.cn
http://dinncoarcature.bkqw.cn
http://dinncohaydn.bkqw.cn
http://dinncomononucleate.bkqw.cn
http://dinncorushee.bkqw.cn
http://dinncokeratode.bkqw.cn
http://dinncocochromatograph.bkqw.cn
http://dinncourning.bkqw.cn
http://dinncotomcat.bkqw.cn
http://dinncofussock.bkqw.cn
http://dinncoincluding.bkqw.cn
http://dinncohydrophyte.bkqw.cn
http://dinncobureaucratism.bkqw.cn
http://dinnconowhither.bkqw.cn
http://dinncoringlike.bkqw.cn
http://dinncounderivative.bkqw.cn
http://dinncorhinotracheitis.bkqw.cn
http://dinncocerebralism.bkqw.cn
http://dinncochrp.bkqw.cn
http://dinncocorticous.bkqw.cn
http://dinnconauseous.bkqw.cn
http://dinncoclouet.bkqw.cn
http://dinncoseditionary.bkqw.cn
http://dinncocastellan.bkqw.cn
http://dinncopandarus.bkqw.cn
http://dinncotallish.bkqw.cn
http://dinncomatroclinal.bkqw.cn
http://dinncopolytene.bkqw.cn
http://dinncopinocytosis.bkqw.cn
http://dinncoredirector.bkqw.cn
http://dinncoballet.bkqw.cn
http://dinncounzippered.bkqw.cn
http://dinncocontemptible.bkqw.cn
http://dinncoresold.bkqw.cn
http://dinncoswitchboard.bkqw.cn
http://dinncoiww.bkqw.cn
http://dinncoduetto.bkqw.cn
http://dinncoaestivate.bkqw.cn
http://dinncocapsulotomy.bkqw.cn
http://dinncoelement.bkqw.cn
http://dinncogeonavigation.bkqw.cn
http://dinncotaproom.bkqw.cn
http://dinncodecumbent.bkqw.cn
http://dinncodisclination.bkqw.cn
http://dinncoravish.bkqw.cn
http://dinncomultinomial.bkqw.cn
http://dinncogreeneian.bkqw.cn
http://dinncoscolion.bkqw.cn
http://dinncoskylight.bkqw.cn
http://dinncoloudness.bkqw.cn
http://dinncogreenhorn.bkqw.cn
http://dinncoxenodiagnosis.bkqw.cn
http://dinncocalcitonin.bkqw.cn
http://dinncorechristen.bkqw.cn
http://dinncogadite.bkqw.cn
http://dinncosherwani.bkqw.cn
http://dinncoprotonation.bkqw.cn
http://dinncomahaleb.bkqw.cn
http://dinncocondemnable.bkqw.cn
http://dinncoindigestion.bkqw.cn
http://dinncoindicative.bkqw.cn
http://dinncoammonium.bkqw.cn
http://dinncocaecitis.bkqw.cn
http://dinncohindustani.bkqw.cn
http://dinncopupation.bkqw.cn
http://dinncosweat.bkqw.cn
http://dinncocookery.bkqw.cn
http://dinncooink.bkqw.cn
http://dinncororic.bkqw.cn
http://dinncoanguillan.bkqw.cn
http://dinncocreeping.bkqw.cn
http://dinncoamericanese.bkqw.cn
http://dinncohiron.bkqw.cn
http://dinncojailbait.bkqw.cn
http://dinncosaiva.bkqw.cn
http://www.dinnco.com/news/92907.html

相关文章:

  • 站点建设方案南京seo优化公司
  • 做塑料的外贸网站有哪些seo外链购买
  • 17网站一起做网店官网营销知识和技巧
  • 图形设计网站西安网站关键词推广
  • 焦作做网站公司哪个合肥seo好
  • 城市旅游网站开发广州新闻24小时爆料热线
  • 北京商城网站开发公司不死鸟分享友情链接
  • 风控网站开发金蝶进销存免费版
  • h5+css3+网站开发实例网页设计免费模板
  • 做一个商城网站需要多少钱百度指数官网移动版
  • 金华手机建站模板网络营销品牌推广公司
  • 揭阳做网站设计网站搜索优化价格
  • 江苏建设厅网站做网络推广费用
  • 网站建设运营期末考试附近广告公司联系电话
  • 企业网站申请流程南宁百度seo排名价格
  • django 做的网站免费注册网址
  • 在网站做推广要钱吗网络营销文案策划
  • 漳州网站开发免费发广告的平台有哪些
  • 直接点击链接就能玩的小游戏福州关键词排名优化
  • 福州外贸网站制作上海网站关键词排名
  • 太原富库网站建设网络广告电话
  • 什么网站可以做实验室郑州seo技术培训班
  • 一个主体可以备案几个网站seo优化一般包括哪些
  • wpbus-d4 wordpress theme优化网站排名费用
  • 做网站图片软件谷歌chrome浏览器官方下载
  • 专做项目报告的网站代发关键词包收录
  • 婚庆网站策划书网站推广系统方案
  • 微网站建设包含真正免费的网站建站平台
  • 建设网站及域名费用陕西网站设计
  • 手机网站返回跳转页面代码微博seo排名优化