对象跟踪中的遮挡处理

时间:2021-02-09 17:16:11

标签: python opencv computer-vision kalman-filter background-subtraction

我正在实施基于运动的对象跟踪程序,该程序使用背景减法、卡尔曼滤波器和匈牙利算法。除了遮挡之外,一切正常。当两个对象彼此足够接近时,背景减法会将其识别为这两个对象之一。拆分后,程序正确识别这两个对象。我正在寻找解决方案/算法,它将检测如下示例中 c) 点所示的遮挡。 enter image description here

我将不胜感激任何涉及使用背景减法时遮挡检测问题的参考资料或代码示例。

1 个答案:

答案 0 :(得分:1)

使用机器学习算法的对象检测应该能够可靠地区分这些对象,即使存在明显遮挡也是如此。您没有分享任何有关您的环境的信息,所以我不知道您有什么样的限制,但是使用 ML 方法,我将如何解决您的问题。

import cv2
from sort import *

tracker = Sort() # Create instance of tracker (see link below for repo)

cap = cv2.VideoCapture(0)
while(True):
    ret, frame = cap.read()

    # Not sure what your environment is, 
    #but get your objects bounding boxes like this
    detected_objects = detector.detect(frame) #pseudo code
    
    # Get tracking IDs for objects and bounding boxes
    detected_objects_with_ids = tracker.update(detected_objects)
...

上面的例子使用了这个Kalman Filter and Hungarian algorithm,它可以实时跟踪多个对象。

同样,不确定您的环境,但您可以找到 pre-built object detection algorithms on the Tensorflow site

相关问题