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

测试环境:

pcl==1.13.0

python-pcl==0.3.1

python==3.7

代码:

# -*- 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()

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

FL1623863129

你的打赏是我写文章最大的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值