Change Feature/Search Size and Feature Center of Track Points

What type of scripts do you need?

Moderator: byronnash

Post Reply
adhishyajnik
Posts: 2
Joined: March 31st, 2021, 12:46 pm

Since working primarily in 4K, using the built-in AE tracker has become a bit of a chore, since the track points are so small by default. I have to first increase the search size and feature size just to be able to grab the point and move it around in the frame, and then I have to zoom into the layer to even separate one point from another. When tracking a lot of shots, this minor slowdown really starts to add up and eat up a lot of time for me.

I'm wondering if there's a script that could take the Current Track and:
1. Separate the Feature Centers of all Track Points apart by a default user-settable (x,y) amount if there are more than 1 Track Points,
2. increase the Feature Size of all Track Points by a default user-settable factor, and
3. increase the Search Size of all Track Points by a default user-settable factor.

Ideally, my tracking workflow would be:
1. Click the Track Motion Button in the Tracker Panel
2. Click the checkboxes for tracking Rotation and Scale if desired
3. Click a KBar button that runs this script, which moves the track points apart and increases their sizes.

Then I'd be able to quickly move the points around and get tracking quickly.

Anyone else interested in something like this? It would be a godsend for me, but unfortunately my scripting knowledge ends with Expressions.

adhishyajnik
Posts: 2
Joined: March 31st, 2021, 12:46 pm

I managed to write a script that does most of what I need, based on a forum post by Paul Tuersley some 16 years ago!

It only doubles the feature size and search size of track points on the selected layer that don't have any keyframes (It's meant to be used before starting a track).

When I scripted a change to the Feature Center and Attach Point, After Effects subsequently wouldn't let me move the track point without resetting its Feature Center, Feature Size, and Search Size back to defaults. That unwanted resetting behavior seems to be caused by moving the Feature Center and the Attach Point independently of each other, parametrically, without affecting the attach point offset. Therefore, I removed that part of the script and it now only doubles the feature and search size, making the points easier to grab.

Here's what it looks like:

Code: Select all

/**
 * Doubles Feature Size and Search Size of Track Points without Feature Center keyframes on the selected layer
 *
 * @author Adhish Yajnik <adhishyajnik@gmail.com> <adhishyajnik.com/post>
 * based on Paul Tuersley's forum post on AE Enhancers: https://aenhancers.com/viewtopic.php?p=208#p208
 * @version 1.0.0
 */

{
	// make sure a comp is selected
	var activeItem = app.project.activeItem;
	if (activeItem == null || !(activeItem instanceof CompItem)){
		alert("You need to select a layer first.");

	} else {

		// make sure at least one layer is selected
		var selectedLayers = activeItem.selectedLayers;
		if (activeItem.selectedLayers.length == 0 ) {
			alert("You need to select a layer first.");

		} else {
			
			currentLayer = selectedLayers[0];

			// search top level properties for Motion Tracker
			for (var g = 1; g <= currentLayer.numProperties; ++g) {
				currentProperty = currentLayer.property(g);

				if (currentProperty.name == "Motion Trackers") {

					// search for each tracker
					for (var h = 1; h <= currentProperty.numProperties; ++h) {
						currentTracker = currentProperty.property(h);
						
						(function doubleTrackPointSize() {
							app.beginUndoGroup('Double Track Point Size');

							// search for each track point
							for (var i = 1; i <= currentTracker.numProperties; ++i) {
								currentTrackpoint = currentTracker.property(i);
								
								// if a track point doesn't have any feature center keyframes, double its feature size and search size
								if (currentTrackpoint.property(1).numKeys < 1) {
									featSize = currentTrackpoint.property(2).value;
									searchSize = currentTrackpoint.property(4).value;
									currentTrackpoint.property(2).setValue(featSize*2);
									currentTrackpoint.property(4).setValue(searchSize*2);
								}
							}
							app.endUndoGroup();
						})();
						}
					}
				}
			}
		}
	}
Post Reply