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

halcon三维点云数据处理(十)locate_cylinder_3d

目录

  • 一、locate_cylinder_3d例程代码
  • 二、gen_binocular_rectification_map函数
  • 三、binocular_disparity函数
  • 四、自定义函数select_best_candidates
  • 五、自定义函数remove_shadowed_regions

一、locate_cylinder_3d例程代码

1、读取或者创建3D形状模型,
2、根据双目相机参数和图像获得校正后图像对的视差图。
3、

gen_cam_par_area_scan_division (0.00855613, -2579.17, 5.99979e-006, 6e-006, 399.681, 232.327, 752, 480, CamParamMatching)
gen_cam_par_area_scan_division (0.0121469, -2514.3, 9.30281e-006, 9.3e-006, 272.773, 273.689, 640, 512, CamParam1)
gen_cam_par_area_scan_division (0.0121592, -2687.76, 9.30085e-006, 9.3e-006, 302.665, 263.738, 640, 512, CamParam2)
create_pose (0.202198, 0.00177953, 0.0376427, 0.325733, 342.295, 359.167, 'Rp+T', 'gba', 'point', RelPose)
gen_binocular_rectification_map (Map1, Map2, CamParam1, CamParam2, RelPose, 1, 'viewing_direction', 'bilinear', CamParamRect1, CamParamRect2, CamPoseRect1, CamPoseRect2, RelPoseRect)
* 
file_exists ('cylinder.sm3', FileExists)
if (FileExists)* Load the model from fileread_shape_model_3d ('cylinder.sm3', ShapeModel3DID)
else* Recreate the model from the DXF fileread_object_model_3d ('cylinder.dxf', 'mm', [], [], ObjectModel3DID, DxfStatus)prepare_object_model_3d (ObjectModel3DID, 'shape_based_matching_3d', 'true', [], [])create_shape_model_3d (ObjectModel3DID, CamParamMatching, rad(90), 0, 0, 'gba', 0, 0, 0, rad(45), 0, rad(360), 0.3, 0.45, 10, 'num_levels', 5, ShapeModel3DID)write_shape_model_3d (ShapeModel3DID, 'cylinder.sm3')
endif
* 
for Index := 1 to 15 by 1* * emphasize() enhances the texture on the cylinders surfaceread_image (Image1, Path + 'stereo_left_' + Index$'02')emphasize (Image1, ImageEmphasize1, 5, 5, 2)map_image (ImageEmphasize1, Map1, ImageMapped1)read_image (Image2, Path + 'stereo_right_' + Index$'02')emphasize (Image2, ImageEmphasize2, 5, 5, 2)map_image (ImageEmphasize2, Map2, ImageMapped2)* * the mask width and height must be (approximately) set according to the size* of the pattern projected onto the setupbinocular_disparity (ImageMapped2, ImageMapped1, Disparity, Score, 'ncc', 7, 7, 0, -20, 140, 1, 0.7, 'left_right_check', 'none')select_best_candidates (Disparity, TopMost)remove_shadowed_regions (Disparity, 0.01)* * display height map and highest object extractedclear_window (WindowHandleL)dev_set_window (WindowHandle)dev_clear_window ()dev_display (ImageMapped2)dev_display (Disparity)wait_seconds (0.5)dev_display (TopMost)dev_display (Disparity)wait_seconds (0.5)* * determine exact 3D pose of highest objectdev_set_window (WindowHandleL)read_image (Image, Path + 'closeup_' + Index$'02')dev_display (Image)find_shape_model_3d (Image, ShapeModel3DID, 0.8, 0.7, [0, 2], [], [], Pose, CovPose, Score_CTRL)if (|Score_CTRL| != 0)dev_set_color ('green')display_match_pose (ShapeModel3DID, Pose, WindowHandleL)elsedisp_message (WindowHandleL, ' No match found ', 'window', 12, 12, 'black', 'true')endif* if (Index != 15)disp_continue_message (WindowHandleL, 'black', 'true')endifstop ()
endfor
disp_message (WindowHandleL, 'Program finished \nPress \'Run\' to clear the shape model', 'window', 1, 1, 'black', 'true')
stop ()
dev_close_window ()

二、gen_binocular_rectification_map函数

生成变换映射,描述双目相机对图像到公共校正图像平面的映射。

gen_binocular_rectification_map( : Map1, Map2 : CamParam1, CamParam2, RelPose, SubSampling, Method, MapType : CamParamRect1, CamParamRect2, CamPoseRect1, CamPoseRect2, RelPoseRect)

三、binocular_disparity函数

使用相关技术计算校正图像对的视差

binocular_disparity(ImageRect1, ImageRect2 : Disparity, Score : Method, MaskWidth, MaskHeight, TextureThresh, MinDisparity, MaxDisparity, NumLevels, ScoreThresh, Filter, SubDisparity : )

四、自定义函数select_best_candidates

下面这段代码的功能是选取最上层的一个圆柱,感觉非常经典,逐句理解一下:
full_domain 将图像的域(ROI)扩大到最大。
scale_image_max 灰度值范围(minimum,maximum ),扩展到范围是(0 ,255)。
regiongrowing_n 对多通道图像使用区域生长来分割图像
intensity 计算灰度值的均值和偏差。
select_gray 根据灰度值特征选择区域。
select_shape借助形状特征选择区域。
min_max_gray确定区域内的最小和最大灰度值。
tuple_sort_index 对Tuple中的所有元素按升序排序
select_obj 选取图像

* 
full_domain (Disparity, DisparityFull)
scale_image_max (DisparityFull, ImageScaleMax2)
gray_dilation_shape (ImageScaleMax2, ImageMax, 3, 3, 'octagon')
* 
* 
regiongrowing_n (ImageMax, cylinders, '2-norm', 0, 5, 200)
intensity (cylinders, ImageScaleMax2, Mean1, Deviation1)
tuple_max (Mean1, MaxVal)
select_gray (cylinders, ImageScaleMax2, SelectedRegions, 'mean', 'and', MaxVal / 2, MaxVal + 1)
select_shape (SelectedRegions, SelectedRegions, ['area', 'rectangularity'], 'and', [7000, 0.65], [25000, 1.0])
intensity (SelectedRegions, ImageScaleMax2, Mean, Deviation)
* 
min_max_gray (SelectedRegions, ImageScaleMax2, 0, Min, Max, Range)
tuple_sort_index (Max, Indices)
select_obj (SelectedRegions, TopMost, Indices[|Max| - 1] + 1)
* 
return ()

五、自定义函数remove_shadowed_regions

对于每个3D相机,遮挡和阴影都会产生非常高视差的小区域,这将被理解为靠近相机的物体,为了提高结果的质量,我们删除了这些区域,把高视差区域灰度设为0。

scale_image_max (Disparity, ImageScaleMax)
gray_histo (ImageScaleMax, ImageScaleMax, AbsoluteHisto, RelativeHisto)
Percent := RelativeHisto[255]
i := 254
while (Percent < Threshold)Percent := RelativeHisto[i] + Percenti := i - 1
endwhile
threshold (ImageScaleMax, Region, i, 255)
overpaint_region (Disparity, Region, 0.0, 'fill')
return ()
http://www.lryc.cn/news/518608.html

相关文章:

  • vue(2,3), react (16及以上)开发者工具资源
  • 2025年华为OD上机考试真题(Java)——整数对最小和
  • 进程间通信——网络通信——UDP
  • 【我的 PWN 学习手札】IO_FILE 之 FSOP
  • 新兴的开源 AI Agent 智能体全景技术栈
  • 统计学习方法(第二版) 概率分布学习
  • 淺談Cocos2djs逆向
  • 【ROS2】RViz2加载URDF模型文件
  • Unity导入特效,混合模式无效问题
  • el-table自定义按钮控制扩展expand
  • opencv CV_TM_SQDIFF未定义标识符
  • 2024acl论文体悟
  • 【Git原理与使用】版本回退reset 详细介绍、撤销修改、删除文件
  • 反规范化带来的数据不一致问题的解决方案
  • 【Android】直接使用binder的transact来代替aidl接口
  • Python机器学习笔记(十八、交互特征与多项式特征)
  • 《跟我学Spring Boot开发》系列文章索引❤(2025.01.09更新)
  • 【AI进化论】 如何让AI帮我们写一个项目系列:将Mysql生成md文档
  • (已开源-AAAI25) RCTrans:雷达相机融合3D目标检测模型
  • Elasticsearch:在 HNSW 中提前终止以实现更快的近似 KNN 搜索
  • unittest VS pytest
  • Tableau数据可视化与仪表盘搭建-基础图表制作
  • Center Loss 和 ArcFace Loss 笔记
  • 3125: 【入门】求1/1+1/2+2/3+3/5+5/8+8/13+13/21……的前n项的和
  • 如何确保获取的淘宝详情页数据的准确性和时效性?
  • 云计算是如何帮助企业实现高可用性的
  • 143.《python中使用pymongo》
  • Babylon.js 的 Mesh 与 Unity 的 GameObject:深入对比与分析
  • MySQL安装,配置教程
  • Android折叠屏适配(权宜之计)