我正在使用Python cv2包处理视频帧(mp4)。对于图像处理,我使用moviepy.editor.VideoFileClip的方法fl_image
。但是,当我以jpg格式保存提取的帧,然后使用matplotlib.image
重新打开它时,加载的图像中有一个小的差异。这两种方法只需取加载图像的平均值即可看出
我想知道为什么两个加载的图像略有不同。这在逐帧处理视频剪辑时造成了一些问题
sampleImage = mpimg.imread("sample-01.jpg")
print("sampleImage", np.mean(sampleImage))
# sampleImage is extracted from the video, say the last frame of the subClip1, and already saved using method imsave
# result
# sampleImage 115.64719075520833
# using the other method
def processFrameImage(image):
print("sampleImage", np.mean(image))
result = extractFeatures(image)
return result
clip1 = VideoFileClip("sample-video.mp4")
subClip1 = clip1.subclip(t_start=0.0, t_end=0.1)
whiteClip = subClip1.fl_image(processFrameImage)
# result
# sampleImage 115.64437065972223
请注意上述打印结果之间的差异
目前没有回答
相关问题 更多 >
编程相关推荐