当前位置: 首页>>代码示例>>Python>>正文


Python shape.PointCloud类代码示例

本文整理汇总了Python中menpo.shape.PointCloud的典型用法代码示例。如果您正苦于以下问题:Python PointCloud类的具体用法?Python PointCloud怎么用?Python PointCloud使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PointCloud类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _recursive_procrustes

    def _recursive_procrustes(self):
        r"""
        Recursively calculates a procrustes alignment.
        """
        from menpo.shape import PointCloud

        if self.n_iterations > self.max_iterations:
            return False
        av_aligned_source = sum(t.aligned_source.points for t in self.transforms) / self.n_sources
        new_target = PointCloud(av_aligned_source)
        # rescale the new_target to be the same size as the original about
        # it's centre
        rescale = UniformScale(self.initial_target_scale / new_target.norm(), self.n_dims)
        centre = Translation(-new_target.centre)
        rescale_about_centre = centre.compose_before(rescale).compose_before(centre.pseudoinverse)
        rescale_about_centre.apply_inplace(new_target)
        # check to see if  we have converged yet
        delta_target = np.linalg.norm(self.target.points - new_target.points)
        if delta_target < 1e-6:
            return True
        else:
            self.n_iterations += 1
            for t in self.transforms:
                t.set_target(new_target)
            self.target = new_target
            return self._recursive_procrustes()
开发者ID:kod3r,项目名称:menpo,代码行数:26,代码来源:procrustes.py

示例2: test_pointcloud_bounding_box_3d

def test_pointcloud_bounding_box_3d():
    points = np.array([[1.0, 2.0, 3.0], [3.0, 2.0, 1.0]])
    pc = PointCloud(points)
    bb = pc.bounding_box()
    bb_bounds = bb.bounds()
    assert_allclose(bb_bounds[0], [1.0, 2.0, 1.0])
    assert_allclose(bb_bounds[1], [3.0, 2.0, 3.0])
开发者ID:nontas,项目名称:menpo,代码行数:7,代码来源:pointcloud_test.py

示例3: test_pointcloud_centre

def test_pointcloud_centre():
    points = np.array([[0, 0],
                       [1., 1],
                       [0, 2]])
    pc = PointCloud(points)
    c = pc.centre()
    assert_allclose(c, [1. / 3., 1.])
开发者ID:JeanKossaifi,项目名称:menpo,代码行数:7,代码来源:pointcloud_test.py

示例4: sparse_target

    def sparse_target(self):
        r"""
        The current sparse `menpo.shape.PointCloud` that this object produces.

        :type: `menpo.shape.PointCloud`
        """
        sparse_target = PointCloud(self.target.points[:self.n_landmarks])
        return self._sparse_instance.from_vector(sparse_target.as_vector())
开发者ID:KeeganRen,项目名称:menpofit,代码行数:8,代码来源:modeldriven.py

示例5: test_pointcloud_flatten_rebuild

def test_pointcloud_flatten_rebuild():
    points = np.array([[1, 2, 3], [1, 1, 1]])
    pc = PointCloud(points)
    flattened = pc.as_vector()
    new_pc = pc.from_vector(flattened)
    assert np.all(new_pc.n_dims == pc.n_dims)
    assert np.all(new_pc.n_points == pc.n_points)
    assert np.all(pc.points == new_pc.points)
开发者ID:nontas,项目名称:menpo,代码行数:8,代码来源:pointcloud_test.py

示例6: test_pointcloud_centre_of_bounds

def test_pointcloud_centre_of_bounds():
    points = np.array([[0, 0],
                       [1., 1],
                       [0, 2]])
    pc = PointCloud(points)
    cb = pc.centre_of_bounds()
    assert_allclose(cb, [0.5, 1.])
    assert 1
开发者ID:JeanKossaifi,项目名称:menpo,代码行数:8,代码来源:pointcloud_test.py

示例7: test_pointcloud_bounding_box

def test_pointcloud_bounding_box():
    points = np.array([[0, 0],
                       [1., 1],
                       [0, 2]])
    pc = PointCloud(points)
    bb = pc.bounding_box()
    bb_bounds = bb.bounds()
    assert_allclose(bb_bounds[0], [0., 0.])
    assert_allclose(bb_bounds[1], [1., 2.])
开发者ID:JeanKossaifi,项目名称:menpo,代码行数:9,代码来源:pointcloud_test.py

示例8: test_pointcloud_copy_method

def test_pointcloud_copy_method():
    points = np.array([[1, 2, 3], [1, 1, 1]])
    landmarks = PointCloud(np.ones([3, 3]), copy=False)

    p = PointCloud(points, copy=False)
    p.landmarks["test"] = landmarks
    p_copy = p.copy()

    assert not is_same_array(p_copy.points, p.points)
    assert not is_same_array(p_copy.landmarks["test"].lms.points, p.landmarks["test"].lms.points)
开发者ID:nontas,项目名称:menpo,代码行数:10,代码来源:pointcloud_test.py

示例9: _parse_marker_size

def _parse_marker_size(marker_size, points):
    if marker_size is None:
        from menpo.shape import PointCloud
        from scipy.spatial.distance import squareform
        pc = PointCloud(points, copy=False)
        if 1 < pc.n_points < 1000:
            d = squareform(pc.distance_to(pc))
            d.sort()
            min_10pc = d[int(d.shape[0] / 10)]
            marker_size = min_10pc / 5
        else:
            marker_size = 0.1
    return marker_size
开发者ID:grigorisg9gr,项目名称:menpo3d,代码行数:13,代码来源:viewmayavi.py

示例10: _align_mean_shape_with_bbox

    def _align_mean_shape_with_bbox(self, bbox):
        # Convert 3D landmarks to 2D by removing the Z axis
        template_shape = PointCloud(self.mm.landmarks.points[:, [1, 0]])

        # Rotation that flips over x axis
        rot_matrix = np.eye(template_shape.n_dims)
        rot_matrix[0, 0] = -1
        template_shape = Rotation(rot_matrix,
                                  skip_checks=True).apply(template_shape)

        # Align the 2D landmarks' bbox with the provided bbox
        return AlignmentSimilarity(template_shape.bounding_box(),
                                   bbox).apply(template_shape)
开发者ID:HaoyangWang,项目名称:menpo3d,代码行数:13,代码来源:fitter.py

示例11: test_pointcloud_init_from_depth_image

def test_pointcloud_init_from_depth_image():
    fake_z = np.random.uniform(size=(10, 10))
    pc = PointCloud.init_from_depth_image(Image(fake_z))
    assert pc.n_points == 100
    assert pc.n_dims == 3
    assert_allclose(pc.range()[:2], [9, 9])
    assert pc.points[:, -1].max() <= 1.0
    assert pc.points[:, -1].min() >= 0.0
开发者ID:JeanKossaifi,项目名称:menpo,代码行数:8,代码来源:pointcloud_test.py

示例12: test_constrain_landmarks_to_bounds

def test_constrain_landmarks_to_bounds():
    im = Image.init_blank((10, 10))
    im.landmarks['test'] = PointCloud.init_2d_grid((20, 20))
    with warnings.catch_warnings():
        warnings.simplefilter('ignore')
        im.constrain_landmarks_to_bounds()
    assert not im.has_landmarks_outside_bounds()
    assert_allclose(im.landmarks['test'].lms.bounds(), im.bounds())
开发者ID:JeanKossaifi,项目名称:menpo,代码行数:8,代码来源:image_basics_test.py

示例13: __init__

    def __init__(self, points, tcoords, texture, trilist=None, copy=True):
        super(TexturedTriMesh, self).__init__(points, trilist=trilist,
                                              copy=copy)
        self.tcoords = PointCloud(tcoords, copy=copy)

        if not copy:
            self.texture = texture
        else:
            self.texture = texture.copy()
开发者ID:Amos-zq,项目名称:menpo,代码行数:9,代码来源:textured.py

示例14: _parse_marker_size

def _parse_marker_size(marker_size, points):
    if marker_size is None:
        from menpo.shape import PointCloud
        pc = PointCloud(points, copy=False)
        # This is the way that mayavi automatically computes the scale factor in
        # case the user passes scale_factor = 'auto'. We use it for both the
        # marker_size as well as the numbers_size.
        xyz_min, xyz_max = pc.bounds()
        x_min, y_min, z_min = xyz_min
        x_max, y_max, z_max = xyz_max
        distance = np.sqrt(((x_max - x_min) ** 2 +
                            (y_max - y_min) ** 2 +
                            (z_max - z_min) ** 2) /
                           (4 * pc.n_points ** 0.33))
        if distance == 0:
            marker_size = 1
        else:
            marker_size = 0.1 * distance
    return marker_size
开发者ID:HaoyangWang,项目名称:menpo3d,代码行数:19,代码来源:viewmayavi.py

示例15: test_pointcloud_init_from_depth_image_masked

def test_pointcloud_init_from_depth_image_masked():
    fake_z = np.random.uniform(size=(10, 10))
    mask = np.zeros(fake_z.shape, dtype=np.bool)
    mask[2:6, 2:6] = True
    im = MaskedImage(fake_z, mask=mask)
    pc = PointCloud.init_from_depth_image(im)
    assert pc.n_points == 16
    assert pc.n_dims == 3
    assert_allclose(pc.range()[:2], [3, 3])
    assert pc.points[:, -1].max() <= 1.0
    assert pc.points[:, -1].min() >= 0.0
开发者ID:JeanKossaifi,项目名称:menpo,代码行数:11,代码来源:pointcloud_test.py


注:本文中的menpo.shape.PointCloud类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。