mbari-org / vars-annotation

Video Annotation Application for MBARI's Media Management (M3) software stack
https://docs.mbari.org/vars-annotation/
Apache License 2.0
16 stars 6 forks source link

Localization sync with Sharktopoda2 is not working correctly #170

Closed hohonuuli closed 7 months ago

hohonuuli commented 7 months ago

This is caused by https://github.com/mbari-org/annosaurus/pull/41. I think the root cause is that we can't set the uuid of objects before we create them in the database. They have to be created by the database's id generator now. We were setting an association's uuid (VARS) to be the localization's uuid (Sharktopoda) so that they match. But after creating the association in the database, it will have a different UUID, so the two apps have different UUIDS for the same object. The offending location in vars-annotation is LocalizedAnnotation.java:165:

    public static Association toAssociation(Localization x) {
        BoundingBox bb = new BoundingBox(x.getX(), x.getY(), x.getWidth(), x.getHeight(), "VARS Annotation");
        String json = gson.toJson(bb);

        return new Association(BoundingBox.LINK_NAME,
                Association.VALUE_SELF,
                json,
                "application/json",
                x.getUuid());    // <--- FIXME
    }

Possible tasks:

  1. create - works
  2. update in VARS - VARS updates correctly but the label does not get propagated to Sharktopda
  3. delete annotation in VARS - works (box is removed from sharktopoda)
  4. delete bouding box association in VARS - Removed in VARS/db but not removed from Sharktopoda view
  5. Move/resize bounding box in Sharktopoda - works
hohonuuli commented 7 months ago

Got it working again. Note that deleting a bounding-box association in VARS does't propagate to Sharktopoda. The reason is:

  1. Changed annotations are picked up by the OutgoingController.handle method. It filters for bounding box associations. However, since it's deleted it doesn't find the localization uuid it needs to tell sharktopoda to drop it.
  2. There's no event for a deleted association on the event bus. It just calls AnnotationServiceDecoraor.refreshAnnotationsView(observationUuids). I should add an AssociationDeletedEvent that can be be picked up by the OutgoingController.

A similar thing happens when editing the bounding box cords in VARS. They don't get propagated to Sharktopoda.

hohonuuli commented 7 months ago

The fix has two parts in IncommingController.handleAdd

  1. Immediately delete the localization in Sharktopoda using the localiation's UUID.
  2. Change the source of the CreateAnnotationAtIndexWithAssociationCmd from LocalizationController.EVENT_SOURCE to anything else. This allows the OutgoingController to re-add the localization with the UUID generated by the database.