2

I'm trying to make a script that adds motion trackers every n frames and tracks them but I can't get the detect_features and track_markers operators to run on a specified frame.

My approach is to jump the time cursor to the next "step" of n frames using any way I know to update the frame, namely:

bpy.context.scene.frame_current
bpy.context.scene.frame_set
bpy.ops.clip.change_frame

But for some reason, the tracking operators ignore all of these commands and always operate on the current frame instead (the one you're on when you press the Run button). Here's a script that shows the problem. You can paste it in Blender’s text editor and run it, provided you have a Movie Clip Editor area with a clip open in it:

import bpy
C = bpy.context
ctx = C.copy()
for area in C.screen.areas:
    if area.type == 'CLIP_EDITOR':
        ctx['area'] = area

for step in range(3) : currFrame = (step*20)+1 C.scene.frame_current = currFrame C.scene.frame_set(currFrame) bpy.ops.clip.change_frame (ctx, frame = currFrame) bpy.ops.clip.detect_features(ctx) bpy.ops.clip.track_markers(ctx, backwards = False, sequence = False)

Notice how after running it, all markers are tracked at the same frame and if you grab the currently selected markers with G, it will reveal the previously added markers underneath, at the same positions.

EDIT: I added a topic on blender devtalk.

EDIT 2: I also made an add-on with an interface for easier automated tracking (under development). Feel free to ask me anything about it.

ChameleonScales
  • 2,510
  • 13
  • 33

0 Answers0