-正常流程
int main (
int argc,
char
** ar** )
//-- 讀取影象
mat img_1 = imread ( ar**[1]
, cv_load_image_color )
; mat img_2 = imread ( ar**[2]
, cv_load_image_color )
; vector keypoints_1, keypoints_2;
vector matches;
find_feature_matches ( img_1, img_2, keypoints_1, keypoints_2, matches )
;cout<<
"一共找到了"
<<
"組匹配點"
<共5個引數:1 2 特徵點1 特徵點2 匹配點向量matches
功能為上一節feature_extraction.cpp類似。
對兩張進行特徵點篩選和匹配,將匹配結果存入向量 matches中
void find_feature_matches (
const mat& img_1,
const mat& img_2,
std::vector
& keypoints_1,
std::vector
& keypoints_2,
std::vector< dmatch >
& matches )
//-- 估計兩張影象間運動
mat r,t;
pose_estimation_2d2d ( keypoints_1, keypoints_2, matches, r, t )
;
void pose_estimation_2d2d ( std::vector keypoints_1,
std::vector keypoints_2,
std::vector< dmatch > matches,
mat& r, mat& t )
/***
引數為兩組關鍵點,響應的匹配向量matches。和矩陣r t的引用
***/
//-- 計算基礎矩陣
mat fundamental_matrix;
fundamental_matrix = findfundamentalmat ( points1, points2, cv_fm_8point )
; cout<<
"fundamental_matrix is "
/-- 計算本質矩陣
point2d principal_point (
325.1
,249.7);
//相機光心, tum dataset標定值
double 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 "
<}
//-- 驗證e=t^r*scale
mat t_x =
( mat_<
double
>(3
,3)<<0,
-t.at<
double
>(2
,0), t.at<
double
>(1
,0),
t.at<
double
>(2
,0),
0,-t.at<
double
>(0
,0),
-t.at<
double
>(1
,0), t.at<
double
>(0
,0),
0); cout<<
"t^r="
/-- 驗證對極約束
mat k =
( mat_<
double
>(3
,3)<<
520.9,0
,325.1,0
,521.0
,249.7,0
,0,1
);for( dmatch m: matches )
return0;
}
2d 2d對極幾何約束
include iostream include include include include include extra.h use this if in opencv2 using namespace std using namespace cv void find feature match...
7 4 求區間和
本題會給你一段長度為n的整數序列,並進行k次詢問。每次詢問要求你給出區間a到b的和 序列下標由1到n 由於區間和可能較大,請你輸出它對10000019取模的結果。注意 如果你想不到高效的做法,可以用樸素演算法得到一部分分,但本題滿分需要你用乙個比較高效的做法。輸入格式 首先一行整數n,代表序列長度。...
(三)對極幾何
對極約束理解 1.對於有重疊紋理的兩幀影象,通過特徵點匹配可以找到一些匹配對,這是對極幾何約束的基礎 2.匹配對是由同一空間點在不同畫素平面投影得到的不同畫素座標,以參考幀為基礎,假設空間點為 p 參考幀投影畫素為 p 當前幀投影畫素為 p 由於空間點 p 深度值不確定,因此其可能在參考幀光心 o ...