• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python shape.PointCloud类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: tojson

    def tojson(self):
        r"""
        Convert this `TriMesh` to a dictionary JSON representation.

        Returns
        -------
        dictionary with 'points' and 'trilist' keys. Both are lists suitable
        for use in the by the `json` standard library package.
        """
        json_dict = PointCloud.tojson(self)
        json_dict['trilist'] = self.trilist.tolist()
        return json_dict
开发者ID:dubzzz,项目名称:menpo,代码行数:12,代码来源:base.py


示例17: test_register_landmark_importer

def test_register_landmark_importer(is_file):
    from menpo.shape import PointCloud
    lmark = PointCloud.init_2d_grid((1, 1))

    def foo_importer(filepath, **kwargs):
        return lmark

    is_file.return_value = True

    with patch.dict(mio.input.extensions.image_landmark_types, {}, clear=True):
        mio.register_landmark_importer('.foo', foo_importer)
        new_lmark = mio.import_landmark_file('fake.foo')
    assert lmark is new_lmark
开发者ID:grigorisg9gr,项目名称:menpo,代码行数:13,代码来源:io_import_test.py


示例18: mean_pointcloud

def mean_pointcloud(pointclouds):
    r"""
    Compute the mean of a `list` of :map:`PointCloud` or subclass objects.
    The list is assumed to be homogeneous i.e all elements of the list are
    assumed to belong to the same point cloud subclass just as all elements
    are also assumed to have the same number of points and represent
    semantically equivalent point clouds.

    Parameters
    ----------
    pointclouds: `list` of :map:`PointCloud` or subclass
        List of point cloud or subclass objects from which we want to compute
        the mean.

    Returns
    -------
    mean_pointcloud : :map:`PointCloud` or subclass
        The mean point cloud or subclass.
    """
    # make a temporary PointCloud (with copy=False for low overhead)
    tmp_pc = PointCloud(sum(pc.points for pc in pointclouds) /
                        len(pointclouds), copy=False)
    # use the type of the first element in the list to rebuild from the vector
    return pointclouds[0].from_vector(tmp_pc.as_vector())
开发者ID:AshwinRajendraprasad,项目名称:menpo,代码行数:24,代码来源:groupops.py


示例19: test_pointcloud_has_nan_values

def test_pointcloud_has_nan_values():
    pcloud = PointCloud(np.random.rand(3, 2), copy=False)
    pcloud.points[0, 0] = np.nan
    assert pcloud.has_nan_values()
开发者ID:JeanKossaifi,项目名称:menpo,代码行数:4,代码来源:pointcloud_test.py


示例20: test_pointcloud_init_2d_grid_incorrect_type_spacing_raises

def test_pointcloud_init_2d_grid_incorrect_type_spacing_raises():
    PointCloud.init_2d_grid([10, 10], spacing={})
开发者ID:JeanKossaifi,项目名称:menpo,代码行数:2,代码来源:pointcloud_test.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python shape.PointUndirectedGraph类代码示例发布时间:2022-05-27
下一篇:
Python shape.LabelledPointUndirectedGraph类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap