Camera animation

I have 513 cameras from a photogrammetry software. They are called Sequence.0001.jpg, Sequence.0002.jpg etc.

Can someone help me write a script that would create an animated camera that will take the location and rotation of all those cameras, one frame after the other? So it will be animated on 513 frames. Thanks.

1 Like

Most cameras (execpt the bottom right one) seems to be placed regularly over semi-circular paths.
In that case, is simply, yo don’t need any Python script.
You have to create a semi-circular path starting in the center of the first camera and finishing in the center of the last one.

Once you have done this, add a Follow Path constraint to you camera, and then create a keyframe in frame 1, and a keyframe in frame number equal to the number of cameras in that path.
Finally, you must go to the graph editor editor and select linear interpolation to ensure that camera will move regularly across the path.

Additionally you must calculate the inclination of the camera, but all seems to be pointed to the same point, so you need to create en empty object placed right in that point, and add the trackTo contraint to your camera and select your empty as target.

The non-semicircular path is more complex, but I think Python script approach will be more complex than a regular path approach.

1 Like
import bpy

#This script will create new camera each time when it runs, with animation based on selected cameras.

# 1. Select cameras which you want to include in animation
# 2. Execute Script
# 3. Check Active Collection to find newly created object

#Create A New Camera data and Camera Object
cam ='Animation_from_Still')
cam_obj ='Animation_from_Still',cam)

#Sort selected objects based on their name so animation stays consistant : seq.0001 is for frame 1, seq.0010 for frame 10
cameras = sorted(bpy.context.selected_objects,key=lambda
#Iterate throught selected cameras 
for i,obj in enumerate(cameras):
    if obj.type != 'CAMERA':
    cam_obj.location = obj.location
    cam_obj.rotation_mode = obj.rotation_mode
    cam_obj.rotation_euler = obj.rotation_euler
    #Assigning focal length =
    #Assign data which is changing in your cameras, above.
    #In general case it'll be location,rotation and focal length

    #insert keyframe for location & rotation on given frame
    cam_obj.keyframe_insert(data_path='location',frame = i+1)
    cam_obj.keyframe_insert(data_path='rotation_euler',frame = i+1)

#active collection in current view layer
coll = bpy.context.view_layer.active_layer_collection.collection
#link new camera object with animation to collection

Perfect! Thank you so much!

1 Like

I did something similar with Animation Nodes before. You can copy camera transformations and camera data from a bunch of cameras (put all of them in a collection) to a specific camera on each frame. You can use the looping group inside Animation Nodes.


Wow, this is super cool. :grinning: