Python-基于OpenCV多画面全景拼接

Python-基于OpenCV多画⾯全景拼接
如何将多张图像进⾏拼接?
如何对将⼀个画⾯全景图复原出来?
多个摄像头画⾯拼接,我们在这⾥是基于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)#保存拼接图像
特别声明:图⽚来⾃软件杯数据集,如有版权问题,请告知;

本文发布于:2024-09-22 19:43:38,感谢您对本站的认可!

本文链接:https://www.17tex.com/tex/1/228101.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:图像   拼接   返回   件夹   复原   轨导   问题
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2024 Comsenz Inc.Powered by © 易纺专利技术学习网 豫ICP备2022007602号 豫公网安备41160202000603 站长QQ:729038198 关于我们 投诉建议