天天看點

HALCON之幾何定位之仿射變換

核心:求變換矩陣
HALCON之幾何定位之仿射變換

代碼

dev_close_window ()
dev_open_window (0, 0, 512, 512, 'white', WindowID)
dev_set_color ('black')
* Draw with the mouse an arbitrary region into the window
draw_region (Region, WindowID)
* 形成一個機關矩陣
hom_mat2d_identity (HomMat2DIdentity)
* 求旋轉矩陣:-0.3是弧度(逆時針為正,順時針為負),繞着(256,256)
hom_mat2d_rotate (HomMat2DIdentity, -0.3, 256, 256, HomMat2DRotate)
* 求縮放矩陣:(1.5,1.5)(x方向縮放1.5倍,y方向)
hom_mat2d_scale (HomMat2DRotate, 1.5, 1.5, 256, 256, HomMat2DScale)
* 求得矩陣作用于區域Region,形成新的區域; 'nearest_neighbor'臨近插值算法
affine_trans_region (Region, RegionAffineTrans, HomMat2DScale, 'nearest_neighbor')
dev_clear_window ()
dev_set_draw ('margin')
dev_set_color ('red')
dev_display (Region)
dev_set_color ('green')
dev_display (RegionAffineTrans)
           

繼續閱讀