Skip to content

Latest commit

 

History

History
111 lines (66 loc) · 3.25 KB

File metadata and controls

111 lines (66 loc) · 3.25 KB

NatronEngine

Track

Synopsis

This class represents one track marker as visible in the tracker node or on the viewer. It is available to Python to easily retrieve the tracked data. See detailed<track.details> description below.

Functions

  • def setScriptName<NatronEngine.Track.setScriptName> (scriptName)
  • def getScriptName<NatronEngine.Track.getScriptName> ()
  • def getParam<NatronEngine.Track.getParam> (paramScriptName)
  • def getParams<NatronEngine.Track.getParams> ()
  • def reset<NatronEngine.Track.reset> ()

Detailed Description

The track is internally represented by multiple parameters<Param> which holds animation curve for various data, such as: the track center, the pattern 4 corners, the error score, the search-window, etc... Each of them can be retrieved with the getParam(scriptName)<NatronEngine.Track.getParam> function.

Here is an example briefly explaining how to retrieve the tracking data for a track:

myTrack = app.Tracker1.tracker.track1

keyframes = []

# get the number of keys for the X dimension only and try match the Y keyframes
nKeys = myTrack.centerPoint.getNumKeys(0)
for k in range(0,nKeys):

    # getKeyTime returns a tuple with a boolean value indicating if it succeeded and
    # the keyframe time

    gotXKeyTuple = myTrack.centerPoint.getKeyTime(k, 0)
    frame = gotXKeyTuple[1]

    # Only consider keyframes which have an X and Y value
    # If Y does not have a keyframe at this frame, ignore the keyframe
    # getKeyIndex returns a value >=0 if there is a keyframe
    yKeyIndex = myTrack.centerPoint.getKeyIndex(frame, 1)

    if yKeyIndex == -1:
        continue

    # Note that even if the x curve or y curve didn't have a keyframe we
    # could still call getValueAtTime but the value would be interpolated by
    # Natron with surrounding keyframes, which is not what we want.

    x = myTrack.centerPoint.getValueAtTime(frame, 0)
    y = myTrack.centerPoint.getValueAtTime(frame, 1)

    keyframes.append((x,y))

print keyframes

Member functions description

NatronEngine.Track.setScriptName(scriptName)

param scriptName

str<NatronEngine.std::string>

Set the script-name of the track. It will then be accessible via a Python script as such:

Tracker1.tracker.MyTrackScriptName

NatronEngine.Track.getScriptName()

rtype

str<NatronEngine.std::string>

Get the script-name of the track

NatronEngine.Track.getParam(paramScriptName)

rtype

Param<NatronEngine.Param>

Get the Param<NatronEngine.Param> with the given paramScriptName. The parameter can also be retrieved as an attribute of the tracker object like this:

Tracker1.tracker.center

NatronEngine.Track.getParams()

rtype

Param<NatronEngine.Param>

Returns a list of all the Param<NatronEngine.Param> for this track.

NatronEngine.Track.reset()

Resets the track completely removing any animation on all parameters and any keyframe on the pattern.