Search code examples
pythondeep-learningcomputer-visionobject-detectionobject-detection-api

Why does an image saved from the bounding box produced from a model have much lesser resolution compared to the original image


I have trained the faster_rcnn_resnet50 model using the the Tensorflow object detection api. I have trained the model for images of size (1366,768) and am using the same size while testing. However, when I save the content of the bounding box as a separate image, I observe that the image dimension gets reduced to (250,50) which is a quite significant drop. Is there a reason why this is happening?

Predicted image: (1366,768) dimension image from test set
Bounding box saved as image image dimension becomes (250,50)

I am adding the following lines of code below the last cell object_detection_tutorial.ipynbto save the region inside the bounding box as a new image

img = cv2.imread(image_path)
box = np.squeeze(boxes)
for i in range(len(boxes)):
    ymin = (int(box[i,0]*height))
    xmin = (int(box[i,1]*width))
    ymax = (int(box[i,2]*height))
    xmax = (int(box[i,3]*width))
    roi = img[ymin:ymax,xmin:xmax].copy()
    cv2.imwrite('path/engine_box_{}.jpg'.format(str(count)), roi)

Solution

  • A bounding box is an area containing the object detected by the model, of course, its size would be much smaller than that of the original image. What is your expectation?