我尝试过:
import cv2
import numpy as np
import matplotlib.pyplot as plt
top=cv2.imread('top.jpg')
bottom=cv2.imread('bottom.jpg')
numpy_vertical= np.vstack((top, bottom))
cv2.imshow('detected', numpy_vertical)
cv2.imwrite('detected.jpg', numpy_vertical)
ValueError:级联轴的所有输入数组维必须完全匹配,但是沿着维1,索引为0的数组的大小为2878,索引为1的数组的大小为5760]
import cv2
import numpy as np
first = cv2.imread(r"path.... \first.png")
second = cv2.imread(r"path.... \second.png")
h1, w1, c1 = first.shape
h2, w2, c2 = second.shape
h, w= h1+h2, max(w1, w2)
out_image = np.zeros((h,w,c1))
out_image[:h1,:w1, ] = first
out_image[h1:h1+h2,:w2, ] = second
cv2.imwrite(r"path ......out.png", out_image)