在交叉路口找到入口出口
Find entry exit on intersect
我正在使用以下代码查找人员的进出计数。
# 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
根据此代码,如果同一个人返回并再次进入,则进入计数仍然与该人已被计数的相同。我想在每次人与线相交时找到进入和退出计数。我该如何解决?
一个快速的方法是完全忽略 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
这是假设您的总计数不是每 人 而是发生的总计。如果是这样,请忽略 if to.counted
因为你不关心它们是否已经被计算过,你只关心你设置的条件是否已经满足
我正在使用以下代码查找人员的进出计数。
# 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
根据此代码,如果同一个人返回并再次进入,则进入计数仍然与该人已被计数的相同。我想在每次人与线相交时找到进入和退出计数。我该如何解决?
一个快速的方法是完全忽略 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
这是假设您的总计数不是每 人 而是发生的总计。如果是这样,请忽略 if to.counted
因为你不关心它们是否已经被计算过,你只关心你设置的条件是否已经满足