-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Hello, may I ask if the compoundPath function in paper.js can be used to achieve the conversion between coco segmentation and compoundPath? I need to convert a compoundPath into segmentation, and at the same time, I also need to convert segmentation into compoundPath, all based on the image's width and height. I hope there is such a similar function.
`
function compoundPathJsonToSegmentation(
compoundPathJson,
imageWidth,
imageHeight,
) {}
function segmentationToCompoundPathJson(
segmentation,
imageWidth,
imageHeight,
) {}
`
this is the example data of compoundPath and segmentation
`
;[
'CompoundPath',
{
applyMatrix: true,
opacity: 0.6,
data: {
annotationId: 0,
categoryId: 0,
uuid: 'aec8b72c-8b7d-450e-a69b-7103deed0615',
},
children: [
[
'Path',
{
applyMatrix: true,
segments: [
[-139, -346],
[-122, -344],
[-62, -345],
[-17, -343],
[5, -340],
[16, -336],
[20, -336],
[28, -333],
[32, -329],
[33, -320],
[30, -305],
[25, -293],
[25, -287],
[23, -282],
[15, -274],
[15, -269],
[18, -263],
[17, -250],
[9, -238],
[0, -217],
[-5, -212],
[-10, -203],
[-24, -196],
[-40, -197],
[-53, -201],
[-57, -204],
[-61, -204],
[-73, -209],
[-86, -212],
[-90, -215],
[-110, -220],
[-119, -224],
[-122, -227],
[-125, -227],
[-145, -237],
[-195, -256],
[-199, -260],
[-199, -266],
[-196, -272],
[-171, -302],
[-168, -310],
[-155, -330],
[-150, -344],
[-147, -346],
],
closed: true,
},
],
],
fillColor: [0.8, 0.7, 0.1],
},
]
const segmentation = [
[
373, 166, 390, 168, 450, 167, 495, 169, 517, 172, 528, 176, 532, 176, 540,
179, 544, 183, 545, 192, 542, 207, 537, 219, 537, 225, 535, 230, 527, 238,
527, 243, 530, 249, 529, 262, 521, 274, 512, 295, 507, 300, 502, 309, 488,
316, 472, 315, 459, 311, 455, 308, 451, 308, 439, 303, 426, 300, 422, 297,
402, 292, 393, 288, 390, 285, 387, 285, 367, 275, 317, 256, 313, 252, 313,
246, 316, 240, 341, 210, 344, 202, 357, 182, 362, 168, 365, 166,
],
]
`