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

open3d 裁剪点云

目录

1. crop_point_cloud

2. crop

3. crop_mesh


1. crop_point_cloud

关键函数

chair = vol.crop_point_cloud(pcd)   # vol: SelectionPolygonVolume
import open3d as o3dif __name__ == "__main__":# 1. read pcdprint("Load a ply point cloud, crop it, and render it")sample_ply_data = o3d.data.DemoCropPointCloud()pcd = o3d.io.read_point_cloud(sample_ply_data.point_cloud_path)# 2. crop# vol: SelectionPolygonVolume, 定义裁剪区域vol = o3d.visualization.read_selection_polygon_volume(sample_ply_data.cropped_json_path) chair = vol.crop_point_cloud(pcd)# 2. view# Flip the pointclouds, otherwise they will be upside down.pcd.transform([[1, 0, 0, 0], [0, -1, 0, 0], [0, 0, -1, 0], [0, 0, 0, 1]])chair.transform([[1, 0, 0, 0], [0, -1, 0, 0], [0, 0, -1, 0], [0, 0, 0, 1]])print("Displaying original pointcloud ...")o3d.visualization.draw([pcd])print("Displaying cropped pointcloud")o3d.visualization.draw([chair])

2. crop

pcd_cropped = pcd.crop(bbox)  # pcd: PointCloud. bbox: AxisAlignedBoundingBox

AxisAlignedBoundingBox https://blog.csdn.net/jizhidexiaoming/article/details/130561514?spm=1001.2014.3001.5501

# 1. read pcd
print("Load a ply point cloud, crop it, and render it")
sample_ply_data = o3d.data.DemoCropPointCloud()
pcd = o3d.io.read_point_cloud(sample_ply_data.point_cloud_path)# 2. 定义裁剪区域。沿着y轴过滤: 只返回y坐标在[0.1,2]之间的点
bounds_list = [[-math.inf, math.inf], [0.8, 2], [-math.inf, math.inf]]  # xyz边界范围
# list2tuple, limit points边界点。itertools.product排列笛卡尔乘积是x,y,z各取一个值,组成xyz点坐标
bbox_pt_list = list(itertools.product(*bounds_list))
bbox_pt_vec = o3d.utility.Vector3dVector(bbox_pt_list)  # list
bbox = o3d.geometry.AxisAlignedBoundingBox.create_from_points(bbox_pt_vec)# 3. crop
pcd_cropped = pcd.crop(bbox)# 4. display
# Flip the pointclouds, otherwise they will be upside down.
pcd_cropped.transform([[1, 0, 0, 0], [0, -1, 0, 0], [0, 0, -1, 0], [0, 0, 0, 1]])
o3d.visualization.draw(pcd_cropped)

3. crop_mesh

上面是裁剪PointCloud,这里裁剪TriangleMesh.

转成numpy,修改mesh的traingles和triangle_normals成员。

import open3d as o3d
import numpy as np
import copyif __name__ == "__main__":# 1. read meshknot_mesh = o3d.data.KnotMesh()mesh = o3d.io.read_triangle_mesh(knot_mesh.path)mesh.compute_vertex_normals()print("Displaying original mesh ...")o3d.visualization.draw([mesh])# 2. crop: triangles and triangle_normalsprint("Displaying mesh of only the first half triangles ...")mesh_cropped = copy.deepcopy(mesh)  # mesh_cropped.triangles. (num, 3)mesh_cropped.triangles = o3d.utility.Vector3iVector(  # trianglesnp.asarray(mesh_cropped.triangles)[:len(mesh_cropped.triangles) // 2, :])mesh_cropped.triangle_normals = o3d.utility.Vector3dVector(  # triangle_normalsnp.asarray(mesh_cropped.triangle_normals)[:len(mesh_cropped.triangle_normals) // 2, :])print(mesh_cropped.triangles)o3d.visualization.draw([mesh_cropped])

 

 

http://www.lryc.cn/news/66365.html

相关文章:

  • 如何对第三方相同请求进行筛选过滤
  • Go RPC
  • 真正的智能不仅仅是一个技术问题
  • 【数据结构】复杂度包装泛型
  • Ae:绘画面板
  • 常见的锁和zookeeper
  • 经验总结:(Redis NoSQL数据库快速入门)
  • form表单与模板引擎
  • 医院检验信息管理系统源码(云LIS系统源码)JQuery、EasyUI
  • React 组件
  • 硕士学位论文的几种常见节奏
  • 找兄弟单词
  • python字典翻转教学
  • sentinel 随笔 3-降级处理
  • 如何解决IP能ping通但无法上网的问题?
  • Autosar实践-CANTp
  • Redis简介
  • 报错问题修改
  • 专访惠众科技|元宇宙应用如何借助3DCAT实时云渲染实现流畅大并发呈现?
  • 加速开放计算产业化,OCTC五大原则瞄准需求痛点
  • 【RabbitMQ】安装及六种模式
  • 数据结构刷题(三十一):1049. 最后一块石头的重量 II、完全背包理论、518零钱兑换II
  • opencv_c++学习(四)
  • 基于AT89C51单片机的篮球计时记分设计
  • 并发编程-Day2
  • 第1章 Nginx简介
  • 一个.Net功能强大、易于使用、跨平台开源可视化图表
  • 浅谈 ext2 文件系统的特点、优缺点以及使用场景
  • Map和Set数据结构和ES6模块化语法
  • 10_Uboot启动流程_2