I have a USD file with a pre-built camera, the camera randomize its position in each frame. and I need to access the information of the bounding_box_2d_loose
for primitives based on the perspective of the camera to obtain occlusion information for these primitives.
Here is the code I’ve written, but it doesn’t seem to work.(The annotator returns empty bounding_box_2d_loose data all the time.) Could you please advise on how to rewrite it to achieve my goal?
from pxr import Usd
import omni.usd
import omni.replicator.core as rep
stage = omni.usd.get_context().get_stage()
cam = stage.GetPrimAtPath("/World/Camera")
rp = rep.create.render_product(str(cam.GetPrimPath()), (1024, 1024))
# Acess the data through annotators
bbox_loose = rep.AnnotatorRegistry.get_annotator("bounding_box_2d_loose")
bbox_loose.attach(rp)
async def get_bbox_loose_data():
global bbox_loose
await rep.orchestrator.step_async()
data = bbox_loose.get_data()
print(data)
import asyncio
asyncio.ensure_future(get_bbox_loose_data())