Compare commits
6 Commits
v0.0.1.202
...
main
Author | SHA1 | Date | |
---|---|---|---|
4937463f80 | |||
38b031d68b | |||
641885f4f5 | |||
ef7318c847 | |||
042cea2fb5 | |||
5a60190b8e |
2
.gitignore
vendored
2
.gitignore
vendored
@ -1 +1,3 @@
|
|||||||
build
|
build
|
||||||
|
release
|
||||||
|
tmp
|
||||||
|
24
CHANGELOG.md
Normal file
24
CHANGELOG.md
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# 更新日志
|
||||||
|
|
||||||
|
|
||||||
|
## v0.0.2.20240925_alpha
|
||||||
|
|
||||||
|
**在之前写的代码基础上正式建立此项目文件,后续将在此项目上进行迭代开发**
|
||||||
|
### 🔄Changed
|
||||||
|
- 加载配置文件变更为绝对路径,会自动寻找exe文件所在文件夹的上层文件夹下的"configs/data_collection_configs.yaml"文件作为配置文件
|
||||||
|
|
||||||
|
### 🚀Refactored
|
||||||
|
- 将.bat文件修改为.ps1文件,即默认使用powershell编译
|
||||||
|
- 实现"./run.ps1"直接运行build文件夹下的所有exe文件
|
||||||
|
- 实现"./run.ps1 b"重新编译,并随后直接运行build文件夹下的所有exe文件
|
||||||
|
- 实现"./run.ps1 p"打包编译好的文件,注意要先执行编译才能打包, 注意在CmakeList.txt文件中修改版本号
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## v0.0.1.20240912_alpha
|
||||||
|
|
||||||
|
**在之前写的代码基础上正式建立此项目文件,后续将在此项目上进行迭代开发**
|
||||||
|
### ⭐️Features
|
||||||
|
- 根据配置文件启动光谱相机并不断保存光谱数据到文件夹
|
||||||
|
- 自动点击选择光谱相机
|
||||||
|
- 可打包生成生产环境中的文件
|
@ -4,13 +4,13 @@ cmake_minimum_required(VERSION 3.20)
|
|||||||
# 设置指定的C++编译器版本是必须的,如果不设置,或者为OFF,则指定版本不可用时,会使用上一版本。
|
# 设置指定的C++编译器版本是必须的,如果不设置,或者为OFF,则指定版本不可用时,会使用上一版本。
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
# 指定为C++20 版本
|
# 指定为C++23 版本
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 23)
|
||||||
|
|
||||||
set(PROJ_NAME "TEST_Specim_Save")
|
set(PROJ_NAME "SEMS-data-collection")
|
||||||
set(PROJ_VERSION_MAJOR 0)
|
set(PROJ_VERSION_MAJOR 0)
|
||||||
set(PROJ_VERSION_MINOR 0)
|
set(PROJ_VERSION_MINOR 0)
|
||||||
set(PROJ_VERSION_PATCH 1)
|
set(PROJ_VERSION_PATCH 4.20241011_alpha)
|
||||||
|
|
||||||
#设置项目名字为HelloWorld
|
#设置项目名字为HelloWorld
|
||||||
project(${PROJ_NAME})
|
project(${PROJ_NAME})
|
||||||
@ -22,27 +22,60 @@ include_directories(${PROJECT_SOURCE_DIR}/include)
|
|||||||
|
|
||||||
|
|
||||||
#要链接的库文件所在的路径
|
#要链接的库文件所在的路径
|
||||||
link_directories(${PROJECT_SOURCE_DIR}/lib)
|
link_directories (${PROJECT_SOURCE_DIR}/lib)
|
||||||
add_library(SpectralCameraLib "${PROJECT_SOURCE_DIR}/src/spectral_camera.cpp")
|
add_library(SpectralCameraLib "${PROJECT_SOURCE_DIR}/src/spectral_camera.cpp")
|
||||||
add_library(DisplayLib "${PROJECT_SOURCE_DIR}/src/display.cpp")
|
add_library(DisplayLib "${PROJECT_SOURCE_DIR}/src/display.cpp")
|
||||||
add_library(DataPreprocessLib "${PROJECT_SOURCE_DIR}/src/data_preprocess.cpp")
|
# add_library(DataPreprocessLib "${PROJECT_SOURCE_DIR}/src/data_preprocess.cpp")
|
||||||
add_library(VisibleLightCameraLIB "${PROJECT_SOURCE_DIR}/src/visible_light_camera.cpp")
|
# add_library(VisibleLightCameraLIB "${PROJECT_SOURCE_DIR}/src/visible_light_camera.cpp")
|
||||||
|
add_library(UtilsLIB "${PROJECT_SOURCE_DIR}/src/utils.cpp")
|
||||||
|
|
||||||
link_directories(${PROJECT_SOURCE_DIR}/../CompliteEnv/Python37)
|
# link_directories (${PROJECT_SOURCE_DIR}/../CompliteEnv/Python37)
|
||||||
|
|
||||||
|
|
||||||
#编译${PROJECT_SOURCE_DIR}/src/main.cpp在这个cpp文件为名为HelloWorld可执行文件
|
#编译${PROJECT_SOURCE_DIR}/src/main.cpp在这个cpp文件为名为HelloWorld可执行文件
|
||||||
add_executable(${PROJ_NAME} "${PROJECT_SOURCE_DIR}/src/main.cpp")
|
add_executable(${PROJ_NAME} "${PROJECT_SOURCE_DIR}/src/main.cpp")
|
||||||
|
|
||||||
#链接动态链接库
|
#链接动态链接库
|
||||||
target_link_libraries(${PROJ_NAME} PUBLIC yaml-cpp)
|
# target_link_libraries(${PROJ_NAME} PUBLIC yaml-cpp)
|
||||||
|
|
||||||
target_link_libraries(${PROJ_NAME} PUBLIC SpectralCameraLib)
|
target_link_libraries(${PROJ_NAME} PUBLIC SpectralCameraLib)
|
||||||
target_link_libraries(${PROJ_NAME} PUBLIC SpecSensor)
|
target_link_libraries(${PROJ_NAME} PUBLIC SpecSensor)
|
||||||
target_link_libraries(${PROJ_NAME} PUBLIC VisibleLightCameraLIB)
|
# target_link_libraries(${PROJ_NAME} PUBLIC VisibleLightCameraLIB)
|
||||||
|
|
||||||
|
|
||||||
target_link_libraries(${PROJ_NAME} PUBLIC DisplayLib)
|
target_link_libraries(${PROJ_NAME} PUBLIC DisplayLib)
|
||||||
|
|
||||||
target_link_libraries(${PROJ_NAME} PUBLIC opencv_core490 opencv_highgui490 opencv_imgproc490 opencv_photo490 opencv_imgcodecs490 opencv_video490 opencv_videoio490)
|
target_link_libraries(${PROJ_NAME} PUBLIC opencv_core490 opencv_highgui490 opencv_imgproc490)
|
||||||
target_link_libraries(${PROJ_NAME} PUBLIC DataPreprocessLib)
|
# target_link_libraries(${PROJ_NAME} PUBLIC DataPreprocessLib)
|
||||||
|
target_link_libraries(${PROJ_NAME} PUBLIC UtilsLIB)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# 设置RPATH(运行时库搜索路径)(仅linux下可用)
|
||||||
|
# set_target_properties(${PROJ_NAME} PROPERTIES
|
||||||
|
# INSTALL_RPATH "$ORIGIN/../lib"
|
||||||
|
# )
|
||||||
|
|
||||||
|
# set(CMAKE_INSTALL_RPATH "$origin/../lib")
|
||||||
|
|
||||||
|
# 安装规则
|
||||||
|
install(TARGETS ${PROJECT_NAME} DESTINATION .)
|
||||||
|
# install(DIRECTORY lib/* DESTINATION .)
|
||||||
|
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib/
|
||||||
|
DESTINATION .
|
||||||
|
USE_SOURCE_PERMISSIONS
|
||||||
|
FILES_MATCHING PATTERN "*")
|
||||||
|
|
||||||
|
# 包括 CPack 打包配置
|
||||||
|
# include(InstallRequiredSystemLibraries)
|
||||||
|
|
||||||
|
|
||||||
|
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
|
||||||
|
set(CPACK_PACKAGE_VERSION_MAJOR "${PROJ_VERSION_MAJOR}")
|
||||||
|
set(CPACK_PACKAGE_VERSION_MINOR "${PROJ_VERSION_MINOR}")
|
||||||
|
set(CPACK_PACKAGE_VERSION_PATCH "${PROJ_VERSION_PATCH}")
|
||||||
|
set(CPACK_GENERATOR "ZIP")
|
||||||
|
include(CPack)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
27
README.md
27
README.md
@ -3,20 +3,21 @@
|
|||||||
注意检查上层目录是否含有CompliteEnv文件夹, 以及其中依赖的编译环境
|
注意检查上层目录是否含有CompliteEnv文件夹, 以及其中依赖的编译环境
|
||||||
|
|
||||||
# 功能
|
# 功能
|
||||||
实现了测试光谱相机缓存机制的代码,确定了Specim FX10e相机默认的缓冲区是500帧图片
|
- 使用`/configs/data_collection_configs.yaml`文件中的参数,配置光谱相机,并持续采集数据保存到指定文件夹
|
||||||
光谱数据调取路径是,我们自己写的程序->官方驱动->通过网线从相机获取
|
|
||||||
- 当程序读取速度大于拍摄速度时,程序会等拍摄完一帧再返回。
|
|
||||||
- 当程序读取速度小于拍摄速度时,驱动会缓存没有及时调取的图像,然后按先进先出的原则返回最旧的一帧图像。当缓存大于500帧时,驱动会清除所有缓存,然后重新进行缓存
|
|
||||||
|
|
||||||
因此,如果想每时每刻都获取最新的一帧图像,只需要将缓冲区设置为2,(经过测试,设置为1会卡死,应该是不能同时操作同一个内存地址)
|
|
||||||
|
|
||||||
|
|
||||||
# 命令手册
|
# 命令手册
|
||||||
|
|
||||||
- run rb : ReBuild 从头编译的命令, 适用于从来没编译过,或修改CMakeLists文件后重新编译。会先删除build文件夹,再重新编译
|
- ./run.ps1 : 执行build文件夹下的所有exe可执行程序
|
||||||
- run rb e : ReBuild Execute 从头编译并执行
|
- ./run.ps1 b : ReBuild 从头编译的命令, 适用于从来没编译过,或修改CMakeLists文件后重新编译。会先删除build文件夹,再重新编译
|
||||||
- run.bat b : Build 编译,适用于已生成过Makefile且CMakeLists.txt没有变化,仅仅需要重新编译生成exe文件
|
- ./run.ps1 p : Pack 打包项目,需先用`./run.ps1 b`编译,然后修改CMakeLists文件中的版本号
|
||||||
- run.bat b e : Build Execute 从头编译并执行
|
|
||||||
- run.bat e : Execute 运行可执行文件
|
# 使用方法
|
||||||
- run.bat c : Clear 清理Build文件夹
|
1. 在本地开发时,使用`./run.ps1 b`进行编译并查看效果
|
||||||
- run.bat p : Pack 打包项目
|
2. 开发过程中使用git进行版本管理,可同步代码到服务器`git@10.8.8.8:222/zhanpeng/SEMS-data-collection.git`
|
||||||
|
3. 开发完毕使用`./run.ps1 p`打包为zip,
|
||||||
|
4. release上述文件到gitea
|
||||||
|
5. 在部署设备上下载最新的发布版本
|
||||||
|
获取最新版本
|
||||||
|
http://10.8.8.8:3000/api/v1/repos/zhanpeng/SEMS-data-collection/releases/latest?token=e9aaae4b5f7756d0a2977764dbcbdfeb68bb2e13
|
||||||
|
https://gitea.zhanpeng.life/api/v1/repos/zhanpeng/SEMS-data-collection/releases/latest?token=e9aaae4b5f7756d0a2977764dbcbdfeb68bb2e13
|
@ -1,4 +1,20 @@
|
|||||||
#ifndef _SPECTRAL_CAMERA_H
|
#ifndef _UYILS_H
|
||||||
#define _SPECTRAL_CAMERA_H
|
#define _UYILS_H
|
||||||
|
|
||||||
|
struct Configs
|
||||||
|
{
|
||||||
|
bool isEmpty = false;
|
||||||
|
int SPECTRUM_deviceTypeIndex;
|
||||||
|
double SPECTRUM_FrameRate;
|
||||||
|
double SPECTRUM_ExposureTime;
|
||||||
|
int SPECTRUM_BinningSpatial;
|
||||||
|
int SPECTRUM_BinningSpectral;
|
||||||
|
bool SPECTRUM_BinningAverage;
|
||||||
|
long long SPECTRUM_RingBufferSize;
|
||||||
|
std::string RAWDATA_Folder;
|
||||||
|
unsigned long long RAWDATA_MaxSize;
|
||||||
|
};
|
||||||
|
|
||||||
|
Configs getConfigFromEnvVar();
|
||||||
|
bool AddExePathtoPATH();
|
||||||
#endif
|
#endif
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
lib/libgcc_s_seh-1.dll
Normal file
BIN
lib/libgcc_s_seh-1.dll
Normal file
Binary file not shown.
BIN
lib/libstdc++-6.dll
Normal file
BIN
lib/libstdc++-6.dll
Normal file
Binary file not shown.
Binary file not shown.
100
run.bat
100
run.bat
@ -1,100 +0,0 @@
|
|||||||
@echo off
|
|
||||||
|
|
||||||
@REM @REM 检查环境变量
|
|
||||||
call:check_path
|
|
||||||
|
|
||||||
@REM 判断第一个参数是否为rb
|
|
||||||
if "%1"=="rb" (
|
|
||||||
|
|
||||||
@REM 判断是否存在build文件夹,若存在就删除
|
|
||||||
call:remove_build_dir
|
|
||||||
|
|
||||||
@REM 编译生成Makefile
|
|
||||||
cmake -B build -G "MinGW Makefiles"
|
|
||||||
@REM 编译生成可执行程序
|
|
||||||
cmake --build build
|
|
||||||
|
|
||||||
@REM 判断第二个参数是否为e,如果有代表要执行编译好的可执行程序
|
|
||||||
if "%2"=="e" (
|
|
||||||
call:run_build_exe
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
@REM run.bat b : Build 编译,适用于已生成过Makefile且CMakeLists.txt没有变化,仅仅需要重新编译生成exe文件
|
|
||||||
@REM run.bat b e : Build Execute 从头编译并执行
|
|
||||||
|
|
||||||
@REM 判断第一个参数是否为rb
|
|
||||||
if "%1"=="b" (
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@REM 编译生成可执行程序
|
|
||||||
cmake --build build
|
|
||||||
|
|
||||||
@REM 判断第二个参数是否为e,如果有代表要执行编译好的可执行程序
|
|
||||||
if "%2"=="e" (
|
|
||||||
call:run_build_exe
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
@REM run.bat e : Execute 运行可执行文件
|
|
||||||
if "%1"=="e" (
|
|
||||||
|
|
||||||
call:run_build_exe
|
|
||||||
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@REM run.bat c : Clear 清理Build文件夹
|
|
||||||
if "%1"=="c" (
|
|
||||||
call:remove_build_dir
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@REM run.bat e : 打包
|
|
||||||
if "%1"=="p" (
|
|
||||||
@REM 判断环境变量中是否存在编译所需要的文件夹,如果没有,就添加到环境变量
|
|
||||||
|
|
||||||
@REM 编译生成Makefile
|
|
||||||
cmake -B build -G "MinGW Makefiles"
|
|
||||||
@REM 编译生成可执行程序
|
|
||||||
cmake --build build
|
|
||||||
@REM 打包为安装包
|
|
||||||
cmake --build build --target package
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@REM 在执行完过程后加上goto :eof跳到文件尾, 避免执行到文件结束才返回
|
|
||||||
goto :eof
|
|
||||||
|
|
||||||
|
|
||||||
:check_path
|
|
||||||
@REM 判断环境变量中是否存在编译所需要的文件夹,如果没有,就添加到环境变量
|
|
||||||
set Nowdir=%cd%
|
|
||||||
cd ../CompliteEnv
|
|
||||||
call set_temp_env.bat
|
|
||||||
cd %Nowdir%
|
|
||||||
set PATH=C:\Program Files\Common Files\Pleora\eBUS SDK;%cd%\lib;%PATH%
|
|
||||||
echo PATH is seted to %PATH%
|
|
||||||
goto:eof
|
|
||||||
|
|
||||||
|
|
||||||
:run_build_exe
|
|
||||||
echo Starting to run EXE files in build folder...
|
|
||||||
@REM 遍历build下的exe文件,并一个一个的执行(其实编译后只有一个可执行文件)
|
|
||||||
for /f %%i in ('dir /b build\*.exe') do .\build\%%i
|
|
||||||
echo Stoped runing EXE files...
|
|
||||||
goto:eof
|
|
||||||
|
|
||||||
:remove_build_dir
|
|
||||||
if exist build (
|
|
||||||
rd /s /Q build
|
|
||||||
echo "The build folder has been removed."
|
|
||||||
) else (
|
|
||||||
echo "The build folder does not exist."
|
|
||||||
)
|
|
||||||
|
|
||||||
goto:eof
|
|
70
run.ps1
Normal file
70
run.ps1
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
Param($cmd)
|
||||||
|
|
||||||
|
#在 PowerShell 中将字符集修改为 UTF-8:
|
||||||
|
$OutputEncoding = [System.Console]::OutputEncoding = [System.Console]::InputEncoding = [System.Text.Encoding]::UTF8
|
||||||
|
|
||||||
|
|
||||||
|
$Env:PATH = "C:\Program Files\Common Files\Pleora\eBUS SDK;" #开发光谱相机所必需的路径
|
||||||
|
$Env:PATH += "C:\Program Files\Git\cmd;C:\Windows\System32\OpenSSH;" #开发所需的git/ssh命令的路径
|
||||||
|
$Env:PATH += (Resolve-Path ../CompliteEnv/mingw64/bin).path + ";" #g++所在路径
|
||||||
|
$Env:PATH += (Resolve-Path ../CompliteEnv/CMake/bin).path + ";" #cmake所在路径
|
||||||
|
$Env:PATH += (Resolve-Path ./lib).path + ";" #本项目所需的动态链接库所在路径
|
||||||
|
|
||||||
|
Write-Host "PATH is set to $Env:PATH"
|
||||||
|
|
||||||
|
|
||||||
|
function Remove-Build-Dir {
|
||||||
|
If (Test-Path "build") {
|
||||||
|
#如果当前目录下build文件夹存在
|
||||||
|
Remove-Item -Path "build" -Recurse #递归阐述build文件夹
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function ReBuild-Target {
|
||||||
|
# 编译生成Makefile
|
||||||
|
cmake -B build -G "MinGW Makefiles"
|
||||||
|
# 编译生成可执行程序
|
||||||
|
cmake --build build
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function Run-All-Exe {
|
||||||
|
$exeFiles = Get-ChildItem -Path "build" -Filter *.exe
|
||||||
|
|
||||||
|
Write-Host "Exe Files: $exeFiles"
|
||||||
|
ForEach ($exeFile in $exeFiles) {
|
||||||
|
Write-Host "Processing file: $($exeFile.FullName)"
|
||||||
|
Start-Process -Wait -FilePath $exeFile.FullName -NoNewWindow -PassThru
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
If ($cmd -eq "b") {
|
||||||
|
Write-Host "Rebuilding all targets..."
|
||||||
|
|
||||||
|
Remove-Build-Dir
|
||||||
|
|
||||||
|
ReBuild-Target
|
||||||
|
|
||||||
|
Run-All-Exe
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
If ($cmd -eq "p") {
|
||||||
|
Write-Host "Packing all targets..."
|
||||||
|
cmake --build build --target package
|
||||||
|
}
|
||||||
|
|
||||||
|
If ([String]::IsNullOrEmpty($cmd)) {
|
||||||
|
#如果没有任何参数就运行所有exe
|
||||||
|
Run-All-Exe
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -10,50 +10,55 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
// #include <vector>
|
// #include <vector>
|
||||||
|
int64_t last_t = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
|
||||||
|
|
||||||
|
void display_spectral_image(unsigned char *raw_data, long long width, long long height, std::string window_name)
|
||||||
void display_spectral_image(unsigned char *raw_data, long long width, long long height,std::string window_name)
|
|
||||||
{
|
{
|
||||||
cv::Mat img = cv::Mat(height, width,CV_16U, raw_data);
|
cv::Mat img = cv::Mat(height, width, CV_16U, raw_data);
|
||||||
|
|
||||||
img.convertTo(img, CV_16F);
|
img.convertTo(img, CV_16F);
|
||||||
img = img / 4095 * 255;
|
img = img / 4095 * 255;
|
||||||
img.convertTo(img, CV_8U);
|
img.convertTo(img, CV_8U);
|
||||||
cv::applyColorMap(img, img, cv::COLORMAP_TURBO);
|
cv::applyColorMap(img, img, cv::COLORMAP_TURBO);
|
||||||
cv::namedWindow("Spectral Image", 0);
|
cv::namedWindow("Spectral Image", 0);
|
||||||
cv::resizeWindow("Spectral Image", width , height );
|
cv::resizeWindow("Spectral Image", width, height);
|
||||||
|
|
||||||
|
|
||||||
uint16_t *p = (uint16_t *)raw_data;
|
uint16_t *p = (uint16_t *)raw_data;
|
||||||
|
|
||||||
cv::Vec3b white= img.at<cv::Vec3b>(0, 0);
|
cv::Vec3b white = img.at<cv::Vec3b>(0, 0);
|
||||||
white[0]=0;
|
white[0] = 0;
|
||||||
white[1]=0;
|
white[1] = 0;
|
||||||
white[2]=0;
|
white[2] = 0;
|
||||||
|
|
||||||
int over_exposure_num=0;
|
int over_exposure_num = 0;
|
||||||
int max_intensity=0;
|
int max_intensity = 0;
|
||||||
for(int i=0;i<width;i++){
|
for (int i = 0; i < width; i++)
|
||||||
for(int j=0;j<height;j++){
|
{
|
||||||
if(*(p+(j*width+i))==4095){
|
for (int j = 0; j < height; j++)
|
||||||
img.at<cv::Vec3b>(j,i)=white;
|
{
|
||||||
|
if (*(p + (j * width + i)) == 4095)
|
||||||
|
{
|
||||||
|
img.at<cv::Vec3b>(j, i) = white;
|
||||||
over_exposure_num++;
|
over_exposure_num++;
|
||||||
}
|
}
|
||||||
if (*(p+(j*width+i))>max_intensity){
|
if (*(p + (j * width + i)) > max_intensity)
|
||||||
max_intensity=*(p+(j*width+i));
|
{
|
||||||
|
max_intensity = *(p + (j * width + i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::string add_text=std::string("Over Exposure:")+std::to_string(over_exposure_num)+std::string(" Max Intensity:")+std::to_string(max_intensity);
|
|
||||||
cv::putText(img,add_text.c_str(),cv::Point(30,400),cv::FONT_HERSHEY_SIMPLEX,1,CV_RGB(255,255,255),1,8);
|
int64_t t = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
|
||||||
|
|
||||||
|
std::string add_text = std::string("Over Exposure:") + std::to_string(over_exposure_num) + std::string(" Max Intensity:") + std::to_string(max_intensity) + " FPS:" + std::to_string(1000 / (double)(t - last_t));
|
||||||
|
last_t = t;
|
||||||
|
cv::putText(img, add_text.c_str(), cv::Point(10, 20), cv::FONT_HERSHEY_SIMPLEX, 0.5, CV_RGB(255, 255, 255), 1, 2);
|
||||||
cv::imshow(window_name, img);
|
cv::imshow(window_name, img);
|
||||||
cv::waitKey(1);
|
cv::waitKey(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void display_img(cv::Mat img, std::string window_name)
|
void display_img(cv::Mat img, std::string window_name)
|
||||||
{
|
{
|
||||||
cv::imshow(window_name, img);
|
cv::imshow(window_name, img);
|
||||||
cv::waitKey(1); // Wait for a keystroke in the window
|
cv::waitKey(1); // Wait for a keystroke in the window
|
||||||
}
|
}
|
||||||
|
|
||||||
|
127
src/main.cpp
127
src/main.cpp
@ -1,28 +1,31 @@
|
|||||||
#include <windows.h>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <cstdio>
|
#include <format>
|
||||||
|
#include <utils.h>
|
||||||
|
|
||||||
|
// #include <windows.h>
|
||||||
|
|
||||||
|
// #include <cstdio>
|
||||||
#include <conio.h>
|
#include <conio.h>
|
||||||
#include "spectral_camera.h"
|
#include "spectral_camera.h"
|
||||||
#include "yaml-cpp/yaml.h"
|
// #include "yaml-cpp/yaml.h"
|
||||||
#include "display.h"
|
#include "display.h"
|
||||||
#include "data_preprocess.h"
|
// #include "data_preprocess.h"
|
||||||
|
|
||||||
#include <chrono>
|
// #include <chrono>
|
||||||
#include <vector>
|
// #include <vector>
|
||||||
#include <opencv2/core.hpp>
|
// #include <opencv2/core.hpp>
|
||||||
#include <opencv2/highgui.hpp>
|
// #include <opencv2/highgui.hpp>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
#include "visible_light_camera.h"
|
// #include "visible_light_camera.h"
|
||||||
|
// #include <windows.h>
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|
||||||
|
extern unsigned long long int last_file_time = 0;
|
||||||
|
extern unsigned long long int frame_num = 0;
|
||||||
|
|
||||||
extern unsigned long long int last_file_time=0;
|
int check_update_file_handle(std::string save_dir, std::ofstream &h_raw_spectal_file, std::ofstream &h_header_file, unsigned long long max_file_size)
|
||||||
extern unsigned long long int frame_num=0;
|
|
||||||
|
|
||||||
int check_update_file_handle(std::string save_dir, std::ofstream &h_raw_spectal_file, std::ofstream &h_header_file, unsigned long long max_file_size, std::ofstream &h_visible_light_file, bool enable_visible_light_camera)
|
|
||||||
{
|
{
|
||||||
if (h_raw_spectal_file.is_open())
|
if (h_raw_spectal_file.is_open())
|
||||||
{
|
{
|
||||||
@ -35,95 +38,72 @@ int check_update_file_handle(std::string save_dir, std::ofstream &h_raw_spectal_
|
|||||||
h_raw_spectal_file.open((raw_data_file_name + std::string(".bin").data()), std::ios::out | std::ios::binary | std::ios::app);
|
h_raw_spectal_file.open((raw_data_file_name + std::string(".bin").data()), std::ios::out | std::ios::binary | std::ios::app);
|
||||||
h_header_file.open((raw_data_file_name + std::string(".csv").data()), std::ios::out | std::ios::app);
|
h_header_file.open((raw_data_file_name + std::string(".csv").data()), std::ios::out | std::ios::app);
|
||||||
|
|
||||||
if (enable_visible_light_camera)
|
unsigned long long int now = (unsigned long long int)now_t;
|
||||||
|
if (last_file_time != 0)
|
||||||
{
|
{
|
||||||
if (h_visible_light_file.is_open())
|
float t = (float)(now - last_file_time) / 1000;
|
||||||
{
|
|
||||||
h_visible_light_file.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
h_visible_light_file.open((raw_data_file_name + std::string(".img").data()), std::ios::out | std::ios::binary | std::ios::app);
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned long long int now=(unsigned long long int)now_t;
|
|
||||||
if (last_file_time!=0){
|
|
||||||
float t=(float)(now-last_file_time)/1000;
|
|
||||||
// std::cout<<now<<last_file_time<<t<<frame_num<<std::endl;
|
// std::cout<<now<<last_file_time<<t<<frame_num<<std::endl;
|
||||||
float fps= frame_num/t;
|
float fps = frame_num / t;
|
||||||
printf("FPS %.2f\n",fps);
|
printf("文件%lld的帧率为 %.2f\n", last_file_time, fps);
|
||||||
frame_num=0;
|
frame_num = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
last_file_time=now;
|
last_file_time = now;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
// std::cout << "Hello" << std::endl;
|
std::cout << "Hello World" << std::endl;
|
||||||
YAML::Node configs = YAML::LoadFile("./configs/configs.yaml");
|
Configs configs = getConfigFromEnvVar();
|
||||||
|
|
||||||
|
if (configs.isEmpty)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!AddExePathtoPATH())
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
SpectralCamera *spec_camera = new SpectralCamera();
|
SpectralCamera *spec_camera = new SpectralCamera();
|
||||||
spec_camera->listDevices();
|
spec_camera->listDevices();
|
||||||
|
|
||||||
spec_camera->init(configs["spectral_camera_configs"]["deviceTypeIndex"].as<int>(),
|
spec_camera->init(configs.SPECTRUM_deviceTypeIndex,
|
||||||
configs["spectral_camera_configs"]["FrameRate"].as<double>(),
|
configs.SPECTRUM_FrameRate,
|
||||||
configs["spectral_camera_configs"]["ExposureTime"].as<double>(),
|
configs.SPECTRUM_ExposureTime,
|
||||||
configs["spectral_camera_configs"]["BinningSpatial"].as<int>(),
|
configs.SPECTRUM_BinningSpatial,
|
||||||
configs["spectral_camera_configs"]["BinningSpectral"].as<int>(),
|
configs.SPECTRUM_BinningSpectral,
|
||||||
configs["spectral_camera_configs"]["BinningAverage"].as<bool>(),
|
configs.SPECTRUM_BinningAverage,
|
||||||
configs["spectral_camera_configs"]["RingBufferSize"].as<long long>());
|
configs.SPECTRUM_RingBufferSize);
|
||||||
|
|
||||||
bool enable_visible_light_camera = configs["visible_light_camera_configs"]["enable"].as<bool>();
|
std::ofstream h_raw_spectal_file, h_header_file;
|
||||||
std::string save_dir = configs["save_configs"]["save_dir"].as<std::string>();
|
check_update_file_handle(configs.RAWDATA_Folder, h_raw_spectal_file, h_header_file, configs.RAWDATA_MaxSize);
|
||||||
unsigned long long max_file_size = configs["save_configs"]["max_file_size"].as<unsigned long long>();
|
|
||||||
|
|
||||||
VisibleLightCamera *visible_light_camera = NULL;
|
|
||||||
if (enable_visible_light_camera)
|
|
||||||
{
|
|
||||||
visible_light_camera = new VisibleLightCamera();
|
|
||||||
visible_light_camera->init(configs["visible_light_camera_configs"]["video_capture_index"].as<int>());
|
|
||||||
}
|
|
||||||
|
|
||||||
std::ofstream h_raw_spectal_file,h_header_file, h_visible_light_file;
|
|
||||||
check_update_file_handle(save_dir, h_raw_spectal_file, h_header_file, max_file_size, h_visible_light_file, enable_visible_light_camera);
|
|
||||||
bool flag_run = true;
|
bool flag_run = true;
|
||||||
while (flag_run)
|
while (flag_run)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
spec_camera->read();
|
spec_camera->read();
|
||||||
spec_camera->save(h_raw_spectal_file, h_header_file);
|
spec_camera->save(h_raw_spectal_file, h_header_file);
|
||||||
frame_num++;
|
frame_num++;
|
||||||
|
|
||||||
|
display_spectral_image(spec_camera->pFrameBuffer, spec_camera->nWidth, spec_camera->nHeight, "Spectral Image");
|
||||||
display_spectral_image(spec_camera->pFrameBuffer, spec_camera->nWidth, spec_camera->nHeight,"Spectral Image");
|
|
||||||
|
|
||||||
|
|
||||||
// 如果启动了可见光相机
|
|
||||||
if (enable_visible_light_camera)
|
|
||||||
{
|
|
||||||
visible_light_camera->read();
|
|
||||||
visible_light_camera->save(h_visible_light_file, h_header_file);
|
|
||||||
display_img(visible_light_camera->image_frame, "Camera");
|
|
||||||
}
|
|
||||||
|
|
||||||
h_header_file << std::endl;
|
h_header_file << std::endl;
|
||||||
|
|
||||||
|
if (h_raw_spectal_file.tellp() > configs.RAWDATA_MaxSize)
|
||||||
if (h_raw_spectal_file.tellp()>max_file_size){
|
{
|
||||||
check_update_file_handle(save_dir, h_raw_spectal_file, h_header_file, max_file_size, h_visible_light_file, enable_visible_light_camera);
|
check_update_file_handle(configs.RAWDATA_Folder, h_raw_spectal_file, h_header_file, configs.RAWDATA_MaxSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_kbhit())
|
if (_kbhit())
|
||||||
{
|
{
|
||||||
char key = _getch();
|
char key = _getch();
|
||||||
if ( (key == 27)|(key == 'q'))
|
if ((key == 27) | (key == 'q'))
|
||||||
{
|
{
|
||||||
flag_run=false;
|
flag_run = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -138,8 +118,5 @@ check_update_file_handle(save_dir, h_raw_spectal_file, h_header_file, max_file_s
|
|||||||
{
|
{
|
||||||
h_header_file.close();
|
h_header_file.close();
|
||||||
}
|
}
|
||||||
if (h_visible_light_file.is_open())
|
return 0;
|
||||||
{
|
|
||||||
h_visible_light_file.close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,20 @@ Error:
|
|||||||
|
|
||||||
int SpectralCamera::init(int deviceTypeIndex, double FrameRate, double ExposureTime, int BinningSpatial, int BinningSpectral, bool BinningAverage, long long RingBufferSize)
|
int SpectralCamera::init(int deviceTypeIndex, double FrameRate, double ExposureTime, int BinningSpatial, int BinningSpectral, bool BinningAverage, long long RingBufferSize)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// char szPath[512] = {0};
|
||||||
|
// GetModuleFileName(NULL, szPath, sizeof(szPath) - 1);
|
||||||
|
// std::string exe_dir(szPath);
|
||||||
|
|
||||||
|
// // 这里返回的是exe文件的完整路径,包括文件名,所以下面执行两边,就是先取出exe文件名,再去除exe所在文件夹
|
||||||
|
// // 即实现找到exe所在文件夹的上层文件夹的绝对路径
|
||||||
|
// size_t lastSlashIndex = exe_dir.find_last_of('\\');
|
||||||
|
// std::string autoclick_path = exe_dir.substr(0, lastSlashIndex + 1) + "autoClick.exe"; //+1是为了也包含最后一个反斜杠
|
||||||
|
// wchar_t *wstr = new wchar_t[autoclick_path.length() + 1];
|
||||||
|
// mbstowcs(wstr, autoclick_path.c_str(), autoclick_path.length() + 1);
|
||||||
|
|
||||||
|
// wprintf(L"Started autoClick.exe in %ls\n", wstr);
|
||||||
|
|
||||||
HINSTANCE state = ShellExecuteW(NULL, L"open", L"autoClick.exe", NULL, NULL, SW_SHOW);
|
HINSTANCE state = ShellExecuteW(NULL, L"open", L"autoClick.exe", NULL, NULL, SW_SHOW);
|
||||||
// autoClick.exe以及依赖的msvcp140d.dll,ucrtbased.dll,vcruntime140d.dll在lib文件夹中
|
// autoClick.exe以及依赖的msvcp140d.dll,ucrtbased.dll,vcruntime140d.dll在lib文件夹中
|
||||||
wprintf(L"Started autoClick.exe. The state code is %d\n", state);
|
wprintf(L"Started autoClick.exe. The state code is %d\n", state);
|
||||||
@ -66,7 +80,7 @@ int SpectralCamera::init(int deviceTypeIndex, double FrameRate, double ExposureT
|
|||||||
this->ExposureTime,
|
this->ExposureTime,
|
||||||
this->BinningSpatial,
|
this->BinningSpatial,
|
||||||
this->BinningSpectral,
|
this->BinningSpectral,
|
||||||
this->BinningAverage,this->RingBufferSize);
|
this->BinningAverage, this->RingBufferSize);
|
||||||
wprintf(L"******************************************************\n");
|
wprintf(L"******************************************************\n");
|
||||||
|
|
||||||
SI_CHK(SI_Open(this->deviceTypeIndex, &this->deviceHandle));
|
SI_CHK(SI_Open(this->deviceTypeIndex, &this->deviceHandle));
|
||||||
@ -123,7 +137,6 @@ Error:
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int SpectralCamera::stop(void)
|
int SpectralCamera::stop(void)
|
||||||
{
|
{
|
||||||
SI_CHK(SI_Command(this->deviceHandle, L"Acquisition.Stop"));
|
SI_CHK(SI_Command(this->deviceHandle, L"Acquisition.Stop"));
|
||||||
@ -136,7 +149,6 @@ Error:
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int SpectralCamera::start(void)
|
int SpectralCamera::start(void)
|
||||||
{
|
{
|
||||||
SI_CHK(SI_Command(this->deviceHandle, L"Acquisition.Start"));
|
SI_CHK(SI_Command(this->deviceHandle, L"Acquisition.Start"));
|
||||||
@ -149,7 +161,7 @@ Error:
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SpectralCamera::reset_FrameRate( double Value)
|
int SpectralCamera::reset_FrameRate(double Value)
|
||||||
{
|
{
|
||||||
SI_CHK(SI_SetFloat(this->deviceHandle, L"Camera.FrameRate", Value));
|
SI_CHK(SI_SetFloat(this->deviceHandle, L"Camera.FrameRate", Value));
|
||||||
return 0;
|
return 0;
|
||||||
@ -161,7 +173,7 @@ Error:
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SpectralCamera::reset_ExposureTime( double Value)
|
int SpectralCamera::reset_ExposureTime(double Value)
|
||||||
{
|
{
|
||||||
SI_CHK(SI_SetFloat(this->deviceHandle, L"Camera.ExposureTime", Value));
|
SI_CHK(SI_SetFloat(this->deviceHandle, L"Camera.ExposureTime", Value));
|
||||||
return 0;
|
return 0;
|
||||||
@ -182,7 +194,6 @@ void SpectralCamera::save(std::ofstream &h_raw_spectral_file, std::ofstream &h_h
|
|||||||
h_header_file << now_t << "," << raw_spectral_file_size << "," << this->nFrameSize;
|
h_header_file << now_t << "," << raw_spectral_file_size << "," << this->nFrameSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int SpectralCamera::read(void)
|
int SpectralCamera::read(void)
|
||||||
{
|
{
|
||||||
SI_CHK(SI_Wait(this->deviceHandle, this->pFrameBuffer, &this->nFrameSize, &this->nFrameNumber, 10000));
|
SI_CHK(SI_Wait(this->deviceHandle, this->pFrameBuffer, &this->nFrameSize, &this->nFrameNumber, 10000));
|
||||||
|
189
src/utils.cpp
189
src/utils.cpp
@ -1,3 +1,188 @@
|
|||||||
#include <chrono>
|
// #include <chrono>
|
||||||
|
|
||||||
const auto t = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
|
// const auto t = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
#include <utils.h>
|
||||||
|
|
||||||
|
bool AddExePathtoPATH()
|
||||||
|
{
|
||||||
|
/*将当前可执行文件所在的路径添加到环境变量中*/
|
||||||
|
wchar_t szPath[512] = {0};
|
||||||
|
if (GetModuleFileNameW(NULL, szPath, sizeof(szPath) - 1) == 0)
|
||||||
|
{
|
||||||
|
std::cerr << "获取exe文件路径失败." << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::wstring exe_dir(szPath);
|
||||||
|
size_t lastSlashIndex = exe_dir.find_last_of('\\');
|
||||||
|
if (lastSlashIndex == std::wstring::npos)
|
||||||
|
{
|
||||||
|
std::cerr << "获取exe文件路径中的反斜杠失败." << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
exe_dir = exe_dir.substr(0, lastSlashIndex);
|
||||||
|
|
||||||
|
wchar_t currentPath[32767];
|
||||||
|
if (GetEnvironmentVariableW(L"PATH", currentPath, 32767) == 0)
|
||||||
|
{
|
||||||
|
std::cerr << "获取当前环境变量PATH失败" << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::wstring newPath = exe_dir + L";" + std::wstring(currentPath);
|
||||||
|
if (SetEnvironmentVariableW(L"PATH", newPath.c_str()) == 0)
|
||||||
|
{
|
||||||
|
std::cerr << "添加当前路径到环境变量PATH失败" << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Configs getConfigFromEnvVar()
|
||||||
|
|
||||||
|
{
|
||||||
|
/*检查*/
|
||||||
|
|
||||||
|
Configs configs;
|
||||||
|
|
||||||
|
std::cout << "***********正在检查此程序所需的环境变量************" << std::endl;
|
||||||
|
|
||||||
|
// char buffer[1024];
|
||||||
|
// DWORD ret = GetEnvironmentVariableW(L"TEST", buffer, 1024);
|
||||||
|
wchar_t buffer[32767];
|
||||||
|
DWORD result;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
result = GetEnvironmentVariableW(L"SPECTRUM_deviceTypeIndex", buffer, 32767);
|
||||||
|
if (result > 0 && result < 32767)
|
||||||
|
{
|
||||||
|
configs.SPECTRUM_deviceTypeIndex = std::stoi(std::wstring(buffer));
|
||||||
|
std::cout << "光谱相机设备型号索引(SPECTRUM_deviceTypeIndex)为\t" << configs.SPECTRUM_deviceTypeIndex << std::endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cout << "未获取到光谱相机设备型号索引(SPECTRUM_deviceTypeIndex)" << std::endl;
|
||||||
|
configs.isEmpty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = GetEnvironmentVariableW(L"SPECTRUM_FrameRate", buffer, 32767);
|
||||||
|
if (result > 0 && result < 32767)
|
||||||
|
{
|
||||||
|
configs.SPECTRUM_FrameRate = std::stod(std::wstring(buffer));
|
||||||
|
std::cout << "光谱相机帧率(SPECTRUM_FrameRate)为\t" << configs.SPECTRUM_FrameRate << std::endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cout << "未获取到光谱相机帧率(SPECTRUM_FrameRate)" << std::endl;
|
||||||
|
configs.isEmpty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = GetEnvironmentVariableW(L"SPECTRUM_ExposureTime", buffer, 32767);
|
||||||
|
if (result > 0 && result < 32767)
|
||||||
|
{
|
||||||
|
configs.SPECTRUM_ExposureTime = std::stod(std::wstring(buffer));
|
||||||
|
std::cout << "光谱相机曝光时间(SPECTRUM_ExposureTime)为\t" << configs.SPECTRUM_ExposureTime << std::endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cout << "未获取到光谱相机曝光时间(SPECTRUM_ExposureTime)" << std::endl;
|
||||||
|
configs.isEmpty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = GetEnvironmentVariableW(L"SPECTRUM_BinningSpatial", buffer, 32767);
|
||||||
|
if (result > 0 && result < 32767)
|
||||||
|
{
|
||||||
|
configs.SPECTRUM_BinningSpatial = std::stoi(std::wstring(buffer));
|
||||||
|
std::cout << "光谱相机空间像素组合(SPECTRUM_BinningSpatial)为\t" << configs.SPECTRUM_BinningSpatial << std::endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cout << "未获取到光谱相机空间像素组合(SPECTRUM_BinningSpatial)" << std::endl;
|
||||||
|
configs.isEmpty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = GetEnvironmentVariableW(L"SPECTRUM_BinningSpectral", buffer, 32767);
|
||||||
|
if (result > 0 && result < 32767)
|
||||||
|
{
|
||||||
|
configs.SPECTRUM_BinningSpectral = std::stoi(std::wstring(buffer));
|
||||||
|
std::cout << "光谱相机光谱像素组合(SPECTRUM_BinningSpectral)为\t" << configs.SPECTRUM_BinningSpectral << std::endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cout << "未获取到光谱相机光谱像素组合(SPECTRUM_BinningSpectral)" << std::endl;
|
||||||
|
configs.isEmpty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = GetEnvironmentVariableW(L"SPECTRUM_BinningAverage", buffer, 32767);
|
||||||
|
if (result > 0 && result < 32767)
|
||||||
|
{
|
||||||
|
|
||||||
|
int tmp = std::stoi(std::wstring(buffer));
|
||||||
|
configs.SPECTRUM_BinningAverage = tmp;
|
||||||
|
std::cout << "光谱相机是否组合平均(SPECTRUM_BinningAverage)为\t" << configs.SPECTRUM_BinningAverage << std::endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cout << "未获取到光谱相机是否组合平均(SPECTRUM_BinningAverage)" << std::endl;
|
||||||
|
configs.isEmpty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = GetEnvironmentVariableW(L"SPECTRUM_RingBufferSize", buffer, 32767);
|
||||||
|
if (result > 0 && result < 32767)
|
||||||
|
{
|
||||||
|
configs.SPECTRUM_RingBufferSize = std::stoll(std::wstring(buffer));
|
||||||
|
std::cout << "光谱相机循环缓存大小(SPECTRUM_RingBufferSize)为\t" << configs.SPECTRUM_RingBufferSize << std::endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cout << "未获取到光谱相机循环缓存大小(SPECTRUM_RingBufferSize)" << std::endl;
|
||||||
|
configs.isEmpty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = GetEnvironmentVariableW(L"RAWDATA_Folder", buffer, 32767);
|
||||||
|
if (result > 0 && result < 32767)
|
||||||
|
{
|
||||||
|
std::wstring tmp = std::wstring(buffer);
|
||||||
|
|
||||||
|
configs.RAWDATA_Folder = std::string(tmp.begin(), tmp.end());
|
||||||
|
// wstring转成string
|
||||||
|
|
||||||
|
std::cout << "原始光谱数据保存路径(RAWDATA_Folder)为\t" << configs.RAWDATA_Folder << std::endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cout << "未获取到原始数据保存路径(RAWDATA_Folder)" << std::endl;
|
||||||
|
configs.isEmpty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = GetEnvironmentVariableW(L"RAWDATA_MaxSize", buffer, 32767);
|
||||||
|
if (result > 0 && result < 32767)
|
||||||
|
{
|
||||||
|
configs.RAWDATA_MaxSize = std::stoull(std::wstring(buffer));
|
||||||
|
std::cout << "原始数据文件最大大小(RAWDATA_MaxSize)为\t" << configs.RAWDATA_MaxSize << " Byte" << std::endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cout << "未获取到原始数据文件最大大小(RAWDATA_MaxSize)" << std::endl;
|
||||||
|
configs.isEmpty = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (const std::invalid_argument &e)
|
||||||
|
{
|
||||||
|
std::cerr << "Invalid argument: " << e.what() << std::endl;
|
||||||
|
configs.isEmpty = true;
|
||||||
|
}
|
||||||
|
catch (const std::out_of_range &e)
|
||||||
|
{
|
||||||
|
std::cerr << "Out of range: " << e.what() << std::endl;
|
||||||
|
configs.isEmpty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return configs;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user