Resize COCO bounding boxes for object detection

1.6k views Asked by At

So here is my first question here. I am preparing a dataset for object detection. I have done the following things so far:

  1. I have an original picture (size w4000 x h3000).
  2. I used the annotation platform Roboflow to annotate it in COCO format, with close to 250 objects in the picture.
  3. Roboflow returned a downscaled picture (2048x1536) with a respective json file with the annotations in COCO format.
  4. Then, to obtain a dataset from my original picture (as I have a lot of objects and the picture is big enough), I decided to tile the original picture in patches of 224x224. For this purpose, I upscaled a bit (4032x3136) to be able to slice it properly, obtaining 252 pictures.

QUESTIONS

  1. How can I resize the bounding boxes of the Roboflow 2048x1536 picture to my original picture (4032x3136)?

  2. Once the b.boxes are resized to my original size picture, how can I resize them again, adapting the size to each of my patches (224x224) created by slicing the original picture?

Thank you!!

1

There are 1 answers

0
Joseph Nelson On

It sounds like the ultimate goal is to have tiled 224x224 images from the source 4032x3136 images with bounding boxes correctly updated.

In Roboflow, at least, you can add tiling as a preprocessing step to your original 4032x3136 images. The images will be broken into the number of tiles you select (2x2, 3x3, NxY). The bounding boxes will be correctly updated to cover the objects across each individual tile as well.

To reimplement in code from what you've described, you would need to:

  1. Upscale your 2048x1536 images to 4032x3136
  2. Scale the bounding boxes accordingly
  3. Break the images into 224x224 tiles using something like Pil
  4. Update the annotations to be broken into the coordinates on the respective tiles; one annotation per tile