改变光谱bin2的波长计算方式为:通过bin1平均相邻波长获取;
This commit is contained in:
@ -34,7 +34,9 @@ public:
|
|||||||
bool getspatialBin(int &spatialBin);
|
bool getspatialBin(int &spatialBin);
|
||||||
bool getEffectiveWindow(int &width, int &offsetx, int &height, int &offsety);
|
bool getEffectiveWindow(int &width, int &offsetx, int &height, int &offsety);
|
||||||
bool getEffectiveWindowRoi(int &width, int &offsetx);
|
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 getGainOffset(float &gain, float &offset);
|
||||||
|
bool getGainOffsetOfSpectralBin1(float &gain, float &offset);
|
||||||
bool getSN(QString &SN);
|
bool getSN(QString &SN);
|
||||||
|
|
||||||
bool getBufferPolicy(int &bufferPolicy);
|
bool getBufferPolicy(int &bufferPolicy);
|
||||||
|
@ -154,6 +154,9 @@ private:
|
|||||||
int m_iImagerState;
|
int m_iImagerState;
|
||||||
int m_iImagerStateTemp;
|
int m_iImagerStateTemp;
|
||||||
|
|
||||||
|
int m_iOffsetyOfSpectralBin1, m_iOffsetyOfSpectralBin2;
|
||||||
|
int m_iHeightOfSpectralBin1, m_iHeightOfSpectralBin2;
|
||||||
|
|
||||||
QThread * m_recordTempThread;
|
QThread * m_recordTempThread;
|
||||||
RecordXimeaTemperature * m_ximeaTemperature;
|
RecordXimeaTemperature * m_ximeaTemperature;
|
||||||
|
|
||||||
|
@ -166,6 +166,28 @@ bool Configfile::getEffectiveWindowRoi(int &width, int &offsetx)
|
|||||||
return true;
|
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)
|
bool Configfile::getGainOffset(float &gain, float &offset)
|
||||||
{
|
{
|
||||||
const Setting& root = cfg.getRoot();
|
const Setting& root = cfg.getRoot();
|
||||||
@ -206,6 +228,35 @@ bool Configfile::getGainOffset(float &gain, float &offset)
|
|||||||
return true;
|
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)
|
bool Configfile::getSN(QString &SN)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -12,6 +12,22 @@ XimeaImager::XimeaImager()
|
|||||||
if(!m_configfile.isConfigfileExist())
|
if(!m_configfile.isConfigfileExist())
|
||||||
m_configfile.createConfigFile();
|
m_configfile.createConfigFile();
|
||||||
m_configfile.parseConfigfile();
|
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_recordTempThread=new QThread();
|
||||||
m_ximeaTemperature = new RecordXimeaTemperature(&m_imager);
|
m_ximeaTemperature = new RecordXimeaTemperature(&m_imager);
|
||||||
@ -66,7 +82,7 @@ void XimeaImager::openImger()
|
|||||||
}
|
}
|
||||||
|
|
||||||
float gain, offset;//用于生成头文件中的波长信息
|
float gain, offset;//用于生成头文件中的波长信息
|
||||||
ret = m_configfile.getGainOffset(gain, offset);
|
ret = m_configfile.getGainOffsetOfSpectralBin1(gain, offset);
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
m_imager.setGainOffset(gain, offset);
|
m_imager.setGainOffset(gain, offset);
|
||||||
@ -643,16 +659,43 @@ void XimeaImager::writeHdr()
|
|||||||
hdrFileHandle << "wavelength units = nanometers\n";
|
hdrFileHandle << "wavelength units = nanometers\n";
|
||||||
hdrFileHandle << "wavelength = {";
|
hdrFileHandle << "wavelength = {";
|
||||||
//hdrFileHandle << std::setprecision(5);
|
//hdrFileHandle << std::setprecision(5);
|
||||||
for (int i = getWindowStartBand(); i < getWindowEndBand(); i++)
|
|
||||||
|
if (m_imager.getSpectralBin() == 1)
|
||||||
{
|
{
|
||||||
hdrFileHandle << geWavelengthAtBand(i);
|
for (int i = getWindowStartBand(); i < getWindowEndBand(); i++)
|
||||||
if (i < getWindowEndBand() - 1)
|
|
||||||
hdrFileHandle << ", ";
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
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 << "}\n";
|
||||||
hdrFileHandle.close();
|
hdrFileHandle.close();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user