2
$\begingroup$

Im trying to get this tracking script for running in the background working. It was working perfectly in the background until I got to the filter tracks portion. Here is the script:

import bpy

for area in bpy.context.screen.areas:
    if area.type == 'CLIP_EDITOR':
        override = bpy.context.copy()
        override['area'] = area
        bpy.ops.clip.detect_features(override, threshold = 0.05, min_distance = 25)
        print('Markers Detected')
        bpy.ops.clip.track_markers(override, sequence=True)
        print('Tracked Forward')
        bpy.ops.clip.track_markers(override, sequence=True, backwards=True)
        print('Tracked Backwards')
        totalFrames = bpy.context.scene.frame_end = bpy.context.scene.frame_start
        bpy.ops.clip.clean_tracks(override, frames=(totalFrames + 1), error=0.5, action='DELETE_TRACK')
        #Can get to here fine, error occurs when doing this filter track function
        bpy.ops.clip.filter_tracks(override['area'], track_threshold=5)
        bpy.ops.wm.save_as_mainfile(filepath="/Applications/blender2.76" + "test.blend")
        break

Does anyone know how I could fix this?

enter image description here

This is currently what the errors are looking like now for this.

$\endgroup$
1
1
$\begingroup$

Change:

bpy.ops.clip.filter_tracks(override['area'], track_threshold=5)

To:

bpy.ops.clip.filter_tracks(track_threshold=5)

And see if that works.

I'm not that familiar with what you are doing, however the reason I believe that you need to take out the extra argument is because of inspecting the auto-complete of the function when I enter it in directly at the console (it just seems like there is a problem with passing more than the threshold value - See Below):

enter image description here

After looking into this a little further, try just commenting this line out.

From the Manual it is meant to smooth out spikes in the track, the problem with this (this context) is: you just deleted the "spike" in your previous line of code, so there is no track to even deal with.

Or

Maybe you just need to check and see if the previous statement deleted the track. Then set a variable to indicate if the track was deleted, then you can make a decision to filter it or not based on that.

$\endgroup$
2
  • 1
    $\begingroup$ I think the override still belongs to match what was used in previous ops. But it should be override not override['area']. $\endgroup$
    – sambler
    Mar 8 '16 at 9:58
  • $\begingroup$ Just made an edit to the post to show the errors I get from terminal. I appreciate your guys help, will keep working at this but if you have any more ideas that would be greatly appreciated. $\endgroup$
    – CSSmitty
    Mar 9 '16 at 6:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.