Open stevensagaert opened 3 months ago
Hi @stevensagaert, I'd like to help by submitting a PR
Hi @Sapienscoding,
I've assigned another issue to you. Let's go with one at a time.
Hi @stevensagaert π
Apologies for the delay. If you're still keen, we'd be happy to include area occupation stats in our PolygonZone.
Hi, it is my first time contributing to open source project and I would like to work on this issue. Please do guide me if possible. Thank you!
Hi, I'll make some time in 2 weeks or so. Right now I'm too busy at work.
From: LinasKo @.> Sent: Tuesday, October 15, 2024 8:48 AM To: roboflow/supervision @.> Cc: Steven Sagaert @.>; Mention @.> Subject: Re: [roboflow/supervision] PolygonZone: estimate how much of the zone is occupied (Issue #1449)
CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
Hi @stevensagaerthttps://github.com/stevensagaert π
Apologies for the delay. If you're still keen, we'd be happy to include area occupation stats in our PolygonZone.
β Reply to this email directly, view it on GitHubhttps://github.com/roboflow/supervision/issues/1449#issuecomment-2413031995, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A7A5SMGF3R5NLUEQ43D6KW3Z3S3CRAVCNFSM6AAAAABMQRAQWKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMJTGAZTCOJZGU. You are receiving this because you were mentioned.Message ID: @.***>
@stevensagaert Can I resolve this issue ?
You mean you want to implement it or just close it? I haven't had time to do it yet.
@stevensagaert I would like to try to implement it.
Ok go ahead π. The bulk of the functionality is in the 2 functions I put in this issue. The rest should be just glue code.
From: Archit H Barve @.> Sent: Wednesday, October 30, 2024 10:01 AM To: roboflow/supervision @.> Cc: Steven Sagaert @.>; Mention @.> Subject: Re: [roboflow/supervision] PolygonZone: estimate how much of the zone is occupied (Issue #1449)
CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
@stevensagaerthttps://github.com/stevensagaert I would like to try to implement it.
β Reply to this email directly, view it on GitHubhttps://github.com/roboflow/supervision/issues/1449#issuecomment-2446244157, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A7A5SMB2O7BWFMEBCJGIMHLZ6CN6XAVCNFSM6AAAAABMQRAQWKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINBWGI2DIMJVG4. You are receiving this because you were mentioned.Message ID: @.***>
Hi @AHB102 π
Assigning this to you.
Note that Detection can take one of 3 forms:
mask
fieldxyxy
field, and not mask
.(N, 4, 2)
-shaped polygon in detections.data[CLASS_NAME_DATA_FIELD]
. (CLASS_NAME_DATA_FIELD
== "xyxyxyxy"
and resides in config.py
)Ideally, this method should work regardless of detection type, but it's okay if it returns a slightly-approximated result.
You may find the polygon_to_mask
method helpful. it resides in: supervision/detection/utils.py
.
@LinasKo Thanks for the insight π, will get started on this.
@LinasKo Hi π,I haven't written much code for this feature. I mostly used Steven's existing code, but I added checks for the detection cases based on your recommendations. Had some questions : 1)Type hinting: I wrote this feature in vanilla Python . I'm new to type hinting, is it still okay to use it ? 2)Code location: I put the feature code in βsupervision/detection/utils.pyβ, outside of the PolygonZone class. Is that the right place? 3)Testing: How do I test the feature? Can I use import statements, or is there a preferred way to write tests before submitting a pull request (PR)?
Hi @AHB102 π
: int
, : str
, : List[str]
and so on. For numpy arrays it's fine to say np.ndarray
. Return type is -> int:
and so on. You can do -> None:
if it returns nothing. I'd encourage you to try!Okay nice! Will definitely make the type hinting work, and can I commit the changes and make a PR ?
Yes, absolutely. Typically contributors fork the repo, make the changes their version of it, on a branch such as feat/estimate-polygonzone-occupation
, and then open a PR via github website to supervision's develop
(there should be a button, as soon as you push to your own fork).
@LinasKo I got a bit lost in the first PR. I believe this one is correct. Thanks for your patienceπ
Thank you @AHB102!
I'll have a look as soon as I can, likely next week.
Search before asking
Description
Next to the count of the objects in the zone, it would be useful to know how much of the zone area is occupied by the objects.
Use case
e.g. for loading zones in warehouses
Additional
Basically I've implemented it myself outside of the PolygonZone class. The core of what is needed is these two functions:
strategy:
1) make union of binary masks of detected objects (only the classes for consideration in zone) 2) make binary mask of the zone 3) do and of zone mask & object masks 4) sum the 1 pixels
Are you willing to submit a PR?