Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: get objects after they have been created #1486

Closed
2 tasks done
frndmg opened this issue May 4, 2020 · 9 comments
Closed
2 tasks done

Feature request: get objects after they have been created #1486

frndmg opened this issue May 4, 2020 · 9 comments
Assignees
Labels
enhancement New feature or request

Comments

@frndmg
Copy link

frndmg commented May 4, 2020

My actions before raising this issue

I am trying to create a set of points and group them using the reducers createAnnotationsAsync and groupAnnotationsAsync in the following way:

onCreateAnnotationsAndGrouping(sessionInstance: any, frame: number, states: any[]): Promise<void> {
    return dispatch(createAnnotationsAsync(sessionInstance, frame, states))
       .then(() => dispatch(groupAnnotationsAsync(sessionInstance, frame, states)))
}

When executing groupAnnotationsAsync the following error is displayed:

Error: The object has not been saved yet. Call annotations.put([state]) before

I have tried setting a timeout before grouping takes place but the same error appears.

The grouping tool works well when I do it by hand.

Expected Behaviour

It should group the points and do not throw any errors.

Current Behaviour

An error is thrown and no grouping occurs.

Possible Solution

I think it should be a bug on the cavt-core API that is causing this. But I can't be sure.

Steps to Reproduce (for bugs)

The code is already shown.

Context

I am trying to develop a way to annotate human pose using keypoints. Right now the approach can lead to pitfalls because you are not forced or encouraged to use correct labels in your annotation process. For now, I just want to programmatically add this points and group them in order to have a template for the human figure.

Eventually, I would like to add a template designer and create a model on the backend side.

It will be good to create a new shape that assembles these graph structures as well.

Your Environment

  • Git hash commit (git log -1): 81a13cb
  • Docker version docker version (e.g. Docker 17.0.05): Not using docker for the development environment but, 18.09.5
  • Are you using Docker Swarm or Kubernetes? No
  • Operating System and version (e.g. Linux, Windows,): uname -srvo: Linux 4.15.0-74-generic #84-Ubuntu SMP Thu Dec 19 08:06:28 UTC 2019 GNU/Linux

Next steps

I already asked this question on Gitter

@frndmg
Copy link
Author

frndmg commented May 4, 2020

@bsekachev
Copy link
Member

@frndmg

In your example you pass states to groupAnnotationsAsync that weren't saved in collection (message is about it). It's wrong using of cvat-core API.

Calling of job.annotations.put(states) (inside createAnnotationsAsync) returns states saved in collection. You should group them instead of.

@bsekachev bsekachev added the question Further information is requested label May 5, 2020
@frndmg
Copy link
Author

frndmg commented May 5, 2020

@bsekachev

Thanks a lot!

I created a new reducer on annotation-actions.ts. I was not sure how to get the new states out of the createAnnotationsAsync.

@bsekachev
Copy link
Member

bsekachev commented May 5, 2020

Theoretically you can get the latest data from the redux storage after createAnnotationsAsync was executed.
But creating a new action and a reducer (as you suggested) is better way I think.

Update:
Also I realized I was mistaked.
sessionInstance.annotations.put doesn't return anything. Just need to get data from the core using sessionInstance.annotations.get after you have done put.

@frndmg
Copy link
Author

frndmg commented May 5, 2020

How could I retrieve the points I just added? @bsekachev

@bsekachev
Copy link
Member

@frndmg

Hmm..
I've just checked how it is possible and I haven't found nice way to do it.
The best option would be to return some information about added objects from annotations.put I suppose. For that we need to update API of cvat-core.

@bsekachev bsekachev added enhancement New feature or request and removed question Further information is requested labels May 5, 2020
@bsekachev bsekachev self-assigned this May 5, 2020
@bsekachev bsekachev changed the title Error when grouping annotations Feature request: get objects after they have been created May 5, 2020
@bsekachev
Copy link
Member

bsekachev commented May 5, 2020

@frndmg

With the PR above you can do something like:

const ids = await session.annotations.put(objectsToSave);
const allObjects = await session.annotations.get(frame);
const objectsJustAdded = allStates.filter((state) => ids.includes(state.clientID));

@frndmg
Copy link
Author

frndmg commented May 5, 2020

I see. This requires fewer changes than I was doing.

I assume it should be allObjects on the last line.

I will add that piece of code until the PR is merged, thanks!

@bsekachev
Copy link
Member

I assume it should be allObjects on the last line.

Sure.
Not at all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants