OpenCV Panorama:TypeError:无法解压缩不可迭代的NoneType对象

时间:2018-12-10 23:16:32

标签: python opencv computer-vision spyder

我正在尝试从图像集中制作全景图。我正在使用Spyder,OpenCV 3.4和Python 3.7。这是代码:

  1. 主要内容:

    s/[0-9]\{10\}/abc&/g
    
  2. 缝线中的针迹.py:

    from stitches import Stitcher
    #from PIL import Image
    import os
    import glob
    import numpy as np
    import imutils
    import cv2
    
    cap = cv2.VideoCapture('C:/Users/VID_20181208_111037881.mp4')
    
    img_dir = "C:/Users/user/images"
    data_path = os.path.join(img_dir, '*g')
    files = glob.glob(data_path)
    args = []
    
    for f1 in files:
        img = cv2.imread(f1)
        args.append(img)
    
    def retImg(img):
        return img
    
    for i in args:
    
        j = i+1
    
        frame = retImg(i)
        frame2 = retImg(j)
    
        #imageA = cv2.imread(frame)
        #imageB = cv2.imread(frame2)
        imageA = imutils.resize(frame, width=400)
        imageB = imutils.resize(frame2, width=400)
    
        # stitch the images together to create a panorama
        stitcher = Stitcher()
        (result, vis) = stitcher.stitch([imageA, imageB], showMatches=False)
    
        frame = result
    
        # show the images
    cv2.imshow("Keypoint Matches", vis)
    cv2.imshow("Result", result)
    cv2.waitKey(0)
    

当我编译它时,显示以下错误:

def stitch(self, images, ratio=0.75, reprojThresh=4.0, showMatches=False):
# unpack the images, then detect keypoints and extract
# local invariant descriptors from them
(imageB, imageA) = images
(kpsA, featuresA) = self.detectAndDescribe(imageA)
(kpsB, featuresB) = self.detectAndDescribe(imageB)

# match features between the two images
M = self.matchKeypoints(kpsA, kpsB, featuresA, featuresB, ratio, reprojThresh)

# if the match is None, then there aren't enough matched
# keypoints to create a panorama
if M is None:
    return None

# together
(matches, H, status) = M
result = cv2.warpPerspective(imageA, H, (imageA.shape[1] + imageB.shape[1], imageA.shape[0]))
result[0:imageB.shape[0], 0:imageB.shape[1]] = imageB

# check to see if the keypoint matches should be visualized
if showMatches:
    vis = self.drawMatches(imageA, imageB, kpsA, kpsB, matches, status)

    # return a tuple of the stitched image and the
    # visualization
    return (result, vis)

# return the stitched image
return result

我不明白为什么。我是Python的新手,所以也许这个错误确实很简单,但是我不知道该怎么做。提前谢谢!

0 个答案:

没有答案