Motion Tracking/ Planar tracking Output -> Txt

Hey! I hope Sergey finds this thread somehow :slight_smile: or anyone else heavily involved with the Motion Tracker and MCE.

There’s an old project I was involved in way back, which I would want to revisit and see if I can do most of the stuff the entire production house did but in Blender.

One of the crucial steps is to be able to track footage, and have the tracking data output to what-ever-format but preferably just a TXT, XML or JSON file, containing the tracking points.

This is not for 3d recontruction, but rather just plane tracking.

Reading the docs, http://wiki.blender.org/index.php/Doc:2.6/Manual/Motion_Tracking
I find nothing, I haven´t really done anyting sharp yet with the tracker but plan to tackle it ASAP I have time.

A suggestion, as there’s already some Comp Nodes added like the Distort > Plane Track Deform. Maybe check the possibilities to add a Output > Plane Track Points Node which could write to disk just as the Output image Node works (simple Path to file, and settings in Prop panel for what file format)

What I am out after is to track footage and do the 3d, and Comp work in Blender. But the using a JavaScript 3d Lib I need to have the tracking coords out from Blender to parse and use.

Anyways, Think it would be a cool idea and fits the current Comp Node structure.

That’s a nice idea !
I haven’t looked in planar tracking part of python API but I think writing an exporter script shouldn’t be too complicated to write.
Having an export node, like in nuke, is also convinient. But looking at the way the compositor work ( re-calculating the nodeTree every single updates ) I think it’s maybe not the good place for that kind of export node yet …

Maybe a better place is somewhere near the export menu with objects exports. Or directly in the tracking panel…

I recall reading that your can iterate over the tracks associated with a clip in python. So then whipping up an exporter cannot be so hard.

I toyed with the api for a few minutes and here is one way to do it (although it might not be super efficient):
import bpy
clip=bpy.data.movieclip[0] # assuming you have only one clip, otherwise you have to find yours
plane_track=clip.tracking.plane_tracks[0] # again assuming you have only one plane track for this clip
for frame in plane_track.markers:
print frame.corners[0][0], corners[0][1], etc…

The only problem here is that for some reason I don’t quite get, in the last statement I cannot simply print the 4x2 float array, so I had to index
it one by one corners[0][0], corners[0][1] are the 2d coordinates of one corner, etc.

Hope that helps.

So, after a good nights sleep, I wrote a little script for you. I have added a blend file with a plane track in it. I didn’t upload the footage, so you cannot use that file as is. I have also included two scripts. One is called extract_marker.py. For now, the easiest is to use it from the command line with blender in background mode:

blender plane_track_python.blend --background --python extract_marker.py

after that, if you want to inspect what the corners are doing, simply use the other script plot_markers.py. It uses numpy and pylab.

Attachments

plane_track_python.zip (104 KB)


PhysicsGuy deserve some beers !