Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ add_subdirectory(Example_2_Load_Measurement_cpp)
add_subdirectory(Example_3_Reprocess_cpp)
add_subdirectory(Example_4_Exporters_cpp)
add_subdirectory(Example_5_Record_Video_cpp)
add_subdirectory(Example_6_Record_Video_From_SessionFile_cpp)
add_subdirectory(Example_7_Change_Distance_cpp)
add_subdirectory(Example_6_Reference_Spectra_cpp)
add_subdirectory(Example_7_Record_Video_From_SessionFile_cpp)
add_subdirectory(Example_8_Change_Distance_cpp)
1 change: 1 addition & 0 deletions Example_1_Take_Snapshot_cpp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ int main(int argc, char* argv[])
saveArgs.allow_overwrite = true;
saveArgs.export_dir = recDir;
saveArgs.allow_session_file = true;
saveArgs.full_export = false; // do not include the cube in the export

// Setup the Cube Exporter for saving the measurements to disk in the SessionFile format(.cu3s)
cuvis::CubeExporter exporter(saveArgs);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#!/bin/bash

# Usage:
# example app path [string] E.g. ./05_recordSingleImages_cpp.exe for windows or ./05_recordSingleImages_cpp for linux
# example app path [string] E.g. ./Example_1_Take_Snapshot_cpp.exe for windows or ./Example_1_Take_Snapshot_cpp for linux
# user settings directory [string] Default is C:/Program Files/cuvis/user/settings for windows or /etc/cuvis/user/settings for linux
# factory directory [string] Default is C:/Program Files/cuvis/factory for windows or /etc/cuvis/factory for linux
# name of recording directory [string] The name of your recording folder realtive to the example app path
# name of recording directory [string] The name of your recording folder relative to the example app path
# exposure time [int ] exposure (integration) time in ms
# number of images to record [int ] the number of images you want to record

if [[ "$OSTYPE" == "linux-gnu"* ]]; then
##########LINUX##########
./05_recordSingleImages_cpp \
./Example_1_Take_Snapshot_cpp \
"/etc/cuvis/user/settings" \
"/etc/cuvis/factory" \
"images" \
Expand All @@ -19,7 +19,7 @@ if [[ "$OSTYPE" == "linux-gnu"* ]]; then

else
##########WINDOWS##########
./05_recordSingleImages_cpp.exe \
./Example_1_Take_Snapshot_cpp.exe \
"C:/Program Files/cuvis/user/settings" \
"C:/Program Files/cuvis/factory" \
"images" \
Expand Down
10 changes: 10 additions & 0 deletions Example_2_Load_Measurement_cpp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,16 @@ int main(int argc, char* argv[])
}
}

// SessionFiles are saved without the cube by default (Preview mode): compute it now (ProcessingContext, see Example 3)
if (mesu.get_meta()->processing_mode == cuvis::processing_mode_t::Preview)
{
cuvis::ProcessingContext proc(sess);
cuvis::ProcessingArgs procArgs;
procArgs.processing_mode = cuvis::processing_mode_t::Cube_Raw;
proc.set_processingArgs(procArgs);
proc.apply(mesu);
}

assert(
mesu.get_meta()->processing_mode == Cube_Raw &&
"This example requires raw mode");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
#!/bin/bash

# Usage:
# example app path [string] E.g. ./01_loadMeasurement_cpp.exe for windows or ./01_loadMeasurement_cpp for linux
# user settings directory [string] Default is ../../../sample_data/set_examples/settings
# sessionfile (.cu3s) [string] Default is ../../../sample_data/set_examples/set0_single/single.cu3s
# example app path [string] E.g. ./Example_2_Load_Measurement_cpp.exe for windows or ./Example_2_Load_Measurement_cpp for linux
# user settings directory [string] Default is ../settings
# sessionfile (.cu3s) [string] Default is ../SDK_Training_Example_Data/single_raw.cu3s (demo data, Ultris X20)

if [[ "$OSTYPE" == "linux-gnu"* ]]; then
##########LINUX##########
./01_loadMeasurement_cpp \
"../../../sample_data/set_examples/settings" \
"../../../sample_data/set_examples/set0_single/single.cu3s" \
./Example_2_Load_Measurement_cpp \
"../settings" \
"../SDK_Training_Example_Data/single_raw.cu3s" \

else
##########WINDOWS##########
./01_loadMeasurement_cpp.exe \
"../../../sample_data/set_examples/settings" \
"../../../sample_data/set_examples/set0_single/single.cu3s" \
./Example_2_Load_Measurement_cpp.exe \
"../settings" \
"../SDK_Training_Example_Data/single_raw.cu3s" \

fi
28 changes: 21 additions & 7 deletions Example_3_Reprocess_cpp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,30 +91,43 @@ int main(int argc, char* argv[])

std::cout << "loading dark... " << std::endl;
cuvis::SessionFile sessDark(darkLoc);
auto optDark = sessDark.get_mesu(0);
// use the reference stored in the file (e.g. the demo data), otherwise its first measurement
auto optDark = sessDark.get_ref(0, cuvis::reference_type_t::Reference_Dark);
if (!optDark.has_value())
{
optDark = sessDark.get_mesu(0);
}
assert(optDark.has_value());
cuvis::Measurement dark = optDark.value();

std::cout << "loading white... " << std::endl;
cuvis::SessionFile sessWhite(whiteLoc);
auto optWhite = sessWhite.get_mesu(0);
auto optWhite = sessWhite.get_ref(0, cuvis::reference_type_t::Reference_White);
if (!optWhite.has_value())
{
optWhite = sessWhite.get_mesu(0);
}
assert(optWhite.has_value());
cuvis::Measurement white = optWhite.value();

/*
* Distance Calibration
* Most Ultris cameras(except for Relay - variants) require distance calibration to achieve optimal results.
* Most Ultris cameras (except for relay variants) require distance calibration to achieve optimal results.
*
* ** Please note : **The provided default demo dataset was recorded with a relay - equipped camera(Ultris XM with relay optics).Thus this step is not applicable to this dataset.
* Please note: Distance calibration is not supported for R models (relay optics, e.g. Ultris XMR). P models (pan sensor, e.g. Ultris X20P) only support it with a distance reference measurement, not with a distance in mm.
*
* Distance calibration is an operation that can be done with already recorded data and requires a distance reference measurement.
* The reference should contain high - contrast data over the relevant spectral channels at the desired distance that data should be calibrated to.
* The reference should contain high-contrast data over the relevant spectral channels at the desired distance that data should be calibrated to.
*
* In this example, the measurement itself will be used as the distance reference.If the target object is suitable(high contrast, non - repeating patterns), this can suffice for good results.
* In this example, the distance reference stored in the distance file is used, otherwise its first measurement. If the target object is suitable (high contrast, non-repeating patterns), the measurement itself can suffice for good results.
*/
std::cout << "loading distance... " << std::endl;
cuvis::SessionFile sessDistance(distanceLoc);
auto optDistance = sessDistance.get_mesu(0);
auto optDistance = sessDistance.get_ref(0, cuvis::reference_type_t::Reference_Distance);
if (!optDistance.has_value())
{
optDistance = sessDistance.get_mesu(0);
}
assert(optDistance.has_value());
cuvis::Measurement distance = optDistance.value();

Expand Down Expand Up @@ -149,6 +162,7 @@ int main(int argc, char* argv[])
saveArgs.allow_overwrite = true;
saveArgs.allow_session_file = true;
saveArgs.allow_info_file = false;
saveArgs.full_export = false; // do not include the cube in the export

std::map<std::string, cuvis::processing_mode_t> target_modes = {
{"Raw", cuvis::processing_mode_t::Cube_Raw},
Expand Down
38 changes: 19 additions & 19 deletions Example_3_Reprocess_cpp/run_Example_3_Reprocess_cpp.sh
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
#!/bin/bash

# Usage:
# example app path [string] E.g. .02_reprocessMeasurement.exe for windows or ./02_reprocessMeasurement_cpp for linux
# user settings directory [string] Default is ../../../sample_data/set_examples/settings
# measurement file (.cu3s) [string] Default is ../../../sample_data/set0_single/single_raw.cu3s
# dark file (.cu3s) [string] Default is ../../../sample_data/set0_single/single_dark.cu3s
# white file (.cu3s) [string] Default is ../../../sample_data/set0_single/single_white.cu3s
# distance file (.cu3s) [string] Default is ../../../sample_data/set0_single/single_distance.cu3s
# name of output directory [string] The name of your output folder realtive to the example app path
# example app path [string] E.g. ./Example_3_Reprocess_cpp.exe for windows or ./Example_3_Reprocess_cpp for linux
# user settings directory [string] Default is ../settings
# measurement file (.cu3s) [string] Default is ../SDK_Training_Example_Data/single_raw.cu3s (demo data, Ultris X20)
# dark file (.cu3s) [string] Default is ../SDK_Training_Example_Data/single_raw.cu3s
# white file (.cu3s) [string] Default is ../SDK_Training_Example_Data/single_raw.cu3s
# distance file (.cu3s) [string] Default is ../SDK_Training_Example_Data/single_raw.cu3s
# name of output directory [string] The name of your output folder relative to the example app path

if [[ "$OSTYPE" == "linux-gnu"* ]]; then
##########LINUX##########
./02_reprocessMeasurement_cpp \
"../../../sample_data/set_examples/settings" \
"../../../sample_data/set_examples/set0_single/single_raw.cu3s" \
"../../../sample_data/set_examples/set0_single/single_dark.cu3s" \
"../../../sample_data/set_examples/set0_single/single_white.cu3s" \
"../../../sample_data/set_examples/set0_single/single_distance.cu3s" \
./Example_3_Reprocess_cpp \
"../settings" \
"../SDK_Training_Example_Data/single_raw.cu3s" \
"../SDK_Training_Example_Data/single_raw.cu3s" \
"../SDK_Training_Example_Data/single_raw.cu3s" \
"../SDK_Training_Example_Data/single_raw.cu3s" \
"reprocessed" \

else
##########WINDOWS##########
./02_reprocessMeasurement_cpp.exe \
"../../../sample_data/set_examples/settings" \
"../../../sample_data/set_examples/set0_single/single_raw.cu3s" \
"../../../sample_data/set_examples/set0_single/single_dark.cu3s" \
"../../../sample_data/set_examples/set0_single/single_white.cu3s" \
"../../../sample_data/set_examples/set0_single/single_distance.cu3s" \
./Example_3_Reprocess_cpp.exe \
"../settings" \
"../SDK_Training_Example_Data/single_raw.cu3s" \
"../SDK_Training_Example_Data/single_raw.cu3s" \
"../SDK_Training_Example_Data/single_raw.cu3s" \
"../SDK_Training_Example_Data/single_raw.cu3s" \
"reprocessed" \

fi
58 changes: 52 additions & 6 deletions Example_4_Exporters_cpp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,29 @@ int main(int argc, char* argv[])
* - Have the Cuvis SDK installed
*
* Run properties
* - "path/to/settings" path/to/measurement/single.cu3s" "path/to/user/plugin/file.xml" "OutputFolderName"
* - "path/to/settings" "path/to/measurement/file.cu3s" measurementIndex "path/to/user/plugin/file.xml" "OutputFolderName"
*/
if (argc != 5)
if (argc != 6)
{
std::cout << std::endl << "Too few Arguments! Please provide:" << std::endl;
std::cout << "user settings directory" << std::endl;
std::cout << "sessionfile (.cu3s)" << std::endl;
std::cout << "measurement index" << std::endl;
std::cout << "user plugin file (.xml)" << std::endl;
std::cout << "Name of export directory" << std::endl;

return -1;
}
char* const userSettingsDir = argv[1];
char* const sessionLoc = argv[2];
char* const pluginLoc = argv[3];
char* const exportDir = argv[4];
int const mesuIndex = std::stoi(argv[3]);
char* const pluginLoc = argv[4];
char* const exportDir = argv[5];

std::cout << "Example 04 export measurement" << std::endl;
std::cout << "User Settings Dir: " << userSettingsDir << std::endl;
std::cout << "sessionfile (.cu3s): " << sessionLoc << std::endl;
std::cout << "measurement index: " << mesuIndex << std::endl;
std::cout << "user plugin file (.xml): " << pluginLoc << std::endl;
std::cout << "Export Dir: " << exportDir << std::endl;

Expand All @@ -56,11 +59,28 @@ int main(int argc, char* argv[])
cuvis::SessionFile sess(sessionLoc);

std::cout << "loading measurement... " << std::endl;
auto optmesu = sess.get_mesu(0);
auto optmesu = sess.get_mesu(mesuIndex);
assert(optmesu.has_value());
cuvis::Measurement mesu = optmesu.value();

assert(mesu.get_meta()->processing_mode != cuvis::processing_mode_t::Preview);
// the exporters need a cube: SessionFiles are saved without it by default (Preview mode), so compute it now
if (mesu.get_meta()->processing_mode == cuvis::processing_mode_t::Preview)
{
cuvis::ProcessingContext proc(sess);
// distance calibration (see Example 3) with the measurement itself, as the demo file has no distance reference
try
{
proc.set_reference(mesu, cuvis::reference_type_t::Reference_Distance);
}
catch (cuvis::cuvis_sdk_exception const& e) // R models (relay optics) do not support distance calibration
{
std::cout << "distance not set: " << e.what() << std::endl;
}
cuvis::ProcessingArgs procArgs;
procArgs.processing_mode = cuvis::processing_mode_t::Cube_Raw;
proc.set_processingArgs(procArgs);
proc.apply(mesu);
}

{
/*
Expand Down Expand Up @@ -156,6 +176,31 @@ int main(int argc, char* argv[])

cuvis::ViewExporter exporter(args);
exporter.apply(mesu);

/*
* View Exporter - Pansharpening
* Only for cameras with a panchromatic sensor (P models, e.g. Ultris X20P).
* Pansharpening fuses the cube (high spectral resolution) with the pan image (high spatial resolution).
* It is set in the pansharpening settings of any exporter. With the *ViewExporter* it is applied after rendering the view, which is fast.
* - `pan_scale`: 0.0 = off, 1.0 = resolution of the pan image
* - `pan_algorithm`: `CubertMacroPixel` works in all processing modes, `CubertPanRatio` needs Reflectance mode, `Noop` only upscales
* - `pre_pan_sharpen_cube`: sharpen the whole cube before rendering (more accurate, much slower)
*/
if (mesu.get_imdata()->count(CUVIS_MESU_PAN_KEY) > 0) // only with a pan image
{
std::cout << "Export pansharpened view to file" << std::endl;
char exportDirPansharpen[CUVIS_MAXBUF];
strcpy(exportDirPansharpen, exportDir);
strcat(exportDirPansharpen, "/pansharpened");
args.export_dir = exportDirPansharpen;
args.pansharpening_settings.pan_scale = 1.0;
args.pansharpening_settings.pan_interpolation_type = pan_sharpening_interpolation_type_Linear;
args.pansharpening_settings.pan_algorithm = pan_sharpening_algorithm_CubertMacroPixel;
args.pansharpening_settings.pre_pan_sharpen_cube = false;

cuvis::ViewExporter pansharpenExporter(args);
pansharpenExporter.apply(mesu);
}
}
{
/*
Expand Down Expand Up @@ -183,6 +228,7 @@ int main(int argc, char* argv[])
saveArgs.export_dir = exportDirView;
saveArgs.allow_overwrite = true;
saveArgs.allow_session_file = true;
saveArgs.full_export = false; // do not include the cube in the export

cuvis::CubeExporter exporter(saveArgs);
exporter.apply(mesu);
Expand Down
29 changes: 16 additions & 13 deletions Example_4_Exporters_cpp/run_Example_4_Exporters_cpp.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
#!/bin/bash

# Usage:
# example app path [string] E.g. ./03_exportMeasurement_cpp.exe for windows or ./03_exportMeasurement_cpp for linux
# user settings directory [string] Default is ../../../sample_data/set_examples/settings
# sessionfile (.cu3s) [string] Default is ../../../sample_data/set_examples/set0_single/single.cu3s
# user plugin file (.xml) [string] Default is ../../../sample_data/set_examples/plugin/ref/cai.xml
# name of export directory [string] The name of your output folder realtive to the example app path
# example app path [string] E.g. ./Example_4_Exporters_cpp.exe for windows or ./Example_4_Exporters_cpp for linux
# user settings directory [string] Default is ../settings
# sessionfile (.cu3s) [string] Default is ../SDK_Training_Example_Data/Drone.cu3s (demo data, Ultris X20P with pan sensor)
# measurement index [int ] Default is 2 (in Drone.cu3s, 0 and 1 are copies of the Dark and White references)
# user plugin file (.xml) [string] Default is ../plugins/00_RGB.xml
# name of export directory [string] The name of your output folder relative to the example app path

if [[ "$OSTYPE" == "linux-gnu"* ]]; then
##########LINUX##########
./03_exportMeasurement_cpp \
"../../../sample_data/set_examples/settings" \
"../../../sample_data/set_examples/set0_single/single.cu3s" \
"../../../sample_data/set_examples/plugin/ref/cai.xml" \
./Example_4_Exporters_cpp \
"../settings" \
"../SDK_Training_Example_Data/Drone.cu3s" \
2 \
"../plugins/00_RGB.xml" \
"export" \

else
##########WINDOWS##########
./03_exportMeasurement_cpp.exe \
"../../../sample_data/set_examples/settings" \
"../../../sample_data/set_examples/set0_single/single.cu3s" \
"../../../sample_data/set_examples/plugin/ref/cai.xml" \
./Example_4_Exporters_cpp.exe \
"../settings" \
"../SDK_Training_Example_Data/Drone.cu3s" \
2 \
"../plugins/00_RGB.xml" \
"export" \

fi
Expand Down
1 change: 1 addition & 0 deletions Example_5_Record_Video_cpp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ int main(int argc, char* argv[])
sargs.operation_mode = OperationMode_Internal;
sargs.allow_overwrite = true;
sargs.allow_session_file = true;
sargs.full_export = false; // do not include the cube in the export
sargs.export_dir = std::filesystem::path(recDir);

std::cout << "Writing Files to: " << sargs.export_dir << std::endl;
Expand Down
8 changes: 4 additions & 4 deletions Example_5_Record_Video_cpp/run_Example_5_Record_Video_cpp.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#!/bin/bash

# Usage:
# example app path [string] E.g. ./06_recordVideo_cpp.exe for windows or ./06_recordVideo_cpp for linux
# example app path [string] E.g. ./Example_5_Record_Video_cpp.exe for windows or ./Example_5_Record_Video_cpp for linux
# user settings directory [string] Default is C:/Program Files/cuvis/user/settings for windows or /etc/cuvis/user/settings for linux
# factory directory [string] Default is C:/Program Files/cuvis/factory for windows or /etc/cuvis/factory for linux
# name of recording directory [string] The name of your output folder realtive to the example app path
# name of recording directory [string] The name of your output folder relative to the example app path
# exposure time [int ] exposure (integration) time in ms
# auto exposure [bool ] 1 is "on", 0 is "off"; if "on" the aquisition will start with the given exposure time and then adjust on the fly
# target fps [double] Frames Per Second that shall be recorded.

if [[ "$OSTYPE" == "linux-gnu"* ]]; then
##########LINUX##########
./06_recordVideo_cpp \
./Example_5_Record_Video_cpp \
"/etc/cuvis/user/settings" \
"/etc/cuvis/factory" \
"video01" \
Expand All @@ -21,7 +21,7 @@ if [[ "$OSTYPE" == "linux-gnu"* ]]; then

else
##########WINDOWS##########
./06_recordVideo_cpp.exe \
./Example_5_Record_Video_cpp.exe \
"C:/Program Files/cuvis/user/settings" \
"C:/Program Files/cuvis/factory" \
"video01" \
Expand Down
Loading