Skip to content
Merged
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
2 changes: 1 addition & 1 deletion C/Applications/Examples/loadMeasurement/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ list(APPEND CMAKE_MODULE_PATH
"${CMAKE_SOURCE_DIR}/../../../SDK/cmake/")
find_package(Cuvis REQUIRED)
add_executable(main main.c)
target_link_libraries(main PRIVATE cuvis::cuvis)
target_link_libraries(main PRIVATE cuvis::c)
2 changes: 1 addition & 1 deletion C/SDK/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ If cuvis is installed to default locations, they are found automatically. Else,
Finally, link against *cuvis::cuvis*. In the following example, the tarket *main* is linked against cuvis:
```
add_executable(main main.c)
target_link_libraries(main PRIVATE cuvis::cuvis)
target_link_libraries(main PRIVATE cuvis::c)
```
7 changes: 4 additions & 3 deletions C/SDK/cmake/FindCuvis.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ find_package_handle_standard_args(Cuvis DEFAULT_MSG

mark_as_advanced(CUVIS_LIBRARY CUVIS_INCLUDE_DIR)

if(Cuvis_FOUND AND NOT TARGET cuvis::cuvis)
add_library(cuvis::cuvis STATIC IMPORTED)
if(Cuvis_FOUND AND NOT TARGET cuvis::c)
add_library(cuvis::c STATIC IMPORTED)
set_target_properties(
cuvis::cuvis
cuvis::c
PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${CUVIS_INCLUDE_DIR}"
IMPORTED_LOCATION ${CUVIS_LIBRARY})

endif()
7 changes: 7 additions & 0 deletions Cpp/Applications/Examples/loadMeasurement/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 3.20.0)
project(Example)
list(APPEND CMAKE_MODULE_PATH
"${CMAKE_SOURCE_DIR}/../../../SDK/cmake/")
find_package(CuvisCpp REQUIRED)
add_executable(main main.cpp)
target_link_libraries(main PRIVATE cuvis::cpp)
102 changes: 102 additions & 0 deletions Cpp/Applications/Examples/loadMeasurement/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#include "cuvis.hpp"

#include <cassert>
#include <iostream>
//#include <opencv/opencv.hpp>
int main(int argc, char* argv[])
{


if (argc != 3)
{
std::cout << "To few Arguments! Please provide:" << std::endl;
std::cout << "user settings directory" << std::endl;
std::cout << "measurement file (.cu3)" << std::endl;

return -1;
}
char* const userSettingsDir = argv[1];
char* const measurementLoc = argv[2];




std::cout << "Example 01 load measurement cpp " << std::endl;
std::cout <<"User Settings Dir: " << userSettingsDir << std::endl;
std::cout << "measurement file(.cu3): " <<measurementLoc << std::endl;

std::cout << "loading user settings..." << std::endl;
cuvis::General::init(userSettingsDir);
cuvis::General::set_log_level(loglevel_info);

std::cout << "loading measurement file..." << std::endl;
cuvis::Measurement mesu(measurementLoc);

std::cout
<< "Data 1" << mesu.get_meta()->name << " "
<< "t=" << mesu.get_meta()->integration_time << " ms "
<< "mode=" << mesu.get_meta()->processing_mode << " "
<< std::endl;
if (mesu.get_meta()->measurement_flags.size() > 0)
{
std::cout << " Flags" << std::endl;
for (auto const& flags : mesu.get_meta()->measurement_flags)
{
std::cout << " - " << flags.first << " (" << flags.second << ")" << std::endl;
}
}


assert(
mesu.get_meta()->processing_mode == Cube_Raw &&
"This example requires raw mode");


auto const& cube_it = mesu.get_imdata()->find(CUVIS_MESU_CUBE_KEY);
assert(
cube_it != mesu.get_imdata()->end() &&
"Cube not found");

auto cube = std::get<cuvis::image_t<std::uint16_t>>(cube_it->second);

//uncomment to show a single channel with openCV
/*
cv::Mat img(
cv::Size(cube._width, cube._height),
CV_16UC(cube._channels),
const_cast<void*>(reinterpret_cast<const void*>(cube._data)),
cv::Mat::AUTO_STEP);

cv::Mat singleChannel;
cv::extractChannel(
img, singleChannel, 25); // extract channel 25 as an example
singleChannel.convertTo(singleChannel, CV_8U, 1 / 16.0);
cv::imshow("channel 25", singleChannel);
cv::waitKey(0);
*/


std::size_t x = 120;
std::size_t y = 200;

assert(x < cube._width && "x index exceeds cube width");
assert(y < cube._height && "x index exceeds cube width");

std::cout << "lambda [nm]; raw counts [au] " << std::endl;

for (std::size_t chn = 0; chn < cube._channels; chn++)
{
// memory layout:
//unsigned index = (y * cube.width + x) * cube.channels + chn;
//uint16_t value = cube16bit[index];


auto const value = cube.get(x, y, chn);
unsigned lambda = cube._wavelength[chn];

std::cout << lambda << "; " << value << std::endl;
}
std::cout << "finished. " << std::endl;


}
25 changes: 25 additions & 0 deletions Cpp/SDK/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# CUVIS CPP SDK

## Importing Cuvis CPP SDK via CMake

In order to import cuvis to your CMake project, Cuvis must be installed (todo: add link to compatible version).

First, you need to add the directory containing *FindCuvisCpp.cmake* to *CMAKE_MODULE_PATH*, e.g.:
```
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/")
```

Then you need to run the *find_package* function:
```
find_package(CuvisCpp REQUIRED)
```

If cuvis is installed to default locations, they are found automatically. Else, locate the cuvis.lib and the directory containing cuvis.h.

Finally, link against *cuvis::cuvis*. In the following example, the tarket *main* is linked against cuvis:
```
add_executable(main main.cpp)
target_link_libraries(main PRIVATE cuvis::cpp)
```

Please note, that linking against cuvis::cpp will enable c++17 on the target.
Empty file added Cpp/SDK/auxiliary/.gitkeep
Empty file.
32 changes: 32 additions & 0 deletions Cpp/SDK/cmake/FindCuvisCpp.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
include(GNUInstallDirs)

find_library(
CUVIS_LIBRARY
NAMES "cuvis"
HINTS "/lib/cuvis" "$ENV{PROGRAMFILES}/Cuvis/bin")

find_path(CUVIS_INCLUDE_DIR
NAMES cuvis.h
HINTS "/usr/include/" "$ENV{PROGRAMFILES}/Cuvis/sdk/cuvis_c")

include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(CuvisCpp DEFAULT_MSG
CUVIS_LIBRARY
CUVIS_INCLUDE_DIR)

mark_as_advanced(CUVIS_LIBRARY CUVIS_INCLUDE_DIR)

if(CuvisCpp_FOUND AND NOT TARGET cuvis::cpp)

add_library(cuvis::cpp STATIC IMPORTED)

#simmilar to the c library, we use the cuvis.dll, howver we add
#the cpp interface file as well as force the utilizing target to switch to c++17
set_target_properties(
cuvis::cpp
PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${CUVIS_INCLUDE_DIR};${CMAKE_CURRENT_LIST_DIR}/../interface"
IMPORTED_LOCATION ${CUVIS_LIBRARY})
target_compile_features(cuvis::cpp INTERFACE cxx_std_17)
endif()
Loading