Open MRLoghmani opened 7 years ago
You could implement a plugin that updates the annotations on request.
The plugin constructor will get the LabelTool object as a parameter.
You can retrieve the path of the currently selected image with: labeltool.currentImage()["filename"]
Thanks for your answer! It's still not clear to me how I am supposed to update the Annotation Widget. Let's say I want to send a request by pressing the 'Space' key. So I override the HOTKEYS in the myconfig.py file. How do I do it? For now I am basically calling sloth.core.loadAnnotations(), but this reloads the whole annotation file and thus de-selects the image. Even by calling gotoNext() after, the image doesn't appear unless you manually select it in the tree of the Annotation Widget.
Afaik sloth only reads a config file when you tell it to do so (either clicking on the Open
button or in the menu File->Open
. To update the config automatically, you would need to create some kind of watchdog for the file that will re-call the fileOpen
function or you create a "Reload Config" button somewhere (search for example for Open
in the code and you will get an idea on how to do so by modifying sloth/gui/labeltool.{ui,py}
). But keep in mind, any not saved changes made in the GUI will be lost then, unless you figure out how to merge the currently used config (i.e. annotation state) and the new one. Please feel free to submit a Pull Request for this feature, might actually be useful for more people than just yourself!
@nilsonholger thank you for your answer. For my purpose I am not really interested in enriching the GUI because my purpose is to make things as fast as possible. This is why I wrote that I want to include these functionalities in a HOTKEY (e.g. the 'Space' button). Now my application is complete, but with the same flaw I pointed out in my previous comment: when I save the changes, load again the annotation file and select the next image ( based on 'onCurrentImageChanged()' ), the image I select doesn't have the new labels (even if they appear in the treeview). If I click on the corresponding image in the tree of the Annotation Widget, than it visualizes the new labels as well. I really don't get how to overcome this problem.
Sorry for the late answer. This sounds like there is a GUI update missing...here's what I did to reproduce:
So yeah, there seems to be some update step missing...right now I have no idea where to look for it, except for the code that executes right after the fileOpen
call in the GUI...
I'm trying to extend the tool for my scenario, but I got stuck because of two small tasks: 1) I need to get the name of the currently selected image in my script; 2) Since I update the annotation (.json file with the labels) from other sources other than the GUI, I would like to update the annotation section (in the GUI) while the app is running;
Any solutions / suggestions?