Created
May 28, 2013 15:04
-
-
Save anonymous/5663418 to your computer and use it in GitHub Desktop.
Blender python script to export the motion tracking markers to .csv files.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
import bpy | |
D = bpy.data | |
printFrameNums = False # include frame numbers in the csv file | |
relativeCoords = False # marker coords will be relative to the dimensions of the clip | |
f2=open('export-markers.log', 'w') | |
print('First line test', file=f2) | |
for clip in D.movieclips: | |
print('clip {0} found\n'.format(clip.name), file=f2) | |
width=clip.size[0] | |
height=clip.size[1] | |
for ob in clip.tracking.objects: | |
print('object {0} found\n'.format(ob.name), file=f2) | |
for track in ob.tracks: | |
print('track {0} found\n'.format(track.name), file=f2) | |
fn = 'data/{0}_{1}_tr_{2}.csv'.format(clip.name.split('.')[0], ob.name, track.name) | |
with open(fn, 'w') as f: | |
framenum = 0 | |
while framenum < clip.frame_duration: | |
markerAtFrame = track.markers.find_frame(framenum) | |
if markerAtFrame: | |
coords = markerAtFrame.co.xy | |
if relativeCoords: | |
if printFrameNums: | |
print('{0},{1},{2}'.format(framenum, coords[0], coords[1]), file=f) | |
else: | |
print('{0},{1}'.format(coords[0], coords[1]), file=f) | |
else: | |
if printFrameNums: | |
print('{0},{1},{2}'.format(framenum, coords[0]*width, coords[1]*height), file=f) | |
else: | |
print('{0},{1}'.format(coords[0]*width, coords[1]*height), file=f) | |
framenum += 1 | |
f2.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is .txt format