Skip to content

Conversation

@souhhmm
Copy link
Contributor

@souhhmm souhhmm commented Dec 1, 2024

Fixes #275. Changed format to [x, y, width, height] as per NMSBoxes() and Rect_().

@souhhmm souhhmm changed the title fix: change to x,y,w,h format in NMSBoxes() [re] fix: change to x,y,w,h format in NMSBoxes() Dec 1, 2024
Copy link
Member

@fengyuentau fengyuentau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your fix! We can make use of RotatedRect instead. You could have a look below for more details.

bboxes[:, 0] = np.min(dets[:, [0, 2, 4, 6]], axis=1) # top-left x
bboxes[:, 1] = np.min(dets[:, [1, 3, 5, 7]], axis=1) # top-left y
bboxes[:, 2] = np.max(dets[:, [0, 2, 4, 6]], axis=1) - bboxes[:, 0] # width
bboxes[:, 3] = np.max(dets[:, [1, 3, 5, 7]], axis=1) - bboxes[:, 1] # height
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually NMSBoxes supports RotatedRect (See https://docs.opencv.org/4.x/d6/d0f/group__dnn.html#gaeec27cb32195e71e6d88032bda193162). So there is no need to de-rotate the boxes.

self._decode returns a set of four corners points but RotatedRect only needs three points for constructor (See https://docs.opencv.org/4.x/db/dd6/classcv_1_1RotatedRect.html). So try to remove one set of a corner point from dets and make it being initialized as RotatedRect.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@souhhmm Do you have updates on this?

@souhhmm souhhmm closed this by deleting the head repository Apr 24, 2025
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

Successfully merging this pull request may close these issues.

license_plate_detection_yunet NMSBoxes call with wrong bboxes

2 participants