diff options
author | erwincoumans <erwincoumans@google.com> | 2022-01-11 22:15:24 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-11 22:15:24 -0800 |
commit | 478da7469a34074aa051e8720734287ca371fd3e (patch) | |
tree | 783df5437db687552e3e2d4d0ef52d8b1a10a9c0 | |
parent | dc72081eb19831e5b28b071dc76ec51fc1fe9451 (diff) | |
parent | 51a5aa802667456d14af99c181550e63d780fca3 (diff) | |
download | bullet3-478da7469a34074aa051e8720734287ca371fd3e.tar.gz |
Merge pull request #4116 from jamesbraza/fixing-imaging-examples
Fixing pybullet example on getting a point cloud
-rw-r--r-- | examples/pybullet/examples/getCameraImageTest.py | 1 | ||||
-rw-r--r-- | examples/pybullet/examples/pointCloudFromCameraImage.py | 6 |
2 files changed, 5 insertions, 2 deletions
diff --git a/examples/pybullet/examples/getCameraImageTest.py b/examples/pybullet/examples/getCameraImageTest.py index ceae99566..7b894e3b0 100644 --- a/examples/pybullet/examples/getCameraImageTest.py +++ b/examples/pybullet/examples/getCameraImageTest.py @@ -31,6 +31,7 @@ images = p.getCameraImage(width, projection_matrix, shadow=True, renderer=p.ER_BULLET_HARDWARE_OPENGL) +# NOTE: the ordering of height and width change based on the conversion rgb_opengl = np.reshape(images[2], (height, width, 4)) * 1. / 255. depth_buffer_opengl = np.reshape(images[3], [width, height]) depth_opengl = far * near / (far - (far - near) * depth_buffer_opengl) diff --git a/examples/pybullet/examples/pointCloudFromCameraImage.py b/examples/pybullet/examples/pointCloudFromCameraImage.py index a156090f8..23fbe302f 100644 --- a/examples/pybullet/examples/pointCloudFromCameraImage.py +++ b/examples/pybullet/examples/pointCloudFromCameraImage.py @@ -72,8 +72,10 @@ imgW = int(width / 10) imgH = int(height / 10) img = p.getCameraImage(imgW, imgH, renderer=p.ER_BULLET_HARDWARE_OPENGL) -rgbBuffer = img[2] -depthBuffer = img[3] +rgbBuffer = np.reshape(img[2], (imgH, imgW, 4)) +# NOTE: this depth buffer's reshaping does not match the [w, h] convention for +# OpenGL depth buffers. See getCameraImageTest.py for an OpenGL depth buffer +depthBuffer = np.reshape(img[3], [imgH, imgW]) print("rgbBuffer.shape=", rgbBuffer.shape) print("depthBuffer.shape=", depthBuffer.shape) |