Add per-class counting to LineZone, create LineZoneAnnotatorMulticlass
Description
This PR adds per-class counting capabilities to LineZone.
The results can be visualized with the newly added LineZoneAnnotatorMultiClass.
Type of change
Please delete options that are not relevant.
- [x] New feature (non-breaking change which adds functionality)
How has this change been tested, please provide a testcase or example of how you tested the change?
Rigorously tested locally.
Known issues that are NOT to be addressed as part of this PR:
- Table isn't the best-looking. We can experiment with Pillow in the future.
- The table only caters to LineZone, whereas tools like PolygonZone may also want to write into it.
- The list of arguments is dauntingly large.
- The text may overflow - both horizontally and vertically
- There's no blacklist or whitelist for displayed classes.
Any specific deployment considerations
Docs
- [x] Docs updated? What were the changes:
in_count,out_countare now properties- New properties:
in_count_per_class,out_count_per_class - New class:
LineZoneAnnotatorMulticlass
Hi @onuralpszr 👋
If you have some time, can you skim through this one, see if anything stands out?
Hi @onuralpszr 👋
If you have some time, can you skim through this one, see if anything stands out?
Hello 👋 let me setup and try out sure
Example results: (Tell me if it doesn't load, or run the Colab)
https://github.com/user-attachments/assets/7d48fb44-fe18-4a75-96a4-68337013c77f
Example results: (Tell me if it doesn't load, or run the Colab)
out_normal.mp4
Video not loading*
My Review/Test Branch
!pip install git+https://github.com/roboflow/supervision.git@line-zone-class-test -q
!pip install ultralytics -q
Accepted the refactor:
- String builder is a much better approach
- Not a fan of precomputing all options for positions, but it is slightly more readable
- Loop over In/Out is good
- I'm not a fan of Python ternaries - it feels like it ups the complexity for the reader, while still obviously being the same
ifcondition, only without indentation.
At the end of the day - some subjective changes and I don't mind, and some very welcome improvements. Thank you very much @onuralpszr ! Will merge it after giving it another couple of runs.