在相交处找到入口出口

时间:2018-11-07 14:40:43

标签: python opencv image-processing tracking dlib

我使用以下代码查找人员的出入境计数。

 # check to see if the object has been counted or not
            if not to.counted:
                # if the direction is negative (indicating the object
                # is moving up) AND the centroid is above the center
                # line, count the object
                if direction < 0 and centroid[1] < H // 2:
                    totalUp += 1
                    to.counted = True

                # if the direction is positive (indicating the object
                # is moving down) AND the centroid is below the
                # center line, count the object
                elif direction > 0 and centroid[1] > H // 2:
                    totalDown += 1
                    to.counted = True

根据此代码,如果同一个人返回并再次输入,则条目计数仍与已被计数的人员相同。每当人与线相交时,我都想查找进入和退出计数。如何解决?

1 个答案:

答案 0 :(得分:0)

一种快速的方法是完全忽略in test (1): 1 in test (2): 1 2 1 2 substitution: in test (3): 1 2 3 After command substitution: 1 2 in test (5): 1 2 5 in subshell: 1 2 5 after subshell: 1 2 属性:

counted

这是假设您的总数不是每个,而是总数的总和。如果是这种情况,请忽略# if the direction is negative (indicating the object # is moving up) AND the centroid is above the center # line, count the object if direction < 0 and centroid[1] < H // 2: totalUp += 1 # if the direction is positive (indicating the object # is moving down) AND the centroid is below the # center line, count the object elif direction > 0 and centroid[1] > H // 2: totalDown += 1 ,因为您不在乎是否已被计算在内,而只是在乎是否满足您设置的条件