首页 > 解决方案 > (success, box) = tracker.update(frame) cv2.error: OpenCV(4.5.1669: error: (-209:Sizes of input arguments do not match)

问题描述

请检查一下,我正在使用 python 3.9 和 OpenCV 4.5.1.48

**tracker = OPENCV_OBJECT_TRACKERS"kcf" while True: # 抓取当前帧,如果我们使用的是 VideoStream 或 VideoCapture 对象则处理 ret,frame = vs.read() (H, W) = frame.shape[:2 ] #h=480 w=640 #print(H,W) if imagee is not None: # 抓取物体的新边界框坐标 tracker.init(frame, imagee)

            fps = FPS().start()
            (success, box) = tracker.update(frame)
            keypoints_sift1, descriptors1 = orb.detectAndCompute(frame, None)
            try:
                matches = bf.match(descriptors,descriptors1)
                #frame = cv2.drawMatches(frame,keypoints_sift1,imcorp,keypoints_sift,matches[::], None,flags=2)
                # check to see if the tracking was a success
                if success:
                    (x, y, w, h) = [int(v) for v in box]
                    cv2.rectangle(frame, (x, y), (x + w, y + h),(0, 255, 0), 2)
                    newx=(x+x+w)/2
                    newy=(y+y+h)/2
                    
            except:
                pass
            # update the FPS counter
            fps.update()
            fps.stop()
            # initialize the set of information we'll be displaying on
            # the frame
            info = [
                    ("Tracker", "tld"),
                    ("Success", "Yes" if success else "No"),
                    ("FPS", "{:.2f}".format(fps.fps())),
            ]
            # loop over the info tuples and draw them on our frame
            for (i, (k, v)) in enumerate(info):
                text = "{}: {}".format(k, v)
                cv2.putText(frame, text, (10, H - ((i * 20) + 20)),cv2.FONT_HERSHEY_SIMPLEX, 0.6, (0, 0, 255), 2)
                
        cv2.imshow("Frame", frame)
        key = cv2.waitKey(1) & 0xFF**
        

标签: opencv

解决方案


推荐阅读