Find entry exit on intersect
up vote
0
down vote
favorite
Im using the following code to find entry and exit count of the people.
# 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
As per this code if the same person comes back and enters again, the entry count is still the same as the person has been counted already. I want to find the entry and exit count everytime when the person intersects the line. How do I sort it out?
python opencv image-processing tracking dlib
add a comment |
up vote
0
down vote
favorite
Im using the following code to find entry and exit count of the people.
# 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
As per this code if the same person comes back and enters again, the entry count is still the same as the person has been counted already. I want to find the entry and exit count everytime when the person intersects the line. How do I sort it out?
python opencv image-processing tracking dlib
1
What is theto
object? If it's a class you define, you could keep track ofcounted
as anint
and incrementcounted
withto.counted+=1
. This would also require you get rid of theif
statement, otherwise you'll only count at the instancecounted=0
or in your casecounted=False
– C.Nivs
Nov 7 at 14:44
object is the person..
– RockKil
Nov 7 at 14:45
Add the code used to defineto
(including any class definition) to your question, that might make things a touch more clear for us to help and we can see exactly what you're working with
– C.Nivs
Nov 7 at 14:47
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Im using the following code to find entry and exit count of the people.
# 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
As per this code if the same person comes back and enters again, the entry count is still the same as the person has been counted already. I want to find the entry and exit count everytime when the person intersects the line. How do I sort it out?
python opencv image-processing tracking dlib
Im using the following code to find entry and exit count of the people.
# 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
As per this code if the same person comes back and enters again, the entry count is still the same as the person has been counted already. I want to find the entry and exit count everytime when the person intersects the line. How do I sort it out?
python opencv image-processing tracking dlib
python opencv image-processing tracking dlib
asked Nov 7 at 14:40
RockKil
31
31
1
What is theto
object? If it's a class you define, you could keep track ofcounted
as anint
and incrementcounted
withto.counted+=1
. This would also require you get rid of theif
statement, otherwise you'll only count at the instancecounted=0
or in your casecounted=False
– C.Nivs
Nov 7 at 14:44
object is the person..
– RockKil
Nov 7 at 14:45
Add the code used to defineto
(including any class definition) to your question, that might make things a touch more clear for us to help and we can see exactly what you're working with
– C.Nivs
Nov 7 at 14:47
add a comment |
1
What is theto
object? If it's a class you define, you could keep track ofcounted
as anint
and incrementcounted
withto.counted+=1
. This would also require you get rid of theif
statement, otherwise you'll only count at the instancecounted=0
or in your casecounted=False
– C.Nivs
Nov 7 at 14:44
object is the person..
– RockKil
Nov 7 at 14:45
Add the code used to defineto
(including any class definition) to your question, that might make things a touch more clear for us to help and we can see exactly what you're working with
– C.Nivs
Nov 7 at 14:47
1
1
What is the
to
object? If it's a class you define, you could keep track of counted
as an int
and increment counted
with to.counted+=1
. This would also require you get rid of the if
statement, otherwise you'll only count at the instance counted=0
or in your case counted=False
– C.Nivs
Nov 7 at 14:44
What is the
to
object? If it's a class you define, you could keep track of counted
as an int
and increment counted
with to.counted+=1
. This would also require you get rid of the if
statement, otherwise you'll only count at the instance counted=0
or in your case counted=False
– C.Nivs
Nov 7 at 14:44
object is the person..
– RockKil
Nov 7 at 14:45
object is the person..
– RockKil
Nov 7 at 14:45
Add the code used to define
to
(including any class definition) to your question, that might make things a touch more clear for us to help and we can see exactly what you're working with– C.Nivs
Nov 7 at 14:47
Add the code used to define
to
(including any class definition) to your question, that might make things a touch more clear for us to help and we can see exactly what you're working with– C.Nivs
Nov 7 at 14:47
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
A quick way to do that would be to ignore the counted
attribute entirely:
# 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
This is assuming that your total counts are not per person but a grand total of occurrences. If that's the case, ignore the if to.counted
because you don't care if they've been counted already, you just care if the conditions you've set have been satisfied
I tried doing so. It increments the count dramatically fast.
– RockKil
Nov 7 at 14:56
Is that expected behavior? If not, why not?
– C.Nivs
Nov 7 at 14:58
it is not the expected behaviour. Everytime when the person hits the line, either the entry or exit count should increase only once until he hits it again... if he hits it again, entry or exit count should increment once more... it shall not increment constantly.
– RockKil
Nov 7 at 15:08
based on theif
logic and available code, the only way the entry or exit values are incremented is if they satisfy one of the two conditions. Are you sure that the program is not finding those matches at a fairly high rate and so it looks like the count is increasing constantly? I would need to see your entire code to tell why the values are increasing at an unacceptable rate
– C.Nivs
Nov 7 at 22:28
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
A quick way to do that would be to ignore the counted
attribute entirely:
# 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
This is assuming that your total counts are not per person but a grand total of occurrences. If that's the case, ignore the if to.counted
because you don't care if they've been counted already, you just care if the conditions you've set have been satisfied
I tried doing so. It increments the count dramatically fast.
– RockKil
Nov 7 at 14:56
Is that expected behavior? If not, why not?
– C.Nivs
Nov 7 at 14:58
it is not the expected behaviour. Everytime when the person hits the line, either the entry or exit count should increase only once until he hits it again... if he hits it again, entry or exit count should increment once more... it shall not increment constantly.
– RockKil
Nov 7 at 15:08
based on theif
logic and available code, the only way the entry or exit values are incremented is if they satisfy one of the two conditions. Are you sure that the program is not finding those matches at a fairly high rate and so it looks like the count is increasing constantly? I would need to see your entire code to tell why the values are increasing at an unacceptable rate
– C.Nivs
Nov 7 at 22:28
add a comment |
up vote
0
down vote
accepted
A quick way to do that would be to ignore the counted
attribute entirely:
# 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
This is assuming that your total counts are not per person but a grand total of occurrences. If that's the case, ignore the if to.counted
because you don't care if they've been counted already, you just care if the conditions you've set have been satisfied
I tried doing so. It increments the count dramatically fast.
– RockKil
Nov 7 at 14:56
Is that expected behavior? If not, why not?
– C.Nivs
Nov 7 at 14:58
it is not the expected behaviour. Everytime when the person hits the line, either the entry or exit count should increase only once until he hits it again... if he hits it again, entry or exit count should increment once more... it shall not increment constantly.
– RockKil
Nov 7 at 15:08
based on theif
logic and available code, the only way the entry or exit values are incremented is if they satisfy one of the two conditions. Are you sure that the program is not finding those matches at a fairly high rate and so it looks like the count is increasing constantly? I would need to see your entire code to tell why the values are increasing at an unacceptable rate
– C.Nivs
Nov 7 at 22:28
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
A quick way to do that would be to ignore the counted
attribute entirely:
# 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
This is assuming that your total counts are not per person but a grand total of occurrences. If that's the case, ignore the if to.counted
because you don't care if they've been counted already, you just care if the conditions you've set have been satisfied
A quick way to do that would be to ignore the counted
attribute entirely:
# 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
This is assuming that your total counts are not per person but a grand total of occurrences. If that's the case, ignore the if to.counted
because you don't care if they've been counted already, you just care if the conditions you've set have been satisfied
answered Nov 7 at 14:53
C.Nivs
1,6661414
1,6661414
I tried doing so. It increments the count dramatically fast.
– RockKil
Nov 7 at 14:56
Is that expected behavior? If not, why not?
– C.Nivs
Nov 7 at 14:58
it is not the expected behaviour. Everytime when the person hits the line, either the entry or exit count should increase only once until he hits it again... if he hits it again, entry or exit count should increment once more... it shall not increment constantly.
– RockKil
Nov 7 at 15:08
based on theif
logic and available code, the only way the entry or exit values are incremented is if they satisfy one of the two conditions. Are you sure that the program is not finding those matches at a fairly high rate and so it looks like the count is increasing constantly? I would need to see your entire code to tell why the values are increasing at an unacceptable rate
– C.Nivs
Nov 7 at 22:28
add a comment |
I tried doing so. It increments the count dramatically fast.
– RockKil
Nov 7 at 14:56
Is that expected behavior? If not, why not?
– C.Nivs
Nov 7 at 14:58
it is not the expected behaviour. Everytime when the person hits the line, either the entry or exit count should increase only once until he hits it again... if he hits it again, entry or exit count should increment once more... it shall not increment constantly.
– RockKil
Nov 7 at 15:08
based on theif
logic and available code, the only way the entry or exit values are incremented is if they satisfy one of the two conditions. Are you sure that the program is not finding those matches at a fairly high rate and so it looks like the count is increasing constantly? I would need to see your entire code to tell why the values are increasing at an unacceptable rate
– C.Nivs
Nov 7 at 22:28
I tried doing so. It increments the count dramatically fast.
– RockKil
Nov 7 at 14:56
I tried doing so. It increments the count dramatically fast.
– RockKil
Nov 7 at 14:56
Is that expected behavior? If not, why not?
– C.Nivs
Nov 7 at 14:58
Is that expected behavior? If not, why not?
– C.Nivs
Nov 7 at 14:58
it is not the expected behaviour. Everytime when the person hits the line, either the entry or exit count should increase only once until he hits it again... if he hits it again, entry or exit count should increment once more... it shall not increment constantly.
– RockKil
Nov 7 at 15:08
it is not the expected behaviour. Everytime when the person hits the line, either the entry or exit count should increase only once until he hits it again... if he hits it again, entry or exit count should increment once more... it shall not increment constantly.
– RockKil
Nov 7 at 15:08
based on the
if
logic and available code, the only way the entry or exit values are incremented is if they satisfy one of the two conditions. Are you sure that the program is not finding those matches at a fairly high rate and so it looks like the count is increasing constantly? I would need to see your entire code to tell why the values are increasing at an unacceptable rate– C.Nivs
Nov 7 at 22:28
based on the
if
logic and available code, the only way the entry or exit values are incremented is if they satisfy one of the two conditions. Are you sure that the program is not finding those matches at a fairly high rate and so it looks like the count is increasing constantly? I would need to see your entire code to tell why the values are increasing at an unacceptable rate– C.Nivs
Nov 7 at 22:28
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53191680%2ffind-entry-exit-on-intersect%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
What is the
to
object? If it's a class you define, you could keep track ofcounted
as anint
and incrementcounted
withto.counted+=1
. This would also require you get rid of theif
statement, otherwise you'll only count at the instancecounted=0
or in your casecounted=False
– C.Nivs
Nov 7 at 14:44
object is the person..
– RockKil
Nov 7 at 14:45
Add the code used to define
to
(including any class definition) to your question, that might make things a touch more clear for us to help and we can see exactly what you're working with– C.Nivs
Nov 7 at 14:47