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

Python transform.UniformScale类代码示例

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

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



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

示例1: detect

def detect(detector_callable, image, greyscale=True, image_diagonal=None, group_prefix="object", channels_at_back=True):
    r"""
    Apply the general detection framework.

    This involves converting the image to greyscale if necessary, rescaling
    the image to a given diagonal, performing the detection, and attaching
    the scaled landmarks back onto the original image.

    uint8 images cannot be converted to greyscale by this framework, so must
    already be greyscale or ``greyscale=False``.

    Parameters
    ----------
    detector_callable : `callable` or `function`
        A callable object that will perform detection given a single parameter,
        a `uint8` numpy array with either no channels, or channels as the
        *last* axis.
    image : `menpo.image.Image`
        A Menpo image to detect. The bounding boxes of the detected objects
        will be attached to this image.
    greyscale : `bool`, optional
        Convert the image to greyscale or not.
    image_diagonal : `int`, optional
        The total size of the diagonal of the image that should be used for
        detection. This is useful for scaling images up and down for detection.
    group_prefix : `str`, optional
        The prefix string to be appended to each each landmark group that is
        stored on the image. Each detection will be stored as group_prefix_#
        where # is a count starting from 0.
    channels_at_back : `bool`, optional
        If ``True``, the image channels are placed onto the last axis (the back)
        as is common in many imaging packages. This is contrary to the Menpo
        default where channels are the first axis (at the front).

    Returns
    -------
    bounding_boxes : `list` of `menpo.shape.PointDirectedGraph`
        A list of bounding boxes representing the detections found.
    """
    d_image = image

    if greyscale:
        d_image = _greyscale(d_image)

    if image_diagonal is not None:
        scale_factor = image_diagonal / image.diagonal()
        d_image = d_image.rescale(scale_factor)

    pcs = detector_callable(menpo_image_to_uint8(d_image, channels_at_back=channels_at_back))

    if image_diagonal is not None:
        s = UniformScale(1 / scale_factor, n_dims=2)
        pcs = [s.apply(pc) for pc in pcs]

    padding_magnitude = len(str(len(pcs)))
    for i, pc in enumerate(pcs):
        key = "{prefix}_{num:0{mag}d}".format(mag=padding_magnitude, prefix=group_prefix, num=i)
        image.landmarks[key] = pc
    return pcs
开发者ID:menpo,项目名称:menpodetect,代码行数:59,代码来源:detect.py


示例2: test_uniformscale_2d_pseudoinverse

def test_uniformscale_2d_pseudoinverse():
    scale = 0.5
    homo = np.array([[scale, 0, 0],
                     [0, scale, 0],
                     [0, 0, 1]])

    tr = UniformScale(2, 2)
    assert_almost_equal(tr.pseudoinverse().h_matrix, homo)
开发者ID:HaoyangWang,项目名称:menpo,代码行数:8,代码来源:h_scale_test.py


示例3: test_align_2d_uniform_scale_set_h_matrix_raises_notimplemented_error

def test_align_2d_uniform_scale_set_h_matrix_raises_notimplemented_error():
    scale = UniformScale(2.5, 2)
    source = PointCloud(np.array([[0, 1], [1, 1], [-1, -5], [3, -5]]))
    target = scale.apply(source)
    # estimate the transform from source and source
    estimate = AlignmentUniformScale(source, source)
    # and set the target
    estimate.set_h_matrix(scale.h_matrix)
开发者ID:kritsong,项目名称:menpo,代码行数:8,代码来源:h_align_test.py


示例4: test_align_2d_uniform_scale

def test_align_2d_uniform_scale():
    scale = UniformScale(2.5, 2)
    source = PointCloud(np.array([[0, 1], [1, 1], [-1, -5], [3, -5]]))
    target = scale.apply(source)
    # estimate the transform from source and target
    estimate = AlignmentUniformScale(source, target)
    # check the estimates is correct
    assert_allclose(scale.h_matrix, estimate.h_matrix)
开发者ID:kritsong,项目名称:menpo,代码行数:8,代码来源:h_align_test.py


示例5: test_uniformscale3d_from_vector

def test_uniformscale3d_from_vector():
    scale = 2
    homo = np.array([[scale, 0, 0, 0],
                     [0, scale, 0, 0],
                     [0, 0, scale, 0],
                     [0, 0, 0, 1]])

    uniform_scale = UniformScale(1, 3)
    tr = uniform_scale.from_vector(scale)
    assert_equal(tr.h_matrix, homo)
开发者ID:AshwinRajendraprasad,项目名称:menpo,代码行数:10,代码来源:test_homogeneous.py


示例6: test_uniformscale2d_update_from_vector

def test_uniformscale2d_update_from_vector():
    # make a uniform scale of 1, 2 dimensional
    uniform_scale = UniformScale(1, 2)
    new_scale = 2
    homo = np.array([[new_scale, 0, 0],
                     [0, new_scale, 0],
                     [0, 0, 1]])

    uniform_scale._from_vector_inplace(new_scale)
    assert_equal(uniform_scale.h_matrix, homo)
开发者ID:AshwinRajendraprasad,项目名称:menpo,代码行数:10,代码来源:test_homogeneous.py


示例7: test_homog_compose_before_alignment_nonuniformscale

def test_homog_compose_before_alignment_nonuniformscale():
    homog = Homogeneous(np.array([[0, 1, 0],
                                  [1, 0, 0],
                                  [0, 0, 1]]))
    scale = UniformScale(2.5, 2)
    source = PointCloud(np.array([[0, 1],
                                  [1, 1],
                                  [-1, -5],
                                  [3, -5]]))
    target = scale.apply(source)
    # estimate the transform from source and target
    s = AlignmentUniformScale(source, target)
    res = homog.compose_before(s)
    assert(type(res) == Homogeneous)
开发者ID:AshwinRajendraprasad,项目名称:menpo,代码行数:14,代码来源:test_h_compose.py


示例8: test_uniformscale_set_h_matrix_raises_notimplementederror

def test_uniformscale_set_h_matrix_raises_notimplementederror():
    s = UniformScale(2, 3)
    s.set_h_matrix(s.h_matrix)
开发者ID:dubzzz,项目名称:menpo,代码行数:3,代码来源:homogeneous_test.py


示例9: test_uniformscale_compose_after_translation

def test_uniformscale_compose_after_translation():
    t = Translation([3, 4])
    s = UniformScale(2, 2)
    res = s.compose_after(t)
    assert(type(res) == Similarity)
开发者ID:AshwinRajendraprasad,项目名称:menpo,代码行数:5,代码来源:test_h_compose.py


示例10: test_uniformscale_identity_3d

def test_uniformscale_identity_3d():
    assert_allclose(UniformScale.init_identity(3).h_matrix, np.eye(4))
开发者ID:HaoyangWang,项目名称:menpo,代码行数:2,代码来源:h_scale_test.py


示例11: test_uniformscale_identity_2d

def test_uniformscale_identity_2d():
    assert_allclose(UniformScale.identity(2).h_matrix, np.eye(3))
开发者ID:Amos-zq,项目名称:menpo,代码行数:2,代码来源:h_scale_test.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python visualize.print_dynamic函数代码示例发布时间:2022-05-27
下一篇:
Python transform.Translation类代码示例发布时间: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