Software/Arduino Core/Camera

VisionConfig Reference

Fields of the VisionConfig structure passed to Vision.begin, with defaults and semantics.

intermediateOV5640VD66GY4 min read

VisionConfig is the configuration structure accepted by Vision.begin(). Most fields apply to both sensors; af is OV5640 only and isp_enabled is VD66GY only, as noted in the table. Its constructor assigns every field, so a freshly declared instance is valid. Fields are set individually; the structure is not brace-initialised.

cpp
VisionConfig cfg;
cfg.camera    = CAMERA_VGA;
cfg.fps       = FPS_30;
cfg.transport = TRANSPORT_USB;
Vision.begin(&NN_Instance_yolov8_iseg, PostProcess_YOLOv8_ISEG(0.4f, 0.5f), cfg);

Fields

FieldDefaultMeaning
cameraCAMERA_WVGASensor output mode. See Resolutions and Frame Rates
fpsFPS_DEFAULTFrame rate, clamped to the mode's maximum. On TRANSPORT_LCD also the panel refresh
mirror_flipCAMERA_AUTO_FLIPOrientation. Auto selects per carrier. Alternatives: CAMERA_MIRROR_FLIP_NONE, CAMERA_FLIP, CAMERA_MIRROR, CAMERA_MIRROR_FLIP
nn.width, nn.height256, 256Model input size in pixels
nn.aspectASPECT_STRETCHMapping of the camera frame into the model input
nn.crop_x, nn.crop_y, nn.crop_w, nn.crop_h0Crop rectangle in camera pixels. Read only under ASPECT_CROP_OFFSET
nn.max_fps0 (uncapped)Maximum rate at which Vision.run() performs inference
transportTRANSPORT_USBDestination of the video
lcdfalseAlso show the image on the display while using a host transport
afAF_DISABLEDOV5640 only. Autofocus mode: AF_SINGLE, AF_CONTINUOUS. Ignored on the VD66GY
strobeSTROBE_DISABLEDBoth sensors. Flash LED synchronised to exposure
isp_enabledisp_tuning_disabledVD66GY only. ISP tuning: VD66_isp_tuning_auto, VD66_isp_tuning_manual. Ignored on the OV5640
band_locN6_MEM_AUTOLocation of the encoder line buffer
framebuf_locN6_MEM_AUTOLocation of the display framebuffer

Neural network pipe

The camera frame reaches the model through a hardware pipe that crops and scales it. nn.width and nn.height are the model's input dimensions and must match the model. The bundled YOLOv8 and Nia models take 256x256, the palm detector 192x192 and the face detector 128x128.

nn.aspect selects how a rectangular frame is fitted to the input:

ValueBehaviour
ASPECT_STRETCHThe whole frame is scaled non-uniformly into the input. Full field of view with distortion
ASPECT_CROP_CENTERThe largest centred rectangle with the input's aspect ratio is scaled uniformly. No distortion; the sides are excluded from the model but remain in the stream and on the display
ASPECT_CROP_OFFSETThe rectangle given by nn.crop_* is used

Under ASPECT_CROP_OFFSET the rectangle must lie within the camera frame and be at least the model input size, because the pipe only downsizes. A rectangle violating either bound is rewritten and a single [VISION WARN] crop clamped line names the reason. Values are rounded down to even numbers.

Post-processors map results back to the full camera frame under every mode. See Aspect Modes and Coordinates.

nn.max_fps limits how often Vision.run() performs inference. The camera and video continue at cfg.fps; only the inference pass and its overlay refresh are skipped, with a short yield. It was introduced for the thermal camera, whose video link has a hard deadline and lost frames when a model ran at 45 fps. It applies to Vision.run() only; runWith() and runRoi() callers control their own cadence.

Transport

ValueDestinationRequirement
TRANSPORT_USBNeuro Studio over USBNone
TRANSPORT_WIFI_SOFTAPNeuro Studio over a network hosted by the board#include <MayaW476.h>
TRANSPORT_WIFI_STANeuro Studio over an existing network#include <MayaW476.h>
TRANSPORT_LCDThe on-board panel, no host videoTFT carrier, mode at or below WVGA

The destinations are mutually exclusive. Under TRANSPORT_LCD the JPEG encoder is not started. The serial console is available under every transport. A WiFi transport without the library, or on a board without the module, falls back to USB with a warning.

lcd = true shows the image and overlay on the panel while a host transport is active. It requires the TFT carrier and a mode at or below WVGA. The panel and the encoder share the PSRAM bus, and the panel may tear under load.

Memory placement

band_loc and framebuf_loc accept N6_MEM_AUTO, N6_MEM_AXISRAM and N6_MEM_PSRAM. Auto prefers on-chip AXISRAM and falls back to PSRAM when the buffer does not fit. AXISRAM forces on-chip placement and fails at begin() if the buffer does not fit. PSRAM forces external placement.

band_loc places the encoder line buffer used by USB and WiFi transports. On-chip placement keeps the encoder's reads off the external bus.

framebuf_loc places the camera framebuffer under TRANSPORT_LCD, about 750 KB at WVGA. On-chip placement keeps the camera's traffic off the bus the display reads from and reduces tearing. The overlay layer is always in PSRAM.

begin overloads

CallUse
Vision.begin(model, pp)One model, default configuration
Vision.begin(model, pp, cfg)One model, explicit configuration
Vision.begin() or Vision.begin(cfg)No bound model. Camera-only sketches, or sketches that dispatch through runWith()
Vision.beginRawOnly(model)Camera, NPU and USB with no post-processor. Paired with runRaw()

Fixed after begin

Resolution, frame rate, transport and buffer placement are fixed at begin(). The model's crop can change per pass through runRoi(). Exposure, gain, white balance, focus and strobe can change at any time through the camera object.