I hate to ask for someone to make this simpler, but does anyone have a code snippet that gets the frame number so I can move the camera along a line or something? (I’m trying to do some structure from motion tests so I need a controlled set of camera positions, not random ones.)
Getting the frame number inside the writer doesn’t do me any good except name the file, does it?
I’m not sure where to execute this, when I put it inside
with rep.trigger.on_frame(num_frames=5): # , rt_subframes=100):
I get
2023-09-24 01:06:50 [Error] [omni.ui.python] UnboundLocalError: local variable ‘time’ referenced before assignment
with camera:
theta = np.linspace(0, 2*np.pi, 213)
rad = np.random.uniform(2000, 3000, theta.shape) # generate a random radius
x = rad * np.cos(theta)
z = rad * np.sin(theta)
# y = np.full(theta.shape, 4500) # create y-vector of constant 1000
y = np.random.uniform(4000, 5000, theta.shape) # create y-vector of random values between 4000 and 5000
x_list = x.tolist()
y_list = y.tolist()
z_list = z.tolist()
camera_positions = list(zip(x_list, y_list, z_list))
# get a reference to the timeline
timeline = omni.timeline.get_timeline_interface()
# get the current time
time = timeline.get_current_time()
# get the frames per second
fps = timeline.get_time_codes_per_seconds()
# set the current frame
frame = time * fps
camPos = camera_positions[int(frame)]
rep.modify.pose(position=camPos, look_at= looky)
rep.orchestrator.run(num_frames=24, start_timeline=True)
But since this is only run once, (because replicator does the iterations in some ogn that I don’t understand, yet) I just get time = 0 and therefore one camera position.
I thought that was the script I was emulating. However I don’t have a usd with a moving camera (or know how to do that) as he mentions so perhaps that’s the missing piece.
I AM actually using a predefined list, just getting them randomly, how do I get them in order? Or even guaranteed to visit each one once. AFAIK I still get a random sampling of them.