File: EuclideanClusterExtraction_172.pxi

package info (click to toggle)
python-pcl 0.3.0~rc1%2Bdfsg-14
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 31,828 kB
  • sloc: python: 3,094; cpp: 283; makefile: 181; sh: 24; ansic: 12
file content (71 lines) | stat: -rw-r--r-- 2,422 bytes parent folder | download | duplicates (3)
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
61
62
63
64
65
66
67
68
69
70
71
# -*- coding: utf-8 -*-
cimport _pcl
cimport pcl_segmentation_172 as pclseg
cimport pcl_defs as cpp
from libcpp.vector cimport vector

cdef class EuclideanClusterExtraction:
    """
    Segmentation class for EuclideanClusterExtraction
    """
    cdef pclseg.EuclideanClusterExtraction_t *me
    def __cinit__(self):
        self.me = new pclseg.EuclideanClusterExtraction_t()
    def __dealloc__(self):
        del self.me
    
    def set_ClusterTolerance(self, double b):
        self.me.setClusterTolerance(b)
    
    def set_MinClusterSize(self, int min):
        self.me.setMinClusterSize(min)
    
    def set_MaxClusterSize(self, int max):
        self.me.setMaxClusterSize(max)
    
    def set_SearchMethod(self, _pcl.KdTree kdtree):
        self.me.setSearchMethod(kdtree.thisptr_shared)
    
    # def set_Search_Method(self, _pcl.KdTreeFLANN kdtree):
    #    # self.me.setSearchMethod(kdtree.thisptr())
    #    self.me.setSearchMethod(kdtree.thisptr_shared)
    
    # def set_
    #   self.me.setInputCloud (cloud_filtered)
    def Extract(self):
        cdef vector[cpp.PointIndices] inds
        self.me.extract (inds)
        # NG(not use Python)
        # return inds
        # return 2-dimension Array?
        # return [inds[0].indices[i] for i in range(inds[0].indices.size())]
        cdef vector[vector[int]] result
        cdef vector[int] dim
        
        # for j, ind in enumerate(inds):
        # for ind in inds.iterator:
        #    for i in range(ind):
        #        dim.push_back(ind.indices[i])
        #    result.push_back(dim)
        # return result
        
        # use Iterator
        # http://cython.readthedocs.io/en/latest/src/userguide/wrapping_CPlusPlus.html
        # http://stackoverflow.com/questions/29200592/how-to-iterate-throught-c-sets-in-cython
        # itertools?
        # http://qiita.com/tomotaka_ito/items/35f3eb108f587022fa09
        # https://docs.python.org/2/library/itertools.html
        # set numpy?
        # http://kesin.hatenablog.com/entry/20120314/1331689014
        cdef vector[cpp.PointIndices].iterator it = inds.begin()
        while it != inds.end():
            idx = deref(it)
            # for i in range(it.indices.size()):
            for i in range(idx.indices.size()):
                dim.push_back(idx.indices[i])
            result.push_back(dim)
            inc(it)
            dim.clear()
        
        return result