halcon投影变换矩阵projective_trans_point_2d的使用(用于平移标定)
* 读取二进制平移矩阵
open_file('平移矩阵.mat','input_binary', FileHandle)
fread_serialized_item(FileHandle, SerializedItemHandle)
deserialize_hom_mat2d(SerializedItemHandle, HomMat2D)
close_file(FileHandle)
* 自定义矩阵的创建
create_matrix (3, 3,[0.9992299, -0.0038126598, -3.7288625,-0.001563689, -1.0002826, 5.2663364,3.2570754e-06, -1.12908565e-05, 1], MatrixID)
get_full_matrix (MatrixID, Values)
* 投影变换矩阵的使用(平面就使用1)
projective_trans_point_2d(HomMat2D, 100,200, 1, Qx, Qy, Qw)
outX1:=Qx/Qw
outY1:=Qy/Qw
* 投影变换矩阵的使用
projective_trans_point_2d(Values, 100,200, 1, Qx2, Qy2, Qw2)
outX2:=Qx2/Qw2
outY2:=Qy2/Qw2
角度转换
if(Px==0 and Py==0 and PAngle==0)
PAngle:=0.1
Px:=0.1
Py:=0.1
endif
*角度
phi:=rad(PAngle)
Px2:=Px-Py/tan(phi)
Py2:=0
*projective_trans_pixel(HomMat2D, Px2, Py2, Qx2, Qy2)
projective_trans_point_2d(MatrixID, Px2, Py2, 1, Qx2, Qy2, Qw2)
Qx2:=Qx2/Qw2
Qy2:=Qy2/Qw2
tPhi:=atan((Qy-Qy2)/(Qx-Qx2))
tAngle:=deg(tPhi)
outAngle:=tAngle