【发布时间】:2020-07-15 05:33:03
【问题描述】:
我使用 python 将 5576 个图像组合成一个 30 fps 的视频。
我尝试了许多在互联网上发布的代码,但我总是收到此错误。
Process finished with exit code 137 (interrupted by signal 9: SIGKILL)
我查看操作系统正在杀死我的进程。
我正在使用 ubuntu、pycharm、python3.8 64 位。
import time
import cv2
import numpy as np
import glob
import re
#Natural key for natural sort
def atoi(text):
return int(text) if text.isdigit() else text
def natural_keys(text):
return [ atoi(c) for c in re.split(r'(\d+)', text) ]
li = []
for filename in glob.glob('det/*.jpg'):
li.append(filename)
li.sort(key=natural_keys)
img_array = []
for filename in li:
img = cv2.imread(filename)
height, width, layers = img.shape
size = (width, height)
img_array.append(img)
time.sleep(0.1)
print(f"Frame #{filename}")
out = cv2.VideoWriter('Video/label_vid.avi', cv2.VideoWriter_fourcc(*'DIVX'), 30, size)
for i in range(len(img_array)):
out.write(img_array[i])
out.release()
【问题讨论】:
标签: python python-3.x opencv image-processing video