2
$\begingroup$

i'm having some troubles in a script that use the auto detect features function from the tracking layout. The above script return the error:

RuntimeError: Operator bpy.ops.clip.detect_features.poll() failed, context is incorrect

Does someone knows how to force a change context to clip tracking?

import bpy
import random

scene = bpy.context.scene

bpy.ops.clip.open(directory="/home/lucasa/Vídeos/", files=[{"name":"100_0921.MP4", "name":"100_0921.MP4"}], relative_path=True)
print('video clip imported')

clip = bpy.data.movieclips[0]
print("\nMovie Clip %s" % clip.name)

bpy.ops.clip.detect_features()
print('\nDetect Features')
$\endgroup$
2
  • 1
    $\begingroup$ Maybe the answer is already here: blender.stackexchange.com/questions/6101/… $\endgroup$ Commented Oct 19, 2014 at 20:01
  • $\begingroup$ I don't know which layout you need, but the way described in this link under "Change Area.type" seems what you are searching for. $\endgroup$ Commented Oct 19, 2014 at 20:02

1 Answer 1

3
$\begingroup$

I know this is years late but I will answer this incase anyone stumbles across this.

In this case you need to force context since the operators require a certain context to execute. To do this for the detect_features method you can do:

ctx = bpy.context.copy()
for area in bpy.context.screen.areas:
    if area.type == 'CLIP_EDITOR':
        ctx['area'] = area
bpy.ops.clip.detect_features(ctx)
$\endgroup$
1
  • $\begingroup$ If there is no clip editor open on the screen this wont work. Toggling context.area = 'CLIP_EDITOR', copying context and toggling back, may be a more foolproof way to make a context override. $\endgroup$ Commented Oct 19, 2017 at 4:48

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.