当前位置: 首页 > article >正文

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

目录

  • 一、calibrate_sheet_of_light_3d_calib_object例程代码
  • 二、标定过程
  • 三、校准后的3D模型和原3D模型对齐过程
  • 四、获得模型标定结果,并生成3D模型
  • 五、set_paint 和 dev_set_paint函数

一、calibrate_sheet_of_light_3d_calib_object例程代码

1、第一部分:读视差图,读3D模型,可视化
2、第二部分:创建激光三角测量模型
3、第三部分:基于视差图像进行校准,获得校准后的3D模型
4、第四部分:基于表面匹配对齐校准后的3D模型和原3D模型,移除背景,下采样,可视化
5、第五部分:可视化标定结果

**第一部分
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、进行标定

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模型对齐过程

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 是一个针对激光三角测量模型生成的函数。

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不同的是,显示模式还用于之后打开的所有新图形窗口。

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]


http://www.kler.cn/a/547844.html

相关文章:

  • 基于AIOHTTP、Websocket和Vue3一步步实现web部署平台,无延迟控制台输出,接近原生SSH连接
  • lean4安装
  • 把 CSV 文件摄入到 Elasticsearch 中 - CSVES
  • Pythong 解决Pycharm 运行太慢
  • C#(Winform)通过添加AForge添加并使用系统摄像机
  • 提取MV视频中的音频到mp3
  • 【Golang学习之旅】Go 语言微服务架构实践(gRPC、Kafka、Docker、K8s)
  • 国内 网络安全沙箱
  • 基于Odoo的数据中台建设:助力企业数据驱动决策
  • C#打印设计器
  • 机器学习:二分类和多分类
  • 解锁 DeepSeek 超强能力:蓝耘智算平台搭建实战秘籍
  • k8s集群离线安装kuberay operator
  • 以若依移动端版为基础,实现uniapp的flowable流程管理
  • 【第7章:注意力机制与Transformer模型—7.3 注意力机制与Transformer模型的优化与改进策略】
  • sql sqlserver的特殊函数COALESCE和PIVOT的用法分析
  • Jenkins+maven+gitlab+shell 实现项目自动化部署
  • Sentinel 源码深度解析
  • resultType,jdbcType,parameterType区别
  • 大数据学习(46) - Flink按键分区处理函数