Skip to content

Commit

Permalink
feat: export bbox & area for keypoints
Browse files Browse the repository at this point in the history
  • Loading branch information
cefeng06 committed Dec 11, 2023
1 parent 0ba4fe4 commit f182287
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions packages/app/src/utils/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,25 @@ export const convertToCocoDateset = (
keypoints.push(points[i * 6], points[i * 6 + 1], points[i * 6 + 4]);
num_keypoints += 1;
}

Object.assign(newAnnotation, {
keypoints,
num_keypoints,
area: 0,
bbox: [0, 0, 0, 0],
});

if (annotation.boundingBox) {
const { x, y, width, height } = translateBoundingBoxToRect(
annotation.boundingBox,
{
width: image.width,
height: image.height,
},
);
const area = width * height;
const bbox = [x, y, width, height];
Object.assign(newAnnotation, { area, bbox });
}

const targetCategory = cocoDataset.categories.find(
(item) => item.name === categoryName,
);
Expand Down

0 comments on commit f182287

Please sign in to comment.