Halcon - 3D equivalent of affine_trans_contour_xld

六眼飞鱼酱① 提交于 2020-12-13 04:40:05

问题


I have a XLD contour that i need to convert from world plane to image plane.. but I can only find affine_trans_contour_xld, that accepts a 2D Mat, and not a 3D mat.. how can I transform the xld Contour from the world plane to the image plane?

basically what I need is the inverse of contour_to_world_plane_xld

EDIT: I THINK that the solution would be to find the 2D Mat of the XY plane, but couldnt find how to do that either..


回答1:


I solved it this way:

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

affine_trans_point_3d(Mat3D, 0, 0, 0, X, Y, Z)
project_3d_point(X, Y, Z, CamParam, Xp1, Yp1)
affine_trans_point_3d(Mat3D, 0, 0.1, 0, X, Y, Z)
project_3d_point(X, Y, Z, CamParam, Xp2, Yp2)
affine_trans_point_3d(Mat3D, 0.1, 0.1, 0, X, Y, Z)
project_3d_point(X, Y, Z, CamParam, Xp3, Yp3)
affine_trans_point_3d(Mat3D, 0.1, 0, 0, X, Y, Z)
project_3d_point(X, Y, Z, CamParam, 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,100,0], [0,0,100,100], [1,1,1,1], 
[Xp1,Xp2,Xp3,Xp4], [Yp1,Yp2,Yp3,Yp4], [1,1,1,1], '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)



回答2:


I write a code I used some times ago.

Procedure Name: world_plane_coordinates_to_image_points

Input Control Parameters: CamParam, Pose, X, Y

Output Control Parameters: Row, Column

* 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, 0, Z)    

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

You can read understand better the solution by studying the document: https://www.mvtec.com/fileadmin/Redaktion/mvtec.com/documentation/solution_guide/solution_guide_iii_c_3d_vision.pdf

The information is at:

3.3.5 Transforming World Coordinates into Image Coordinates



来源:https://stackoverflow.com/questions/64371266/halcon-3d-equivalent-of-affine-trans-contour-xld

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!