用于对比YOLO视频检测出来的实验结果
import cv2
import numpy as np
if __name__ == '__main__':
source1 = "video/test1.mp4"
source2 = "video/test2.mp4"
RESULT_PATH = 'result.mp4'
vidcap1 = cv2.VideoCapture(source1)
vidcap2 = cv2.VideoCapture(source2)
success1, image1 = vidcap1.read()
success2, image2 = vidcap2.read()
videoWriter = None
count = 0
while success2 and success1:
image = np.concatenate([image1, image2], axis=1)
cv2.putText(image1, source1, (5,50), 0, 0.5, [225, 255, 255], thickness=1, lineType=cv2.LINE_AA)
cv2.putText(image2, source2, (5,50), 0, 0.5, [225, 255, 255], thickness=1, lineType=cv2.LINE_AA)
if videoWriter is None:
fourcc = cv2.VideoWriter_fourcc('m', 'p', '4', 'v')
videoWriter = cv2.VideoWriter(
RESULT_PATH, fourcc, 30, (image.shape[1], image.shape[0]))
videoWriter.write(image)
success1, image1 = vidcap1.read()
success2, image2 = vidcap2.read()
count += 1
videoWriter.release()
vidcap1.release()
vidcap2.release()