halcon激光三角测量(十七)calibrate_sheet_of_light_3d_calib_object

目录

一、calibrate_sheet_of_light_3d_calib_object例程代码

1、第一部分:读视差图,读3D模型,可视化

2、第二部分:创建激光三角测量模型

3、第三部分:基于视差图像进行校准,获得校准后的3D模型

4、第四部分:基于表面匹配对齐校准后的3D模型和原3D模型,移除背景,下采样,可视化

5、第五部分:可视化标定结果

csharp 复制代码
**第一部分
dev_update_off ()
read_image (CalibObjectDisparity, 'sheet_of_light/calib_object_disparity')
get_image_size (CalibObjectDisparity, Width, Height)
dev_close_window ()
dev_open_window_fit_image (CalibObjectDisparity, 0, 0, -1, -1, WindowHandle)
set_display_font (WindowHandle, 16, 'mono', 'true', 'false')

read_object_model_3d ('calib_object.dxf', 'm', [], [], CalibObject3D, Status)
create_pose (0.000, 0.07, 2.7, 130, 350, 125, 'Rp+T', 'gba', 'point', VisualizationPoseModel)
Instructions[0] := 'Rotate: Left button'
Instructions[1] := 'Zoom:   Shift + left button'
Instructions[2] := 'Move:   Ctrl  + left button'
Title := 'CAD model of the calibration object\nThe object must be scanned low edge first'
visualize_object_model_3d (WindowHandle, CalibObject3D, [], VisualizationPoseModel, [], [], Title, [], Instructions, PoseOut)
* 
**第二部分
gen_cam_par_area_scan_division (0.016, 0, 4.65e-06, 4.65e-06, 640, 512, 1280, 1024, CameraParam)
set_system ('clip_region', 'false')
get_cam_par_data (CameraParam, 'image_width', ImageWidth)
get_cam_par_data (CameraParam, 'image_height', ImageHeight)
gen_rectangle1 (Domain, 0, 0, ImageHeight - 1, ImageWidth - 1)
create_sheet_of_light_model (Domain, [], [], SheetOfLightModelID)
set_sheet_of_light_param (SheetOfLightModelID, 'camera_parameter', CameraParam)
set_sheet_of_light_param (SheetOfLightModelID, 'calibration_object', 'calib_object.dxf')
* 
*第三部分 
dev_clear_window ()
dev_set_paint (['3d_plot', 'shaded', 8, 0.9, 0.02, 0.3, -0.3, 0.3, -0.01, -0.003, -0.025])
dev_display (CalibObjectDisparity)
disp_message (WindowHandle, 'Measured disparity of the calibration object', 'window', 12, 12, 'black', 'true')
set_profile_sheet_of_light (CalibObjectDisparity, SheetOfLightModelID, [])
disp_message (WindowHandle, 'Now calibrating. This may take a minute...', 'image', Height - 50, 12, 'orange', 'false')
dev_set_paint ('default')

calibrate_sheet_of_light (SheetOfLightModelID, Error)

set_profile_sheet_of_light (CalibObjectDisparity, SheetOfLightModelID, [])
get_sheet_of_light_result_object_model_3d (SheetOfLightModelID, ObjectModel3D)
dev_clear_window ()
* 
*第四部分 
create_surface_model (CalibObject3D, 0.03, [], [], SurfaceModelID)
find_surface_model (SurfaceModelID, ObjectModel3D, 0.05, 0.2, 0, 'false', [], [], Pose, Score, SurfaceMatchingResultID)
pose_to_hom_mat3d (Pose, CHomMat3D)
affine_trans_object_model_3d (CalibObject3D, CHomMat3D, ObjectModel3DAffineTrans)
create_pose (0.1, 0.02, 2.8, 135, 360, 110, 'Rp+T', 'gba', 'point', VisualizationPoseResult)

select_points_object_model_3d (ObjectModel3D, 'point_coord_z', 0.001, 1, ObjectModel3DThresholded)
sample_object_model_3d (ObjectModel3DThresholded, 'accurate', 0.001, [], [], ObjectModel3DSampled)
Title := 'Calibrated reconstruction of the measurement (yellow) together with the calibration object (blue)'
TitleWrapped := regexp_replace(Title + ' ',['(.{0,60})\\s', 'replace_all'],'$1\n')
visualize_object_model_3d (WindowHandle, [ObjectModel3DSampled,ObjectModel3DAffineTrans], [], VisualizationPoseResult, ['alpha_0', 'alpha_1', 'color_0', 'color_1'], [0.5, 0.3, 'yellow', 'blue'], TitleWrapped, [], Instructions, PoseOut)
* 
*第五部分 
get_sheet_of_light_param (SheetOfLightModelID, 'camera_parameter', CamParamResult)
get_sheet_of_light_param (SheetOfLightModelID, 'camera_pose', CameraPose)
get_sheet_of_light_param (SheetOfLightModelID, 'lightplane_pose', LightPlanePose)
get_sheet_of_light_param (SheetOfLightModelID, 'movement_pose', MovementPose)
dev_inspect_ctrl ([CameraParam,CamParamResult,CameraPose,LightPlanePose,MovementPose])
stop ()
dev_close_inspect_ctrl ([CameraParam,CamParamResult,CameraPose,LightPlanePose,MovementPose])
* 
* Visualize setup with calibration object
gen_sheet_of_light_object_model_3d (SheetOfLightModelID, 0.2, 0.05, 0.4, OM3DLightPlane, OM3DMovement, OM3DCamera, OM3DCone)
visualize_object_model_3d (WindowHandle, [CalibObject3D,OM3DLightPlane,OM3DMovement,OM3DCamera,OM3DCone], [], [0.0309362, 0.15155, 8.14821, 100.687, 1.86383, 90.368, 0], ['alpha_1', 'alpha_3', 'alpha_4', 'alpha_5', 'color_0', 'color_3', 'color_4', 'color_5'], [0.5, 0.5, 0.5, 0.5, 'blue', 'green', 'green', 'green'], 'Setup with calibration object', [], [], PoseOut)
* 
* Visualize setup with reconstructed object
visualize_object_model_3d (WindowHandle, [ObjectModel3DSampled,OM3DLightPlane,OM3DMovement,OM3DCamera,OM3DCone], [], PoseOut, ['alpha_1', 'alpha_3', 'alpha_4', 'alpha_5', 'color_0', 'color_3', 'color_4', 'color_5'], [0.5, 0.5, 0.5, 0.5, 'blue', 'green', 'green', 'green'], 'Setup with reconstructed object', [], [], PoseOut)

二、标定过程

1、创建激光三角测量模型

2、设置模型的相机参数、视差图、模型图

3、进行标定

csharp 复制代码
create_sheet_of_light_model (Domain, [], [], SheetOfLightModelID)
set_sheet_of_light_param (SheetOfLightModelID, 'camera_parameter', CameraParam)
set_sheet_of_light_param (SheetOfLightModelID, 'calibration_object', 'calib_object.dxf')
set_profile_sheet_of_light (CalibObjectDisparity, SheetOfLightModelID, [])
calibrate_sheet_of_light (SheetOfLightModelID, Error)

三、校准后的3D模型和原3D模型对齐过程

csharp 复制代码
create_surface_model (CalibObject3D, 0.03, [], [], SurfaceModelID)
find_surface_model (SurfaceModelID, ObjectModel3D, 0.05, 0.2, 0, 'false', [], [], Pose, Score, SurfaceMatchingResultID)
pose_to_hom_mat3d (Pose, CHomMat3D)
affine_trans_object_model_3d (CalibObject3D, CHomMat3D, ObjectModel3DAffineTrans)
create_pose (0.1, 0.02, 2.8, 135, 360, 110, 'Rp+T', 'gba', 'point', VisualizationPoseResult)

四、获得模型标定结果,并生成3D模型

gen_sheet_of_light_object_model_3d 是一个针对激光三角测量模型生成的函数。

csharp 复制代码
get_sheet_of_light_param (SheetOfLightModelID, 'camera_parameter', CamParamResult)
get_sheet_of_light_param (SheetOfLightModelID, 'camera_pose', CameraPose)
get_sheet_of_light_param (SheetOfLightModelID, 'lightplane_pose', LightPlanePose)
get_sheet_of_light_param (SheetOfLightModelID, 'movement_pose', MovementPose)
gen_sheet_of_light_object_model_3d (SheetOfLightModelID, 0.2, 0.05, 0.4, OM3DLightPlane, OM3DMovement, OM3DCamera, OM3DCone)

五、set_paint 和 dev_set_paint函数

定义灰度值输出模式,dev_set_paint与set_paint不同的是,显示模式还用于之后打开的所有新图形窗口。

csharp 复制代码
set_paint( : : WindowHandle, Mode : )
dev_set_paint( : : Mode : )

不同的图像类型对应不同的模式:

灰度图像可以根据其灰度值被解读为三维数据。要查看这些三维图表,请选择"3d_plot"模式;

三通道图像被解读为 RGB 图像;

向量场图像可以被视为"向量场"。
三种模式对应三组类型参数:

'default'

['3d_plot', Mode, Step, qa, qb, qc, qd, ZoomFac, CenterRow, CenterCol, CenterHeight]

['vector_field', Mode, Step, MinLength, ScaleLength, CircleSize]

相关推荐
jimumeta7 小时前
VR虚拟展厅如何改变企业展示的传播方式?
3d·vr·虚拟展厅·3d展厅
摸鱼仙人~15 小时前
太空飞船任务,生成一个地球发射、火星着陆以及下一次发射窗口返回地球的动画3D代码
3d
CASAIM17 小时前
CASAIM与韩国DOOSAN集团达成合作,开启工业制造自动化检测新篇
计算机视觉·3d·自动化
AomanHao1 天前
图像质量评价指标-UCIQE-UIQM
图像处理·人工智能·计算机视觉·评价指标
C#Thread1 天前
机器视觉--图像的运算(乘法)
图像处理·人工智能·计算机视觉
佳佳费_1 天前
浅谈模组-相机鬼像
图像处理·人工智能·计算机视觉
qq_386170501 天前
3DM转换成GLB
3d
青衫弦语1 天前
统一的多摄像头3D感知框架!PETRv2论文精读
图像处理·人工智能·深度学习·目标检测·自动驾驶
mm_exploration1 天前
halcon激光三角测量(二十一)calibrate_sheet_of_light_calplate
图像处理·3d·halcon·点云处理
视觉人机器视觉2 天前
机器视觉检测中,2D面阵相机和线扫相机的区别
人工智能·数码相机·计算机视觉·3d·视觉检测