[Bf-vfx] Getting Marker Size using Python
Peter Rennert
mailinglists at rennert.io
Sun Mar 13 01:07:30 CET 2016
Hi,
I am trying to export motion tracking tracks from Blender using Python. Is there any way of getting the size and maybe orientation of the markers?
I have found code to extract the location online, but I could not make my way to finding the size properties.
Any help would be appreciated,
Peter
my current code:
https://gist.github.com/groakat/e7d8394d57fd4d3fe016 <https://gist.github.com/groakat/e7d8394d57fd4d3fe016>
from __future__ import print_function
import bpy
import os
D = bpy.data
printFrameNums = True # include frame numbers in the csv file
relativeCoords = False # marker coords will be relative to the dimensions of the clip
proj_folder = os.path.join(bpy.path.abspath('//'))
if os.path.dirname(os.path.dirname(proj_folder)) == 'blender':
output_folder = os.path.join(bpy.path.abspath('//'), '../..', 'tracks/B_man/')
else:
output_folder = os.path.join(bpy.path.abspath('//'), '..', 'tracks/B_man/')
f2=open(output_folder + '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 = output_folder + '{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 and not markerAtFrame.mute:
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()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.blender.org/pipermail/bf-vfx/attachments/20160313/9e76005b/attachment.htm
More information about the Bf-vfx
mailing list