how to combine 2 videos in opencv code example
Example 1: opencv combine video
# creates the resulting image with double the size and 3 channels
output = np.zeros((w+h+h , w + h + h, 3), dtype="uint8")
# top img
output[0:h, h:h+w] = img
# left img (rotated 90°)
output[h:h+w, 0:h] = np.rot90(img,1)
# right img (rotated 270°)
output[h:h + w, h + w:h +w +h] = np.rot90(img,3)
# bottom img (rotated 180°)
output[h+w:h+w+h, h:h+w] = np.rot90(img,2)
Example 2: opencv combine video
import cv2
import numpy as np
#loads images and gets data
img = cv2.imread("img.png")
h,w,_ = img.shape
# creates the resulting image with double the size and 3 channels
output = np.zeros((h * 2, w * 2, 3), dtype="uint8")
# copies the image to the top left
output[0:h, 0:w] = img
# copies the image to the top right
output[0:h, w:w * 2] = img
# copies the image to the bottom left
output[h:h * 2, w:w * 2] = img
# copies the image to the bottom right
output[h:h * 2, 0:w] = img