fix(sim): use getRamImageAs for correct channel order (#37528)

getRamImage() returns panda3d's internal BGRA format. on macOS this
produces swapped red/blue channels in the sim camera feed.

getRamImageAs("RGBA") requests explicit RGBA reordering from panda3d,
correct on all platforms. no-op where internal format is already RGBA.

ref: https://docs.panda3d.org/1.10/python/reference/panda3d.core.Texture#panda3d.core.Texture.getRamImageAs

fixes #37526
This commit is contained in:
Utkarsh Gill
2026-03-07 11:44:31 +05:30
committed by GitHub
parent 5e1a576f3d
commit 793f8fee32

View File

@@ -13,9 +13,9 @@ class CopyRamRGBCamera(RGBCamera):
def get_rgb_array_cpu(self): def get_rgb_array_cpu(self):
origin_img = self.cpu_texture origin_img = self.cpu_texture
img = np.frombuffer(origin_img.getRamImage().getData(), dtype=np.uint8) img = np.frombuffer(origin_img.getRamImageAs("RGBA").getData(), dtype=np.uint8)
img = img.reshape((origin_img.getYSize(), origin_img.getXSize(), -1)) img = img.reshape((origin_img.getYSize(), origin_img.getXSize(), 4))
img = img[:,:,:3] # RGBA to RGB img = img[:, :, :3]
# img = np.swapaxes(img, 1, 0) # img = np.swapaxes(img, 1, 0)
img = img[::-1] # Flip on vertical axis img = img[::-1] # Flip on vertical axis
return img return img