Track — Natron 2.5.0 documentation

# 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 description below.

### Functions

- def `setScriptName` (scriptName)

- def `getScriptName` ()

- def `getParam` (paramScriptName)

- def `getParams` ()

- def `reset` ()

## Detailed Description

The track is internally represented by multiple parameters 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)` 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)
  Parameters

    scriptName – `str`

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

    Tracker1.tracker.MyTrackScriptName

NatronEngine.Track.getScriptName()
  Return type

    `str`

  Get the script-name of the track

NatronEngine.Track.getParam(paramScriptName)
  Return type

    `Param`

  Get the `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()
  Return type

    `Param`

  Returns a list of all the `Param` for this track.

NatronEngine.Track.reset()

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