Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Showing only one bounding box per frame (coreml) #49

Open
1omarsaid opened this issue Feb 2, 2019 · 16 comments
Open

Showing only one bounding box per frame (coreml) #49

1omarsaid opened this issue Feb 2, 2019 · 16 comments

Comments

@1omarsaid
Copy link

I am trying to find a way to only show one bounding box per frame, meaning that I dont want it to detect three "persons" in one frame. In the view controller I have modified the maxInflightBuffers to 1 but I am not sure if that is the way to go. The reason of such implementation, I am enabling an audio file when a certain bounding box appears, but if there is more than one, it wont play.

@1omarsaid 1omarsaid changed the title Showing only one bounding box per frame Showing only one bounding box per frame (coreml) Feb 2, 2019
@hollance
Copy link
Owner

hollance commented Feb 2, 2019

That is unrelated to the maxInflightBuffers. You need to change the nonMaxSuppression code to sort the bounding boxes by confidence and then pick the one with the highest confidence.

@1omarsaid
Copy link
Author

How can I do that? so far I just have it so it shows the bounding boxes with a prediction above 50%

@1omarsaid
Copy link
Author

@hollance I would really appreciate it if you can give me some guidance into implementing this. Thank you in advance.

@hollance
Copy link
Owner

hollance commented Feb 6, 2019

There’s not much to it: when you get the bounding boxes, sort them by confidence score and keep the one with the highest score.

@1omarsaid
Copy link
Author

What if I just do something like this "return nonMaxSuppression(boxes: predictions, limit: 1, threshold: iouThreshold)" would this be wrong?

@hollance
Copy link
Owner

That's fine but a little bit slower than my previous suggestion.

@1omarsaid
Copy link
Author

How would I be able to reduce the number of bounding boxes (per second) without reducing the "Desired frame rate"

@hollance
Copy link
Owner

You would have to change the model for that. It always predicts the same number of bounding boxes in every frame.

@1omarsaid
Copy link
Author

sorry what I meant was, how can I have a tiny delay between each bounding box, so if I want to associate a bounding box with a half second audio, it doesnt cut off because it shows a new bounding box that also activates the audio file

@1omarsaid
Copy link
Author

Do you know if there is a way to do that? I tried setting up delays of when they would trigger the "show" function but it doesnt seem to work.

@hollance
Copy link
Owner

Every new video frame gives completely new predictions. There is no way to track an object across multiple frames with YOLO. So I’m not really sure what you’re trying to accomplish but it sounds like it needs more than just bounding box detection.

@1omarsaid
Copy link
Author

I see, so there isnt a way to be able to only get predictions on every other frame?

@hollance
Copy link
Owner

If you want predictions every other frame, then simply keep a counter and only do a prediction when the counter is even.

@1omarsaid
Copy link
Author

would the counter be in the viewcontroller? Please give me some tips in how I can execute that? what if I want to make it make a prediction every n frames?

@1omarsaid
Copy link
Author

which function does the actual prediction? I can wrap it with an if statement this way.

@1omarsaid
Copy link
Author

I created an if statement around

      } else {
        boundingBoxes[i].hide()
      }```

it seemed to do the job

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants