python 图像拼接
import cv2 import math import os # 文件夹所有图片 path = "Images/ROIRun" images = [] for filename in os.listdir(path): # listdir的参数是文件夹的路径 filenames = path + '\\' + filename # print(filenames) img_orig = cv2.imread(filenames, 1) print(filenames) if img_orig is None: print("Warning: No Pictures") else: images.append(img_orig) # 初始化OpenCV的图像sticher对象,然后执行图像拼接 print("[INFO] stitching images.........................") # stitcher = cv2.createStitcher() if imutils.is_cv3() else cv2.Stitcher_create() stitcher = cv2.Stitcher_create() (status, stitched) = stitcher.stitch(images) # print(status, stitched) # 如果状态为“0”,则OpenCV成功执行图像拼接 # if the status is '0', then OpenCV successfully performed image stitching if status == 0: # write the output stitched image to disk cv2.imwrite("Images/stitch.jpg", stitched) # display the output stitched image to our screen cv2.imshow("Stitched", stitched) cv2.waitKey(0) # otherwise the stitching failed, likely due to not enough keypoints) being detected else: print("[INFO] image stitching failed ({})".format(status))
分类:
python
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· 写一个简单的SQL生成工具
· AI 智能体引爆开源社区「GitHub 热点速览」
· C#/.NET/.NET Core技术前沿周刊 | 第 29 期(2025年3.1-3.9)