Python-图像拼接神器-stitching

多幅图像的拼接

采用这个包,图像拼接结果很好~

代码只需要三四行

python 复制代码
import stitching
import cv2


imgs = ["data/test02/1Hill.jpg","data/test02/2Hill.jpg","data/test02/3Hill.jpg",]
stitcher = stitching.Stitcher()
panorma = stitcher.stitch(imgs)
cv2.imshow("after",panorma)
cv2.waitKey(0)

测试图片

图片1

图片2

图片3

拼接后的效果图

图像拼接的效果图:

其他优点说明

比如:你想将这三张图片拼接在一起,但是在这里面有混入了一张无关的照片,他还是会拼接的很好;

什么意思呢

具体来说:

我把这四张图片放在一起进行拼接

图片1

图片2

图片3

图片4

将以上四张图片一起拼接会发生什么呢?

这个就是图片拼接后的结果。

代码优化

python 复制代码
# 代码优化
#当你有很多图片要读取时,一个个的在img的列表中写文件名称时,比较繁琐
#因此作出此优化改进

import stitching
import cv2
import glob

def read_images(image_paths):
    images = []
    for image_path in image_paths:
        image = cv2.imread(image_path)
        images.append(image)
    return images

# 图片路径列表
image_paths = glob.glob("data/test01/*.jpg")

# 读取图片
images = read_images(image_paths)

# imgs = ["data/test01/1Hill.jpg","data/test01/1.jpg","data/test01/2.jpg","data/test01/3.jpg"]
stitcher = stitching.Stitcher()
panorma = stitcher.stitch(images)
cv2.imshow("after",panorma)
cv2.waitKey(0)
```python

# 完结撒花
![在这里插入图片描述](https://img-blog.csdnimg.cn/80318465378840cc99aa4777f66bcf3d.png)
相关推荐
码路飞2 小时前
写了个 AI 聊天页面,被 5 种流式格式折腾了一整天 😭
javascript·python
曲幽4 小时前
FastAPI压力测试实战:Locust模拟真实用户并发及优化建议
python·fastapi·web·locust·asyncio·test·uvicorn·workers
敏编程9 小时前
一天一个Python库:jsonschema - JSON 数据验证利器
python
前端付豪9 小时前
LangChain记忆:通过Memory记住上次的对话细节
人工智能·python·langchain
databook9 小时前
ManimCE v0.20.1 发布:LaTeX 渲染修复与动画稳定性提升
python·动效
花酒锄作田1 天前
使用 pkgutil 实现动态插件系统
python
前端付豪1 天前
LangChain链 写一篇完美推文?用SequencialChain链接不同的组件
人工智能·python·langchain
曲幽1 天前
FastAPI实战:打造本地文生图接口,ollama+diffusers让AI绘画更听话
python·fastapi·web·cors·diffusers·lcm·ollama·dreamshaper8·txt2img
老赵全栈实战1 天前
Pydantic配置管理最佳实践(一)
python
阿尔的代码屋1 天前
[大模型实战 07] 基于 LlamaIndex ReAct 框架手搓全自动博客监控 Agent
人工智能·python