File: RandomSampleConsensus.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 (72 lines) | stat: -rw-r--r-- 2,991 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
72
# -*- coding: utf-8 -*-
from libcpp.vector cimport vector

cimport pcl_defs as cpp
cimport pcl_sample_consensus as pcl_sac


cdef class RandomSampleConsensus:
    """
    represents an implementation of the RANSAC (RAndom SAmple Consensus) algorithm.
    """
    cdef pcl_sac.RandomSampleConsensus_t *me


    # build error
    def __cinit__(self, model=None):
        cdef SampleConsensusModel tmpModel
        cdef SampleConsensusModelCylinder tmpModelCylinder
        cdef SampleConsensusModelSphere tmpModelSphere
        cdef SampleConsensusModelLine tmpModelLine
        cdef SampleConsensusModelPlane tmpModelPlane
        cdef SampleConsensusModelRegistration tmpModelRegistration
        cdef SampleConsensusModelStick tmpModelStick

        if model is None:
            return
        elif isinstance(model, SampleConsensusModel):
            tmpModel = model
            # tmpModel.thisptr()[0] = model.thisptr()[0]
            self.me = new pcl_sac.RandomSampleConsensus_t(<pcl_sac.SampleConsensusModelPtr_t> tmpModel.thisptr_shared)
        elif isinstance(model, SampleConsensusModelCylinder):
            tmpModelCylinder = model
            # tmpModelCylinder.thisptr()[0] = model.thisptr()[0]
            self.me = new pcl_sac.RandomSampleConsensus_t(<pcl_sac.SampleConsensusModelPtr_t> tmpModelCylinder.thisptr_shared)
        elif isinstance(model, SampleConsensusModelLine):
            tmpModelLine = model
            self.me = new pcl_sac.RandomSampleConsensus_t(<pcl_sac.SampleConsensusModelPtr_t> tmpModelLine.thisptr_shared)
        elif isinstance(model, SampleConsensusModelPlane):
            tmpModelPlane = model
            self.me = new pcl_sac.RandomSampleConsensus_t(<pcl_sac.SampleConsensusModelPtr_t> tmpModelPlane.thisptr_shared)
        elif isinstance(model, SampleConsensusModelRegistration):
            tmpModelRegistration = model
            self.me = new pcl_sac.RandomSampleConsensus_t(<pcl_sac.SampleConsensusModelPtr_t> tmpModelRegistration.thisptr_shared)
        elif isinstance(model, SampleConsensusModelSphere):
            tmpModelSphere = model
            self.me = new pcl_sac.RandomSampleConsensus_t(<pcl_sac.SampleConsensusModelPtr_t> tmpModelSphere.thisptr_shared)
        elif isinstance(model, SampleConsensusModelStick):
            tmpModelStick = model
            self.me = new pcl_sac.RandomSampleConsensus_t(<pcl_sac.SampleConsensusModelPtr_t> tmpModelStick.thisptr_shared)
        else:
            raise TypeError("Can't initialize a RandomSampleConsensus from a %s"
                            % type(model))
        pass


    def __dealloc__(self):
        del self.me

    def computeModel(self):
        self.me.computeModel(0)

    # base Class(SampleConsensus)
    def set_DistanceThreshold(self, double param):
        self.me.setDistanceThreshold(param)

    # base Class(SampleConsensus)
    def get_Inliers(self):
        cdef vector[int] inliers
        self.me.getInliers(inliers)
        return inliers