尽管初始大小固定,但BoundingBox/ROI跟踪对象的大小仍在不断增加

Rah*_*bub 9 c++ python opencv kinect simplecv

我试图使用Media Flow Tracker根据区域跟踪我的手,但是一段时间后边界框会不断增加.它在前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()
Run Code Online (Sandbox Code Playgroud)

ros*_*oss 3

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

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

来自 SimpleCV文档

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

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

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