從特徵點匹配到 ,通過三角測量估計三維點座標

2021-10-07 06:22:18 字數 3147 閱讀 1981

#include

#include

#include

#include

#include

using

namespace std;

using

namespace cv;

void find_feature_matches (

const mat& img_1,

const mat& img_2,

std::vector

& keypoints_1,

std::vector

& keypoints_2,

std::vector< dmatch >

& matches )

;void pose_estimation_2d2d (

const std::vector

& keypoints_1,

const std::vector

& keypoints_2,

const std::vector< dmatch >

& matches,

mat& r, mat& t )

;void triangulation (

const vector

& keypoint_1,

const vector

& keypoint_2,

const std::vector< dmatch >

& matches,

const mat& r,

const mat& t,

vector

& points);

// 畫素座標轉相機歸一化座標

point2f pixel2cam

(const point2d& p,

const mat& k )

;int main (

int argc,

char

** ar** )

return0;

}void find_feature_matches (

const mat& img_1,

const mat& img_2,

std::vector

& keypoints_1,

std::vector

& keypoints_2,

std::vector< dmatch >

& matches )

printf (

"-- max dist : %f \n"

, max_dist )

; printf (

"-- min dist : %f \n"

, min_dist )

;//當描述子之間的距離大於兩倍的最小距離時,即認為匹配有誤.但有時候最小距離會非常小,設定乙個經驗值30作為下限.

for(

int i =

0; i < descriptors_1.rows; i++)}

}void pose_estimation_2d2d (

const std::vector

& keypoints_1,

const std::vector

& keypoints_2,

const std::vector< dmatch >

& matches,

mat& r, mat& t )

//-- 計算基礎矩陣

mat fundamental_matrix;

fundamental_matrix = findfundamentalmat ( points1, points2, fm_ransac )

; cout<<

"fundamental_matrix is "

point2d principal_point (

325.1

,249.7);

//相機主點, tum dataset標定值

int focal_length =

521;

//相機焦距, tum dataset標定值

mat essential_matrix;

essential_matrix = findessentialmat ( points1, points2, focal_length, principal_point )

; cout<<

"essential_matrix is "

mat homography_matrix;

homography_matrix = findhomography ( points1, points2, ransac,3)

; cout<<

"homography_matrix is "

recoverpose ( essential_matrix, points1, points2, r, t, focal_length, principal_point )

; cout<<

"r is "

"t is "

<}void triangulation (

const vector< keypoint >

& keypoint_1,

const vector< keypoint >

& keypoint_2,

const std::vector< dmatch >

& matches,

const mat& r,

const mat& t,

vector< point3d >

& points )

mat pts_4d;

cv::

triangulatepoints

( t1, t2, pts_1, pts_2, pts_4d )

; cout<<

"pts_4d:"

for(

int i=

0; ipoint2f pixel2cam (

const point2d& p,

const mat& k )

利用三角測量計算幀間特徵點的空間位置

需要安裝opencv3中的features2d模組 中的1.png 中的2.png 來自高翔slam十四講 include include include include includeusing namespace std using namespace cv void find feature ...

三角測量原理與雙目視覺景深恢復

眼睛是靈敏的光學感覺器官,是一切動物與外界聯絡的資訊接受器。眾所周知人類依靠雙眼可以感知現實世界 物體的顏色 距離 大小等。隨著生物解剖學的發展,人們對人眼的生物結構及機能有了科學的認識。人眼是乙個天然的高階光學系統。結構非常複雜。形象的說,人眼像一架自動攝像機,水晶體如同攝像機的物鏡,能夠在人的神...

(七)ORBSLAM特徵點的三角化

orbslam2特徵點三角化簡介 插入關鍵幀以後,我們還需要插入新的地圖點。為了確保新插入的地圖點是足夠魯棒的,進行嚴格的檢查是必要的。orbslam2在插入地圖點的時候也十分仔細,上一講我們提到了地圖的更新策略,唯獨三角化沒有細講,倒不是因為它不重要而不提,而是因為三言兩語說不清楚,所以才需要單獨...