示例#1
0
from menpo.base import partial_doc

from .landmark import asf_importer, pts_importer

asf_image_importer = partial_doc(asf_importer, image_origin=True)

pts_image_importer = partial_doc(pts_importer, image_origin=True)
示例#2
0
    return (
        np.require(
            np.rollaxis(output.reshape((shape[0], shape[1], -1)), -1),
            dtype=np.double,
            requirements=["C"],
        ),
        np.require(centers.reshape((shape[0], shape[1], -1)), dtype=np.int),
    )


# A predefined method for a 'faster' dsift method
fast_dsift = partial_doc(
    dsift,
    fast=True,
    cell_size_vertical=5,
    cell_size_horizontal=5,
    num_bins_horizontal=1,
    num_bins_vertical=1,
    num_or_bins=8,
)


# Predefined dsift that returns a 128d vector
def vector_128_dsift(x, dtype=np.float32):
    r"""
    Computes a SIFT feature vector from a square patch (or image). Patch
    **must** be square and the output vector will *always* be a ``(128,)``
    vector. Please see :func:`dsift` for more information.

    Parameters
    ----------
示例#3
0
文件: base.py 项目: eosulliv/menpo
    extension : `str`
        File extension to support. May be multi-part e.g. '.tar.gz'
    callable : `callable`
        The callable to invoke if a file with the provided extension is
        discovered during importing. Should take a single argument (the
        filepath) and any number of kwargs.
    """
    if not isinstance(extension, basestring):
        raise ValueError("Only string type keys are supported.")
    if extension in ext_map:
        warnings.warn("Replacing an existing importer for the '{}' "
                      "extension.".format(extension))
    ext_map[_normalize_extension(extension)] = callable


register_image_importer = partial_doc(_register_importer, image_types)

register_video_importer = partial_doc(_register_importer, ffmpeg_video_types)

register_landmark_importer = partial_doc(_register_importer,
                                         image_landmark_types)

register_pickle_importer = partial_doc(_register_importer, pickle_types)

menpo_data_dir_path = partial_doc(_data_dir_path, menpo_src_dir_path)

menpo_ls_builtin_assets = partial_doc(_ls_builtin_assets, menpo_data_dir_path)

menpo_data_path_to = partial_doc(_data_path_to, menpo_data_dir_path,
                                 menpo_ls_builtin_assets)
示例#4
0
    Default image texture resolver. Returns **the lexicographically
    sorted first** texture found to have the same stem as the asset. A warning
    is raised if more than one texture is found.
    """
    # pattern finding all landmarks with the same stem
    pattern = path.with_suffix('.*')
    texture_paths = sorted(paths_callable(pattern))
    if len(texture_paths) > 1:
        warnings.warn('More than one texture found for file, returning '
                      'only the first.')
    if not texture_paths:
        return None
    return texture_paths[0]


same_name_landmark = partial_doc(same_name, paths_callable=landmark_file_paths)

menpo3d_data_dir_path = partial_doc(_data_dir_path, menpo3d_src_dir_path)

menpo3d_ls_builtin_assets = partial_doc(_ls_builtin_assets,
                                        menpo3d_data_dir_path)

menpo3d_data_path_to = partial_doc(_data_path_to, menpo3d_data_dir_path,
                                   menpo3d_ls_builtin_assets)

_menpo3d_import_builtin_asset = partial_doc(_import_builtin_asset,
                                            menpo3d_data_path_to,
                                            mesh_types,
                                            mesh_landmark_types,
                                            texture_resolver=same_name_texture)
示例#5
0
            info_str += "  - Fast mode is enabled.\n"
        info_str += "Output image size {}W x {}H x {}.".format(
            int(shape[1]), int(shape[0]), output.shape[0])
        print(info_str)

    # return SIFT and centers in the correct form
    return (np.require(np.rollaxis(output.reshape((shape[0], shape[1], -1)),
                                   -1),
                       dtype=np.double, requirements=['C']),
            np.require(centers.reshape((shape[0], shape[1], -1)),
                       dtype=np.int))


# A predefined method for a 'faster' dsift method
fast_dsift = partial_doc(dsift, fast=True, cell_size_vertical=5,
                         cell_size_horizontal=5, num_bins_horizontal=1,
                         num_bins_vertical=1, num_or_bins=8)


# Predefined dsift that returns a 128d vector
def vector_128_dsift(x, dtype=np.float32):
    r"""
    Computes a SIFT feature vector from a square patch (or image). Patch
    **must** be square and the output vector will *always* be a ``(128,)``
    vector. Please see :func:`dsift` for more information.

    Parameters
    ----------
    x : :map:`Image` or subclass or ``(C, Y, Y)`` `ndarray`
        Either the image object itself or an array with the pixels. The first
        dimension is interpreted as channels. Must be square i.e.
示例#6
0
    extension : `str`
        File extension to support. May be multi-part e.g. '.tar.gz'
    callable : `callable`
        The callable to invoke if a file with the provided extension is
        discovered during importing. Should take a single argument (the
        filepath) and any number of kwargs.
    """
    if not isinstance(extension, basestring):
        raise ValueError('Only string type keys are supported.')
    if extension in ext_map:
        warnings.warn("Replacing an existing importer for the '{}' "
                      "extension.".format(extension))
    ext_map[_normalize_extension(extension)] = callable


register_image_importer = partial_doc(_register_importer, image_types)

register_video_importer = partial_doc(_register_importer, ffmpeg_video_types)

register_landmark_importer = partial_doc(_register_importer,
                                         image_landmark_types)

register_pickle_importer = partial_doc(_register_importer, pickle_types)


menpo_data_dir_path = partial_doc(_data_dir_path, menpo_src_dir_path)

menpo_ls_builtin_assets = partial_doc(_ls_builtin_assets, menpo_data_dir_path)

menpo_data_path_to = partial_doc(_data_path_to, menpo_data_dir_path,
                                 menpo_ls_builtin_assets)
示例#7
0
from menpo.base import partial_doc
from .features import igo

double_igo = partial_doc(igo, double_angles=True)
示例#8
0
    Default image texture resolver. Returns **the lexicographically
    sorted first** texture found to have the same stem as the asset. A warning
    is raised if more than one texture is found.
    """
    # pattern finding all landmarks with the same stem
    pattern = path.with_suffix('.*')
    texture_paths = sorted(paths_callable(pattern))
    if len(texture_paths) > 1:
        warnings.warn('More than one texture found for file, returning '
                      'only the first.')
    if not texture_paths:
        return None
    return texture_paths[0]


same_name_landmark = partial_doc(same_name, paths_callable=landmark_file_paths)

menpo3d_data_dir_path = partial_doc(_data_dir_path, menpo3d_src_dir_path)

menpo3d_ls_builtin_assets = partial_doc(_ls_builtin_assets, 
                                        menpo3d_data_dir_path)

menpo3d_data_path_to = partial_doc(_data_path_to, menpo3d_data_dir_path,
                                   menpo3d_ls_builtin_assets)

_menpo3d_import_builtin_asset = partial_doc(_import_builtin_asset,
                                            menpo3d_data_path_to,
                                            mesh_types, mesh_landmark_types,
                                            texture_resolver=same_name_texture)

from menpo.base import partial_doc

from .landmark import asf_importer, pts_importer


asf_image_importer = partial_doc(asf_importer, image_origin=True)

pts_image_importer = partial_doc(pts_importer, image_origin=True)
示例#10
0
from menpo.base import partial_doc
from .features import igo, hog

double_igo = partial_doc(igo, double_angles=True)
sparse_hog = partial_doc(hog, mode='sparse')