python如何将多种图片进行拼接融合变成一张图类似全景拍照?
网友回复
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)原图两张:
拼接后的