上下標定義:
c -> current;r -> reference;w -> world;tab
t_a^b
tab
-> t_ba -> 從a系到b系的變換陣
img_align建立新類sparseimgalign,初始化相關引數(哪些引數?)
img_align.run:輸入為上一針last_fram_和當前幀new_frame_;輸出為稀疏影象跟蹤匹配點數img_align_n_tracked,跳轉到sparse_img_align.cpp檔案中的run函式
判斷採用那種優化演算法(gn/lm),這裡nllssolver建構函式(nlls_solver.h)初始化method_為levenbergmarquardt,lm優化optimizelevenbergmarquardt;
如果初始化method_為gaussnewton,gn優化optimizegaussnewton。
取出當前迭代的(level_層)金字塔影象 cur_img;
預計算(precomputereferencepatches() )參考幀特徵patch的快取,將ref_patch_cache_開闢的儲存空間填上相應的值,可以暫時認為ref_patch_cache_中已經有值了;
建立誤差項errors,數量為特徵點個數;
利用輸入的t_cr和相機投影模型,遍歷參考幀上的特徵點,計算當次遍歷的特徵點在當前影象中的畫素座標:1) 通過特徵的世界座標pos_和參考幀的世界座標ref_pos計算深度depth (z_r);2) 通過參考幀計算 pwr
=xyz
ref=
k−1×
zr×p
uvr=
zr×(
k−1×
puvr
)=de
pth×
fr=d
epth
×[ur
,vr,
1]
tp_ = xyz_ = k^ × z_r × p_ = z_r × (k^ × p_) = depth × f_r = depth × [u_r, v_r, 1]^t
pwr=
xyzr
ef=
k−1×
zr×
puvr
=z
r×(
k−1×
puvr
)=
dept
h×fr
=de
pth×
[ur
,vr
,1]t
;3) 參考幀特徵通過初始化的或上次迭代估計的幀間位姿計算在當前幀相機座標系下的座標 xyz
cur=
pwc=
tcr×
pwr=
k−1×
zc×p
uv
cxyz_ = p_ = t_ × p_ = k^ × z_c × p_
xyzcur
=pw
c=
tcr
×pwr
=k
−1×z
c×p
uvc
;4) 通過相機投影變換獲得影象畫素座標,金字塔scale puv
c=xy
zcur
/z
cp_ = xyz_ / z_c
puvc
=xyz
cur
/zc
floorf計算畫素座標整型,為後面做雙線性插值,通過雙線性插值計算畫素光度值;
判斷當前的畫素座標是否小於0以及此畫素對應的patch是否在當前影象的範圍內;
對當前影象進行雙線性插值演算法,計算雙線性插值引數,左上,右上,左下,右下;
指向當前特徵patch的指標:頭指標ref_patch_cache_.data (總體特徵跟蹤塊) + 當前特徵數feature_counter×每個特徵patch的畫素個數patch_area_(16);
從當前特徵patch的左上角開始遍歷16個畫素,進行雅克比計算:1) 從4*4 patch的左上角開始,畫素陣列和畫素座標之間存在乙個轉換(按行儲存),指向當前特徵塊上當前畫素值的指標:cur_img_ptr = v × cols + u;2) 根據雙線性插值計算當前遍歷的pixel的畫素值intensity_cur; 3) 計算光度誤差res = 當前pixel畫素值 (intensity_cur)-參考幀畫素值 (*ref_patch_cache_ptr);4) 取出預計算中儲存的雅克比矩陣j,jacobian_cache_中對應於此pixel(feature_counter × patch_area_ + pixel_counter)的列;5) 計算hessian矩陣:h=j
×jt×
(wei
ght)
h^ = j × j^t × (weight)
h=j×jt
×(we
ight
) 其中weight預設為0; 6) 計算最速下降的增量 δx=
−j×f
(x)=
δres
=−j×
res×
(wei
ght)
\delta x = -j × f(x) = \delta res = -j × res × (weight)
δx=−j×
f(x)
=δre
s=−j
×res
×(we
ight
)computeresiduals:
函式中compute_weight_scale,use_weights_,scale_相關的**
value函式,compute函式的實現
SVO學習日記 2 2021 1 16
include include include include include include include include include include include include namespace svo 析構函式,主要作用是刪除幀上的特徵點 frame frame 初始化幀 void...
SVO學習日記 8 2021 2 1
ifndef svo pose optimizer h define svo pose optimizer h include namespace svo endif include include include include include include include namespace ...
SVO學習日記 13 2021 2 22
include include include include include include include include include include include include include include include include include include includ...