Hi Nils, You won't be able to do this with an Executable, because the execute() function is called on a background thread rather than the UI thread (to keep the UI responsive).
See this thread for an example of code that can be used to do this from a UI callback, such as a knob_changed call: http://community.thefoundry.co.uk/discussion/topic.aspx?f=191&t=115659 The magic line is "gotoContext(ctx, false)", which will update the UI context to be the context passed in. Here, "false" means that the UI will not be updated when the context changes, but if instead you were to pass in "true" here, the UI context (and therefore the image displayed by the Viewer) would change to reflect the frame currently being processed. It's not possible to do this without blocking the UI, though. You'll find that all our nodes (including the Camera Tracker) do not allow UI interaction while analysis is in progress (apart from to cancel the analysis). Regards, Lucy On Wed, Nov 4, 2015 at 1:20 PM, Nils Plath <[email protected]> wrote: > Dear Nuke-dev community, > > I feel that an answer to the following question already exist somewhere > but couldn't yet find it and > keep running into dead ends. > > TLDR: How can an implementation of Executable display its currently > processed image in the viewer? > > The official example [1] demonstrates quite nicely that the viewer does > not display the currently > processed frame while DD::Image::Executable is processing an image > sequence, i.e. it continues to > display the last frame that was selected before starting Executable. > > Interestingly, when adding > > build_handles( ViewerContext * ctx ) > draw_handle( ViewerContext * ctx ) > > to the above example, the handles are drawn > > * each time before Executable::executable() and > * the first time a row of the input is fetched: row.get( input0(), ... > > How does that go together? > > The CameraTracker is able to do this kind of viewer update, but it seems > to use some sort of unknown > trickery since it doesn't appear to be an instance of > DD::Image::Executable: > > // Assuming input(0) of the Op connects to an instance of the > CameraTracker. > DD::Image::Executable* ex0 = input(0)->execute(); > DD::Image::Executable* ex1 = dynamic_cast<DD::Image::Executable*>( > input(0) ); > // ex0 and ex1 are both NULL > > A similar question has been asked in forum [3] but never received an > answer. A couple of years back > Georgiy Osipov suggested a way to manually process an image sequence which > allows to set the context > to the current frame and also updates the viewer [2]. While his methods > does what I want it blocks > the UI of Nuke. > > I also tried to switch the frame from inside Executable::execute via the > NDK and via the Python > interface - to no avail. I thought of (but didn't try yet) to fetch the > image from the input Op > inside draw_handle() and then manually turn it into an OpenGL texture and > display it. But I'm not > sure that even works. > > Since I don't think that the original authors of the CameraTracker feel an > overwhelming urge to > share how they tackled this problem (am I wrong?!?), I wonder if this can > be done at all with the > current NDK? If yes, did someone else face this problem and found a > solution to it? > > > Sincerely, > Nils > > [1]: > http://docs.thefoundry.co.uk/nuke/90/ndkreference/examples/NormaliseExecute.cpp > [2]: > https://www.mail-archive.com/nuke-dev%40support.thefoundry.co.uk/msg00902.html > [3]: > http://community.thefoundry.co.uk/discussion/topic.aspx?f=191&t=108573 > > -- > Nils Plath > Researcher > imcube labs GmbH > > Helmholtzstraße 2-9 > D-10587 Berlin > > phone: + 49 30 367405320 > mail: [email protected] <mailto:[email protected]> > web: www.imcube.de <http://www.imcube.de> > > Handelsregister | Register of Commerce AG | District Court] Berlin | > Charlottenburg HRB 120009 > [Geschäftsführer | Managing Directors] Dr. Sebastian Knorr > > Please consider your environmental responsibility before printing this > e-mail. > > This message is exclusively for the person addressed or their > representative. If you are not the intended recipient of this message and > its contents, please notify the sender immediately. Any form of > unauthorised use, publication, reproduction, copying or disclosure of the > content of this e-mail is not permitted. Electronically transmitted > messages can contain errors for which we assume no liability. > > > _______________________________________________ > Nuke-dev mailing list > [email protected], http://forums.thefoundry.co.uk/ > http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-dev > > -- Lucy Wilkes Senior Software Engineer The Foundry 5 Golden Square, London, W1F 9HT Tel: +44 (0)20 7479 4350 Web: www.thefoundry.co.uk Email: [email protected] The Foundry Visionmongers Ltd. Registered in England and Wales No: 4642027
_______________________________________________ Nuke-dev mailing list [email protected], http://forums.thefoundry.co.uk/ http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-dev
