File: test_surface.py

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 (64 lines) | stat: -rw-r--r-- 1,631 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
import os.path
import pickle
import shutil
import tempfile
import unittest

import pcl
import numpy as np


from nose.plugins.attrib import attr


# surface
### ConcaveHull ###
class TestConcaveHull(unittest.TestCase):

    def setUp(self):
        self.p = pcl.load("tests" + os.path.sep + "flydracyl.pcd")
        self.surf = self.p.make_ConcaveHull()
        # self.surf = pcl.ConcaveHull()
        # self.surf.setInputCloud()

    def testreconstruct(self):
        alpha = 1.0
        self.surf.set_Alpha(alpha)
        clonepc = self.surf.reconstruct()
        # new instance is returned
        self.assertNotEqual(self.p, clonepc)
        # concavehull retains the same number of points?
        self.assertNotEqual(self.p.size, clonepc.size)


### MovingLeastSquares ###
class TestMovingLeastSquares(unittest.TestCase):

    def setUp(self):
        self.p = pcl.load("tests" + os.path.sep + "flydracyl.pcd")
        self.surf = self.p.make_moving_least_squares()

    def testFilter(self):
        self.surf.set_search_radius(0.5)
        self.surf.set_polynomial_order(2)
        self.surf.set_polynomial_fit(True)
        f = self.surf.process()
        # new instance is returned
        self.assertNotEqual(self.p, f)
        # mls filter retains the same number of points
        self.assertEqual(self.p.size, f.size)


def suite():
    suite = unittest.TestSuite()

    # surface
    suite.addTests(unittest.makeSuite(TestConcaveHull))
    suite.addTests(unittest.makeSuite(TestMovingLeastSquares))

    return suite


if __name__ == '__main__':
    testSuite = suite()
    unittest.TextTestRunner().run(testSuite)