Skip to content

Instantly share code, notes, and snippets.

@st-le
Last active July 1, 2020 09:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save st-le/d62c8c7b7399463f7e4b8fe484ddcb31 to your computer and use it in GitHub Desktop.
Save st-le/d62c8c7b7399463f7e4b8fe484ddcb31 to your computer and use it in GitHub Desktop.
install python-pcl strawlab
# -*- coding: utf-8 -*-
from __future__ import print_function
import numpy as np
import pcl
import os
def main():
root = '/home/mpnet/mpnet_ws/src/ur_moveit_experiments/data/test/pcd/real_pcd_0630'
fn = 'slm_active-response_269_1440520000_compressed'
ext = '.pcd'
abspath = os.path.join(root, fn+ext)
cloud = pcl.load(abspath)
clipper = cloud.make_cropbox()
print('clipper = ', clipper)
outcloud = pcl.PointCloud()
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 = -0.7
miny = -0.3
minz = 0
mins = 0
maxx = 0.7
maxy = 1
maxz = 2
maxs = 0
clipper.set_MinMax(minx, miny, minz, mins, maxx, maxy, maxz, maxs)
clipper.set_InputCloud(cloud)
print('before -----')
print(cloud)
outcloud = clipper.filter()
print('after -----')
print(outcloud)
pcl.save(outcloud, "test.pcd")
if __name__ == "__main__":
main()

pcl-dev is required:

$ sudo apt-get update -y
$ sudo apt-get install libpcl-dev -y

non-exhaustive list of the required packages:

pip install --upgrade pip
pip install cython
pip install numpy

clone the source code:

git clone https://github.com/strawlab/python-pcl.git
cd python-pcl

checkout the has that supports python 2.7:

git checkout 9491615033f85db317c9e29b6a9fe89603f97365

use --record in case you want to remove the installation later:

python setup.py build_ext -i
python setup.py install --record files.txt --user

(optional) if later, an installation removal is needed:

args rm -rf < files.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment