天天看点

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)
           

继续阅读