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

目录

首先说明一下这部分代码在find_box_3d这个例程中,非常好用的一个坐标系生成函数。

一、reduce_object_model_3d_by_view函数

通过将3D对象模型投影到虚拟视图并删除给定区域外的所有点来删除3D对象模型中的点。

csharp 复制代码
reduce_object_model_3d_by_view(Region : : ObjectModel3D, CamParam, Pose : ObjectModel3DReduced)

二、reduce_object_model_3d_by_view函数调用过程

csharp 复制代码
* ********************************************************

read_object_model_3d ('glass_mug', 'cm', [], [], ObjectModel3D, Status)
* 
* Prepare the Visualization
dev_update_off ()
dev_close_window ()
dev_open_window (0, 0, 768, 512, 'black', WindowHandle)
dev_set_draw ('margin')
set_display_font (WindowHandle, 16, 'mono', 'true', 'false')
* 
gen_cam_par_area_scan_division (0.01, 0, 7e-6, 7e-6, 384, 255, 768, 512, CamParam)
create_pose (-0.1e-3, -0.47e-3, 55.8e-3, 104.5, 358.0, 353.0, 'Rp+T', 'gba', 'point', Pose)
GenParamName := ['color_0', 'disp_pose_0', 'alpha_0']
GenParamValue := ['yellow', 'true', 0.3]
GenParamName := [GenParamName,'color_1', 'attribute_1', 'disp_background']
GenParamValue := [GenParamValue,'blue', 'points', 'true']
gen_image_gray_ramp (Ramp, -0.5, 0, 300, 0, 512, 768, 512)
* 
* Show current 3D object model
Title := 'Move and rotate the object to an appropriate pose, before'
Title[1] := 'selecting the region of the points to be trimmed off.'
Instructions[0] := 'Rotate: Left button'
Instructions[1] := 'Zoom:   Shift + left button'
Instructions[2] := 'Move:   Ctrl  + left button'
dev_display (Ramp)
visualize_object_model_3d (WindowHandle, [ObjectModel3D,ObjectModel3D], CamParam, Pose, GenParamName, GenParamValue, Title, [], Instructions, Pose)
* 
* Now, select the points to be trimmed off by entering a
* suitable region
Message := 'Now draw region with the mouse to cut out part of the model'
Message[1] := '(Right click to finish)'
disp_message (WindowHandle, Message, 'window', 12, 12, 'black', 'true')
* Wait for a region
dev_set_line_width (3)
dev_set_color ('red')
draw_region (Region, WindowHandle)
get_cam_par_data (CamParam, 'image_width', ImageWidth)
get_cam_par_data (CamParam, 'image_height', ImageHeight)
gen_rectangle1 (Rectangle, 0, 0, ImageHeight, ImageWidth)
difference (Rectangle, Region, RegionComplement)
* Apply the region drawn before to the 3d object model
reduce_object_model_3d_by_view (RegionComplement, ObjectModel3D, CamParam, Pose, ObjectModel3DReduced)
* 
* Visualize the result
Title := 'Resulting reduced 3d object model'
dev_display (Ramp)
visualize_object_model_3d (WindowHandle, [ObjectModel3DReduced,ObjectModel3DReduced], CamParam, Pose, GenParamName, GenParamValue, Title, [], Instructions, Pose)

下面是这个例程比较特色的三个点

1、gen_image_gray_ramp (Ramp, -0.5, 0, 300, 0, 512, 768, 512),使用这个函数生成一个灰度渐变图像作为3D模型显示得背景。

2、reduce_object_model_3d_by_view (RegionComplement, ObjectModel3D, CamParam, Pose, ObjectModel3DReduced)

通过将3D对象模型投影到虚拟视图,选取RegionComplement内的点,完成模型筛选。

也可以通过下面的方式:

csharp 复制代码
get_object_model_3d_params (ObjectModel3DScene, 'has_xyz_mapping', HasXYZMappings)
if (HasXYZMappings == 'true')
    * In 2D space.
    threshold (ZScene, Regions, MinDist, MaxDist)
    reduce_object_model_3d_by_view (Regions, ObjectModel3DScene, [], [], ObjectModel3DReduced)

3、GenParamName := 'color_0', 'disp_pose_0', 'alpha_0'

GenParamValue := 'yellow', 'true', 0.3

GenParamName := GenParamName,'color_1', 'attribute_1', 'disp_background'

GenParamValue := GenParamValue,'blue', 'points', 'true'

visualize_object_model_3d (WindowHandle, ObjectModel3DReduced,ObjectModel3DReduced, CamParam, Pose, GenParamName, GenParamValue, Title, \[\], Instructions, Pose)

上面一个3D模型显示函数,设置了一些属性,包括'color_0', 'disp_pose_0', 'alpha_0','color_1', 'attribute_1', 'disp_background'

相关推荐
W_326006 小时前
Python-OpenCV 轮廓进阶:旋转最小外接矩形、图像矩求质心、嵌套层级 hierarchy、轮廓形状匹配
图像处理·python·opencv·机器学习·计算机视觉
牧羊人.3338 小时前
计算机视觉基础 第 9 章|实战:银行卡号识别
图像处理·人工智能·opencv·计算机视觉·图搜索算法
AndrewHZ9 小时前
图像处理入门010 | Pillow 与 OpenCV 对比:双库图像读写实战
图像处理·opencv·计算机视觉·pillow
杀生丸学AI10 小时前
【三维重建】QuerySplat:在 3DGS 预测中解耦几何与外观表征
人工智能·3d·三维重建·扩散模型·高斯泼溅·空间智能·室内重建
杀生丸学AI1 天前
【世界模型】Lyra 2.0:可探索的生成式3D世界(NVIDIA)
人工智能·深度学习·3d·数据挖掘·transformer·世界模型·高斯泼溅
毕安格 - BimAngle1 天前
国家电网 GIM 格式模型一键输出 3D Tiles (for Cesium) 和 glTF/glb 更新时间:2026-08-18
3d·gis·cesium·gltf·glb·3d tiles·gim
W_326001 天前
Python-OpenCV边缘检测与阈值分割:Sobel、Scharr、Laplacian、Canny、全局与自适应阈值
开发语言·图像处理·python·opencv·机器学习
这张生成的图像能检测吗1 天前
图像处理 / 底层视觉论文解析汇总目录
图像处理·人工智能
AndrewHZ1 天前
图像处理入门009 | OpenCV 图像读取与显示:imread/imshow 全解析
图像处理·python·opencv·算法·计算机视觉·图像显示
W_326002 天前
Python-OpenCV图像像素与通道:通道拆分合并、深浅拷贝
图像处理·人工智能·python·opencv·机器学习