Halcon-相当于affine_trans_contour_xld的3D

问题描述

我有一个XLD轮廓,我需要将其从世界平面转换为图像平面。.但是我只能找到affine_trans_contour_xld,它可以接受2D Mat,而不能接受3D Mat。 xld从世界平面到图像平面的轮廓?

基本上,我需要的是contour_to_world_plane_xld的反函数

编辑:我认为解决方案是找到XY平面的2D Mat,但也找不到解决方法

解决方法

我这样解决了:

*get the points of a 100 mm square on my XY plane. Since the XLD is in 1px=1mm

affine_trans_point_3d(Mat3D,X,Y,Z)
project_3d_point(X,Z,CamParam,Xp1,Yp1)
affine_trans_point_3d(Mat3D,0.1,Xp2,Yp2)
affine_trans_point_3d(Mat3D,Xp3,Yp3)
affine_trans_point_3d(Mat3D,Xp4,Yp4)

*0 on my Image corrisponds to 0 on my XY plane. 100 px square equals the 0.1m square above.
*generate the 2D mat by projection

hom_vector_to_proj_hom_mat2d ([0,100,0],[0,100],[1,1,1],[Xp1,Xp4],[Yp1,Yp2,Yp3,Yp4],'dlt',HomMat2D)

*load the first Z plane
select_obj(ListZplanes,CurrentZplaneXLD,i)

*project the Z plane onto the Plane
projective_trans_contour_xld(CurrentZplaneXLD,CurrentZplaneTransXLD,HomMat2D)
,

我写了我以前使用的代码。

程序名称:world_plane_coordinates_to_image_points

输入控制参数: CamParam,Pose,X,Y

输出控制参数: 行,列

* given the X,Y coordinates on the world plane,* the procedure returns the relative points on the image (original or unwarped)

* create arrays with z coordinates all equal to 0
tuple_length (X,NumPoints)
tuple_gen_const (NumPoints,Z)    

* Coordinates in the distorted image
pose_to_hom_mat3d(Pose,HomMat3D)
affine_trans_point_3d(HomMat3D,Qx,Qy,Qz)
project_3d_point(Qx,Qz,Row,Column)

通过阅读文档,您可以阅读以更好地了解解决方案: https://www.mvtec.com/fileadmin/Redaktion/mvtec.com/documentation/solution_guide/solution_guide_iii_c_3d_vision.pdf

信息位于:

3.3.5将世界坐标转换为图像坐标