NaturalIntelligence / imglab

To speedup and simplify image labeling/ annotation process with multiple supported formats.
https://solothought.com/imglab/
MIT License
985 stars 608 forks source link

Importing in COCO format changes shape.type #136

Closed alecGraves closed 5 years ago

alecGraves commented 6 years ago

Describe the bug Stored type 'rect' shape objects are turned into type 'polygon' when imported from a .json with the coco.js dataformatter

To Reproduce

  1. console.log(shape) in the toCOCO loop in dataformatters/coco.js

  2. console.log(labellingData[ image.file_name ].shapes[-1]) in the fromCOCO function in dataformatters/coco.js

  3. Export then import some rectangle labels to/from a coco .json while watching console log

  4. notice the change in shape.type from 'rect' to 'polygon'

Device detail (please complete the following information):

Additional context This did not impact saving and loading bbox data, which is the functionality I need. I have added this issue mostly to document the problem.

I think it may have something to do with this logic that tries to reconstruct different shapes.

Watch for changes, or Bookmark for easy discovery. Fund this project for new features and maintenance. [Showcase] your project with us by raising an issue

amitguptagwl commented 6 years ago

@jbovee will you be able to check the issue?

jbovee commented 6 years ago

I'm pretty sure the issue is a result of how shapes are saved in the COCO format. Since the shape type (rect, polygon, circle) is not saved, a rectangle and a polygon with the exact same points and with the polygon points created in clockwise order are indistinguishable. I'll try taking a closer look to see if there's any way around it.

amitguptagwl commented 6 years ago

Thanks for your attention.

On Wed, 7 Nov 2018 09:57 jbovee, notifications@github.com wrote:

I'm pretty sure the issue is a result of how shapes are saved in the COCO format. Since the shape type (rect, polygon, circle) is not saved, a rectangle and a polygon with the exact same points and with the polygon points created in clockwise order are indistinguishable. I'll try taking a closer look to see if there's any way around it.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/NaturalIntelligence/imglab/issues/136#issuecomment-436501009, or mute the thread https://github.com/notifications/unsubscribe-auth/AHVgKAL8u3RIMmv9lQ71jqa9wNNxPUzRks5usmEvgaJpZM4YRsTH .

amitguptagwl commented 6 years ago

@jbovee I believe you wanted to check if the saved shape is rectangle then don't create polygon. What's about this condition;

} else if (segLength !== 8 || (segmentation[2] - segmentation[0]) !== (segmentation[4] - segmentation[6]) || (segmentation[3] - segmentation[1]) !== (segmentation[5] - segmentation[7]) ) {
   //crete polygon
}
amitguptagwl commented 5 years ago

I've fixed this change. @alecGraves I hope you should not see the issue anymore. Feel free to reopen the issue if you still face it.