The short answer to this is, you aren’t going to be able to sample an image in 
the middle of a Python script. The interpreter runs on the main (GUI) thread, 
and will thus block any other operations from occurring until it has finished 
(including letting Nuke process any image data).

The only way you would (potentially) be able to do something like this is to 
run your function on a background thread, and somehow ensure that you don’t 
trigger a frame change before your image has updated and been sampled, but I 
would be very surprised if the necessary hooks were in place to let you avoid a 
blocking situation of some kind.

Similar scenario here: 
http://forums.thefoundry.co.uk/phpBB2/viewtopic.php?t=7579


-Nathan



From: mikeCG 
Sent: Monday, February 18, 2013 10:50 AM
To: nuke-python@support.thefoundry.co.uk 
Subject: [Nuke-python] wait to finish a function before starting a new one

hi guys !

So I'm having this (probably very noob) issue where i'm trying to execute a 
function on every frame for a framerange. (say from frame 1 to 20)

Part of that function includes sampling an image and getting red and green 
value at specific x,y coordinates.
Then applying the resulting values to a point in a rotopaint curve.
then moving nuke.frame() to the next frame

The thing is, the fonction ran with that script can be a little heavy and take 
up to half a second per processed frame.

The problem is that nuke seems to process things wayyyyy too quickly and 
doesn't wait for it to finish before running another iteration of that 
function. As a result, my sampling is not done properly and my rotopaint curve 
goes completely messy. 

So here is my question:
if i run that function manually and wait to see my timeslider move before 
running a new iteration, everything is fine.
So, is there a way to tell nuke to wait to finish that function before running 
a new iteration ?

Note: time.sleep(x) doesn't help :s

Thank you very much !


--------------------------------------------------------------------------------
_______________________________________________
Nuke-python mailing list
Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
_______________________________________________
Nuke-python mailing list
Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

Reply via email to