首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >[python][pcl]python-pcl案例之cropbox操作

[python][pcl]python-pcl案例之cropbox操作

作者头像
云未归来
发布2025-07-19 15:03:45
发布2025-07-19 15:03:45
1220
举报

测试环境:

pcl==1.13.0

python-pcl==0.3.1

python==3.7

代码:

代码语言:javascript
复制
# -*- coding: utf-8 -*-
from __future__ import print_function

import numpy as np
import pcl


def main():
    cloud = pcl.load('./examples/pcldata/tutorials/table_scene_mug_stereo_textured.pcd')

    # pcl::CropBox<PointXYZI> clipper;
    # clipper.setInputCloud(cloud);
    clipper = cloud.make_cropbox()

    # pcl::PCDWriter writer;
    # pcl::PointCloud<PointXYZI>::Ptr outcloud;
    outcloud = pcl.PointCloud()

    # clipper.setTranslation(Eigen::Vector3f(pose->tx, pose->ty, pose->tz));
    # clipper.setRotation(Eigen::Vector3f(pose->rx, pose->ry, pose->rz));
    # clipper.setMin(-Eigen::Vector4f(tracklet->l/2, tracklet->w/2, 0, 0));
    # clipper.setMax(Eigen::Vector4f(tracklet->l/2, tracklet->w/2, tracklet->h, 0));
    # clipper.filter(*outcloud);
    tx = 0
    ty = 0
    tz = 0
    clipper.set_Translation(tx, ty, tz)
    rx = 0
    ry = 0
    rz = 0
    clipper.set_Rotation(rx, ry, rz)
    minx = -1.5
    miny = -1.5
    minz = 2
    mins = 0
    maxx = 3.5
    maxy = 3.5
    maxz = 3
    maxs = 0
    clipper.set_MinMax(minx, miny, minz, mins, maxx, maxy, maxz, maxs)
    outcloud = clipper.filter()

    pcl.save(outcloud, "test.pcd")

    # stringstream outfilename;
    # outfilename << outfile << tracklet->objectType << i << ".pcd";
    # if(!outcloud->empty()){
    #   cout << "Found "<<outcloud->size() << " points, writing to " << outfilename.str() << endl;
    #   writer.write<PointXYZI> (outfilename.str(), *outcloud, false);
    # }else{
    #   cerr << "Couldn't find points for tracklet" << tracklet->objectType << i << endl;
    # }


if __name__ == "__main__":
    # import cProfile
    # cProfile.run('main()', sort='time')
    main()
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2023-07-01,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档