多个摄像头画⾯拼接,我们在这⾥是基于python的OpenCV库进⾏拼接;
python = 3.7.0
OpenCV > 3.0
"""
吊车轨导⼊基本库
"""
import os
节能蒸汽炉
import cv2
import imutils
import numpy as np
import imutils
这⾥我们将要拼接的图像放在⼀个⽂件夹⾥⾯,循环读取(笨⽅法); img_dir ='H:\\ruanjain'
names = os.listdir(img_dir)
images =[]
for name in names_2:
img_path = os.path.join(img_dir, name)#路径拼接
image = cv2.imread(img_path)#读取图⽚
images.append(image)
造图像拼接对象stitcher
stitcher = ateStitcher()if imutils.is_cv3()else cv2.Stitcher_create()
把图像列表传⼊.stitch函数,该函数会返回状态和拼接好的全景图 如果图像拼接成功会返回 status = 0,stitched 为拼接成功后的图像
status, stitched = stitcher.stitch(images)
在拼接成功后,我们进⾏图像保存
if status==0:
print(1)
cv2.imwrite('H:\stitch_1.jpg', stitched)
后桥壳
在图像拼接成功后我们可以将图像进⾏拉伸处理,将图像的⾼变回原来图像的“⾼”。这样图像的拼接就成功了;完整代码
import os
import cv2
import imutils
import numpy as np
img_dir ='H://frg'#拼接图像的⽂件夹路劲
names = os.listdir(img_dir)
images =[]
for name in names:
img_path = os.path.join(img_dir, name)展示柜制作
image = cv2.imread(img_path)
#image = size(image,(1919,1078))
images.append(image)
stitcher = ateStitcher()if imutils.is_cv3()else cv2.Stitcher_create() status, stitched = stitcher.stitch(images)
海洋工程船print(status)
if status==0:
枸杞采摘机print(1)
cv2.imwrite('H:\stitch_2.jpg', stitched)#保存拼接图像
特别声明:图⽚来⾃软件杯数据集,如有版权问题,请告知;