I would like to move my cube in a variety of stylish poses and capture the images into a .png or .jpg file.
I’m having issues with taking images though. It often seems to cause omniverse to crash and when it doesn’t I seem to get the cube in it’s final position on all the images. I tried awaiting capture handler but just get a bunch of errors telling me that I’m handling Async incorrectly.
I’d really like to get as much speed from this as possible but need to reliably capture an image of each set of positions in the np.array that i’m bringing in.
Here’s what I have so far:
def move_and_capture(data):
stage = Usd.Stage.Open('/home/doug_the_computer/Downloads/test2.usd')
viewport_window = omni.ui.Window('SimpleViewport', width=2 * 1280, height=2 * 720)
with viewport_window.frame:
viewport_widget = ViewportWidget(resolution=(2 * 1280, 2 * 720))
viewport_api = viewport_widget.viewport_api
camera_path = "/World/Camera"
camera = stage.GetPrimAtPath(camera_path)
viewport_api.camera_path = camera_path
cube_path = "/World/Cube"
cube = stage.GetPrimAtPath(cube_path)
scale, rotate, rot_order, translation = omni.usd.get_local_transform_SRT(cube, time=Usd.TimeCode.Default())
print(
f"Scale: {scale}\n"
f"Rotation: {rotate}\n"
f"Rot Order: {rot_order}\n"
f"Translation: {translation}"
)
frame_num = 0
output = []
for row in data:
# Translation
translate = Gf.Vec3d(row[0], row[1], row[2])
cube.GetAttribute("xformOp:translate").Set(translate)
# Rotation
rotation = Gf.Vec3d(row[3], row[4], row[5])
cube.GetAttribute("xformOp:rotateXYZ").Set(rotation)
print(
f"-----------------------------------------------------------\n"
f"Frame# {frame_num}\n"
f"Scale: {scale}\n"
f"Rotation: {rotate}\n"
f"Rot Order: {rot_order}\n"
f"Translation: {translation}"
)
# Capture Image here
###
frame_num = frame_num + 1
print("-----------------------------------------------------------\n")
np.savetxt("/home/doug_the_computer/Downloads/data.csv", output, delimiter=",")
I’ve read through a lot of documentation but just haven’t been able to get this to work. Would appreciate any help!