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

How to register detection in PolygonZone for any overlap #1022

Open
1 task done
marcospgp opened this issue Mar 19, 2024 · 2 comments
Open
1 task done

How to register detection in PolygonZone for any overlap #1022

marcospgp opened this issue Mar 19, 2024 · 2 comments
Labels
question Further information is requested

Comments

@marcospgp
Copy link

Search before asking

  • I have searched the Supervision issues and found no similar feature requests.

Question

How can I register a detection inside a PolygonZone when there is any overlap? Without requiring the entire bounding box to be contained inside the zone.

image

I tried using triggering_anchors but it didn't work:

    polygon_zone = sv.PolygonZone(
        polygon=zone_ndarray,
        frame_resolution_wh=(img_width, img_height),
        # Make a detection be considered inside the zone if there is any
        # overlap.
        triggering_anchors=[
            Position.TOP_LEFT,
            Position.TOP_RIGHT,
            Position.BOTTOM_RIGHT,
            Position.BOTTOM_LEFT,
        ],
    )

Thanks!

Additional

No response

@marcospgp marcospgp added the question Further information is requested label Mar 19, 2024
@marcospgp
Copy link
Author

marcospgp commented Mar 19, 2024

I believe my code would work if this line had an np.any instead of np.all:

is_in_zone: npt.NDArray[np.bool_] = np.all(is_in_zone, axis=1)

Maybe there could be a way to specify whether one wants to register a detection if all anchors are contained, or if any is?

Maybe a require_all_anchors=True parameter to the sv.PolygonZone() constructor, which by defaulting to True would not cause any breaking changes.

This list of anchors way of specifying how to determine presence is not ideal maybe, I believe most use cases would be either "full overlap" or "any overlap". Currently, only full overlap is possible, and the default of (Position.BOTTOM_CENTER) does not seem like a common use case at all 🤔

@SkalskiP
Copy link
Collaborator

Hi once again, @marcospgp 👋🏻 Yup, it looks like changing this one line could unlock you. Would you like to implement such a feature for us?

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

No branches or pull requests

2 participants