【发布时间】:2021-07-08 16:20:54
【问题描述】:
我想在图像底部添加两个图。它应该是这样的:
dog
plot(两个图看起来非常相似)
我想将这两张图片结合在一起,专门将情节附加到狗图片的底部。我希望结果看起来像:
此链接有助于将绘图转换为正确的图像格式,但我不知道如何将它们附加到主图像
Combining cv2.imshow() with matplotlib plt.show() in real time
编辑
高级伪代码:
import cv2
import pandas
import matplotlib.pyplot as plt
vid = cv2.VideoCapture('video.mp4')
global data
data = pd.read_csv('data.csv')
assert len(data) == cv2.CAP_PROP_FRAMES_COUNT()
def pipeline(frame):
frame_index = next(dfi[0])
current_plot1 = plt.plot(df.time[:frame_index], df.data1[:frame_index]
current_plot2 = plt.plot(df.time[:frame_index], df.data2[:frame_index]
# add plots to frame somehow here
frame = frame+current_plot1+current_plot2
return frame
# write video
dfi = df.iterrows()
video = VideoFileClip(vid)
out_video = video.fl_image(pipeline)
out_video.write_videofile("vidout.mp4", temp_audiofile='temp-audio.m4a', remove_temp=True, codec="libx264", audio_codec="aac")
【问题讨论】:
-
opencv 图像会更新还是静态的?如果它是静态的,你可以做一个简单的
imshow,那么你可以像这样安排它们:matplotlib.org/stable/tutorials/intermediate/… -
理想情况下它可以更新。我的总体目标是制作一个视频,其中狗的图像是许多帧中的 1 个,并且情节会根据每帧的附加数据进行更新。
-
对不起,如果我听起来很愚蠢,所以你想把
cv2.imshow创建两个底部图并动态更新它们的窗口放入?还是从cv2中捕获的图像/帧到matplotlib中的几个帧,最后用预处理数据创建一个电影? -
别担心,我更新了一些伪代码以提供高级概述
标签: python image opencv matplotlib image-processing