1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
# -*- coding: utf-8 -*-
from libcpp.vector cimport vector
from libcpp cimport bool
cimport pcl_defs as cpp
cimport pcl_filters as pclfil
from boost_shared_ptr cimport shared_ptr
cdef class CropHull:
"""
Must be constructed from the reference point cloud, which is copied,
so changed to pc are not reflected in CropHull(pc).
"""
cdef pclfil.CropHull_t *me
def __cinit__(self, PointCloud pc not None):
self.me = new pclfil.CropHull_t()
(<cpp.PCLBase_t*>self.me).setInputCloud (pc.thisptr_shared)
def __dealloc__(self):
del self.me
def set_InputCloud(self, PointCloud pc not None):
(<cpp.PCLBase_t*>self.me).setInputCloud (pc.thisptr_shared)
# def SetParameter(self, shared_ptr[cpp.PointCloud[cpp.PointXYZ]] points, cpp.Vertices vt):
def SetParameter(self, PointCloud points, Vertices vt):
cdef const vector[cpp.Vertices] tmp_vertices
# NG
# tmp_vertices.push_back(deref(vt))
# tmp_vertices.push_back<cpp.Vertices>(vt)
# tmp_vertices.push_back[cpp.Vertices](vt)
# tmp_vertices.push_back(vt)
# tmp_vertices.push_back(deref(vt.thisptr()))
self.me.setHullIndices(tmp_vertices)
# self.me.setHullCloud(<shared_ptr[cpp.PointCloud[cpp.PointXYZ]]> points)
# convert <PointCloud> to <shared_ptr[cpp.PointCloud[cpp.PointXYZ]]>
self.me.setHullCloud(points.thisptr_shared)
self.me.setDim(<int> 2)
self.me.setCropOutside(<bool> False)
def Filtering(self, PointCloud outputCloud):
# Cython 0.25.2 NG(0.24.1 OK)
# self.me.filter(deref(outputCloud.thisptr()))
# self.me.filter(<cpp.PointCloud[cpp.PointXYZ]> outputCloud.thisptr()[0])
# Cython 0.24.1 NG(0.25.2 OK)
# self.me.filter(<vector[int]> outputCloud)
# self.me.filter(<vector[int]&> outputCloud)
self.me.c_filter(outputCloud.thisptr()[0])
print("filter: outputCloud size = " + str(outputCloud.size))
return outputCloud
def filter(self):
cdef PointCloud pc = PointCloud()
self.me.c_filter(pc.thisptr()[0])
print("filter: pc size = " + str(pc.size))
return pc
|