| Title: | R Bindings for the Cubert CUVIS Hyperspectral SDK |
|---|---|
| Description: | Provides R bindings to the Cubert CUVIS C SDK for reading, processing, and exporting hyperspectral imaging data from Cubert snapshot cameras. Supports loading proprietary '.cu3s' session files, applying the full calibration pipeline (dark subtraction, white reference normalization, spectral radiance, reflectance), and exporting to standard formats (ENVI, TIFF). Requires the Cubert CUVIS SDK to be installed separately. This package mirrors the API of 'cuvis.python' (<https://github.com/cubert-hyperspectral/cuvis.python>) for R users. |
| Authors: | R. Heller [aut, cre] (ORCID: <https://orcid.org/0000-0001-8006-9742>) |
| Maintainer: | R. Heller <[email protected]> |
| License: | Apache License (>= 2) | file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-10-14 14:52:43 UTC |
| Source: | https://github.com/CTTIR/cuvis.r |
Tests whether the Cubert CUVIS SDK library is linked and usable.
cuvis_available()cuvis_available()
Logical. TRUE if the SDK is available, FALSE otherwise.
Writes the measurement data as an ENVI header/binary file pair.
cuvis_export_envi(measurement, dir, permissive = TRUE)cuvis_export_envi(measurement, dir, permissive = TRUE)
measurement |
A cuvis_measurement object. |
dir |
Character. Output directory. |
permissive |
Logical. Allow export even if some data is missing.
Default |
Invisible dir.
Saves the measurement as a new .cu3s session file.
cuvis_export_session(measurement, dir, permissive = TRUE)cuvis_export_session(measurement, dir, permissive = TRUE)
measurement |
A cuvis_measurement object. |
dir |
Character. Output directory for the |
permissive |
Logical. Default |
Invisible dir.
Export a Measurement to TIFF Format
cuvis_export_tiff( measurement, dir, format = c("MultiChannel", "Single", "MultiPage"), compression = c("None", "LZW"), permissive = TRUE )cuvis_export_tiff( measurement, dir, format = c("MultiChannel", "Single", "MultiPage"), compression = c("None", "LZW"), permissive = TRUE )
measurement |
A cuvis_measurement object. |
dir |
Character. Output directory. |
format |
Character. TIFF format: |
compression |
Character. Compression mode: |
permissive |
Logical. Default |
Invisible dir.
Returns the 3D data cube as an R array with wavelength metadata.
cuvis_get_cube(measurement)cuvis_get_cube(measurement)
measurement |
A cuvis_measurement object. |
A numeric 3D array with dimensions [rows, cols, bands].
The "wavelengths" attribute contains a numeric vector of band center
wavelengths in nanometers.
## Not run: cuvis_init() session <- cuvis_session("path/to/file.cu3s") mesu <- cuvis_get_measurement(session, 1) cube <- cuvis_get_cube(mesu) dim(cube) # e.g., c(100, 100, 61) attr(cube, "wavelengths") # wavelengths in nm cuvis_shutdown() ## End(Not run)## Not run: cuvis_init() session <- cuvis_session("path/to/file.cu3s") mesu <- cuvis_get_measurement(session, 1) cube <- cuvis_get_cube(mesu) dim(cube) # e.g., c(100, 100, 61) attr(cube, "wavelengths") # wavelengths in nm cuvis_shutdown() ## End(Not run)
Extracts a single measurement from a session file by index.
cuvis_get_measurement(session, index = 1L, item_type = "no_gaps")cuvis_get_measurement(session, index = 1L, item_type = "no_gaps")
session |
A cuvis_session object. |
index |
Integer. 1-based measurement index. |
item_type |
Character. Type of items to enumerate: |
A cuvis_measurement S3 object, or NULL if no measurement
exists at that index.
Returns metadata fields for a measurement including name, integration time, serial number, processing mode, and more.
cuvis_get_metadata(measurement)cuvis_get_metadata(measurement)
measurement |
A cuvis_measurement object. |
A named list with fields: name, path, comment,
integration_time (ms), averages, distance, serial_number,
product_name, assembly, processing_mode (integer),
capture_time (ms since epoch), measurement_flags (integer).
Convenience function to extract just the wavelength vector from a measurement's cube data.
cuvis_get_wavelengths(measurement)cuvis_get_wavelengths(measurement)
measurement |
A cuvis_measurement object. |
Numeric vector of wavelengths in nm.
Check if a Reference is Set
cuvis_has_reference( ctx, type = c("dark", "white", "white_dark", "sprad", "distance") )cuvis_has_reference( ctx, type = c("dark", "white", "white_dark", "sprad", "distance") )
ctx |
A cuvis_processing_context object. |
type |
Character. Reference type to check. |
Logical.
Must be called before any other cuvis.r function. Loads the Cubert CUVIS SDK and configures the user settings directory.
cuvis_init(settings_dir = NULL)cuvis_init(settings_dir = NULL)
settings_dir |
Character. Path to the CUVIS settings directory — the
one holding |
The settings directory is not optional in practice. The SDK loads its
factory calibration from it, and pointing it at an empty directory makes
every subsequent cuvis_proc_cont_apply() fail with "Could not process
measurement" — which looks like a corrupt recording rather than a
configuration problem. Hence the search over real install locations before
falling back to a temporary directory, and the warning when it does.
Invisible NULL.
## Not run: cuvis_init() # ... use SDK ... cuvis_shutdown() ## End(Not run)## Not run: cuvis_init() # ... use SDK ... cuvis_shutdown() ## End(Not run)
Is the CUVIS SDK Currently Initialised?
cuvis_is_initialized()cuvis_is_initialized()
Logical.
cuvis_is_initialized()cuvis_is_initialized()
Creates a processing context from a session file or measurement. This context holds calibration references and processing parameters for reprocessing measurements.
cuvis_processing_context(base, load_references = TRUE)cuvis_processing_context(base, load_references = TRUE)
base |
A cuvis_session or cuvis_measurement object. |
load_references |
Logical. If |
A cuvis_processing_context S3 object.
Named integer vector of processing modes matching the CUVIS SDK C enum values.
Used internally by cuvis_reprocess().
cuvis_processing_modescuvis_processing_modes
Raw (0): Raw sensor data, no processing
DarkSubtract (1): Dark current subtracted
Reflectance (2): Normalized reflectance (0-1)
SpectralRadiance (3): Calibrated to physical radiance (W/m^2/sr/nm)
Preview (5): Low-resolution preview only
Named integer vector of reference types matching the CUVIS SDK C enum values.
Used by cuvis_set_reference().
cuvis_reference_typescuvis_reference_types
Dark (0): Dark reference frame
White (1): White reference frame
WhiteDark (2): Dark reference for the white reference
SpRad (3): Spectral radiance calibration
Distance (4): Distance calibration
Applies processing context settings to a measurement, converting it to the requested calibration level (e.g., reflectance).
cuvis_reprocess( ctx, measurement, mode = c("reflectance", "spectral_radiance", "dark_subtract", "raw", "preview"), allow_recalib = FALSE )cuvis_reprocess( ctx, measurement, mode = c("reflectance", "spectral_radiance", "dark_subtract", "raw", "preview"), allow_recalib = FALSE )
ctx |
A cuvis_processing_context with references set. |
measurement |
A cuvis_measurement to reprocess. |
mode |
Character. Target processing mode: |
allow_recalib |
Logical. Allow recalibration if needed. Default |
The same cuvis_measurement object, reprocessed in place.
Extract the cube with cuvis_get_cube().
Returns the path to Cubert sample data. Searches in order:
.cuvis/ directory in the working directory or any parent (up to 5 levels)
CUVIS_DATA environment variable
SDK default install location
cuvis_sample_data(file = NULL)cuvis_sample_data(file = NULL)
file |
Character. Specific file name (e.g., |
Character path, or NULL if not found.
Convenience function that locates and loads the first .cu3s file
found in the sample data directories.
cuvis_sample_session()cuvis_sample_session()
A cuvis_session object, or NULL with a warning if sample
data is not found.
Opens a .cu3s session file containing one or more hyperspectral
measurements with their calibration references.
cuvis_session(path)cuvis_session(path)
path |
Character. Path to a |
A cuvis_session S3 object (wrapping an external pointer to the
SDK session handle). Use cuvis_get_measurement() to extract individual
measurements.
## Not run: cuvis_init() session <- cuvis_session("path/to/measurement.cu3s") print(session) cuvis_shutdown() ## End(Not run)## Not run: cuvis_init() session <- cuvis_session("path/to/measurement.cu3s") print(session) cuvis_shutdown() ## End(Not run)
Assigns a reference measurement (dark, white, etc.) to a processing context.
cuvis_set_reference( ctx, measurement, type = c("dark", "white", "white_dark", "sprad", "distance") )cuvis_set_reference( ctx, measurement, type = c("dark", "white", "white_dark", "sprad", "distance") )
ctx |
A cuvis_processing_context object. |
measurement |
A cuvis_measurement object (the reference frame). |
type |
Character. One of |
Invisible ctx (modified in place via external pointer).
Releases all SDK resources. Call when done using cuvis.r functions.
cuvis_shutdown()cuvis_shutdown()
Invisible NULL.
Note: The SDK must be initialized with cuvis_init() before calling
this function.
cuvis_version()cuvis_version()
Character string with the SDK version.