def put_genpix_in_frame():
file = '/home/guser/catkin_ws/src/lsdc/tensorflow_data/sawyer/dna_correct_nummask/vid_rndaction_var10_66002_diffmotions_b0_l30.gif'
frames_dna = getFrames(file)
file = '/home/guser/catkin_ws/src/lsdc/tensorflow_data/sawyer/1stimg_bckgd_cdna/vid_rndaction_var10_64002_diffmotions_b0_l30.gif'
frames_cdna = getFrames(file)
t = 1
dest_path = '/home/guser/frederik/doc_video'
frame = Image.open(dest_path + '/frame_comp_oadna.png', mode='r')
writer = imageio.get_writer(dest_path + '/genpix_withframe.mp4', fps=3)
pic_path = dest_path + "/animated"
if not os.path.exists(pic_path):
os.mkdir(pic_path)
for i, img_dna, img_cdna in zip(range(len(frames_dna)), frames_dna, frames_cdna):
newimg = copy.deepcopy(np.asarray(frame)[:, :, :3])
img_dna, size_insert = resize(img_dna)
# Image.fromarray(img_dna)
startr = 230
startc = 650
newimg[startr:startr + size_insert[0], startc: startc + size_insert[1]] = img_dna
img_cdna, size_insert = resize(img_cdna)
# Image.fromarray(img_cdna)
startr = 540
startc = 650
newimg[startr:startr + size_insert[0], startc: startc + size_insert[1]] = img_cdna
writer.append_data(newimg)
Image.fromarray(newimg).save(pic_path + '/img{}.png'.format(i))
writer.close()
评论列表
文章目录