【opencv-python 使用stitcher.stitch进行全景的拼接】将多张图片拼接成全景,采用了stitcher.stitch

效果

左边两张为拼接前,右边为拼接后
【opencv-python 使用stitcher.stitch进行全景的拼接】将多张图片拼接成全景,采用了stitcher.stitch_第1张图片

关键函数

stitcher = cv2.Stitcher.create()
(status,res) =stitcher.stitch(imglist)

代码

import os
import cv2

imgdir = 'fullview'
imgnamelist =  os.listdir(imgdir)
print(imgnamelist)
imglist=[]
for imgmane in imgnamelist:
    path = imgdir+'/'+imgmane
    img = cv2.imread(path)
    #对图片进行缩放
    img = cv2.resize(img,(0,0),None,0.5,0.5)
    cv2.imshow(imgmane,img)
    cv2.waitKey(1)
    imglist.append(img)
    
stitcher = cv2.Stitcher.create()
(status,res) = stitcher.stitch(imglist)
if(status == cv2.STITCHER_OK):
    print('successful')
    cv2.imshow('res',res)
else:
    print('fail')
cv2.waitKey(0)

你可能感兴趣的:(opencv,opencv,python,计算机视觉,人工智能,图像处理)