Ejemplo n.º 1
0
    def test_entropy_in_cylinders(self):
        """Test computing of eigenvalues in cylinder."""
        num_all_pc_points = len(self.point_cloud[keys.point]["x"]["data"])
        rand_indices = [
            random.randint(0, num_all_pc_points) for p in range(20)
        ]
        target_point_cloud = utils.copy_point_cloud(self.point_cloud,
                                                    rand_indices)
        n_targets = len(target_point_cloud[keys.point]["x"]["data"])
        radius = 25
        neighbors = compute_neighbors.compute_cylinder_neighborhood(
            self.point_cloud, target_point_cloud, radius)

        target_idx_base = 0
        for x in neighbors:
            feature_extractor.compute_features(self.point_cloud,
                                               x,
                                               target_idx_base,
                                               target_point_cloud,
                                               ["entropy_z"],
                                               InfiniteCylinder(5),
                                               layer_thickness=0.1)
            target_idx_base += len(x)

        for i in range(n_targets):
            H = utils.get_attribute_value(target_point_cloud, i, "entropy_z")
            self.assertTrue(H >= 0)
        self.assertEqual(
            "laserchicken.feature_extractor.entropy_feature_extractor",
            target_point_cloud[keys.provenance][0]["module"])
        self.assertEqual([0.1],
                         target_point_cloud[keys.provenance][0]["parameters"])
Ejemplo n.º 2
0
 def test_normalize_tiny_unequal_point_cloud(self):
     point_cloud = create_point_cloud([0, 0, 0], [0, 0, 0], [1, 2, 3])
     normalized_point_cloud = normalize(point_cloud)
     normalized_values = get_attribute_value(normalized_point_cloud,
                                             range(3), normalized_height)
     np.testing.assert_allclose(normalized_values,
                                np.array([0, 1, 2]),
                                atol=1e-7)
Ejemplo n.º 3
0
 def test_GetPointCloudPointFeature(self):
     """ Should not raise exception. """
     pc = test_tools.generate_tiny_test_point_cloud()
     cols = 0.5 * (pc[keys.point]["x"]["data"] +
                   pc[keys.point]["y"]["data"])
     pc[keys.point]["color"] = {"type": "double", "data": cols}
     x, y, z = utils.get_point(pc, 1)
     c = utils.get_attribute_value(pc, 1, "color")
     self.assertEqual(c, 0.5 * (x + y))
Ejemplo n.º 4
0
 def test_normalize_tiny_unequal_point_cloud_multiple_cells(self):
     """Last of the 3 points is not in the neighborhood of the others."""
     point_cloud = create_point_cloud([0, 0, 5], [0, 0, 0], [1, 2, 3])
     normalized_point_cloud = normalize(point_cloud, cell_size=2)
     normalized_values = get_attribute_value(normalized_point_cloud,
                                             range(3), normalized_height)
     np.testing.assert_allclose(normalized_values,
                                np.array([0, 1, 0]),
                                atol=1e-7)
    def test_entropy_positive_value(self):
        """Test computing of eigenvalues in cylinder."""
        target_point_cloud = self._find_neighbors_for_random_targets_and_compute_entropy(
        )
        n_targets = len(target_point_cloud[keys.point]["x"]["data"])

        for i in range(n_targets):
            entropy_z = utils.get_attribute_value(target_point_cloud, i,
                                                  "entropy_z")
            self.assertTrue(entropy_z >= 0)
Ejemplo n.º 6
0
 def extract(self, sourcepc, neighborhood, targetpc, targetindex, volume):
     t1b = utils.get_attribute_value(targetpc, targetindex,
                                     self.requires()[0])
     x, y, z = utils.get_point(targetpc, targetindex)
     return [x + t1b, y + t1b, z + t1b]  # x + 3z/2, y + 3z/2, 5z/2
 def _extract_one(self, target_point_cloud, target_index):
     t1b = utils.get_attribute_value(target_point_cloud, target_index,
                                     self.requires()[0])
     x, y, z = utils.get_point(target_point_cloud, target_index)
     return [x + t1b, y + t1b, z + t1b]  # x + 3z/2, y + 3z/2, 5z/2
def _assert_feature_name_all_valued(expected, feature_name, n, target):
    v = get_attribute_value(target, range(n), feature_name)
    np.testing.assert_allclose(v, expected)