Replicator 3d coordinates

Isaac sim 5.1

I’m trying to get 3D world coordinates of a lego block using the code below, but my code breaks in world_p = camera.get_world_points_from_image_coords(np.array([[u,v]]),depth_img[j-1:j,i-1:i][0] + (4.0 - depth_img[j-1:j,i-1:i][0]) / 2 + 0.01), I’m getting this message: 2026-01-14T04:02:21Z [386,388ms] [Warning] [omni.replicator.core.scripts.utils.utils] ‘ReplicatorItem’ object has no attribute ‘get_world_points_from_image_coords’
code

import omni.replicator.core as rep

import asyncio

async def test_bbox_2d_tight():

with rep.new_layer():

    BLOCK_PRIM_PATH = "/World/block_r/block_r/tn__Part1_f5/Mesh"

    BASE_PRIM_PATH = "/World/basePartz/basePartz/tn__Part1_f5/Mesh"

    ZED_CAMERA_PATH = "/World/ZED_X/base_link/ZED_X/CameraRight"



    \# Create replicator wrappers for existing prims

    block = rep.get.prim_at_path(BLOCK_PRIM_PATH)

    base = rep.get.prim_at_path(BASE_PRIM_PATH)



    \# Apply semantics to each object

    with block:

        rep.modify.semantics(\[('class', 'lego_block')\])

    with base:

        rep.modify.semantics(\[('class', 'lego_base')\])



    \# Setup camera and attach it to render product

    zed_camera = rep.get.prim_at_path(ZED_CAMERA_PATH)

    render_product = rep.create.render_product(zed_camera, resolution=(1024, 1024))



    bbox_2d_tight = rep.AnnotatorRegistry.get_annotator(

        "bounding_box_2d_tight", init_params={"semanticFilter": "\*:lego_block|lego_base"}

    )

    bbox_2d_tight.attach(render_product)



    \# After bbox_2d_tight, add these annotators:

    depth_annotator = rep.AnnotatorRegistry.get_annotator("distance_to_image_plane")

    depth_annotator.attach(render_product)

    rgb_annotator = rep.AnnotatorRegistry.get_annotator("rgb")

    rgb_annotator.attach(render_product)



    \# After await rep.orchestrator.step_async():

    rgb_data = rgb_annotator.get_data()

    depth_data = depth_annotator.get_data()  # This is your distance_to_image_plane data

    

    depth_img = depth_data  # Direct use, already float32

    rgb_img = rgb_data

    

    await rep.orchestrator.step_async()

    data = bbox_2d_tight.get_data()

    print(data)

    bbox_data = data\['data'\]

    first_bbox = bbox_data\[0\]

    print(first_bbox)

    x0 = first_bbox\['x_min'\]

    y0 = first_bbox\['y_min'\]

    x1 = first_bbox\['x_max'\]

    y1 = first_bbox\['y_max'\]

    #目标物体中心像素坐标的计算

    u = (x0 + x1) / 2 

    v = (y0 + y1) / 2

    i = (int)(u)

    j = (int)(v)

    #像素坐标到世界的转换

    world_p = camera.get_world_points_from_image_coords(np.array(\[\[u,v\]\]),depth_img\[j-1:j,i-1:i\]\[0\] + (4.0 - depth_img\[j-1:j,i-1:i\]\[0\]) / 2 + 0.01)

    print(world_p)

asyncio.ensure_future(test_bbox_2d_tight())

Hi there, the function you are trying to use is for the camera sensor, in the example you are using a replicator wrapped camera prim.

Here is an example snippet using the function:

  • /standalone_examples/api/isaacsim.sensors.camera/camera.py
1 Like

is there a similar function for the replicator ?

you could you the 3d bounding box annotator data, or reading the transforms directly from USD.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.