修改:
记录上次设置的帧率和曝光时间,打开时,将上次的帧率和曝光时间设置为当前参数;
This commit is contained in:
@ -45,6 +45,29 @@ public:
|
|||||||
bool createConfigFile();
|
bool createConfigFile();
|
||||||
bool updateConfigFile();
|
bool updateConfigFile();
|
||||||
|
|
||||||
|
private:
|
||||||
|
string m_configfilePath;
|
||||||
|
Config cfg;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ParameterConfigfile
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ParameterConfigfile();
|
||||||
|
void setConfigfilePath(string configfilePath);
|
||||||
|
bool isConfigfileExist();
|
||||||
|
bool parseConfigfile();
|
||||||
|
|
||||||
|
bool getFrameRate(int &frameRate);
|
||||||
|
bool setFrameRate(int frameRate);
|
||||||
|
|
||||||
|
bool getExposeTime(float &exposeTime);
|
||||||
|
bool setExposeTime(float exposeTime);
|
||||||
|
|
||||||
|
bool createConfigFile();
|
||||||
|
// bool updateConfigFile();
|
||||||
|
bool writeConfig2File();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
string m_configfilePath;
|
string m_configfilePath;
|
||||||
Config cfg;
|
Config cfg;
|
||||||
|
@ -130,7 +130,7 @@ public:
|
|||||||
|
|
||||||
void setFramerate(double framerate);
|
void setFramerate(double framerate);
|
||||||
double getFramerate();
|
double getFramerate();
|
||||||
double setExposureTime(float exposureTime);
|
double setExposureTime(float exposureTime_in_us);
|
||||||
int wrapSetExposureTime(float exposureTime_in_us);
|
int wrapSetExposureTime(float exposureTime_in_us);
|
||||||
double getExposureTime();
|
double getExposureTime();
|
||||||
double autoExposure();
|
double autoExposure();
|
||||||
@ -188,6 +188,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
Configfile m_configfile;
|
Configfile m_configfile;
|
||||||
|
ParameterConfigfile m_parameterConfigfile;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -468,3 +468,172 @@ bool Configfile::updateConfigFile()
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ParameterConfigfile::ParameterConfigfile()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ParameterConfigfile::setConfigfilePath(string configfilePath)
|
||||||
|
{
|
||||||
|
m_configfilePath = configfilePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ParameterConfigfile::isConfigfileExist()
|
||||||
|
{
|
||||||
|
QFileInfo info(QString::fromStdString(m_configfilePath));
|
||||||
|
|
||||||
|
return info.exists();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ParameterConfigfile::parseConfigfile()
|
||||||
|
{
|
||||||
|
// Read the file. If there is an error, report it and exit.
|
||||||
|
try
|
||||||
|
{
|
||||||
|
cfg.readFile(m_configfilePath);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch(const FileIOException &fioex)
|
||||||
|
{
|
||||||
|
std::cerr << "I/O error while reading file." << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
catch(const ParseException &pex)
|
||||||
|
{
|
||||||
|
std::cerr << "Parse error at " << pex.getFile() << ":" << pex.getLine()
|
||||||
|
<< " - " << pex.getError() << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ParameterConfigfile::createConfigFile()
|
||||||
|
{
|
||||||
|
using namespace std;
|
||||||
|
using namespace libconfig;
|
||||||
|
|
||||||
|
Config cfg;
|
||||||
|
|
||||||
|
Setting &root = cfg.getRoot();
|
||||||
|
|
||||||
|
// Add some settings to the configuration.
|
||||||
|
// Setting &SN = root.add("SN", Setting::TypeString) = "0098";
|
||||||
|
// Setting &spatialBin = root.add("spatialBin", Setting::TypeInt) = 2;
|
||||||
|
// Setting &SpectralBin = root.add("spectralBin", Setting::TypeInt) = 2;
|
||||||
|
|
||||||
|
Setting &ximeaParam = root.add("ximeaParam", Setting::TypeGroup);
|
||||||
|
ximeaParam.add("frameRate", Setting::TypeInt) = 100;
|
||||||
|
ximeaParam.add("exposeTime", Setting::TypeFloat) = 10.0;
|
||||||
|
|
||||||
|
|
||||||
|
// Write out the new configuration.
|
||||||
|
try
|
||||||
|
{
|
||||||
|
QList<QString> fileInfo = getFileInfo(QString::fromStdString(m_configfilePath));
|
||||||
|
bool ret = createDir(fileInfo[0]);
|
||||||
|
|
||||||
|
cfg.writeFile(m_configfilePath.c_str());
|
||||||
|
cerr << "New configuration successfully written to: " << m_configfilePath.c_str() << endl;
|
||||||
|
|
||||||
|
}
|
||||||
|
catch(const FileIOException &fioex)
|
||||||
|
{
|
||||||
|
cerr << "I/O error while writing configuration file: " << m_configfilePath.c_str() << endl;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ParameterConfigfile::getFrameRate(int &frameRate)
|
||||||
|
{
|
||||||
|
const Setting& root = cfg.getRoot();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
const Setting &ximeaParam = root["ximeaParam"];
|
||||||
|
frameRate = ximeaParam.lookup("frameRate");
|
||||||
|
|
||||||
|
std::cout << "----------------"<< frameRate<<std::endl;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch(const SettingNotFoundException &nfex)
|
||||||
|
{
|
||||||
|
cerr << "No 'frameRate' setting in configuration file." << endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ParameterConfigfile::setFrameRate(int frameRate)
|
||||||
|
{
|
||||||
|
const Setting& root = cfg.getRoot();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Setting &frameRate2 = root["ximeaParam"]["frameRate"];
|
||||||
|
frameRate2 = frameRate;
|
||||||
|
|
||||||
|
writeConfig2File();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch(const SettingNotFoundException &nfex)
|
||||||
|
{
|
||||||
|
cerr << "No 'frameRate' setting in configuration file." << endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ParameterConfigfile::getExposeTime(float &exposeTime)
|
||||||
|
{
|
||||||
|
const Setting& root = cfg.getRoot();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
const Setting &ximeaParam = root["ximeaParam"];
|
||||||
|
exposeTime = ximeaParam.lookup("exposeTime");
|
||||||
|
|
||||||
|
std::cout << "----------------"<< exposeTime<<std::endl;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch(const SettingNotFoundException &nfex)
|
||||||
|
{
|
||||||
|
cerr << "No 'exposeTime' setting in configuration file." << endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ParameterConfigfile::setExposeTime(float exposeTime)
|
||||||
|
{
|
||||||
|
const Setting& root = cfg.getRoot();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Setting &frameRate2 = root["ximeaParam"]["exposeTime"];
|
||||||
|
frameRate2 = exposeTime;
|
||||||
|
|
||||||
|
writeConfig2File();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch(const SettingNotFoundException &nfex)
|
||||||
|
{
|
||||||
|
cerr << "No 'exposeTime' setting in configuration file." << endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ParameterConfigfile::writeConfig2File()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
QList<QString> fileInfo = getFileInfo(QString::fromStdString(m_configfilePath));
|
||||||
|
bool ret = createDir(fileInfo[0]);
|
||||||
|
|
||||||
|
cfg.writeFile(m_configfilePath.c_str());
|
||||||
|
cerr << "New configuration successfully written to: " << m_configfilePath.c_str() << endl;
|
||||||
|
}
|
||||||
|
catch(const FileIOException &fioex)
|
||||||
|
{
|
||||||
|
cerr << "I/O error while writing configuration file: " << m_configfilePath.c_str() << endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
std::cout<<"ximeaAirborneSystem 版本:"<< "36." <<std::endl;
|
std::cout<<"ximeaAirborneSystem 版本:"<< "37." <<std::endl;
|
||||||
QCoreApplication a(argc, argv);
|
QCoreApplication a(argc, argv);
|
||||||
|
|
||||||
//UdpServer* x=new UdpServer();
|
//UdpServer* x=new UdpServer();
|
||||||
|
@ -28,6 +28,11 @@ XimeaImager::XimeaImager()
|
|||||||
std::cout<<"ximea.cfg 错误:bin1 波段数小于 bin2 波段数的 2 倍!"<<std::endl;
|
std::cout<<"ximea.cfg 错误:bin1 波段数小于 bin2 波段数的 2 倍!"<<std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString ximeaParamCfgFile = "/media/nvme/300TC/config/ximeaParam.cfg";
|
||||||
|
m_parameterConfigfile.setConfigfilePath(ximeaParamCfgFile.toStdString());
|
||||||
|
if(!m_parameterConfigfile.isConfigfileExist())
|
||||||
|
m_parameterConfigfile.createConfigFile();
|
||||||
|
m_parameterConfigfile.parseConfigfile();
|
||||||
|
|
||||||
m_recordTempThread=new QThread();
|
m_recordTempThread=new QThread();
|
||||||
m_ximeaTemperature = new RecordXimeaTemperature(&m_imager);
|
m_ximeaTemperature = new RecordXimeaTemperature(&m_imager);
|
||||||
@ -121,7 +126,20 @@ void XimeaImager::openImger()
|
|||||||
m_imager.setAcqBufferSize(acqBufferSize);
|
m_imager.setAcqBufferSize(acqBufferSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
setFramerate(100);
|
if (m_parameterConfigfile.isConfigfileExist())
|
||||||
|
{
|
||||||
|
int frameRate;
|
||||||
|
m_parameterConfigfile.getFrameRate(frameRate);
|
||||||
|
setFramerate(frameRate);
|
||||||
|
|
||||||
|
float exposeTime;
|
||||||
|
m_parameterConfigfile.getExposeTime(exposeTime);
|
||||||
|
wrapSetExposureTime(exposeTime);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setFramerate(100);
|
||||||
|
}
|
||||||
|
|
||||||
//经验证:frameSizeManual和frameSizeAuto相等
|
//经验证:frameSizeManual和frameSizeAuto相等
|
||||||
int frameSizeManual = m_imager.get_band_count()*m_imager.get_sample_count()*2;
|
int frameSizeManual = m_imager.get_band_count()*m_imager.get_sample_count()*2;
|
||||||
@ -186,14 +204,16 @@ void XimeaImager::setFramerate(double framerate)
|
|||||||
{
|
{
|
||||||
m_imager.set_framerate(framerate);
|
m_imager.set_framerate(framerate);
|
||||||
|
|
||||||
int maxExposureTimeInUs=1/framerate*1000000*0.01;
|
int maxExposureTimeInUs=1/framerate*1000000;
|
||||||
setExposureTime(maxExposureTimeInUs);
|
// setExposureTime(maxExposureTimeInUs);
|
||||||
// setExposureTime(1000);
|
// setExposureTime(1000);
|
||||||
|
|
||||||
m_iImagerState=102;
|
m_iImagerState=102;
|
||||||
emit ximeaImageStatus(m_iImagerState);
|
emit ximeaImageStatus(m_iImagerState);
|
||||||
|
|
||||||
emit frameRateSignal(framerate);
|
emit frameRateSignal(framerate);
|
||||||
|
|
||||||
|
m_parameterConfigfile.setFrameRate(framerate);
|
||||||
}
|
}
|
||||||
catch(int xiApiErrorCodes)
|
catch(int xiApiErrorCodes)
|
||||||
{
|
{
|
||||||
@ -240,6 +260,7 @@ double XimeaImager::setExposureTime(float exposureTime_in_us)
|
|||||||
|
|
||||||
//返回设置的积分时间
|
//返回设置的积分时间
|
||||||
integrationTime2Return=m_imager.get_integration_time();
|
integrationTime2Return=m_imager.get_integration_time();
|
||||||
|
m_parameterConfigfile.setExposeTime(integrationTime2Return);
|
||||||
|
|
||||||
return integrationTime2Return;
|
return integrationTime2Return;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user