First, the back story. I was working on a film for class and, as usual, I tossed away the software they asked me to use in favor of Blender. This is a habit I can’t seem to shake for the past three years. It gets me in to big trouble some times… but I digress.
Tthe story goes that we were supposed to use Adobe After Effects to make a video that combines reality with silly stuff like time reversal and all that other nonsense that noodley teachers like to assign. ONe of the shots that I wanted to execute involved putting some video on a t-shirt I was wearing. The process went as follows:
- Buy a black t-shirt and a silver paint pen
- Paint a 4:3 grid of 25 dots (for resolution) on the center of the shirt
- Film the shot of me wearing the shirt
- Track all the silver dots
- line up a video element deformed by a mesh where each point is fixed to an animated tracking point.
- Composite the render on top of the original video
The second to last step was the trip-up. After Effects, for those of you not versed in the ways of Adobe, is a beast program. Like all other adobe products the mesh deform feature was likely appropriated from some software developer before it was finished and you can’t animate the individual points. Lame. That ruled out After Effects all together. But then a second problem arose. There was no software package out there that would allow me to export 2D tracking data that Blender would use. All of it came formatted for Shake (which I didn’t even have access to in the University’s labs) and one for Maya which I would have been lost in.
There was nothing left to do but write code to solve my problem.
### Coded by Wray Bowling ### rgbk.org ### because i have a deadline and for some reason ### i couldn't find anything that would do this for me import Blender from Blender import Object, Scene, Window def import_icarus2d(file_path): Blender.Window.WaitCursor(1) file_contents = open(file_path, 'r') selected = Blender.Object.GetSelected() this_scene = Scene.GetCurrent() for line in file_contents.readlines(): words = line.split() if len(words) == 0 or words.startswith('#'): #skip comment lines pass elif words.startswith('"'): empty_name = words.strip('"') ob = Object.New("Empty",empty_name) ob.LocX=0 ob.LocY=0 this_scene.objects.link(ob) print "created " + empty_name print "the selected object is " + ob.name my_ipo = Blender.Ipo.New('Object', empty_name) ob.setIpo(my_ipo) LocX = my_ipo.addCurve('LocX') LocY = my_ipo.addCurve('LocY') elif len(words) == 1: #skip the line that says how many frames there are pass else: # import LocX try: animation = LocX.getPoints()[i] animation.setPoints(words, words) except: LocX.addBezier((int(words), float(words)/100)) # import LocY try: animation = LocY.getPoints()[i] animation.setPoints(words, words) except: LocY.addBezier((int(words), float(words)/100)) Window.RedrawAll() Blender.Window.FileSelector(import_icarus2d, 'Import')
The above script works for Icarus’s 2D user features as well as user features in PFTrack of any version. Export the 2D data as a human readable format TXT and then use this script to get the animation curves in as empties.
When I used this script, I deleted the empties it makes automatically and then re-assigned those IPOs to empties that were Hooks to a 5x5 mesh with my video texture.
These are my results. I’d love to entertain any questions and make a full video tutorial some time soon. I’d also live to see what some of you can do with 2D tracking data. I’m getting ideas already… Mocap, Digital puppetry, and so on!