About
A Mt2dTrackData object stores information on 2D tracks created with the Motion Tracker object. It provides access to Mt2dTrack objects that represent such tracks. Spacial information is represented by MtData objects.
Access
The Mt2dTrackData object is obtained from the parent MotionTrackerObject.
- MotionTrackerObject::Get2dTrackData(): Returns a new Mt2dTrackData object.
- Mt2dTrackData::Free(): Deletes the given Mt2dTrackData object.
- Warning
- The returned object is a copy owned by the caller.
Mt2dTrackData* trackData = moTrackObject->Get2dTrackData();
if (trackData == nullptr)
const Int32 trackCount = trackData->GetTrackCount();
Mt2dTrackData::Free(trackData);
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:69
#define ApplicationOutput(formatString,...)
Definition: debugdiagnostics.h:204
maxon::Int32 Int32
Definition: ge_sys_math.h:51
Access Tracks
The Mt2dTrackData object provides access to 2D tracks:
- Mt2dTrackData::GetTrackCount(): Returns the number of tracks.
- Mt2dTrackData::GetTrackByIndex(): Returns a copy of the track with the given index.
- Mt2dTrackData::GetTrackByGid(): Returns a copy of the track with the given ID.
- Mt2dTrackData::GetTrackIndices(): Returns a BaseSelect containing the valid indices for user tracks and/or auto tracks.
- Mt2dTrackData::GetTrackByName(): Returns a copy of the track with the given Name.
A copy of a track has to be freed with:
- Mt2dTrack::Free(): Deletes the given Mt2dTrack.
Mt2dTrackData* trackData = moTrackObject->Get2dTrackData();
if (trackData == nullptr)
AutoFree<Mt2dTrackData> freeData;
freeData.Assign(trackData);
const Int32 trackCount = trackData->GetTrackCount();
{
Mt2dTrack* track = trackData->GetTrackByIndex(
i);
if (track == nullptr)
AutoFree<Mt2dTrack> freeTrack;
freeTrack.Assign(track);
const String trackName = track->GetName();
const String trackIndex = String::IntToString(
i);
}
Py_ssize_t i
Definition: abstract.h:645
Access Track Data
A Mt2dTrack object stores several properties:
- Mt2dTrack::GetName(): Returns the name of the track.
- Mt2dTrack::GetId(): Returns the ID of the track. An ID is represented by a MtTrkGid object.
- Mt2dTrack::GetStatus(): Returns the status of the track.
A valid status is:
- ::INVALID_TRACK: Not a valid track.
- ::UNTRACKED: Has not yet been tracked.
- ::TRACKED_VALID: Has been tracked, and is up to date.
- ::TRACKED_STALE: Has been tracked, but needs updating.
A track may only be valid for certain frames. This validity is stored in a BaseSelect object:
- Mt2dTrack::GetFramesWithTrackData(): Returns a copy of a BaseSelect that stores the valid frames for the given track.
BaseSelect* frameRange = track->GetFramesWithTrackData();
if (frameRange == nullptr)
AutoFree<BaseSelect> freeFrames;
freeFrames.Assign(frameRange);
{
const String segmentBeginStr = String::IntToString(a);
const String segmentEndStr = String::IntToString(b);
const String trackName = track->GetName();
ApplicationOutput(trackName +
" contains data for the range " + segmentBeginStr +
" to " + segmentEndStr);
}
Definition: apibasemath.h:34
Position Data
The information on the position of the track for a given frame is stored in a MtData object. Such an object is returned by the Mt2dTrack:
- Mt2dTrack::GetDataForFrame(): Returns a copy of a MtData object for the given frame.
- Mt2dTrack::GetDataForCurrentFrame(): Returns a copy of a MtData object for the current frame of the active BaseDocument.
Spacial information is obtained from that MtData object:
- MtData::GetNormalisedPosition(): Returns the normalized position.
- MtData::GetPixelPosition(): Returns the position in pixel coordinates.
- MtData::GetCameraSpaceDirection(): Returns a ray in camera space corresponding to the position of the track.
const Int32 firstFrame = footage->GetFirstFrameNumber();
const Int32 lastFrame = footage->GetLastFrameNumber();
{
if (frameRange->IsSelected(
frame))
{
MtData* frameData = track->GetDataForFrame(
frame);
if (frameData == nullptr)
AutoFree<MtData> freeMtData;
freeMtData.Assign(frameData);
const Vector pos = frameData->GetPixelPosition(footage,
true);
const String posStr = String::VectorToString(
pos);
const String frameStr = String::IntToString(
frame);
}
}
void Py_ssize_t * pos
Definition: dictobject.h:50
maxon::Vec3< maxon::Float64, 1 > Vector
Definition: ge_math.h:140
PyFrameObject * frame
Definition: pycore_traceback.h:92
Further Reading