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

Copy labelled shape meta data to pasted shape #137

Open flurmbo opened 6 years ago

flurmbo commented 6 years ago

Purpose / Goal

Implements #115. Copies category, label, feature point labels, clones attribute and tag arrays and then stores them as properties of a metadata object passed into attachShapeToImg.

This might not be the cleanest implementation. I think it would be better if the shapes in the selectedElements array already had a copy of the metadata, but I wasn't sure how to do that. I am also not completely sure what the difference between shape and getShape(shape.node.id) is.

This implementation seems to work though so thought I would make a pull request anyways to see what others think.

Type

Please mention the type of PR

Note : Please ensure that you've read contribution guidelines before raising this PR.

amitguptagwl commented 6 years ago

@flurmbo there is an object labelledData which contains all the detail of shape, points, and images. What you need is particular id to get the detail. When you need metadata of a shape or to store it you can directly interact with labelledData. I hope, it can answer your question.

Though you've done the good job to do the changes but I believe some of the changes may introduce the bugs. I'll really appreciate it recheck your changes and test the application.

flurmbo commented 6 years ago

Hi @amitguptagwl, thanks for your prompt reply! I think you mean labellingData? If so, I did use that. In the function getMetadata(), I call getShape() which interacts with the labellingData array.

What I don't understand is why the objects returned from labellingData contain the metadata while the objects in selectedElements do not. So perhaps a more intuitive solution than my pull request would be to go in and change how selectedElements is set.

amitguptagwl commented 6 years ago

As I said previously, labellingData contains all the detail. When a user copies the shapes from one image, this action should basically capture the shape detail from the workarea and paste the same on other image. Hence it doesn't have metadata. Now as we want to copy the metadata as well, there are 2 solutions I can see;

  1. When a user copies shapes, capture the metadata from the labellingData and save it to copiedElements. When the user pastes the data, read everything from copiedElements and insert into labellingData then re-render the workarea..
  2. When a user copies shapes, capture only the IDs (or necessary data) to copiedElements. When the user pastes the data, read data from labellingData and insert into labellingData then re-render the workarea.