常見應用
參考文獻
gtsam::rot2 prior = gtsam::rot2::
fromangle(30
* degree)
;gtsam::noisemodel::isotropic::shared_ptr model =
gtsam::noisemodel::isotropic::
sigma(1
,1* degree)
;gtsam::symbol key
('x',1
);gtsam::prio***ctor
factor
(key, prior, model)
;
nonlinea***ctorgraph graph;
graph.
push_back
(factor)
;
values initial;
initial.
insert
(key, rot2::
fromangle(20
* degree)
);
values result =
levenbergmarquardtoptimizer
(graph, initial)
.optimize()
;
該問題的測量值是 3d 座標點p, p的2d投影 p, 優化變數是camera pose
// 自定義factor class,因為該factor屬於standard gaussian noise model,
// 因此繼承於 noisemodelfactor1
class
resectioningfactor
:public noisemodelfactor1
// 必須要過載的函式,計算error,arg: 優化變數 camera pose, 測量方程的雅各比矩陣
virtual vector evaluateerror
(const pose3& pose,
boost::optional> h = boost::none)
const
};
/* read camera intrinsic parameters */
cal3_s2::shared_ptr calib
(new
cal3_s2(1
,1,0
,50,50
));nonlinea***ctorgraph graph;
// add measurement factors
shareddiagonal measurementnoise = diagonal::
sigmas
(vector2
(0.5
,0.5))
;graph.emplace_shared
(measurementnoise,x(
1), calib,
point2(55
,45),
point3(10
,10,0
));graph.emplace_shared
(measurementnoise,x(
1), calib,
point2(45
,45),
point3(-
10,10,
0));
graph.emplace_shared
(measurementnoise,x(
1), calib,
point2(45
,55),
point3(-
10,-10
,0))
;graph.emplace_shared
(measurementnoise,x(
1), calib,
point2(55
,55),
point3(10
,-10,
0));
// 設定 camera pose的初始值
values initial;
initial.
insert(x
(1),
pose3
(rot3(1
,0,0
,0,-
1,0,
0,0,
-1),
point3(0
,0,2
)));
values result =
levenbergmarquardtoptimizer
(graph, initial)
.optimize()
;
API之NSDictionary的常見用法
nsdictionary dic1 nsdictionary alloc initwithobjectsandkeys 李四 name 不明 gender nil 字典中的物件可以重複儲存 71 instancetype initwithobjectsandkeys id firstobject,n...
遞迴演算法常見用例
1.遞迴逆序列印字串 void reverse char s 2.遞迴方式將鍊錶逆序 p 為指向非空單鏈表中第乙個結點的指標,本演算法逆轉鍊錶並返回逆轉後的頭指標。基本思路是 如果鍊錶中只有乙個結點,則空操作,否則先逆轉a2開始的鍊錶,然後將 a1聯接到逆轉後的鍊錶的表尾 即a2 之後。linkli...
numpy和pandas 各種比較常見的用法總結
經常會遇到np.reshape a,1 或者np.reshape 1,a 這樣的情況 a 1,2,3,4,5 1是乙個比較神奇的功能,意思是我只要確定需要分成a行後者a列,剩下的資料你隨便分,反正結果都一樣。例 arr np.array 1,2,3,4,5,6,7,8,9,10,11,12 乙個一維...