Overview
cuvis.r provides R bindings to the Cubert CUVIS C SDK for reading, processing, and exporting hyperspectral imaging data from Cubert snapshot cameras. It mirrors the API of cuvis.python.
Prerequisites
- Install the Cubert CUVIS SDK for a supported Linux or Windows platform from https://github.com/cubert-hyperspectral/cuvis.sdk/releases
- Set the
CUVIS_SDKenvironment variable to the SDK install directory - Install cuvis.r from GitHub:
remotes::install_github("cttir/cuvis.r")Quick Start
The SDK may be initialized only once per R process. Keep it active
for the whole batch, then shut down once. Restart R before another batch
after shutdown. macOS supports stub installation, not the vendor
runtime. Exports require a new or empty directory unless
overwrite = TRUE is explicitly requested.
Initialize the SDK
Every cuvis.r session begins with cuvis_init() and ends
with cuvis_shutdown():
Load a Session File
Cubert cameras store measurements in .cu3s session
files. Load one with cuvis_session():
session <- cuvis_session("path/to/measurement.cu3s")
print(session)Extract a Measurement
Session files contain one or more measurements. Access them by index (1-based):
mesu <- cuvis_get_measurement(session, 1)
print(mesu)Inspect Metadata
md <- cuvis_get_metadata(mesu)
md$name
md$integration_time
md$serial_number
md$product_nameGet the Data Cube
The hyperspectral data cube is returned as a 3D R array
[rows, cols, bands] with wavelength metadata attached:
# First, process to generate the cube
ctx <- cuvis_processing_context(session)
cuvis_reprocess(ctx, mesu, mode = "raw")
cube <- cuvis_get_cube(mesu)
dim(cube) # e.g., c(100, 100, 61)
attr(cube, "wavelengths") # wavelengths in nmYou can subset bands, compute means, or use standard R array operations:
Export to Standard Formats
# ENVI format (widely supported by remote sensing tools)
cuvis_export_envi(mesu, "output/envi/")
# Multi-channel TIFF
cuvis_export_tiff(mesu, "output/tiff/")Next Steps
- See
vignette("cuvis-r-calibration")for the full calibration workflow (dark/white references, reflectance conversion) - See the cuvis.python examples for workflow patterns that translate directly to cuvis.r