(h,w)= image.shape [:2] ValueError:没有足够的值可解包(预期2,得到1)

时间:2020-05-15 13:10:12

标签: python

我正在尝试执行违规检测,但这给了我这个错误

“ C:\ Users \ Khuram Yasin \ Anaconda3 \ envs \ test \ python.exe” “ D:/ Study / FYP / FYP_1 test / test.py”追溯(最近一次通话结束):
在第6行的文件“ D:/ Study / FYP / FYP_1 test / test.py” detection.MainProcessor(“ cam_01”)文件“ D:\ Study \ FYP \ FYP_1 test \ detection.py”,第21行, init abc = self.processor.cross_violation(frame)文件“ D:\ Study \ FYP \ FYP_1 test \ processor \ TrafficProcessor.py”,第34行,在 cross_violation self.frame = imutils.resize(numpy.array(frame),width = 500)文件“ C:\ Users \ Khuram Yasin \ Anaconda3 \ envs \ test \ lib \ site-packages \ imutils \ convenience.py”, 第69行,调整大小 (h,w)= image.shape [:2] ValueError:没有足够的值可解包(预期2,得到1)

代码为:

MainProcessor类:

def __init__(self, camera_id):
    self.cam_id = camera_id
    frame = cv2.VideoCapture("Videos/uk_motorway.mkv").read()

    if camera_id == 'cam_01' or camera_id == 'cam_03':
        self.processor = TrafficProcessor()
        self.processor.zone1 = (100, 150)
        self.processor.zone2 = (450, 145)
        self.processor.thres = 30
        self.processor.cross_violation(frame)
        return frame

def cross_violation(self, frame):
    text = ""
    isCar = False
    cropped_cars = []  # list for taking all violated car's snap

    # resize the frame, convert it to grayscale, and blur it
    self.frame = imutils.resize(numpy.array(frame), width=500)
    self.gray = cv2.cvtColor(self.frame, cv2.COLOR_BGR2GRAY)
    self.gray = cv2.GaussianBlur(self.gray, (21, 21), 0)

    # if the first frame is None, initialize it
    if self.firstFrame is None:
        self.firstFrame = self.gray
        pack = {'frame': self.frame, 'reference': self.firstFrame, 'list_of_cars': cropped_cars, 'cnt': self.cnt}
        return pack

0 个答案:

没有答案