opencv的stitcher可以实现
import sys原图两张:
import cv2
if __name__ == "__main__":
img1 = cv2.imread('/img/1.jpg') # 图片绝对路径,
img2 = cv2.imread('/img/2.jpg')
# stitcher = cv2.createStitcher(False) # 老的OpenCV版本,用这一个
stitcher = cv2.Stitcher.create(cv2.Stitcher_PANORAMA) # 我的是OpenCV4
(status, pano) = stitcher.stitch((img1, img2))
if status != cv2.Stitcher_OK:
print("不能拼接图片, error code = %d" % status)
sys.exit(-1)
print("拼接成功.")
cv2.imshow('pano', pano)
# cv2.imwrite("pano.jpg", pano)
cv2.waitKey(0)
拼接后的
网友回复