cocodataset / cocoapi

COCO API - Dataset @ http://cocodataset.org/
Other
6.1k stars 3.76k forks source link

what format is coco annotations? #102

Open zbsean opened 6 years ago

zbsean commented 6 years ago

what format is coco annotations?my annotations format is [[x1,y1],[x2,y2],...[xn,yn]]. but coco annotation format is [[312.29, 562.89, 402.25, 232.61, 560.32, 300.72, 571.89]], what different?

dexter1608 commented 6 years ago

https://github.com/cocodataset/cocoapi/issues/111 any suggestions ? thank you

rafaelpadilla commented 6 years ago

According to here it should be "bbox" : [x,y,width,height]

suhyunified commented 5 years ago

Is it right that x means xmin?

rafaelpadilla commented 5 years ago

Is it right that x means xmin?

For object detection annotations, the format is "bbox" : [x,y,width,height] Where: x, y: the upper-left coordinates of the bounding box width, height: the dimensions of your bounding box

nirandiw commented 5 years ago

Wasn't the question on the "segmentations" within "annotations". Did you figure out how to convert the [[x, y]...] to the values in "segmentations"?

I'm having the same problem.

Atul997 commented 3 years ago

@nirandiw use this to generate segmentation from bounding box annotation["segmentation"] = [[x1,y1,x1,(y1 + y2), (x1 + x2), (y1 + y2), (x1 + x2), y1]]

jpatrickpark commented 3 years ago

@zbsean @nirandiw

COCO segmentation format seems to be a list which contains multiple polygons. Each item in the list should be a separate polygon. Each polygon consists of multiple points, which are stored in the following format of [x0, y0, x1, y1, ..., xn, yn].

For example, in the following segmentation [[224.24, 297.18, 228.29, 297.18, 234.91, 298.29, 243.0, 297.55, 249.25, 296.45, 252.19, 294.98, 256.61, 292.4, 254.4, 264.08, 251.83, 262.61, 241.53, 260.04, 235.27, 259.67, 230.49, 259.67, 233.44, 255.25, 237.48, 250.47, 237.85, 243.85, 237.11, 240.54, 234.17, 242.01, 228.65, 249.37, 224.24, 255.62, 220.93, 262.61, 218.36, 267.39, 217.62, 268.5, 218.72, 295.71, 225.34, 297.55]]:

For another example, I am visualizing an image that has 17 polygons inside a bbox below (using matplotlib.patches.Polygon). Blue lines indicate bbox, and the red lines indicate the polygons. To get segmentation, you should fill inside each of the polygons. image

ricber commented 2 years ago

Hi! May I know why the polygon coordinates are float and not integers? I was expecting integer numbers because I thought they were expressed in terms of pixels. Does it mean that I can have polygons' coordinates in the middle of pixels with a centesimal precision?

Abhishek2271 commented 2 years ago

This could be because of resize, based on the discussions here: https://github.com/cocodataset/cocoapi/issues/34