Skip To Main Content
Support Knowledge Base

Incorrect Coordinates When Creating Bounding Box in Custom Detection Application

Content Type: Troubleshooting   |   Article ID: 000092862   |   Last Reviewed: 06/14/2023

Description

  • Function used to arrange the model architecture to generate bounding box with correct coordinates as below: 

    detections = result.reshape(-1, 5) 
         for i, detection in enumerate(detections): 
             xmin, ymin, xmax, ymax, confidence = detection 
             if confidence > 0.2: 
                 xmin = int(max((xmin * image.shape[1]), 10)) 
                 ymin = int(max((ymin * image.shape[0]), 10)) 
                 xmax = int(min((xmax * image.shape[1]), image.shape[1] - 10)) 
                  ymax = int(min((ymax * image.shape[0]), image.shape[0] - 10)) 

  • Obtained incorrect coordinates of the bounding box. 

Resolution

Set the margin at least ten pixels from the image edge when drawing the bounding box as below:

xmin = int(max(xmin, 10))

ymin = int(max(ymin, 10))

xmax = int(min(xmax, image.shape[1] - 10))

ymax = int(min(ymax, image.shape[0] - 10))

Related Products

This article applies to 1 products.