create_gif_old.py 文件源码

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

项目:visual_mpc 作者: febert 项目源码 文件源码
def insert_in_frame(file_path, conf):
    t = 1
    imlist = create_video_pixdistrib_gif(file_path, conf, t, suffix='_t{}'.format(t), n_exp=6, suppress_number=True, makegif= False)

    frame = Image.open(file_path + '/frame.png', mode='r')

    writer = imageio.get_writer(file_path + '/genpix_withframe.mp4', fps=3)

    pic_path = file_path + "/animated"
    if not os.path.exists(pic_path):
        os.mkdir(pic_path)

    import copy
    for i, img in enumerate(imlist):
        origsize = img.shape
        img = Image.fromarray(img)
        img = img.resize((origsize[1]*2, origsize[0]*2), Image.ANTIALIAS)
        img = np.asarray(img)

        size_insert = img.shape

        newimg = copy.deepcopy(np.asarray(frame)[:,:,:3])
        if 'ndesig' in conf:
            startr = 350
        else:
            startr = 380
        startc = 295
        newimg[startr :startr + size_insert[0],startc: startc + size_insert[1]] = img
        # Image.fromarray(newimg).show()

        writer.append_data(newimg)
        Image.fromarray(newimg).save(pic_path + '/img{}.png'.format(i))

    writer.close()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号