sunnypilot v2026.002.000
version: sunnypilot v2026.002.000 (staging) date: 2026-07-21T07:44:02 master commit: 2c334ede443d7391d27575af8c854a095ba702a8
This commit is contained in:
commit
de77c89cf6
3995 files changed
+1260688
No files matched your search
@@ -0,0 +1,35 @@
|
||||
import numpy as np
|
||||
|
||||
from metadrive.component.sensors.rgb_camera import RGBCamera
|
||||
from panda3d.core import Texture, GraphicsOutput
|
||||
|
||||
|
||||
class CopyRamRGBCamera(RGBCamera):
|
||||
"""Camera which copies its content into RAM during the render process, for faster image grabbing."""
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.cpu_texture = Texture()
|
||||
self.buffer.addRenderTexture(self.cpu_texture, GraphicsOutput.RTMCopyRam)
|
||||
|
||||
def get_rgb_array_cpu(self):
|
||||
origin_img = self.cpu_texture
|
||||
img = np.frombuffer(origin_img.getRamImageAs("RGB").getData(), dtype=np.uint8)
|
||||
img = img.reshape((origin_img.getYSize(), origin_img.getXSize(), 3))
|
||||
img = img[::-1] # Flip on vertical axis
|
||||
return img
|
||||
|
||||
|
||||
class RGBCameraWide(CopyRamRGBCamera):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
lens = self.get_lens()
|
||||
lens.setFov(120)
|
||||
lens.setNear(0.1)
|
||||
|
||||
|
||||
class RGBCameraRoad(CopyRamRGBCamera):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
lens = self.get_lens()
|
||||
lens.setFov(40)
|
||||
lens.setNear(0.1)
|
||||
Reference in new issue
Block a user