From 47002ad894884b0109c2c957aa305aab312e73fe Mon Sep 17 00:00:00 2001 From: tangchao0503 <735056338@qq.com> Date: Wed, 28 Jun 2023 11:59:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=8F=98=E5=85=89=E8=B0=B1bin2?= =?UTF-8?q?=E7=9A=84=E6=B3=A2=E9=95=BF=E8=AE=A1=E7=AE=97=E6=96=B9=E5=BC=8F?= =?UTF-8?q?=E4=B8=BA=EF=BC=9A=E9=80=9A=E8=BF=87bin1=E5=B9=B3=E5=9D=87?= =?UTF-8?q?=E7=9B=B8=E9=82=BB=E6=B3=A2=E9=95=BF=E8=8E=B7=E5=8F=96=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Header_Files/configfile.h | 2 ++ Header_Files/ximeaimager.h | 3 ++ Source_Files/configfile.cpp | 51 ++++++++++++++++++++++++++++++++ Source_Files/ximeaimager.cpp | 57 +++++++++++++++++++++++++++++++----- 4 files changed, 106 insertions(+), 7 deletions(-) diff --git a/Header_Files/configfile.h b/Header_Files/configfile.h index 09a9603..7a5216b 100644 --- a/Header_Files/configfile.h +++ b/Header_Files/configfile.h @@ -34,7 +34,9 @@ public: bool getspatialBin(int &spatialBin); bool getEffectiveWindow(int &width, int &offsetx, int &height, int &offsety); bool getEffectiveWindowRoi(int &width, int &offsetx); + bool getWindowOffsety_HeightOfSpectral(int &offsety, int &height, string spectralBinString);//spectralBinString = "bin1"或者”bin2“ bool getGainOffset(float &gain, float &offset); + bool getGainOffsetOfSpectralBin1(float &gain, float &offset); bool getSN(QString &SN); bool getBufferPolicy(int &bufferPolicy); diff --git a/Header_Files/ximeaimager.h b/Header_Files/ximeaimager.h index e1065ea..c4ca537 100644 --- a/Header_Files/ximeaimager.h +++ b/Header_Files/ximeaimager.h @@ -154,6 +154,9 @@ private: int m_iImagerState; int m_iImagerStateTemp; + int m_iOffsetyOfSpectralBin1, m_iOffsetyOfSpectralBin2; + int m_iHeightOfSpectralBin1, m_iHeightOfSpectralBin2; + QThread * m_recordTempThread; RecordXimeaTemperature * m_ximeaTemperature; diff --git a/Source_Files/configfile.cpp b/Source_Files/configfile.cpp index dcb873d..530db55 100644 --- a/Source_Files/configfile.cpp +++ b/Source_Files/configfile.cpp @@ -166,6 +166,28 @@ bool Configfile::getEffectiveWindowRoi(int &width, int &offsetx) return true; } +bool Configfile::getWindowOffsety_HeightOfSpectral(int &offsety, int &height, string spectralBinString) +{ + const Setting& root = cfg.getRoot(); + + try + { + const Setting &spectralArgument = root["effective_window"][spectralBinString]["spectral"]; + if(!(spectralArgument.lookupValue("height", height) + && spectralArgument.lookupValue("offsety", offsety))) + { + return false; + } + } + catch(const SettingNotFoundException &nfex) + { + // Ignore. + return false; + } + + return true; +} + bool Configfile::getGainOffset(float &gain, float &offset) { const Setting& root = cfg.getRoot(); @@ -206,6 +228,35 @@ bool Configfile::getGainOffset(float &gain, float &offset) return true; } +bool Configfile::getGainOffsetOfSpectralBin1(float &gain, float &offset) +{ + const Setting& root = cfg.getRoot(); + + try + { + const Setting &gainOffset = root["gainOffset"]; + int count = gainOffset.getLength(); + + string spectralBinString = "spectralBin1"; + + const Setting &gainOffsetSetting = gainOffset[spectralBinString]; + string name = gainOffsetSetting.getName(); + + if(!(gainOffsetSetting.lookupValue("gain", gain) + && gainOffsetSetting.lookupValue("offset", offset))) + { + return false; + } + } + catch(const SettingNotFoundException &nfex) + { + // Ignore. + return false; + } + + return true; +} + bool Configfile::getSN(QString &SN) { try diff --git a/Source_Files/ximeaimager.cpp b/Source_Files/ximeaimager.cpp index 6150362..6057254 100644 --- a/Source_Files/ximeaimager.cpp +++ b/Source_Files/ximeaimager.cpp @@ -12,6 +12,22 @@ XimeaImager::XimeaImager() if(!m_configfile.isConfigfileExist()) m_configfile.createConfigFile(); m_configfile.parseConfigfile(); + m_configfile.getWindowOffsety_HeightOfSpectral(m_iOffsetyOfSpectralBin1, m_iHeightOfSpectralBin1, "bin1"); + m_configfile.getWindowOffsety_HeightOfSpectral(m_iOffsetyOfSpectralBin2, m_iHeightOfSpectralBin2, "bin2"); + //检查 ximea.cfg 是否满足要求 + if(m_iOffsetyOfSpectralBin2 != m_iOffsetyOfSpectralBin1 / 2) + { + std::cout<<"ximea.cfg 错误:m_iOffsetyOfSpectralBin2 != m_iOffsetyOfSpectralBin1 / 2!"< m_iOffsetyOfSpectralBin1 + m_iHeightOfSpectralBin1) + { + printf("XimeaImager::writeHdr 出现错误:窗口中,光谱 bin1 波段数小于 bin2 的 2 倍。\n"); + break; + } + + hdrFileHandle << (geWavelengthAtBand(i*2) + geWavelengthAtBand(i*2 + 1)) / 2; + counter++; + if (i < m_iOffsetyOfSpectralBin2 + m_iHeightOfSpectralBin2 - 1) + hdrFileHandle << ", "; + else + { + printf("头文件中写入了多少个波段:%d\n", counter); + } + } + } + + hdrFileHandle << "}\n"; hdrFileHandle.close(); }