Weird point cloud results

I followed the tutorial shown in the link below in order to try to save a point cloud file (.ply) and then visualize it using open3d, but the result looks strange.

https://docs.omniverse.nvidia.com/extensions/latest/ext_replicator/annotators_details.html#point-cloud

Here’s the script for generating a .ply file.

import omni.replicator.core as rep
import asyncio

import os
import numpy as np
import omni.kit.pipapi
omni.kit.pipapi.install("open3d")
import open3d as o3d


async def test_pointcloud():
    # Add Default Light
    distance_light = rep.create.light(rotation=(315,0,0), intensity=3000, light_type="distant")

    camera = rep.create.camera()
    render_product = rep.create.render_product(camera, (1024, 512))
    cube = rep.create.cube(semantics=[("class", "cube")])
    
    pointcloud_anno = rep.annotators.get("pointcloud")
    pointcloud_anno.attach(render_product)

    # Camera positions to capture the cube
    #camera = rep.create.camera(position=(200, 200, 200), look_at=worker)  
    camera = rep.create.camera(position=(100, 100, 100), look_at=cube)  

    # Accumulate points
    points = []
    points_rgb = []
    await rep.orchestrator.step_async()

    pc_data = pointcloud_anno.get_data()
    #print(pc_data)
    points.append(pc_data["data"])
    points_rgb.append(pc_data["info"]["pointRgb"].reshape(-1, 4)[:, :3])

    # Output pointcloud as .ply file
    ply_out_dir = 'output/point_cloud'
    print(ply_out_dir)
    os.makedirs(ply_out_dir, exist_ok=True)

    pc_data = np.concatenate(points)
    pc_rgb = np.concatenate(points_rgb)

    pcd = o3d.geometry.PointCloud()
    pcd.points = o3d.utility.Vector3dVector(pc_data)
    pcd.colors = o3d.utility.Vector3dVector(pc_rgb  / 255.0)
    o3d.io.write_point_cloud(os.path.join(ply_out_dir, "pointcloud2.ply"), pcd)
    print('Saved.')

asyncio.ensure_future(test_pointcloud())

For comparison I also try to visualize a .bin point cloud data downloaded from KITTI dataset
(The KITTI Vision Benchmark Suite)

Then I tried to visualize both pointcloud files using the following code snippet:

import os
import numpy as np
import struct
import open3d as o3d

def read_bin_velodyne(path):
    pc_list=[]
    with open(path, 'rb') as f:
    	content = f.read()
    	pc_iter = struct.iter_unpack('ffff',content)
    	for idx, point in enumerate(pc_iter):
    	    pc_list.append([point[0], point[1], point[2]])
    	    
    return np.asarray(pc_list, dtype=np.float32)
    
def main():
    bin_file = '000000.bin'
    pcd = o3d.open3d.geometry.PointCloud()
    
    example = read_bin_velodyne(bin_file)
    pcd.points = o3d.open3d.utility.Vector3dVector(example)
    print(np.asarray(pcd.points))
    o3d.open3d.visualization.draw_geometries([pcd], width=700, height=700, left=100, top=100)
    
    #############################################################################################
    
    ply_file = 'pointcloud.ply'
    pcd = o3d.io.read_point_cloud(ply_file)
    print(np.asarray(pcd.points))
    o3d.open3d.visualization.draw_geometries([pcd], width=700, height=700, left=100, top=100)

    
if __name__=="__main__":
    main()

I can view the .bin file without any problem using open3d, yet the .ply file generated from the omniverse script
mentioned above looks strange. I only see a black rectangle.


If I zoom in on the said rectangle, it looks like this:

Even if I replaced the object, the cube, with some other non-cube object, I still got the same black rectangle result. I’m not sure what step was done incorrectly.