尽管初始大小固定,但用于跟踪对象的边界框/ROI 的大小仍在不断增加



我正在尝试使用媒体流跟踪器根据区域跟踪我的手,但一段时间后边界框不断增加。它在前 10 秒左右正常工作。

下面是一个代码片段:

def main():
display = SimpleCV.Display()
cam = Kinect()
ts = []
bb = None
img = cam.getDepth().flipHorizontal()
while display.isNotDone():
    depth = cam.getDepth().flipHorizontal()
    filtered = depth.stretch(0, 180).binarize().dilate(1)
    if bb is None:
        blobs = filtered.findBlobs()
        if blobs:
            hand = blobs.filter(abs(7000 - blobs.area()) < 500)
            print hand
            if hand:
                bb = hand[0].boundingBox()
                print bb
    if bb is not None:
        ts = filtered.track("mftrack", ts, img, bb)
        if ts:
            ts.drawBB()
            ts.showPixelVelocityRT()
            ts.drawPath()
    filtered.show()

我会从以下行中删除对dilate的调用:

filtered = depth.stretch(0, 180).binarize().dilate(1)

从 SimpleCV 文档中:

扩张(迭代次数=1) 应用形态扩张。膨胀具有平滑斑点的效果,同时增强噪声斑点的数量。此实现使用默认的 openCV 3X3 方形内核侵蚀实际上是一个局部极大值检测器,内核在图像上移动并在内核内获取最大值。

变量filtered在每次循环迭代中使用,filtered.findBlobs() .这些斑点的强度和密度用于确定边界框的尺寸。

您正在调用 stretch 函数以及扩张。随着时间的推移,对dilate的调用会导致噪音被检测为手的一部分,因此边界框相应增加。