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


Python io.export_landmark_file函数代码示例

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


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

示例1: test_export_landmark_ljson

def test_export_landmark_ljson(mock_open, exists, json_dump):
    exists.return_value = False
    fake_path = '/fake/fake.ljson'
    with open(fake_path) as f:
        type(f).name = PropertyMock(return_value=fake_path)
        mio.export_landmark_file(test_lg, f, extension='ljson')
    json_dump.assert_called_once()
开发者ID:ersisimou,项目名称:menpo,代码行数:7,代码来源:io_export_test.py

示例2: test_export_landmark_pts

def test_export_landmark_pts(mock_open, exists, save_txt):
    exists.return_value = False
    fake_path = '/fake/fake.pts'
    with open(fake_path) as f:
        type(f).name = PropertyMock(return_value=fake_path)
        mio.export_landmark_file(test_lg, f, extension='pts')
    save_txt.assert_called_once()
开发者ID:ersisimou,项目名称:menpo,代码行数:7,代码来源:io_export_test.py

示例3: test_export_filepath_no_overwrite

def test_export_filepath_no_overwrite(mock_open, exists, landmark_types):
    exists.return_value = False
    mio.export_landmark_file(test_lg, fake_path)
    mock_open.assert_called_once_with("wb")
    landmark_types.__getitem__.assert_called_once_with(".fake")
    export_function = landmark_types.__getitem__.return_value
    export_function.assert_called_once()
开发者ID:luukhoavn,项目名称:menpo,代码行数:7,代码来源:io_export_test.py

示例4: test_export_filepath_no_overwrite

def test_export_filepath_no_overwrite(mock_open, exists, landmark_types):
    exists.return_value = False
    mio.export_landmark_file(test_lg, fake_path)
    mock_open.assert_called_with('wb')
    landmark_types.__getitem__.assert_called_with('.fake')
    export_function = landmark_types.__getitem__.return_value
    assert export_function.call_count == 1
开发者ID:HaoyangWang,项目名称:menpo,代码行数:7,代码来源:io_export_test.py

示例5: test_export_filepath_overwrite_exists

def test_export_filepath_overwrite_exists(mock_open, exists, landmark_types):
    exists.return_value = True
    mio.export_landmark_file(test_lg, fake_path, overwrite=True)
    mock_open.assert_called_once_with('wb')
    landmark_types.__getitem__.assert_called_once_with('.fake')
    export_function = landmark_types.__getitem__.return_value
    export_function.assert_called_once()
开发者ID:ersisimou,项目名称:menpo,代码行数:7,代码来源:io_export_test.py

示例6: test_export_filepath_explicit_ext_dot

def test_export_filepath_explicit_ext_dot(mock_open, exists, landmark_types):
    exists.return_value = False
    mio.export_landmark_file(test_lg, fake_path, extension='.fake')
    mock_open.assert_called_once_with('wb')
    landmark_types.__getitem__.assert_called_once_with('.fake')
    export_function = landmark_types.__getitem__.return_value
    export_function.assert_called_once()
开发者ID:ersisimou,项目名称:menpo,代码行数:7,代码来源:io_export_test.py

示例7: test_export_file_handle_file_non_file_buffer

def test_export_file_handle_file_non_file_buffer(mock_open, exists, landmark_types):
    exists.return_value = False
    with open(fake_path) as f:
        del f.name  # Equivalent to raising an AttributeError side effect
        mio.export_landmark_file(test_lg, f, extension="fake")
    landmark_types.__getitem__.assert_called_once_with(".fake")
    export_function = landmark_types.__getitem__.return_value
    export_function.assert_called_once()
开发者ID:luukhoavn,项目名称:menpo,代码行数:8,代码来源:io_export_test.py

示例8: test_export_file_handle_file_exists_overwrite

def test_export_file_handle_file_exists_overwrite(mock_open, exists, landmark_types):
    exists.return_value = True
    with open(fake_path) as f:
        type(f).name = PropertyMock(return_value=fake_path)
        mio.export_landmark_file(test_lg, f, overwrite=True, extension="fake")
    landmark_types.__getitem__.assert_called_once_with(".fake")
    export_function = landmark_types.__getitem__.return_value
    export_function.assert_called_once()
开发者ID:luukhoavn,项目名称:menpo,代码行数:8,代码来源:io_export_test.py

示例9: test_export_filepath_explicit_ext_no_dot

def test_export_filepath_explicit_ext_no_dot(mock_open, exists, landmark_types):
    exists.return_value = False
    landmark_types.__contains__.return_value = True
    mio.export_landmark_file(test_lg, fake_path, extension='fake')
    mock_open.assert_called_with('wb')
    landmark_types.__getitem__.assert_called_with('.fake')
    export_function = landmark_types.__getitem__.return_value
    assert export_function.call_count == 1
开发者ID:grigorisg9gr,项目名称:menpo,代码行数:8,代码来源:io_export_test.py

示例10: test_export_file_handle_file_non_file_buffer

def test_export_file_handle_file_non_file_buffer(mock_open, exists,
                                                 landmark_types):
    exists.return_value = False
    landmark_types.__contains__.return_value = True
    with open(fake_path) as f:
        del f.name  # Equivalent to raising an AttributeError side effect
        mio.export_landmark_file(test_lg, f, extension='fake')
    landmark_types.__getitem__.assert_called_with('.fake')
    export_function = landmark_types.__getitem__.return_value
    assert export_function.call_count == 1
开发者ID:grigorisg9gr,项目名称:menpo,代码行数:10,代码来源:io_export_test.py

示例11: test_export_file_handle_file_exists_overwrite

def test_export_file_handle_file_exists_overwrite(mock_open, exists,
                                                  landmark_types):
    exists.return_value = True
    landmark_types.__contains__.return_value = True
    with open(fake_path) as f:
        type(f).name = PropertyMock(return_value=fake_path)
        mio.export_landmark_file(test_lg, f, overwrite=True, extension='fake')
    landmark_types.__getitem__.assert_called_with('.fake')
    export_function = landmark_types.__getitem__.return_value
    assert export_function.call_count == 1
开发者ID:grigorisg9gr,项目名称:menpo,代码行数:10,代码来源:io_export_test.py

示例12: test_export_landmark_ljson_nan_values

def test_export_landmark_ljson_nan_values(mock_open, exists):
    exists.return_value = False
    mock_writer = MagicMock()
    mock_open.return_value.__enter__.return_value = mock_writer
    fake_path = '/fake/fake.ljson'
    with open(fake_path) as f:
        type(f).name = PropertyMock(return_value=fake_path)
        mio.export_landmark_file(nan_lg, f, extension='ljson')

    # yeah this is grim, but it should work.
    assert 'null' in '{}'.format(mock_open.mock_calls)
开发者ID:grigorisg9gr,项目名称:menpo,代码行数:11,代码来源:io_export_test.py

示例13: test_export_landmark_ljson_nan_values

def test_export_landmark_ljson_nan_values(mock_open, exists):
    exists.return_value = False
    fake_path = '/fake/fake.ljson'
    with open(fake_path) as f:
        type(f).name = PropertyMock(return_value=fake_path)
        mio.export_landmark_file(nan_lg, f, extension='ljson')

    # This is a bit ugly, but we parse the write calls to check that json
    # wrote null values
    first_null = mock_open.mock_calls[97][1][0][1:].strip()
    second_null = mock_open.mock_calls[98][1][0][1:].strip()
    assert first_null == 'null'
    assert second_null == 'null'
开发者ID:ersisimou,项目名称:menpo,代码行数:13,代码来源:io_export_test.py

示例14: process_frame

def process_frame(frame_name, clip, img_type, svm_p, loop=False):
    """
    Applies the AAM fitter (global var) in a frame. Additionally, it might apply an
    SVM to verify it's a face if required.
    :param frame_name: str: Name of the frame along with extension, e.g. '000001.png'.
    :param clip:       str: Name of the clip.
    :param img_type:   str: Suffix (extension) of the frames, e.g. '.png'.
    :param svm_p:      dict: Required params for SVM classification.
    :param loop:       bool: (optional) Declares whether this is a 2nd fit for AAM (loop).
    :return:
    """
    global fitter
    name = frame_name[:frame_name.rfind('.')]
    p0 = clip.path_read_ln[0] + name + '_0.pts'
    # find if this is 2nd fit or 1st.
    if loop:  # if 2nd fit, then if landmark is 'approved', return. Otherwise proceed.
        try:
            ln = import_landmark_file(p0)
            copy2(p0, clip.path_write_ln[0] + name + '_0.pts')
            return      # if the landmark already exists, return (for performance improvement)
        except ValueError:
            pass
        try:
            ln = import_landmark_file(clip.path_read_ln[1] + name + '_0.pts')
        except ValueError:  # either not found or no suitable importer
            return
    else:
        try:
            ln = import_landmark_file(p0)
        except ValueError:  # either not found or no suitable importer
            return
    im = im_read_greyscale(frame_name, clip.path_frames, img_type)
    if not im:
        return
    im.landmarks['PTS2'] = ln
    fr = fitter.fit_from_shape(im, im.landmarks['PTS2'].lms, crop_image=0.3)
    p_wr = clip.path_write_ln[0] + im.path.stem + '_0.pts'
    export_landmark_file(fr.fitted_image.landmarks['final'], p_wr, overwrite=True)

    # apply SVM classifier by extracting patches (is face or not).
    if not svm_p['apply']:
        return
    im.landmarks.clear()  # temp solution
    im.landmarks['ps_pbaam'] = fr.fitted_image.landmarks['final']
    im_cp = im.crop_to_landmarks_proportion(0.2, group='ps_pbaam')
    im_cp = svm_p['feat'](im_cp)
    im2 = warp_image_to_reference_shape(im_cp, svm_p['refFrame'], 'ps_pbaam')
    _p_nd = im2.extract_patches_around_landmarks(group='source', as_single_array=True,
                                                 patch_shape=svm_p['patch_s']).flatten()
    if svm_p['clf'].decision_function(_p_nd) > 0:
        copy2(p_wr, clip.path_write_ln[1] + im.path.stem + '_0.pts')
开发者ID:caomw,项目名称:robust_deformable_face_tracking,代码行数:51,代码来源:ps_pbaam.py

示例15: detect_in_frame

def detect_in_frame(frame_name, clip, img_type):
    # if normalise=True in im_read_greyscale: before calling dlib detector, image should be converted to uint8
    im = im_read_greyscale(frame_name, clip.path_frames, img_type, normalise=False)
    if not im:
        print(frame_name, clip.path_frames)
        return
    res_dlib = dlib_init_detector(im, group_prefix='dlib')  # call dlib detector
    im_pili = np.array(im.as_PILImage())
    for kk, g in enumerate(im.landmarks.group_labels):
        pts_end = im.path.stem + '_' + str(kk) + pts_type_out  # define the ending of each pts that will be exported
        export_landmark_file(im.landmarks[g], clip.path_write_ln[0] + pts_end, overwrite=True)
        # from bounding box to points (dlib predictor)
        init_pc = detection_to_pointgraph(predictor_dlib(im_pili, pointgraph_to_rect(im.landmarks[g].lms)))
        export_landmark_file(LandmarkGroup.init_with_all_label(init_pc), clip.path_write_ln[1] + pts_end, overwrite=True)
开发者ID:caomw,项目名称:robust_deformable_face_tracking,代码行数:14,代码来源:dlib_predictor.py


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