Desired script for "wiggle" rendering for 3D

I’ve seen some “wigglegrams” – still images with 1 or 2 quick-changing frames which make an item look 3D without glasses or anything like that. I’m wondering if it is possible to write a python script that uses two cameras. For even number of frames, it would render from camera 1; for odd, camera 2. That way the animation would still render, but it would get some wiggle effect to make it look 3D.

Am I crazy? How difficult or easy would it be to implement this?

Something like this, but animated.

mini Python idea: your f (from range) is I think an integer so to check even or oneven use % :wink:


if f % 2 :
   #1 is True thus ONEVEN
else:
   #0 is False  thus Even

Another way
Set the frame step to 2.
Render animation with start frame 1… eg 1,3,5,… with camera_odd
render animation with start frame 2 with camera_even


scene.frame_step = 2
scene.frame_start = 1
scene.camera = camera_odd
bpy.ops.render.render(animation=True, write_still=True)
scene.frame_start = 2
scene.camera = camera_even
bpy.ops.render.render(animation=True,write_still=True)

I used app.handlers for this


import bpy

def cam_switch(scene):
    curr_scene=bpy.context.scene
    f = bpy.context.scene.frame_current
    if not f % 2:
        curr_scene.camera=bpy.data.objects['Camodd']
    else:
        curr_scene.camera=bpy.data.objects['Cameven']
bpy.app.handlers.frame_change_pre.append(cam_switch)

#to remove last added handler type in console
#bpy.app.handlers.frame_change_pre.pop()

After running this script when you ‘play animation’ or render it ,it will alternate between ‘Cameven’ and ‘Camodd’

The only comment I would add to Brenel’s solution is that you do not want to reference bpy.context directly. A scene is provided to you, make use of it. (very minor, but can prevent crashing during rendering)


import bpy

def cam_switch(scene):
    f = scene.frame_current
    if not f % 2:
        scene.camera=bpy.data.objects['Camodd']
    else:
        scene.camera=bpy.data.objects['Cameven']
bpy.app.handlers.frame_change_pre.append(cam_switch)

remove the not before f%2 and swich eventuall odd and even part :wink:

Isn’t it easy enough to just render with Frame Step 2, first with camera A from frame 1, then with camera B from frame 2?
To be honest I suspect the result will mostly be headache-inducing. Here’s a superquick test… http://www.youtube.com/watch?v=TKsqcnnQ_M4

maybe it works better at some other framerate? With some sort of frame blending?