Esempio n. 1
0
 def test_selectBelow_onlyOnePoint():
     """ Selecting below some threshold should only result the correct lowest point. """
     pc_in = get_test_data()
     pc_out = select_below(pc_in, 'z', 3.2)
     assert_equal(len(pc_out[point]['x']['data']), 1)
     assert_almost_equal(pc_out[point]['x']['data'][0], 1.1)
     assert_almost_equal(pc_out[point]['y']['data'][0], 2.1)
     assert_almost_equal(pc_out[point]['z']['data'][0], 3.1)
     assert_almost_equal(pc_out[point]['return']['data'][0], 1)
    def test_tutorial_once(self):
        """This test should be identical to running all cells in the tutorial notebook once, in order."""
        from laserchicken import load
        point_cloud = load('testdata/AHN3.las')

        point_cloud

        from laserchicken.normalize import normalize
        normalize(point_cloud)

        point_cloud

        from laserchicken.filter import select_polygon
        polygon = "POLYGON(( 131963.984125 549718.375000," + \
                  " 132000.000125 549718.375000," + \
                  " 132000.000125 549797.063000," + \
                  " 131963.984125 549797.063000," + \
                  " 131963.984125 549718.375000))"
        point_cloud = select_polygon(point_cloud, polygon)

        from laserchicken.filter import select_above, select_below
        points_below_1_meter = select_below(point_cloud, 'normalized_height', 1)
        points_above_1_meter = select_above(point_cloud, 'normalized_height', 1)

        from laserchicken import compute_neighborhoods
        from laserchicken import build_volume
        targets = point_cloud
        volume = build_volume("sphere", radius=5)
        neighborhoods = compute_neighborhoods(point_cloud, targets, volume)

        from laserchicken import compute_features
        compute_features(point_cloud, neighborhoods, targets, ['std_z', 'mean_z', 'slope'], volume)

        from laserchicken import register_new_feature_extractor
        from laserchicken.feature_extractor.band_ratio_feature_extractor import BandRatioFeatureExtractor
        register_new_feature_extractor(BandRatioFeatureExtractor(None, 1, data_key='normalized_height'))
        register_new_feature_extractor(BandRatioFeatureExtractor(1, 2, data_key='normalized_height'))
        register_new_feature_extractor(BandRatioFeatureExtractor(2, None, data_key='normalized_height'))
        register_new_feature_extractor(BandRatioFeatureExtractor(None, 0, data_key='z'))

        from laserchicken.feature_extractor.feature_extraction import list_feature_names
        sorted(list_feature_names())

        cylinder = build_volume("infinite cylinder", radius=5)
        neighborhoods = compute_neighborhoods(point_cloud, targets, cylinder)
        compute_features(point_cloud, neighborhoods, targets, ['band_ratio_1<normalized_height<2'], cylinder)

        from laserchicken import export
        export(point_cloud, 'my_output.ply')
Esempio n. 3
0
def select_below_ridiculous_high_z(pc_in):
    return select_below(pc_in, 'z', 100000)
Esempio n. 4
0
 def test_selectBelow_maskAll():
     """ Correct number of results. """
     pc_in = get_test_data()
     mask_out = select_below(pc_in, 'return', 3, return_mask=True)
     assert_equal(sum(mask_out), 3)
Esempio n. 5
0
 def test_selectBelow_maskCorrect():
     """ Correct number of results. """
     pc_in = get_test_data()
     mask_out = select_below(pc_in, 'return', 2, return_mask=True)
     assert_equal(mask_out, np.array([1, 1, 0], dtype=bool))