Skip to content

Commit

Permalink
Merge pull request #127 from alecGraves/master
Browse files Browse the repository at this point in the history
Convert 'bbox' annotation in json to vaid COCO format.
  • Loading branch information
amitguptagwl committed Oct 27, 2018
2 parents 07ed692 + 1876598 commit 429ec9a
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion dataformaters/coco.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ var cocoFormater = {
const annotation = cocoData.annotations[ annot_i ],
segLength = annotation.segmentation[0].length;
if (annotation.image_id === image.id) {
// convert COCO to old format
if (!('x' in annotation.bbox)) {
annotation.bbox = {
x : annotation.bbox[0],
y : annotation.bbox[1],
width : annotation.bbox[2],
height : annotation.bbox[3],
w : annotation.bbox[2],
h : annotation.bbox[3],
cx : annotation.bbox[0]+annotation.bbox[2] / 2, // x max
cy : annotation.bbox[1]+annotation.bbox[3] / 2, // y max
}
}
let id = "SvgjsRect",
type = "rect",
bbox = annotation.bbox,
Expand Down Expand Up @@ -122,7 +135,7 @@ var cocoFormater = {
area : area,
"iscrowd": 0,
"image_id": image_i+1,
"bbox": shape.bbox,
"bbox": [shape.bbox.x, shape.bbox.y, shape.bbox.width, shape.bbox.height],
"category_id": categories.indexOf(shape.category) + 1,
"id": shape_i+1,
"ignore": 0
Expand Down

0 comments on commit 429ec9a

Please sign in to comment.