Copy matrix_world uninfluenced by "Camera Solver" constraint, ie set constraint influence to 0, set the frame to the first frame of the simulation, save a matrix_world copy, then reset the influence.
The track positions are mworldcopy * Track.bundle
Camera tracking points in red, object tracking points in green, resultant object tracking points in yellow.
import bpy
from sound_drivers.BGL_draw_visualiser import BGLWidget
context = bpy.context
scene = context.scene
scene.frame_set(1)
camera = cam = scene.camera
cam_const = cam.constraints[0]
cam_const.influence = 0
mw = cam.matrix_world.copy()
cam_const.influence = 1
class ShowTracks(BGLWidget):
def draw_region(self, context):
clip = context.scene.active_clip
tracking = clip.tracking
tracking_object = clip.tracking.objects.active
# match to object tracking
# from bl_operators/clip.py
if camera:
reconstruction = tracking_object.reconstruction
framenr = scene.frame_current - clip.frame_start + 1
reconstructed_matrix = reconstruction.cameras.matrix_from_frame(framenr)
matrix = camera.matrix_world * reconstructed_matrix.inverted()
else:
return
tracks = tracking.objects
# track points in global space current frame
pts = [matrix * t.bundle for t in tracks['Object'].tracks]
pts = self.points3d_points2d(context, pts)
self.draw_points(pts, lw=2, color=(1, 1, 0, 1))
# tracking data
pts = [mw * t.bundle for t in tracks['Camera'].tracks]
pts = self.points3d_points2d(context, pts)
self.draw_points(pts, lw=1, color=(1, 0, 0, 1))
pts = [mw * t.bundle for t in tracks['Object'].tracks]
pts = self.points3d_points2d(context, pts)
self.draw_points(pts, lw=1, color=(0, 1, 0, 1))
v = ShowTracks(None, bpy.context, bpy.types.SpaceView3D)