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

halcon激光三角测量(二十三)inspect_3d_surface_intersections

目录

  • 一、inspect_3d_surface_intersections代码第一部分
  • 二、inspect_3d_surface_intersections代码第二部分
  • 三、inspect_3d_surface_intersections代码第三部分

一、inspect_3d_surface_intersections代码第一部分

1、创建一个未标定的激光三角测量模型
2、获得参考3D Model,创建一个基于表面匹配的模板

NumDisparityProfiles := 441
read_image (DisparityProfile, 'sheet_of_light/metal_part_1_disparity_line_000')
create_sheet_of_light_model (DisparityProfile, 'calibration', 'offset_scale', SheetOfLightModelID)
ScaleX := 1
ScaleY := 4
ScaleZ := 0.5
set_sheet_of_light_param (SheetOfLightModelID, 'scale_x', ScaleX)
set_sheet_of_light_param (SheetOfLightModelID, 'scale_y', ScaleY)
set_sheet_of_light_param (SheetOfLightModelID, 'scale_z', ScaleZ)

set_profile_sheet_of_light (ImageModel, SheetOfLightModelID, [])
get_sheet_of_light_result_object_model_3d (SheetOfLightModelID, Model3DFull)
surface_normals_object_model_3d (Model3D, 'mls', 'mls_force_inwards', 'true', ObjectModel3DNormals)
triangulate_object_model_3d (ObjectModel3DNormals, 'greedy', 'greedy_remove_small_surfaces', 200, ObjectModel3DReference, Information)
create_surface_model (ObjectModel3DReference, 0.03, 'model_invert_normals', 'true', SurfaceModelID)

二、inspect_3d_surface_intersections代码第二部分

1、创建三个平面
2、将3D对象模型与平面相交
3、确定交点并将其转换为 XLD 轮廓

create_pose (300, 230, 250, -90, 0, 0, 'Rp+T', 'gba', 'point', PoseIntersectionPlane1)
create_pose (300, 900, 250, -90, 0, 0, 'Rp+T', 'gba', 'point', PoseIntersectionPlane2)
create_pose (300, 1570, 250, -90, 0, 0, 'Rp+T', 'gba', 'point', PoseIntersectionPlane3)
gen_plane_object_model_3d (PoseIntersectionPlane1, [-1, -1, 1, 1] * VisualizationPlaneSize, [-1, 1, 1, -1] * VisualizationPlaneSize, IntersectionPlane1)
gen_plane_object_model_3d (PoseIntersectionPlane2, [-1, -1, 1, 1] * VisualizationPlaneSize, [-1, 1, 1, -1] * VisualizationPlaneSize, IntersectionPlane2)
gen_plane_object_model_3d (PoseIntersectionPlane3, [-1, -1, 1, 1] * VisualizationPlaneSize, [-1, 1, 1, -1] * VisualizationPlaneSize, IntersectionPlane3)

intersect_plane_object_model_3d (ObjectModel3DReference, PoseIntersectionPlane1, ObjectModel3DIntersection1)
intersect_plane_object_model_3d (ObjectModel3DReference, PoseIntersectionPlane2, ObjectModel3DIntersection2)
intersect_plane_object_model_3d (ObjectModel3DReference, PoseIntersectionPlane3, ObjectModel3DIntersection3)

project_object_model_3d_lines_to_contour_xld (Intersection1, PoseIntersectionPlane1, ObjectModel3DIntersection1)
project_object_model_3d_lines_to_contour_xld (Intersection2, PoseIntersectionPlane2, ObjectModel3DIntersection2)
project_object_model_3d_lines_to_contour_xld (Intersection3, PoseIntersectionPlane3, ObjectModel3DIntersection3)
* 
* Determine the nominal dimensions and the tolerance limits by
* analysing the measurements from the reference sample
OrientationRef := 20
OrientationTolerance := 20
analyze_intersection (Intersection1, FittedLines1, OrientationRef, OrientationTolerance, MinDistance1, MaxDistance1, Angle1)
analyze_intersection (Intersection2, FittedLines2, OrientationRef, OrientationTolerance, MinDistance2, MaxDistance2, Angle2)
analyze_intersection (Intersection3, FittedLines3, OrientationRef, OrientationTolerance, MinDistance3, MaxDistance3, Angle3)
* 

下面是函数project_object_model_3d_lines_to_contour_xld (Intersection, PoseIntersectionPlane, ObjectModel3DIntersection)的实现过程
1、获取三维点集的直径,定义为最小外接轴平行长方体的对角线长度。
2、这里PoseIntersectionPlane为什么要invert:
输入的是PoseIntersectionPlane,平面在模型坐标系的姿态,取反就是模型在平面坐标系的姿态,平面坐标系,z上加个diameter看作相机坐标系。就是保证投影平面在相机前。这里其实随意加个数就可以,因为使用的是远心镜头参数,相当于垂直于这个平面去看这个轮廓。平面的中心对应图像中心原点。
3、采用分式模型生成一个远心镜头相机参数。
4、将一个三维物体模型投影到图像坐标系中.

pose_invert (PoseIntersectionPlane, PoseInvert)
get_object_model_3d_params (ObjectModel3DIntersection, 'diameter_axis_aligned_bounding_box', Diameter)
PoseInvert[2] := PoseInvert[2] + Diameter

Scale := 1
gen_cam_par_area_scan_telecentric_division (1.0, 0, 1.0 / Scale, 1.0 / Scale, 0, 0, 512, 512, CamParam)
project_object_model_3d (Intersection, ObjectModel3DIntersection, CamParam, PoseInvert, 'data', 'lines')
return ()

三、inspect_3d_surface_intersections代码第三部分

1、根据激光三角测量模型,获得3D模型,表面匹配,把平面变换到当前3D场景中。
2、获得模型和平面相机部分,投影到图像上,进行轮廓分析。

reset_sheet_of_light_model (SheetOfLightModelID)
read_image (ImageSearch, 'sheet_of_light/metal_part_' + (SceneIndex + 1) + '_disparity_line_' + Index$'03d')
set_profile_sheet_of_light (ImageSearch, SheetOfLightModelID, [])
get_sheet_of_light_result_object_model_3d (SheetOfLightModelID, Scene3DFull)
get_object_model_3d_params (Scene3DFull, 'bounding_box1', BoundingBox1)
MaxZ := BoundingBox1[5]
select_points_object_model_3d (Scene3DFull, 'point_coord_z', MinZ, MaxZ, Scene3D)
find_surface_model (SurfaceModelID, Scene3D, 0.005, 0.2, 0, 'false', [], [], Pose, Score, SurfaceMatchingResultID)
* Align the intersection planes to the test object
rigid_trans_object_model_3d (IntersectionPlane1, Pose, IntersectionPlane1Aligned)
rigid_trans_object_model_3d (IntersectionPlane2, Pose, IntersectionPlane2Aligned)
rigid_trans_object_model_3d (IntersectionPlane3, Pose, IntersectionPlane3Aligned)
get_object_model_3d_params (IntersectionPlane1Aligned, 'primitive_parameter_pose', IntersectionPlane1AlignedPose)
get_object_model_3d_params (IntersectionPlane2Aligned, 'primitive_parameter_pose', IntersectionPlane2AlignedPose)
get_object_model_3d_params (IntersectionPlane3Aligned, 'primitive_parameter_pose', IntersectionPlane3AlignedPose)

disp_message (WindowHandle, Message[0:2], 'window', 12, 12, 'black', 'true')
triangulate_object_model_3d (Scene3D, 'greedy', [], [], Scene3DTest, Information)
dev_clear_window ()
disp_object_model_3d (WindowHandle, [Scene3DTest,IntersectionPlane1Aligned,IntersectionPlane2Aligned,IntersectionPlane3Aligned], VisualizationCamParam, VisualizationPose, ['color_1', 'color_2', 'color_3', 'alpha', 'alpha_0'], [VisualizationColors,0.75, 1])
Message := 'Test object ' + SceneIndex + ' with aligned intersection planes'
MessageWrapped := regexp_replace(Message + ' ',['(.{0,25})\\s', 'replace_all'],'$1\n')
disp_message (WindowHandle, MessageWrapped, 'window', 12, 12, 'black', 'true')

intersect_plane_object_model_3d (Scene3DTest, IntersectionPlane1AlignedPose, ObjectModel3DIntersection1)
intersect_plane_object_model_3d (Scene3DTest, IntersectionPlane2AlignedPose, ObjectModel3DIntersection2)
intersect_plane_object_model_3d (Scene3DTest, IntersectionPlane3AlignedPose, ObjectModel3DIntersection3)

project_object_model_3d_lines_to_contour_xld (Intersection1, IntersectionPlane1AlignedPose, ObjectModel3DIntersection1)
project_object_model_3d_lines_to_contour_xld (Intersection2, IntersectionPlane2AlignedPose, ObjectModel3DIntersection2)
project_object_model_3d_lines_to_contour_xld (Intersection3, IntersectionPlane3AlignedPose, ObjectModel3DIntersection3)

analyze_intersection (Intersection1, FittedLines1, OrientationRef, OrientationTolerance, MinDistance1, MaxDistance1, Angle1)
analyze_intersection (Intersection2, FittedLines2, OrientationRef, OrientationTolerance, MinDistance2, MaxDistance2, Angle2)
analyze_intersection (Intersection3, FittedLines3, OrientationRef, OrientationTolerance, MinDistance3, MaxDistance3, Angle3)
   
    

相关文章:

  • Laravel从入门到上云
  • Deepseek整合SpringAI
  • JVM 类加载器深度解析(含实战案例)
  • MySQL 安装过程记录以及安装选项详解
  • 【C++八股】内存对⻬
  • UniApp 中 margin 和 padding 属性的使用详解
  • vue3项目上线配置 nginx代理
  • hive如何导出csv格式文件
  • Bootstrap CSS 概览
  • postgres源码学习之登录
  • Qt中利用httplib调用https接口
  • Android今日头条的屏幕适配方案
  • c++进阶———继承
  • I2C学习笔记-软件模拟I2C
  • 【分治法】线性时间选择问题
  • 力扣-二叉树-235 二叉搜索树的最近公共祖先
  • HarmonyOS全栈开发指南:从入门到精通,构建万物智联的未来生态(四)
  • C++(23):为类成员函数增加this参数
  • HTTP 和RESTful API 基础,答疑
  • 【JavaScript】实战案例-放大镜效果、图片切换
  • 长沙潮宗街内“金丝楠木老屋文旅博物馆”起火:明火已扑灭,无伤亡
  • 宇树科技王兴兴:第一桶金来自上海,欢迎上海的年轻人加入
  • 李在明正式登记参选下届韩国总统
  • 巴基斯坦称回应挑衅,对印度发起军事行动
  • 古埃及展进入百天倒计时,闭幕前168小时不闭馆
  • 101条关于减重的知识,其中一定有你不知道的