how do I export annotations via python as a function with given filepath.
In my world I imagine something like
exportAnnotatedFrames(filepath+filename+"%04d.jpg")
I managed to import this function form rvui.mu but then i get the gui popupwindow to enter the filepath and name.
If you check out plugins/Mu/rvui.mu’s exportAnnotatedFrames you’ll see that it is effectively doing the following pseudocode:
Save the currently marked frames as a list
Clear the marked frames
Mark the annotated frames
Export the Marked Frames
Clear the marked frames
Restore the saved marked frames.
exportMarked() is where the file system dialog is called.
You can effectively replace the whole sequence of events in Python if you wanted to with something kinda like this (though, admittedly, without feeding the external process back into the State object, it won’t show the built in progress dialog
import rv
import pymu
priorMarked = rv.commands.markedFrames()
annotatedFrames = rv.extra_commands.findAnnotatedFrames()
# Use set differences to figure out what frames we need to mark and unmark
toAdd = list(set(annotatedFrames) - set(priorMarked))
toSub = list(set(priorMarked)-set(annotatedFrames))
# Generalize this into a function so you can reverse it after export.
for f in toSub:
rv.commands.markFrame(f, False)
for f in toAdd:
rv.commands.markFrame(f, True)
rv.commands.redraw()
# Do your path substitution here
rv.runtime.eval("""
require runtime;
use rvtypes;
{
runtime.load_module("export_utils");
let Fname = runtime.intern_name("export_utils.exportMarkedFrames");
(ExternalProcess;string,string) F = runtime.lookup_function(Fname);
F("D:/test.%04d.jpg", "default");
}
""", [])
If you want to get really fancy with parallelism, check out how the h264 exporter example plugin works between Python and Mu with signal passing.
Ok, thank you very much Michael !
There is nothing I can do, cause the company uses the old rv .
But I think your code will help others, it is a thing most companys will need to do and if they don’t have already it wil help.
Is there a way to name the files based on the source image the annotations were drawn on? So if there are 3 shots in a session each with their own annotations, can I export the annotations and get shot1.%04d.jpg, shot2.%04d.jpg, shot3.%04d.jpg?