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)
* 
* 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]
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

处理的对象不是单纯散乱的点云,而是已经3角化的点云数据类型;

read_object_model_3d ('mvtec_bunny.om3', 'm', [], [], ObjectModel3D, Status);这行代码可以读取各种数据格式的点云ply这类的。

get_object_model_3d_params (ObjectModel3D, 'num_points', NumPointsOrig)
visualize_object_model_3d ()

这两行代码主要将点云可视化。

simplify_object_model_3d(ObjectModel3D, 'preserve_point_coordinates', Amount, 'amount_type', 'percentage_remaining', SimplifiedObjectModel3D)

percentage_remaining代表简化的比率以%为单位。

简化之后再显示一下;

你可能感兴趣的:(halcon)