rc.cameraNEORACER DOCS
NEORACER DOCS
These docs are public and open source.Edit on GitHub
API REFERENCE / PYTHON

RC.CAMERA.

The Camera module gives you what the car sees: a 640 by 480 colour frame as a plain NumPy array you can hand straight to . The same 640 by 480 frames come back in the Playground sim and on the car, so your vision code ports without a change.

Sim ↔ car identical640 × 480RGB, no depthNumPy / OpenCV
METHODS

THE METHODS.

rc.camera.get_color_image()returns NDArray[480, 640, 3]

A fresh colour frame as a NumPy array, 480 rows by 640 columns, three channels in blue-green-red order, values 0 to 255. This is a deep copy, so you can edit it freely.

rc.camera.get_color_image_no_copy()returns NDArray[480, 640, 3]

The same frame, but a direct reference rather than a copy. Faster when you only read pixels. The library reuses the buffer next frame, so do not modify it in place.

rc.camera.get_depth_image()returns NDArray[480, 640]

Not available on the NeoRacer: its camera is RGB-only, so this returns an all-zero frame. The method exists because racecar_core is generic and also serves cars with a depth camera (like the RealSense on the MIT RACECAR). For distance, use rc.lidar.

rc.camera.get_width()returns int

The pixel width of the colour frame. 640 on the NeoRacer.

rc.camera.get_height()returns int

The pixel height of the colour frame. 480 on the NeoRacer.

rc.camera.get_max_range()returns float

A depth-camera method, not meaningful on the NeoRacer (no depth camera). On a car that has one, it returns the farthest distance the depth sensor can report.

TYPICAL USE

READING A FRAME.

python
import racecar_core import numpy as np rc = racecar_core.create_racecar() def start(): pass def update(): image = rc.camera.get_color_image() # (480, 640, 3), BGR, 0-255 # average brightness of the colour frame print("brightness:", np.mean(image)) # the centre pixel as blue, green, red. The NeoRacer is RGB-only, # so reach for the LiDAR (rc.lidar), not a depth frame, for distance. h, w = image.shape[0], image.shape[1] b, g, r = image[h // 2, w // 2] print("centre BGR:", b, g, r) rc.set_start_update(start, update) rc.go()