utils_tests.py 文件源码

python
阅读 44 收藏 0 点赞 0 评论 0

项目:object-detector 作者: penny4860 项目源码 文件源码
def test_crop_random():
    # Given one sample image and the following parameters
    image = helpers.get_one_sample_image()
    parameters = {"dst_size" : (20, 20),
        "n_patches" : 5,
    }

    # When perform crop_random()
    patches = utils.crop_random(image, parameters["dst_size"], parameters["n_patches"])

    # Then every patch should be included in an image.
    match_cost = []
    for patch in patches:
        M = cv2.matchTemplate(image, patch, cv2.TM_SQDIFF)
        min_cost, _, _, _ = cv2.minMaxLoc(M)
        match_cost.append(min_cost)
    assert np.array(match_cost).all() == 0, "utils.crop_random() unit test failed!!"
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号