-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Fix polygon trigger false positives when bounding boxes are clipped #1748
base: develop
Are you sure you want to change the base?
Fix polygon trigger false positives when bounding boxes are clipped #1748
Conversation
|
Hi @YoungjaeDev 👋🏻 I'm not sure I understand correctly. Did your bounding boxes have coordinates that extended beyond the video frame? |
Hi, @SkalskiP 👋 |
Hi, In the video, the However, as shown in the image, the bounding box of the person had only the left corner inside the polygon, yet the count still increased. Upon inspecting the In the PR I submitted, the code is as follows original_anchors = np.array([
np.ceil(detections.get_anchors_coordinates(anchor)).astype(int)
for anchor in self.triggering_anchors
])
original_anchors_clamped = np.clip(
original_anchors,
a_min=[0, 0],
a_max=[self.mask.shape[1] - 1, self.mask.shape[0] - 1]
)
is_in_zone_original = self.mask[
original_anchors_clamped[:, :, 1],
original_anchors_clamped[:, :, 0]
].transpose().astype(bool) This code calculates the anchors based on the original detection coordinates and clamps them to the polygon mask’s dimensions. This approach avoids distorting the bounding box and accurately checks whether the anchor is within the polygon. |
Please understand that there are many masks on the image to protect privacy. |
Hi @YoungjaeDev 👋🏻 sorry for the late reply. I had some time off at the turn of the year and just got back. Do I understand correctly that the coordinates of your bounding boxes exceed the dimensions of the image? Otherwise, clipping would not have a negative effect for you. |
Description
Please include a summary of the change and which issue is fixed or implemented. Please also include relevant motivation and context (e.g. links, docs, tickets etc.).
Fixed an issue where objects partially overlapping with polygons were incorrectly detected. Previously, when a polygon was positioned on the left side of the screen and a person on the right, with the person's bounding box slightly overlapping the polygon, the clip_boxes() function would forcefully clip the boxes to fit within the frame. This caused objects outside the frame to be incorrectly identified as being inside the polygon.
Changes
The original bounding box is large, and its bottom center point does not overlap with the polygon. However, during the clipping process, since the bottom-left corner intersects with the polygon, the box is forcefully shrunk. This causes the center point to shift inside the polygon, resulting in false detections.
Thank you
List any dependencies that are required for this change.
Type of change
Please delete options that are not relevant.
How has this change been tested, please provide a testcase or example of how you tested the change?
YOUR_ANSWER
Any specific deployment considerations
For example, documentation changes, usability, usage/costs, secrets, etc.
Docs