BROWN大神03'ICCV和07'IJCV的AutoStitch AutoStitch对于图像拼接效果很好,已经非常成熟,各路拼接软件和应用都纷纷落地,Opencv中也实现了该算法。python调用测试如下:
from __future__ import print_function
import cv2 as cv
import numpy as np
import argparse
import sys
output = 'result3.jpg'
txtpath = 'txtlists/files3.txt' #文档中保存图像的存储路径
fp = open(txtpath, 'r')
filenames = [each.rstrip('\r\n') for each in fp.readlines()]
print(filenames)
imgs = []
for img_name in filenames:
img = cv.imread(img_name)
if img is None:
print("can't read image " + img_name)
sys.exit(-1)
imgs.append(img)
stitcher = cv.createStitcher(cv.Stitcher_PANORAMA) #cv.Stitcher_SCANS
status, pano = stitcher.stitch(imgs)
if status != cv.Stitcher_OK:
print("Can't stitch images, error code = %d" % status)
sys.exit(-1)
cv.imwrite(output, pano);
print("stitching completed successfully. %s saved!" % output)