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 colour frame and a matching depth frame, both as plain NumPy arrays 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 × 480colour + 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. Do not modify it in place, since the library reuses the buffer next frame.

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

A depth frame the same size as the colour image. Each pixel is the distance to that point in centimetres.

rc.camera.get_width()returns int

The pixel width of both the colour and depth frames. 640 on the NeoRacer.

rc.camera.get_height()returns int

The pixel height of both frames. 480 on the NeoRacer.

rc.camera.get_max_range()returns float

The farthest distance in centimetres the depth camera can report. Anything beyond it comes back as the max.

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 depth = rc.camera.get_depth_image() # (480, 640), cm # average brightness of the colour frame print("brightness:", np.mean(image)) # distance straight ahead, at the centre pixel print("centre depth:", depth[240, 320]) rc.set_start_update(start, update) rc.go()