Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Move mask depending on accuracy of MotionTracker

  • Move mask depending on accuracy of MotionTracker

    Posted by John Adams on March 9, 2009 at 1:22 pm

    Hi —
    I’m new to scripting in AE and am looking for some help with an expression to help me automatically move a layer into or out of frame depending on the accuracy of a motionTracker attach point.

    I want the script to check the attachPoint’s position and if it falls within an acceptable range of values then the targeted layer will remain in place. If it falls outwith that range, the targeted layer will move to a different position (out of frame, basically).

    My problem: How can I specify the range of acceptable values in a way AE likes? My inclination is that I will need to use an interpolation expression…

    For what it’s worth, this is what I have so far. Try not to laugh… it’s incomplete, I know, the ‘range’ aspect (leeway) of this expression is half-baked — any help is hugely appreciated.

    layerHome = [960,540]; // target layer's home position
    xTarget = [1230,152]; // the 'perfect' position for attach point
    trkrAttach = thisComp.layer("Cam10").motionTracker("Tracker 1")("Track Point 1").attachPoint; //attach point's  real value
    
    leeway = 10; // range in pixels acceptable for xTarget to deviate
    
    if (trkrAttach != xTarget){
    this_layer.position = [3000,3000]
    } else {
    this_layer.position = layerHome;
    }

    Rugged yet hygienic.

    John Adams replied 17 years, 2 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    March 9, 2009 at 1:49 pm

    I think you just need to change your if statement to something like this:

    if (length(trkrAttach,xTarget) > leeway){

    Dan

  • John Adams

    March 9, 2009 at 2:03 pm

    Brilliant! Works like a charm. Massive thanks, Dan
    You’ve just saved me hours of removing tracking markers from a greenscreen backdrop by hand.

    I’ll have to learn more about “length” as I don’t have a scoobie what it means… but I know it works. Cheers!

    Rugged yet hygienic.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy