Halcon简化3d点云数据的例子

* This program shows how to use simplify_object_model_3d
* to simplify a complex 3d object model to different degrees.
* 
dev_close_window () //关闭窗口
dev_open_window (0, 0, 512, 512, 'black', WindowHandle) //打开窗口
set_display_font (WindowHandle, 14, 'mono', 'true', 'false') //设置字体
* Specify a camera for visualization purposes
gen_cam_par_area_scan_division (0.08, 0, 6e-6, 6e-6, 256, 256, 512, 512, CamParam) //得到相机扫描的参数
create_pose (-40, 45, 2100, 195, 45, 5, 'Rp+T', 'gba', 'point', CamPose) //创建位姿
//以下三行是显示的提示数据
Instructions[0] := 'Rotate: Left button'
Instructions[1] := 'Zoom:   Shift + left button'
Instructions[2] := 'Move:   Ctrl  + left button'
* 
* Read the triangulated 3d object model (note that the
* model must be triangulated to be able to pass it to
* simplify_object_model_3d).
read_object_model_3d ('mvtec_bunny.om3', 'm', [], [], ObjectModel3D, Status) //读取om3格式的点云数据
* 
* Visualize the original 3d object model 
* 以下这两句是显示点云数据
get_object_model_3d_params (ObjectModel3D, 'num_points', NumPointsOrig)
visualize_object_model_3d (WindowHandle, ObjectModel3D, CamParam, CamPose, ['color','disp_background'], ['green','true'], ['Original model','with ' + NumPointsOrig + ' points'], [], Instructions, CamPose)
* 
* Simplify the 3d object model to different degrees
dev_open_window (0, 516, 512, 512, 'black', WindowHandleSimplified) //另开一个窗口
set_display_font (WindowHandleSimplified, 14, 'mono', 'true', 'false') //设置这个窗口的字体
PercentageRemaining := [10,1,0.1] //设置简化的倍数 10、1、0.1
for Index := 0 to |PercentageRemaining| - 1 by 1 //开启循环
    Amount := PercentageRemaining[Index]
    simplify_object_model_3d (ObjectModel3D,  'preserve_point_coordinates', Amount, 'amount_type', 'percentage_remaining', SimplifiedObjectModel3D) //简化点云数据
    dev_clear_window ()
    *以下这两句是显示已经被简化的点云数据
    get_object_model_3d_params (SimplifiedObjectModel3D, 'num_points', NumPoints) 
    visualize_object_model_3d (WindowHandleSimplified, SimplifiedObjectModel3D, CamParam, CamPose, 'color', 'green', ['Simplified model','with ' + NumPoints + ' points (' + Amount + '% of original points)'], [], Instructions, CamPose)
endfor //结束循环

这是Halcon中的例子,我用的是Halcon19.05版,不知道其他版本是否有这个例子。

已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 猿与汪的秘密 设计师:上身试试 返回首页