Hi all,
I want to store some per-frame preprocessed data in my op, and after
some investigations it's not clear to me how this is supposed to be
implemented.
I would even claim that the Serialize example in the NDK, which is
supposed to show how to store arbitrary data, is not working as
expected. If you want to store some state, and make use of that state in
engine(), the example won't work. As soon as multiple instances of your
op are created (for the same node), things will go wrong.
For example, if you just feed some video into the Serialize example
node, and add some code that modifies the internal state (e.g. in
_close(), or any other callback that happens on the UI thread),
everything seems to work fine. The state gets serialized when saving the
project, and de-serialized on loading.
However, now place a TimeBlur node after the Serialize example node. At
some point Nuke decides to create a new instance of your Op, for the
same node. The two instances will share the _same_ 'SerializeKnob'
object, however they each have their own instance of the data
('important_data_to_keep'). from_script is not called again when the new
op instance is created. The two instances now have different views of
the world, i.e. different internal states. If they use this information
in engine() (which is the whole point of storing such data I assume),
they will now produce inconsistent outputs.
I guess the solution would be to store the data as a member of the
'SerializeKnob', instead of as a member of the op. But unfortunately
this is not how the Serialize example is set up, and I wonder why that is.
Some questions remain, for example: if the data is stored in the custom
knob, when is it ok to update it? From which thread? Does the op have to
take care of locking? How and when to store data that has been computed
in engine()?
What I'm actually trying to do is to analyze the input image in engine()
and store that information in the Op for future engine() calls. Think of
tasks like computing the histogram of each frame and storing that
information per frame for future processing. Or computing motion vectors
between two consecutive frames, and storing this information per frame
for further processing in a second pass.
Maybe the answer is to use execute() for such pre-computations. But then
the question is, how to store the pre-computed data, i.e. how to combine
the NormaliseExecute and the Serialize examples. And how to make sure
things still work when multiple instances of an op exist. It would be
really helpful to have such an example in the NDK.
Thanks,
Peter
_______________________________________________
Nuke-dev mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-dev