diff --git a/examples/pybullet/examples/getCameraImageTest.py b/examples/pybullet/examples/getCameraImageTest.py index ceae995661..7b894e3b03 100644 --- a/examples/pybullet/examples/getCameraImageTest.py +++ b/examples/pybullet/examples/getCameraImageTest.py @@ -31,6 +31,7 @@ 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 a156090f85..23fbe302ff 100644 --- a/examples/pybullet/examples/pointCloudFromCameraImage.py +++ b/examples/pybullet/examples/pointCloudFromCameraImage.py @@ -72,8 +72,10 @@ def getRayFromTo(mouseX, mouseY): 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)