改变光谱bin2的波长计算方式为:通过bin1平均相邻波长获取;
This commit is contained in:
@ -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
|
||||
|
@ -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!"<<std::endl;
|
||||
}
|
||||
if(m_iOffsetyOfSpectralBin2 % 2 != 0)
|
||||
{
|
||||
std::cout<<"ximea.cfg 错误:m_iOffsetyOfSpectralBin2 不是 2 的倍数,ximea相机不接受!"<<std::endl;
|
||||
}
|
||||
if(m_iHeightOfSpectralBin1 < m_iHeightOfSpectralBin2 * 2)
|
||||
{
|
||||
std::cout<<"ximea.cfg 错误:bin1 波段数小于 bin2 波段数的 2 倍!"<<std::endl;
|
||||
}
|
||||
|
||||
|
||||
m_recordTempThread=new QThread();
|
||||
m_ximeaTemperature = new RecordXimeaTemperature(&m_imager);
|
||||
@ -66,7 +82,7 @@ void XimeaImager::openImger()
|
||||
}
|
||||
|
||||
float gain, offset;//用于生成头文件中的波长信息
|
||||
ret = m_configfile.getGainOffset(gain, offset);
|
||||
ret = m_configfile.getGainOffsetOfSpectralBin1(gain, offset);
|
||||
if (ret)
|
||||
{
|
||||
m_imager.setGainOffset(gain, offset);
|
||||
@ -643,16 +659,43 @@ void XimeaImager::writeHdr()
|
||||
hdrFileHandle << "wavelength units = nanometers\n";
|
||||
hdrFileHandle << "wavelength = {";
|
||||
//hdrFileHandle << std::setprecision(5);
|
||||
for (int i = getWindowStartBand(); i < getWindowEndBand(); i++)
|
||||
|
||||
if (m_imager.getSpectralBin() == 1)
|
||||
{
|
||||
hdrFileHandle << geWavelengthAtBand(i);
|
||||
if (i < getWindowEndBand() - 1)
|
||||
hdrFileHandle << ", ";
|
||||
else
|
||||
for (int i = getWindowStartBand(); i < getWindowEndBand(); i++)
|
||||
{
|
||||
printf("头文件中写入了多少个波段:%d\n",i-getWindowStartBand()+1);//???????????????
|
||||
hdrFileHandle << geWavelengthAtBand(i);
|
||||
if (i < getWindowEndBand() - 1)
|
||||
hdrFileHandle << ", ";
|
||||
else
|
||||
{
|
||||
printf("头文件中写入了多少个波段:%d\n",i-getWindowStartBand()+1);//???????????????
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (m_imager.getSpectralBin() == 2)
|
||||
{
|
||||
int counter = 0;
|
||||
for (int i = m_iOffsetyOfSpectralBin2; i < m_iOffsetyOfSpectralBin2 + m_iHeightOfSpectralBin2; i++)
|
||||
{
|
||||
if (i*2 + 1 > 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();
|
||||
}
|
||||
|
Reference in New Issue
Block a user