失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > opencv 图像拼接stitcher

opencv 图像拼接stitcher

时间:2020-11-24 16:20:30

相关推荐

opencv 图像拼接stitcher

如果相互重复的至少有1/3效果还有不错的

import cv2import mathimport os# 文件夹所有图片path = "Images/Scan"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 stitchingif status == 0:# write the output stitched image to diskcv2.imwrite("Images/stitch.jpg", stitched)# display the output stitched image to our screencv2.imshow("Stitched", stitched)cv2.waitKey(0)# otherwise the stitching failed, likely due to not enough keypoints) being detectedelse:print("[INFO] image stitching failed ({})".format(status))

如果觉得《opencv 图像拼接stitcher》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。