Convert many cameras into one camera path

I have an fbx exported from Agisoft Metashape containing a mesh plus a whole load of cameras.

There is actually one camera per frame of video, frames that were used to generate the mesh using photogrammetry. As I have the parameters for the camera at each frame, I have a camera track.

I want to take this group of cameras and convert it into a single camera with the position and rotation animated on a path. The path would need to pass through each of the cameras in turn. I suppose this is like ‘un baking’ the camera path.

Any idea how to approach this?

Thanks!

If all the cameras are in the scene you could use constraints with animated intensity or visibility to make it follow. Or just create a curve by snapping to the camera positions then match the rotations at those points.

Naturally there can be a scripted solution too.

Thanks for the suggestion

An automatic / scripted approach is what I’m after. I was hoping this kind of problem might have an existing generic approach - ie ‘path through objects’ kinda thing.

Maybe this won’t help at all but I was trying several open source photogrammetry solutions (Meshroom, Colmap, …) and I always wanted to import an animated camera from their SfM solution.
Some weeks ago a clever guy released this:

And it helped me a lot getting real animated cameras into Blender from Meshroom and Colmap.

Maybe you can get Metashape to export something that this importer understands. Or you could try using the open source alternatives (for free of course) for photogrammetry to get something that fits your needs.

Try Animation Nodes add-on. Something like this will merge all cameras-frames into active one:

2 Likes

Wow amazing responses, thanks!

@SteffenD that photogrammetry importer looks like exactly what I need - I’m trying to get a camera track out alongside the generated mesh. Sadly I don’t think I can get the right data out from Metashape. I might try Meshroom but I hear it’s much slower :frowning:

1 Like

@Serge_L - that’s really great! Animation nodes area amazing. Two questions -

Why do we need to use the Delay Time node? It seems to work without.

I can bake keyframes to bake the animation path into the new camera for export. However, I’d like to be able to space out the source camera keyframes and benefit from interpolation between these generated keyframes. I tried dividing the Time Info frame by (eg) 5, then a math floor on the result, and used this to drive the list lookup. This worked, as in it meant a new camera would be used for keyframing every 5 timeline frames, but ‘dummy’ keyframes were still added between these which I have to then manually delete. Any idea how I can only bake a keyframe on changed data?

Just added it to match camera names and frames, because scene start was 1.

For baking you can use default Blender’s baker: Object->Animation->Bake Action, then set frame step to 5.

If I ‘Bake Action’ a sort of keyframe group is created but with no changing data in it.

If I F3 and choose ‘Bake to Keyframes’ the data is added as individual keyframes but I don’t get any options to choose frame step

you can use this script

ManuPython_CameraForArbres.txt (1.6 KB)

put the number of cameras in “NumberOfObjects” the name of the camera must be “camera”
clone a camera and rename it “MyAnimatedCamera”
run the script

1 Like

Have you enabled auto-execution rules in Animation nodes (T-panel)? Try “Frame changed” or even “Always” and rebake again

why don’t you just scale the keys in dope sheet?

Yay!

Many working solutions :slight_smile:

This community rocks