Tracks and Steps

Figure 2. A PointMass Track with 8 Steps

A PointMass track

A Track represents a single object or video feature that evolves over time. For each video frame, the track stores the image position and/or shape of the object in a Step. The step uses a TPoint array for data storage and interactive mouse control.

Tracks will interpret their steps by providing meaningful world data when queried. They also provide menus and toolbar components that enable users to control their properties with a mouse.

There are several types (subclasses) of tracks and each uses a different type of step, as shown in Table 1. The TPoints associated with each step type are given descriptive names.

Table 1. Tracks, Steps and TPoints

Track Step TPoints
PointMass, CenterOfMass PositionStep position
Force, NetForce VectorStep tip, tail, center handle
CoordAxes CoordAxesStep origin, x-axis handle
TapeMeasure TapeStep end 1, end 2, center handle
OffsetOrigin OffsetOriginStep position
Calibration CalibrationStep position 1, position 2
LineProfile LineProfileStep end 1, end 2, center handle

Tracks implement the OSP Trackable and Interactive interfaces. Every track has a no-argument constructor.

Note: the base class for Tracker tracks is named TTrack rather than Track. This avoids confusion when working with QuickTime movies, which use a Track class to define video and audio tracks. In this tutorial, the word track always refers to a TTrack subclass.

Common Track and Step Methods

Methods that are implemented by all tracks and steps are shown in Listing 1. Here n refers to frame number, and x and y are imagespace coordinates.

Listing 1. Common Track and Step Methods

Track methods: managing steps
public Step createStep(int n, double x, double y);
public Step deleteStep(int n);
public Step getStep(int n); // may return null
public Step[] getSteps();
public boolean isEmpty(); // returns true if the track has no steps

Track methods: setting properties
public void setName(String newName);
public void setVisible(boolean visible);
public void setTrailVisible(boolean visible);
public void setEnabled(boolean enabled); // track responds to mouse input when true
public void setLocked(boolean locked);
public void setAutoAdvance(boolean auto);
public void setMarkByDefault(boolean mark);

Track methods: getting data and components
public DatasetManager getData(TrackerPanel trackerPanel);
public String[] getDataNames(TrackerPanel trackerPanel);
public JMenu getMenu(TrackerPanel trackerPanel);
public ArrayList getToolbarTrackComponents(TrackerPanel trackerPanel);
public ArrayList getToolbarPointComponents(TrackerPanel trackerPanel, TPoint point);

Step methods:
public int getFrameNumber();
public TPoint[] getPoints();

TrackerPanel, an argument in the last four track methods listed, is a subclass of VideoPanel. Tracks use the tracker panel's coords to convert image positions into world data. TrackerPanel is discussed in the TrackerPanel section

Specific Track and Step Methods

Listings 2-6 shows methods defined by specific track and step types.

Listing 2. PointMass Methods

PointMass:
public void setMass(double mass); // default mass is 1.0
public Step[] getVelocities(TrackerPanel trackerPanel); // returns VectorStep[]
public void setVVisible(TrackerPanel trackerPanel, boolean visible);
public Step[] getAccelerations(TrackerPanel trackerPanel); // returns VectorStep[]
public void setAVisible(TrackerPanel trackerPanel, boolean visible);

CenterOfMass (extends PointMass):
public void addMass(PointMass m);
public void removeMass(PointMass m);
public void containsMass(PointMass m);
public PointMass[] getMasses(); // masses that determine the mass and positions of cm

PositionStep:
public TPoint getPosition();

Listing 3. Force Methods

Force:
public Step createStep(int n, double x, double y, double xc, double yc); // xc and yc are components

NetForce (extends Force):
public void addForce(Force f);
public void removeForce(Force f);
public void containsForce(Force f);
public Force[] getForces(); // forces that determine the components of Fnet

VectorStep:
public TPoint getTip();
public TPoint getTail();
public TPoint getHandle();

Listing 4. CoordAxes and TapeMeasure Methods

CoordAxes: no unique methods

CoordAxesStep:
public TPoint getOrigin();
public TPoint getHandle();

TapeMeasure:
public Step createStep(int n, double x1, double y1, double x2, double y2);
public void setFixedTape(boolean fixed); // same position in all frames when true

TapeStep:
public TPoint getEnd1();
public TPoint getEnd2();
public TPoint getHandle();

Listing 5. OffsetOrigin and Calibration Methods

OffsetOrigin: no unique methods

OffsetOriginStep:
public TPoint getPosition();

Calibration:
public Step createStep(int n, double x1, double y1, double x2, double y2);

CalibrationStep:
public TPoint getPosition1();
public TPoint getPosition2();

Listing 6. LineProfile Methods

LineProfile:
public Step createStep(int n, double x1, double y, double x2); // y applies to both ends
public void setSpread(int spread); // spread pixels are given full weight in average
public void setFeather(int feather); // feather pixels are given reduced weight in average

LineProfileStep:
public TPoint getEnd1();
public TPoint getEnd2();
public TPoint getHandle();