本篇的轉換方式是參考高翔老師在視覺slam十四講中的程式進行解讀,目的是編寫乙個標頭檔案和原始檔,實現相機座標、世界座標以及畫素座標之間任意兩項的相互轉化。
首先是原始檔
命名空間為myslam#include "myslam/camera.h"
namespace myslam
vector3d camera::world2camera ( const vector3d& p_w, const se3& t_c_w )
vector3d camera::camera2world ( const vector3d& p_c, const se3& t_c_w )
ector2d camera::camera2pixel ( const vector3d& p_c )
vector3d camera::pixel2camera ( const vector2d& p_p, double depth )
vector2d camera::world2pixel ( const vector3d& p_w, const se3& t_c_w )
vector3d camera::pixel2world ( const vector2d& p_p, const se3& t_c_w, double depth )
}
namespace myslam
t_c_w即歐式矩陣,包含r,t的資訊,公式為 t * p_world
return t_c_w*p_w;
公式參考u=fx*(x/z) +cx ; v=fy*(y/z)+cy。雖然p_c是3*1的矩陣,下方輸出等同於p_c(n)
fx_ * p_c ( 0,0 ) / p_c ( 2,0 ) + cx_,
fy_ * p_c ( 1,0 ) / p_c ( 2,0 ) + cy_
depth等同於z
( p_p ( 0,0 )-cx_ ) *depth/fx_,
( p_p ( 1,0 )-cy_ ) *depth/fy_,
然後是標頭檔案
定義指向自身的指標,camera::ptr camera_ = new(camera);#ifndef camera_h
#define camera_h
#include "myslam/common_include.h"
namespace myslam
vector3d world2camera( const vector3d& p_w, const se3& t_c_w );
vector3d camera2world( const vector3d& p_c, const se3& t_c_w );
vector2d camera2pixel( const vector3d& p_c );
vector3d pixel2camera( const vector2d& p_p, double depth=1 );
vector3d pixel2world ( const vector2d& p_p, const se3& t_c_w, double depth=1 );
vector2d world2pixel ( const vector3d& p_w, const se3& t_c_w ); };
}#endif
typedef std::shared_ptrptr;
SLAM中各個座標系之間的轉換
在視覺slam中,有幾個基本的座標系 如何在各座標系之間相互轉換,把攝像頭輸出的2d影象和我們所在的三維世界一一對應,是slam技術研究的一大重點,從世界座標系如何在各座標系之間相互轉換,把攝像頭輸出的2d影象和我們所在的三維世界一一對應,是slam技術研究的一大重點 1 o點表示camera ce...
IOS IOS UIView中的座標轉換
將畫素point由point所在檢視轉換到目標檢視view中,返回在目標檢視view中的畫素值 cgpoint convertpoint cgpoint point toview uiview view 將畫素point從view中轉換到當前檢視中,返回在當前檢視中的畫素值 cgpoint conv...
IOS UIView中的座標轉換
將畫素point由point所在檢視轉換到目標檢視view中,返回在目標檢視view中的畫素值 cgpoint convertpoint cgpoint point toview uiview view 將畫素point從view中轉換到當前檢視中,返回在當前檢視中的畫素值 cgpoint conv...