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

take into account confidences when selecting final match for most* strategy #36

Open
hqhoang opened this issue Jan 6, 2022 · 3 comments

Comments

@hqhoang
Copy link

hqhoang commented Jan 6, 2022

For frame_strategy of "most", "most_models", and "most_unique", since we have to loop through all the matches anyway, might as well take into consideration the confidences to pick out the best. For example, if three matches all have 1 detected object, the match with the highest confidence should be selected instead of the first one.

It's obviously more complicated when there are multiple detected objects, perhaps compare the sum of the confidences as a simple criteria. Something like this?

for idx,item in enumerate(all_matches):
  if  ((frame_strategy == 'first') or
  ((frame_strategy == 'most') and (len(item['labels']) > len(matched_l))) or
  ((frame_strategy == 'most') and (len(item['labels']) == len(matched_l)) and (sum(matched_c) < sum(item['confidences']))) or
  ((frame_strategy == 'most_models') and (len(item['detection_types']) > len(matched_detection_types))) or
  ((frame_strategy == 'most_models') and (len(item['detection_types']) == len(matched_detection_types)) and (sum(matched_c) < sum(item['confidences']))) or
  ((frame_strategy == 'most_unique') and (len(set(item['labels'])) > len(set(matched_l)))) or
  ((frame_strategy == 'most_unique') and (len(set(item['labels'])) == len(set(matched_l))) and (sum(matched_c) < sum(item['confidences'])))):

I've been testing the above mod in my local installation and it seems to work well in picking out the best detected frame for better accuracy.

@baudneo
Copy link
Contributor

baudneo commented Jan 7, 2022

I will add this to pyzm and test. I don't know if my code will replace the current libs or if it will be a diff branch but pyzm, ZMES and MLAPI will be receiving a fairly robust makeover shortly.

Any other observations or improvements you would like to see?

@hqhoang
Copy link
Author

hqhoang commented Jan 7, 2022

I have a few ideas from my setup but I don't know much about Perl. I'm learning Python slowly so if the new codes will be in Python, I probably can contribute a bit, especially front-end responsive design. Submitting another issue/request for "park_zone" shortly.

@baudneo
Copy link
Contributor

baudneo commented Jan 7, 2022

For the time being the object detection logic is all in python. The websocket server, "event SHM scraper" and the daemon are in the Perl code.

I will implement some of these ideas after testing. I just need to setup a camera to monitor vehicles to create a situation where I can use match_past_detections and test it properly.

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