cropframes.py 文件源码

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

项目:news-shot-classification 作者: gshruti95 项目源码 文件源码
def cropframes(clip_dir, image_files, clip_path):

    clip = clip_path.split('/')[-1]
    clip_name = clip.split('.')[0]

    crop_dir = clip_dir + 'cropped/'
    # crop_dir = '/home/sxg755/dataset/train/all_frames/cropped/'
    if not os.path.exists(crop_dir):
        os.makedirs(crop_dir)

    cropped_files = []
    for idx, image in enumerate(image_files):   
        img = io.imread(image)
        h = img.shape[0]
        w = img.shape[1]
        img_cropped = img[0:4*h/5, 0:w]
        io.imsave(crop_dir + clip_name + '_keyframe' +  "{0:0>4}".format(idx+1) + '.jpg', img_cropped)
        cropped_files.append(crop_dir + clip_name + '_keyframe' +  "{0:0>4}".format(idx+1) + '.jpg')

    return cropped_files
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号