Python 程序未输入嵌套在while循环中的循环

Python 程序未输入嵌套在while循环中的循环,python,Python,在我的代码中,程序没有进入嵌套在while循环中的for循环。因此,输出是一个打印“级联加载”的无限循环 有人能帮我解决这个问题吗?可能upper是空的或不可编辑?detectMultiScale必须根据输入图像返回空元组,因为您传递了参数min\u Neights=6,试着减少参数值以确认。我输入了一个视频文件,减少邻居的数量将带来积极的影响。你能建议其他解决问题的方法吗? haar_upper_body_cascade = cv2.CascadeClassifier("cascade.xml

在我的代码中,程序没有进入嵌套在while循环中的for循环。因此,输出是一个打印“级联加载”的无限循环


有人能帮我解决这个问题吗?

可能upper是空的或不可编辑?
detectMultiScale
必须根据输入图像返回空元组,因为您传递了参数
min\u Neights=6
,试着减少参数值以确认。我输入了一个视频文件,减少邻居的数量将带来积极的影响。你能建议其他解决问题的方法吗?
haar_upper_body_cascade = cv2.CascadeClassifier("cascade.xml")

video_capture = cv2.VideoCapture("00011.MTS")
video_width = video_capture.get(3) #1280
video_height = video_capture.get(4) #720
print ("video loaded")

while True:
   ret, frame = video_capture.read()
   frame = imutils.resize(frame, width=800) # resize original video for better viewing performance
   gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) # convert video to grayscale
   upper = haar_upper_body_cascade.detectMultiScale(gray, 1.4,6)
   print ("cascade loaded")

   # Draw a rectangle around the upper bodies
    for (x, y, wi, he) in upper :
        print("entered loop")
        cv2.rectangle(frame, (x, y), (x + wi, y + he), (0, 255, 0), 1) 
        cv2.putText(frame, "Seat Belt ON", (x + 5, y + 15), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 2) 
        path = 'G:/00004' 
        cv2.imwrite(os.path.join(path , str(counter) + '.jpg'), frame)
        counter += 1
        cv2.imshow('Video', frame)