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?










share|improve this question


















  • 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












  • 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















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?










share|improve this question


















  • 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












  • 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













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?










share|improve this question













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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 7 at 14:40









RockKil

31




31








  • 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












  • 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














  • 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












  • 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








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












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






share|improve this answer





















  • 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 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











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















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

























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






share|improve this answer





















  • 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 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















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






share|improve this answer





















  • 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 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













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






share|improve this answer












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







share|improve this answer












share|improve this answer



share|improve this answer










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 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


















  • 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 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
















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


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














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





















































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







這個網誌中的熱門文章

Xamarin.form Move up view when keyboard appear

Post-Redirect-Get with Spring WebFlux and Thymeleaf

Anylogic : not able to use stopDelay()