2
$\begingroup$

I can currently export camera tracking information from my own program (outside of Blender).

I would like to import this information into Blender. How do I do this? I can export the tracking co-ordinates in ASCII format as text. Is there any plugin to import them even with changing to a different format (.fbx etc.,)

Any pointers to help me get going?

$\endgroup$
1
$\begingroup$

How about the following function? You would just need to get your ascii data to match the XYZ/RXRYRZ.

import bpy 
import bpy.types
import time
from mathutils import *

# positions and rotates an object (globally) and create a keyframe
# at the given frame#
# Change the rotation mode to your liking.
def animate_object( obj, x, y, z, rx, ry, rz, frame_number ):
    obj.location = Vector((x,y,z))
    obj.rotation_mode = 'XYZ'
    obj.rotation_euler = Euler((rx,ry,rz))
    obj.keyframe_insert(data_path="location", frame=frame_number)
    obj.keyframe_insert(data_path="rotation_euler", frame=frame_number)

ex:

cam_positions = (
    ( 1.56,3.13,-1.83, -4.20,-2.58,-3.48 ),
    ( 1.74,3.19,-1.63, -4.40,-1.95,-3.67 ),
    #...
    ( 2.01,3.03,-1.57, -4.32,-1.61,-3.64 )
)

cam = bpy.data.objects["Camera"]

frame_number = 1
for frame_number, cp in enumerate(cam_positions):
    animate_object(cam, *cp, frame_number + 1)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.