From 8142d7684fca88e335baf4c5b31533354f6177c4 Mon Sep 17 00:00:00 2001 From: Soham Date: Sun, 1 Dec 2024 21:34:46 +0530 Subject: [PATCH] fix: change to x,y,w,h format --- models/license_plate_detection_yunet/lpd_yunet.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/models/license_plate_detection_yunet/lpd_yunet.py b/models/license_plate_detection_yunet/lpd_yunet.py index 36d89613..49c56855 100644 --- a/models/license_plate_detection_yunet/lpd_yunet.py +++ b/models/license_plate_detection_yunet/lpd_yunet.py @@ -61,10 +61,17 @@ def infer(self, image): def _postprocess(self, blob): # Decode dets = self._decode(blob) + + # convert to x, y, w, h format + bboxes = np.zeros((dets.shape[0], 4)) + 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 # NMS keepIdx = cv.dnn.NMSBoxes( - bboxes=dets[:, 0:4].tolist(), + bboxes=bboxes.tolist(), scores=dets[:, -1].tolist(), score_threshold=self.confidence_threshold, nms_threshold=self.nms_threshold,