使用 opencv 由灰度图像组成的视频显示了一小部分帧和线
Video made up from grayscale images using opencv, shows a fraction of frames and lines
我有一系列灰度图像。使用 python opencv 代码,我用这些灰度图像制作了一个视频。
import cv2
import numpy as np
A = readimages(img_path) # A is a list of uint8 images of size similar to framesize
framesize = (480,640)
out = cv2.VideoWriter('output_video.avi',cv2.VideoWriter_fourcc('M','J','P','G'), 30.0, framesize, isColor = False)
for img in A:
out.write(cv2.flip(img,0))
out.release()
如下图(左侧部分)所示的结果视频仅显示了输入图像的一小部分以及多行。请任何帮助。
在这种情况下,图像数据类型必须为 uint8,才能写入视频文件。新代码工作正常。
import cv2
import numpy as np
A = readimages(img_path) # A is a list of uint8 images of size similar to framesize
framesize = (480,640)
out = cv2.VideoWriter('output_video.avi',cv2.VideoWriter_fourcc('M','J','P','G'), 30.0, framesize, isColor = False)
for img in A:
out.write(img.astype('uint8'))
out.release()
我有一系列灰度图像。使用 python opencv 代码,我用这些灰度图像制作了一个视频。
import cv2
import numpy as np
A = readimages(img_path) # A is a list of uint8 images of size similar to framesize
framesize = (480,640)
out = cv2.VideoWriter('output_video.avi',cv2.VideoWriter_fourcc('M','J','P','G'), 30.0, framesize, isColor = False)
for img in A:
out.write(cv2.flip(img,0))
out.release()
如下图(左侧部分)所示的结果视频仅显示了输入图像的一小部分以及多行。请任何帮助。
在这种情况下,图像数据类型必须为 uint8,才能写入视频文件。新代码工作正常。
import cv2
import numpy as np
A = readimages(img_path) # A is a list of uint8 images of size similar to framesize
framesize = (480,640)
out = cv2.VideoWriter('output_video.avi',cv2.VideoWriter_fourcc('M','J','P','G'), 30.0, framesize, isColor = False)
for img in A:
out.write(img.astype('uint8'))
out.release()