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

相关推荐
北京青翼科技23 分钟前
PCIe接口-高速模拟采集—高性能计算卡-青翼科技高品质军工级数据采集板-打造专业工业核心板
图像处理·人工智能·fpga开发·信号处理·智能硬件
qyr67893 小时前
深度解析:3D细胞培养透明化试剂供应链与主要制造商分布
大数据·人工智能·3d·市场分析·市场报告·3d细胞培养·细胞培养
CG_MAGIC7 小时前
高模到低模烘焙避坑:ZBrush+SP+3D软件通用解决方案
3d·贴图·zbrush·建模教程·渲云渲染
朗迪锋8 小时前
筑梦天宫的数字基石:MultiViz与MakeReal3D共绘航天数智新图景
3d·信息可视化·数字孪生·数智孪生
esmap8 小时前
技术深度解析:ESMap引擎VS主流数字孪生竞品
人工智能·物联网·3d·编辑器·智慧城市·webgl
云飞云共享云桌面14 小时前
非标自动化设备工厂如何2台服务器带动20个SolidWorks设计
运维·服务器·人工智能·3d·自动化·制造
qq_5260991314 小时前
如何选择适合的工业级图像采集卡
图像处理·计算机视觉·自动化
格林威14 小时前
Baumer相机车牌字符分割与识别:优化车牌识别准确率的 7 种方法,附 OpenCV+Halcon 实战代码!
人工智能·opencv·计算机视觉·视觉检测·halcon·工业相机·智能相机
Yyq1302086968215 小时前
KTH5701 系列低功耗、高精度 3D 霍尔传感器,农业灌溉,旋钮 & 摇杆,线性位置检测,3D位置角度检测, 非接触磁场测量,低功耗磁编
3d·小杨杨13020869682
极客智造15 小时前
ImageSharp 实战应用指南:.NET 跨平台图像处理落地实践
图像处理·.net