【三】3D匹配Matching之外形匹配Shape—Based——create_cam_pose_look_at_point()算子

Halcon 3D相机位姿算子解析
本文详细介绍了Halcon中的create_cam_pose_look_at_point()算子,包括其功能、参数详解及应用场景,并提供了相关的Halcon例程。

😊😊😊欢迎来到本博客😊😊😊

🌟🌟🌟 Halcon算子太多,学习查找都没有系统的学习查找路径,本专栏主要分享Halcon各类算子含义及用法,有时间会更新具体案例。

😊😊😊 具体食用方式:可以点击本专栏【Halcon算子快速查找】–>搜索你要查询的算子名称;或者点击Halcon算子汇总博客,即可食用。

🎁🎁🎁支持:如果觉得博主的文章还不错或者您用得到的话,可以悄悄关注一下博主哈,如果三连收藏支持就更好啦!这就是给予我最大的支持!😙😙😙


学习目标

  • create_cam_pose_look_at_point()

学习内容

算子简介

函数名解释
create_cam_pose_look_at_point()创建一个3D摄像机位置(从摄像机中心观察方向)。

1、create_cam_pose_look_at_point()

  create_cam_pose_look_at_point( : : CamPosX, CamPosY, CamPosZ, LookAtX, LookAtY, LookAtZ, RefPlaneNormal, CamRoll : CamPose)

  函数说明: 创建一个3D摄像机位置(从摄像机中心观察方向);通过两个点和相机的旋转角度创建3D相机相对于世界坐标系的位姿。第一个点是(CamPosX,CamPosY,CamPosZ),第二个点是(LookAtX,lookAtY,lookAtZ)第一个点定义了相机的光学中心在世界坐标系中的位置,即相机坐标系的原点。第二个点定义了相机的观察点,也确定了观察方向。

  因此,第二个点位于相机坐标系的z轴上。确定了这两个点之后,剩下需要确定的就是相机绕z轴旋转的角度。为了确定这个旋转角度,需要指定一个参考平面,RefPlaneNormal表示这个参考平面的法向量,它确定相机的参考方向。最后,相机的旋转角度通过CamRoll来指定,这个角度表示的是相机围绕z轴相对于其参考方向的旋转。也就是说RefPlaneNormal确定了投影的方向,CamRoll,再使得相机相对于这个参考方向旋转一个角度。

  
  函数参数:
    CamPosX输入相机的光线中心对应的X坐标;
    CamPosY输入相机的光学中心对应的Y坐标;
    CamPosZ输入相机光线中心对应的Z坐标;
    LookAtX输入相机指向的3D立体指定点X坐标;
    LookAtY输入相机指向的3D立体指定点y坐标;
    LookAtZ输入相机指向的3D立体指定点z坐标;
    RefPlaneNormal输入给出法向矢量的参考平面;默认:‘-y’ ;参考:‘x’,‘y’, ‘z;’-x’,‘-y’,‘-z’ ;
    CamRoll输入相机倾斜角度;默认: 0;
    CamPose输出3D相机坐标;

  投影方向和投影平面,参数RefPlaneNormal设置情况说明如下

参数参考平面结果
RefPlaneNormal=‘x’yz平面x轴垂直投影得到的2D图像,指向图形外面
RefPlaneNormal=‘-x’yz平面x轴垂直投影得到的2D图像,指向图形里面
RefPlaneNormal=‘y’xz平面y轴垂直投影得到的2D图像,指向图形外面
RefPlaneNormal=‘-y’xz平面x轴垂直投影得到的2D图像,指向图形里面
RefPlaneNormal=‘z’xy平面z轴垂直投影得到的2D图像,指向图形外面
RefPlaneNormal=‘-z’xy平面z轴垂直投影得到的2D图像,指向图形里面

  除了上面说明的几个方向,RefPlaneNormal可以通过一个数组给出[x,y,z],表示任意的方向,并不严格限定为坐标系的坐标轴。

  相机的光学中心和相机的观察点必须不一样。
  此外,参考平面的法向量不能和z坐标轴平行,否则,相机位姿不能很好地确定。当一个3D模型或者3D图形从一个特定的相机位置投影,使用create_cam_pose_look_at_point可视化非常有用。在这种情况下,由这个算子创建的位姿pose可以传入project_object_model_3d 或者 project_shape_model_3d进行投影计算。
  

Halcon例程

vector_to_fundamental_matrix_distortion.hdev		演示未校准立体重建的结果
find_shape_model_3d_recompute_score.hdev			在基于形状的3D匹配的姿势优化之后重新计算分数

【3D匹配Matching之外形匹配Shape—Based】 待更新算子

  • clear_shape_model_3d()
  • clear_all_shape_model_3d()
  • create_cam_pose_look_at_point()
  • create_shape_model_3d()
  • deserialize_shape_model_3d()
  • find_shape_model_3d()
  • get_shape_model_3d_contours()
  • get_shape_model_3d_params()
  • project_shape_model_3d()
  • read_shape_model_3d()
  • serialize_shape_model_3d()
  • trans_pose_shape_model_3d()
  • write_shape_model_3d()

汇总

  本专栏博客汇总:Halcon算子汇总


🚶🚶🚶今天的文章就到这里啦~
喜欢的话,点赞👍、收藏⭐️、关注💟哦 ~

* This program demonstrates the effect of using the * generic parameter 'recompute_score' of the operator * find_shape_model_3d. * * By setting 'recompute_score' to 'true', the score * is recomputed after the pose refinement, which * may lead to slightly different (but more consistent) * score values at the cost of a slightly larger * execution time. * * For this, a 3D shape model of a cube is searched in * a sequence of artificially created images by using * find_shape_model_3d. The images are created by * changing the longitude of the camera in the object * centered spherical coordinate system. * * The matching is performed twice. In the first run, * 'recompute_score' is set to 'false', while in the * second run, 'recompute_score' is set to 'true'. The * score is stored for each of the two runs over all * images. Finally, the score values are plotted with * respect to the camera longitude. * * Note that the variation of the score values is * significantly higher when setting 'recompute_score' * to 'false'. Also note that in real images typically * the variation of the score is lower. * gen_cam_par_area_scan_division (0.01, 0, 7e-6, 7e-6, 320, 240, 640, 480, CamParam) get_cam_par_data (CamParam, 'image_width', Width) get_cam_par_data (CamParam, 'image_height', Height) dev_close_window () dev_open_window (0, 0, Width, Height, 'black', WindowHandle) dev_set_part (0, 0, Height - 1, Width - 1) set_display_font (WindowHandle, 14, 'mono', 'true', 'false') dev_update_off () * * Generate a cube X := [-1,-1,1,1,-1,-1,1,1] Y := [1,-1,-1,1,1,-1,-1,1] Z := [-1,-1,-1,-1,1,1,1,1] Polygons := [4,0,1,2,3,4,4,5,6,7,4,0,1,5,4,4,3,2,6,7,4,0,3,7,4,4,1,2,6,5] gen_object_model_3d_from_points (X, Y, Z, ObjectModel3DID) set_object_model_3d_attrib_mod (ObjectModel3DID, 'polygons', [], Polygons) * * Prepare the 3D object model for matching prepare_object_model_3d (ObjectModel3DID, 'shape_based_matching_3d', 'true', [], []) * * Display the 3D object model disp_object_model_3d_safe (WindowHandle, ObjectModel3DID, CamParam, [0,0,11,30,40,0,0], [], []) disp_message (WindowHandle, '3D Object Model of a Cube', 'window', 12, 12, 'black', 'true') disp_continue_message (WindowHandle, 'black', 'true') stop () * * * Generate the 3D shape model create_cube_shape_model_3d (WindowHandle, ObjectModel3DID, CamParam, ShapeModel3DID) clear_object_model_3d (ObjectModel3DID) * Scores1 := [] Scores2 := [] Times1 := [] Times2 := [] Longitudes := [] Latitude := rad(45) Distance := 11.5 dev_set_color ('green') dev_set_line_width (2) for Longitude := rad(30) to rad(60) by rad(0.25) convert_point_3d_spher_to_cart (Longitude, Latitude, Distance, '-y', '-z', CamX, CamY, CamZ) create_cam_pose_look_at_point (CamX, CamY, CamZ, 0, 0, 0, '-y', 0, CamPose) * Prevent flickering set_system ('flush_graphic', 'false') * * Generate an artificial image of the cube project_cube_image (Image, CamPose, CamParam, X, Y, Z, Polygons) * * Find the cube by using 3D shape-based matching * ('recompute_score' = 'false') count_seconds (Seconds1) find_shape_model_3d (Image, ShapeModel3DID, 0.7, 0.9, 0, [], [], Pose1, CovPose1, Score1) count_seconds (Seconds2) Time1 := (Seconds2 - Seconds1) * 1000.0 * Find the cube by using 3D shape-based matching * ('recompute_score' = 'true') count_seconds (Seconds1) find_shape_model_3d (Image, ShapeModel3DID, 0.7, 0.9, 0, 'recompute_score', 'true', Pose2, CovPose2, Score2) count_seconds (Seconds2) Time2 := (Seconds2 - Seconds1) * 1000.0 * * Display the matching result dev_display (Image) if (|Score1| == 1 and |Score2| == 1) * Display the match project_shape_model_3d (ModelContours, ShapeModel3DID, CamParam, Pose1, 'true', rad(30)) dev_display (ModelContours) * Display the matching time and score disp_message (WindowHandle, 'Matching at Longitude: ' + deg(Longitude)$'3.1f' + ' deg (from 30 to 60 deg)', 'window', 12, 12, 'white', 'false') gen_matching_result_message (Time1, Time2, Score1, Score2, Message) disp_message (WindowHandle, Message, 'window', 420, 12, ['white','yellow','green'], 'false') * Remember the score values Longitudes := [Longitudes,deg(Longitude)] Scores1 := [Scores1,Score1] Scores2 := [Scores2,Score2] Times1 := [Times1,Time1] Times2 := [Times2,Time2] endif * Prevent flickering set_system ('flush_graphic', 'true') * Show what we painted in the loop by drawing a invisible line disp_line (WindowHandle, -1, -1, -1, -1) endfor * * Display the score values dev_clear_window () Title := ['\'recompute_score\'=\'false\'','\'recompute_score\'=\'true\''] Colors := ['yellow','green'] plot_tuple (WindowHandle, Longitudes, [Scores1,Scores2], 'Longitude [deg]', 'Matching score', Colors, ['ticks_x','ticks_y','end_y'], [6,.01,1]) disp_message (WindowHandle, Title, 'window', 12, 350, Colors, 'false') disp_continue_message (WindowHandle, 'black', 'true') stop () dev_clear_window () plot_tuple (WindowHandle, Longitudes, [Times1,Times2], 'Longitude [deg]', 'Matching time [ms]', Colors, 'ticks_x', 6) disp_message (WindowHandle, Title, 'window', 12, 350, Colors, 'false') * * Clear the 3D shape model clear_shape_model_3d (ShapeModel3DID)
最新发布
06-25
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Carlos.Cqy阳

预祝上岸,感谢打赏

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值