1. 读写配置文件类(Configfile):1)修复一些返回值bug,2)添加读写 裁剪有效窗口的参数 的函数getEffectiveWindowRoi;
2. 在没有采集数据时,读取ximea温度,并写入到csv文件中; 3. 在另外的工程更新了ximea控制类(Iris::IrisXimeaImager),并在此工程加入此更新:从获取的有效窗口中裁剪需要的数据,m_imager.setEffectiveWindowRoi(); 4. 在函数XimeaImager::processXiApiErrorCodes中,增加处理ximea错误码12;
This commit is contained in:
@ -10,6 +10,9 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <libconfig.h++>
|
#include <libconfig.h++>
|
||||||
|
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace libconfig;
|
using namespace libconfig;
|
||||||
|
|
||||||
@ -19,22 +22,19 @@ class Configfile
|
|||||||
public:
|
public:
|
||||||
Configfile();
|
Configfile();
|
||||||
void setConfigfilePath(string configfilePath);
|
void setConfigfilePath(string configfilePath);
|
||||||
int parseConfigfile();
|
bool isConfigfileExist();
|
||||||
|
bool parseConfigfile();
|
||||||
|
|
||||||
bool getBin(int &bin);
|
bool getBin(int &bin);
|
||||||
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 getGainOffset(float &gain, float &offset);
|
bool getGainOffset(float &gain, float &offset);
|
||||||
|
|
||||||
int createConfigFile();
|
bool createConfigFile();
|
||||||
int updateConfigFile();
|
bool updateConfigFile();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
string m_configfilePath;
|
string m_configfilePath;
|
||||||
Config cfg;
|
Config cfg;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif //XIMEAIMAGERECORDER_CONFIGFILE_H
|
#endif //XIMEAIMAGERECORDER_CONFIGFILE_H
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include <exception>
|
#include <exception>
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QDateTime>
|
||||||
#include <qthread.h>
|
#include <qthread.h>
|
||||||
|
|
||||||
#include "configfile.h"
|
#include "configfile.h"
|
||||||
@ -42,6 +43,26 @@
|
|||||||
//#include <m3api/xiApi.h> // Linux, OSX
|
//#include <m3api/xiApi.h> // Linux, OSX
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
|
class RecordXimeaTemperature : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
RecordXimeaTemperature(Iris::IrisXimeaImager * imager);
|
||||||
|
|
||||||
|
void stopRecordTemperature();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Iris::IrisXimeaImager * m_imager;
|
||||||
|
|
||||||
|
bool m_bIsRecord;
|
||||||
|
public slots:
|
||||||
|
void recordTemperature(QString filePath);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
class XimeaImager : public QObject
|
class XimeaImager : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -74,7 +95,11 @@ private:
|
|||||||
int m_iImagerState;
|
int m_iImagerState;
|
||||||
int m_iImagerStateTemp;
|
int m_iImagerStateTemp;
|
||||||
|
|
||||||
|
QThread * m_recordTempThread;
|
||||||
|
RecordXimeaTemperature * m_ximeaTemperature;
|
||||||
|
|
||||||
QString m_baseFileName;
|
QString m_baseFileName;
|
||||||
|
QString m_ximeaTemperatureCSVPath;
|
||||||
|
|
||||||
Iris::IrisXimeaImager m_imager;
|
Iris::IrisXimeaImager m_imager;
|
||||||
unsigned short * m_buffer;
|
unsigned short * m_buffer;
|
||||||
@ -115,5 +140,7 @@ public slots:
|
|||||||
signals:
|
signals:
|
||||||
void recordFinished();
|
void recordFinished();
|
||||||
void ximeaImageStatus(int);
|
void ximeaImageStatus(int);
|
||||||
|
|
||||||
|
void recordXimeaTemperatureSignal(QString);
|
||||||
};
|
};
|
||||||
#endif // XIMEAIMAGER_H
|
#endif // XIMEAIMAGER_H
|
||||||
|
@ -14,24 +14,32 @@ void Configfile::setConfigfilePath(string configfilePath)
|
|||||||
m_configfilePath = configfilePath;
|
m_configfilePath = configfilePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Configfile::isConfigfileExist()
|
||||||
|
{
|
||||||
|
QFileInfo info(QString::fromStdString(m_configfilePath));
|
||||||
|
|
||||||
int Configfile::parseConfigfile()
|
return info.exists();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Configfile::parseConfigfile()
|
||||||
{
|
{
|
||||||
// Read the file. If there is an error, report it and exit.
|
// Read the file. If there is an error, report it and exit.
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
cfg.readFile(m_configfilePath);
|
cfg.readFile(m_configfilePath);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
catch(const FileIOException &fioex)
|
catch(const FileIOException &fioex)
|
||||||
{
|
{
|
||||||
std::cerr << "I/O error while reading file." << std::endl;
|
std::cerr << "I/O error while reading file." << std::endl;
|
||||||
return(EXIT_FAILURE);
|
return false;
|
||||||
}
|
}
|
||||||
catch(const ParseException &pex)
|
catch(const ParseException &pex)
|
||||||
{
|
{
|
||||||
std::cerr << "Parse error at " << pex.getFile() << ":" << pex.getLine()
|
std::cerr << "Parse error at " << pex.getFile() << ":" << pex.getLine()
|
||||||
<< " - " << pex.getError() << std::endl;
|
<< " - " << pex.getError() << std::endl;
|
||||||
return(EXIT_FAILURE);
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,12 +49,12 @@ bool Configfile::getBin(int &bin)
|
|||||||
{
|
{
|
||||||
bin = cfg.lookup("bin");
|
bin = cfg.lookup("bin");
|
||||||
|
|
||||||
return(EXIT_SUCCESS);
|
return true;
|
||||||
}
|
}
|
||||||
catch(const SettingNotFoundException &nfex)
|
catch(const SettingNotFoundException &nfex)
|
||||||
{
|
{
|
||||||
cerr << "No 'bin' setting in configuration file." << endl;
|
cerr << "No 'bin' setting in configuration file." << endl;
|
||||||
return(EXIT_FAILURE);
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,16 +79,48 @@ bool Configfile::getEffectiveWindow(int &width, int &offsetx, int &height, int &
|
|||||||
&& window.lookupValue("height", height)
|
&& window.lookupValue("height", height)
|
||||||
&& window.lookupValue("offsety", offsety)))
|
&& window.lookupValue("offsety", offsety)))
|
||||||
{
|
{
|
||||||
return(EXIT_FAILURE);
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(const SettingNotFoundException &nfex)
|
catch(const SettingNotFoundException &nfex)
|
||||||
{
|
{
|
||||||
// Ignore.
|
// Ignore.
|
||||||
int a=1;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(EXIT_SUCCESS);
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Configfile::getEffectiveWindowRoi(int &width, int &offsetx)
|
||||||
|
{
|
||||||
|
const Setting& root = cfg.getRoot();
|
||||||
|
|
||||||
|
// Output a list of all books in the inventory.
|
||||||
|
try
|
||||||
|
{
|
||||||
|
const Setting &effective_window = root["effective_window_roi"];
|
||||||
|
int count = effective_window.getLength();
|
||||||
|
|
||||||
|
int bin;
|
||||||
|
getBin(bin);
|
||||||
|
|
||||||
|
const Setting &window = effective_window[bin-1];
|
||||||
|
string name = window.getName();
|
||||||
|
|
||||||
|
if(!(window.lookupValue("width", width)
|
||||||
|
&& window.lookupValue("offsetx", offsetx)
|
||||||
|
))
|
||||||
|
{
|
||||||
|
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)
|
||||||
@ -102,19 +142,19 @@ bool Configfile::getGainOffset(float &gain, float &offset)
|
|||||||
if(!(gainOffsetSetting.lookupValue("gain", gain)
|
if(!(gainOffsetSetting.lookupValue("gain", gain)
|
||||||
&& gainOffsetSetting.lookupValue("offset", offset)))
|
&& gainOffsetSetting.lookupValue("offset", offset)))
|
||||||
{
|
{
|
||||||
return(EXIT_FAILURE);
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(const SettingNotFoundException &nfex)
|
catch(const SettingNotFoundException &nfex)
|
||||||
{
|
{
|
||||||
// Ignore.
|
// Ignore.
|
||||||
int a=1;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(EXIT_SUCCESS);
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Configfile::createConfigFile()
|
bool Configfile::createConfigFile()
|
||||||
{
|
{
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace libconfig;
|
using namespace libconfig;
|
||||||
@ -129,28 +169,42 @@ int Configfile::createConfigFile()
|
|||||||
Setting &SN = root.add("SN", Setting::TypeString) = "0098";
|
Setting &SN = root.add("SN", Setting::TypeString) = "0098";
|
||||||
|
|
||||||
Setting &effective_window = root.add("effective_window", Setting::TypeGroup);
|
Setting &effective_window = root.add("effective_window", Setting::TypeGroup);
|
||||||
Setting &effective_windowBin1 = effective_window.add("bin1", Setting::TypeGroup);
|
Setting &effective_window_Bin1 = effective_window.add("bin1", Setting::TypeGroup);
|
||||||
Setting &effective_windowBin2 = effective_window.add("bin2", Setting::TypeGroup);
|
Setting &effective_window_Bin2 = effective_window.add("bin2", Setting::TypeGroup);
|
||||||
|
|
||||||
effective_windowBin1.add("width", Setting::TypeInt) = 1;
|
effective_window_Bin1.add("width", Setting::TypeInt) = 1392;
|
||||||
effective_windowBin1.add("offsetx", Setting::TypeInt) = 2;
|
effective_window_Bin1.add("offsetx", Setting::TypeInt) = 272;
|
||||||
effective_windowBin1.add("height", Setting::TypeInt) = 3;
|
effective_window_Bin1.add("height", Setting::TypeInt) = 300;
|
||||||
effective_windowBin1.add("offsety", Setting::TypeInt) = 4;
|
effective_window_Bin1.add("offsety", Setting::TypeInt) = 348;
|
||||||
|
|
||||||
effective_windowBin2.add("width", Setting::TypeInt) = 5;
|
effective_window_Bin2.add("width", Setting::TypeInt) = 712;
|
||||||
effective_windowBin2.add("offsetx", Setting::TypeInt) = 6;
|
effective_window_Bin2.add("offsetx", Setting::TypeInt) = 128;
|
||||||
effective_windowBin2.add("height", Setting::TypeInt) = 7;
|
effective_window_Bin2.add("height", Setting::TypeInt) = 151;
|
||||||
effective_windowBin2.add("offsety", Setting::TypeInt) = 8;
|
effective_window_Bin2.add("offsety", Setting::TypeInt) = 174;
|
||||||
|
|
||||||
|
Setting &effective_window_roi = root.add("effective_window_roi", Setting::TypeGroup);
|
||||||
|
Setting &effective_window_roi_Bin1 = effective_window_roi.add("bin1", Setting::TypeGroup);
|
||||||
|
Setting &effective_window_roi_Bin2 = effective_window_roi.add("bin2", Setting::TypeGroup);
|
||||||
|
|
||||||
|
effective_window_roi_Bin1.add("width", Setting::TypeInt) = 1364;
|
||||||
|
effective_window_roi_Bin1.add("offsetx", Setting::TypeInt) = 14;
|
||||||
|
// effective_window_roi_Bin1.add("height", Setting::TypeInt) = 300;
|
||||||
|
// effective_window_roi_Bin1.add("offsety", Setting::TypeInt) = 348;
|
||||||
|
|
||||||
|
effective_window_roi_Bin2.add("width", Setting::TypeInt) = 682;
|
||||||
|
effective_window_roi_Bin2.add("offsetx", Setting::TypeInt) = 15;
|
||||||
|
// effective_window_roi_Bin2.add("height", Setting::TypeInt) = 151;
|
||||||
|
// effective_window_roi_Bin2.add("offsety", Setting::TypeInt) = 174;
|
||||||
|
|
||||||
Setting &gainOffset = root.add("gainOffset", Setting::TypeGroup);
|
Setting &gainOffset = root.add("gainOffset", Setting::TypeGroup);
|
||||||
Setting &gainOffsetBin1 = gainOffset.add("bin1", Setting::TypeGroup);
|
Setting &gainOffsetBin1 = gainOffset.add("bin1", Setting::TypeGroup);
|
||||||
Setting &gainOffsetBin2 = gainOffset.add("bin2", Setting::TypeGroup);
|
Setting &gainOffsetBin2 = gainOffset.add("bin2", Setting::TypeGroup);
|
||||||
|
|
||||||
gainOffsetBin1.add("gain", Setting::TypeFloat) = 9.12;
|
gainOffsetBin1.add("gain", Setting::TypeFloat) = 2.00313433;
|
||||||
gainOffsetBin1.add("offset", Setting::TypeFloat) = -10.2;
|
gainOffsetBin1.add("offset", Setting::TypeFloat) = -300.46283157590585;
|
||||||
|
|
||||||
gainOffsetBin2.add("gain", Setting::TypeFloat) = 11.789;
|
gainOffsetBin2.add("gain", Setting::TypeFloat) = 4.00626868;
|
||||||
gainOffsetBin2.add("offset", Setting::TypeFloat) = -12.58;
|
gainOffsetBin2.add("offset", Setting::TypeFloat) = -299.46126663407176;
|
||||||
|
|
||||||
|
|
||||||
// Write out the new configuration.
|
// Write out the new configuration.
|
||||||
@ -162,14 +216,14 @@ int Configfile::createConfigFile()
|
|||||||
}
|
}
|
||||||
catch(const FileIOException &fioex)
|
catch(const FileIOException &fioex)
|
||||||
{
|
{
|
||||||
cerr << "I/O error while writing file: " << output_file << endl;
|
cerr << "I/O error while writing configuration file: " << output_file << endl;
|
||||||
return(EXIT_FAILURE);
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(EXIT_SUCCESS);
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Configfile::updateConfigFile()
|
bool Configfile::updateConfigFile()
|
||||||
{
|
{
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace libconfig;
|
using namespace libconfig;
|
||||||
@ -191,13 +245,13 @@ int Configfile::updateConfigFile()
|
|||||||
catch(const FileIOException &fioex)
|
catch(const FileIOException &fioex)
|
||||||
{
|
{
|
||||||
std::cerr << "I/O error while reading file." << std::endl;
|
std::cerr << "I/O error while reading file." << std::endl;
|
||||||
return(EXIT_FAILURE);
|
return false;
|
||||||
}
|
}
|
||||||
catch(const ParseException &pex)
|
catch(const ParseException &pex)
|
||||||
{
|
{
|
||||||
std::cerr << "Parse error at " << pex.getFile() << ":" << pex.getLine()
|
std::cerr << "Parse error at " << pex.getFile() << ":" << pex.getLine()
|
||||||
<< " - " << pex.getError() << std::endl;
|
<< " - " << pex.getError() << std::endl;
|
||||||
return(EXIT_FAILURE);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the 'movies' setting. Add intermediate settings if they don't yet
|
// Find the 'movies' setting. Add intermediate settings if they don't yet
|
||||||
@ -233,8 +287,8 @@ int Configfile::updateConfigFile()
|
|||||||
catch(const FileIOException &fioex)
|
catch(const FileIOException &fioex)
|
||||||
{
|
{
|
||||||
cerr << "I/O error while writing file: " << output_file << endl;
|
cerr << "I/O error while writing file: " << output_file << endl;
|
||||||
return(EXIT_FAILURE);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(EXIT_SUCCESS);
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -10,9 +10,16 @@ XimeaImager::XimeaImager()
|
|||||||
//connect(this, SIGNAL(recordFinished()),this, SLOT());
|
//connect(this, SIGNAL(recordFinished()),this, SLOT());
|
||||||
|
|
||||||
m_configfile.setConfigfilePath("ximea.cfg");
|
m_configfile.setConfigfilePath("ximea.cfg");
|
||||||
|
if(!m_configfile.isConfigfileExist())
|
||||||
|
m_configfile.createConfigFile();
|
||||||
m_configfile.parseConfigfile();
|
m_configfile.parseConfigfile();
|
||||||
|
|
||||||
// m_configfile.createConfigFile();
|
m_recordTempThread=new QThread();
|
||||||
|
m_ximeaTemperature = new RecordXimeaTemperature(&m_imager);
|
||||||
|
m_ximeaTemperature->moveToThread(m_recordTempThread);
|
||||||
|
m_recordTempThread->start();
|
||||||
|
|
||||||
|
connect(this, SIGNAL(recordXimeaTemperatureSignal(QString)),m_ximeaTemperature, SLOT(recordTemperature(QString)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void XimeaImager::openImger()
|
void XimeaImager::openImger()
|
||||||
@ -29,18 +36,36 @@ void XimeaImager::openImger()
|
|||||||
//std::cout<<"XimeaImager::openImger111111111111111111111:正在打开相机!"<<std::endl;
|
//std::cout<<"XimeaImager::openImger111111111111111111111:正在打开相机!"<<std::endl;
|
||||||
m_imager.connect();
|
m_imager.connect();
|
||||||
|
|
||||||
|
bool ret;
|
||||||
|
|
||||||
int bin=0;
|
int bin=0;
|
||||||
m_configfile.getBin(bin);
|
ret = m_configfile.getBin(bin);
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
bool haha = m_imager.setSpectralBin(bin);
|
bool haha = m_imager.setSpectralBin(bin);
|
||||||
bool haha2 = m_imager.setSpatialBin(bin);
|
bool haha2 = m_imager.setSpatialBin(bin);
|
||||||
|
}
|
||||||
|
|
||||||
float gain, offset;//用于生成头文件中的波长信息
|
float gain, offset;//用于生成头文件中的波长信息
|
||||||
m_configfile.getGainOffset(gain, offset);
|
ret = m_configfile.getGainOffset(gain, offset);
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
m_imager.setGainOffset(gain, offset);
|
m_imager.setGainOffset(gain, offset);
|
||||||
|
}
|
||||||
|
|
||||||
int width = 0, offsetx = 0, height = 0, offsety = 0;
|
int width = 0, offsetx = 0, height = 0, offsety = 0;
|
||||||
m_configfile.getEffectiveWindow(width, offsetx, height, offsety);
|
ret = m_configfile.getEffectiveWindow(width, offsetx, height, offsety);
|
||||||
m_imager.setRoi(offsetx, width, offsety, height);
|
if (ret)
|
||||||
|
{
|
||||||
|
m_imager.setEffectiveWindow(offsetx, width, offsety, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
int width_roi = 0, offsetx_roi = 0;
|
||||||
|
ret = m_configfile.getEffectiveWindowRoi(width_roi, offsetx_roi);
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
m_imager.setEffectiveWindowRoi(offsetx_roi, width_roi);
|
||||||
|
}
|
||||||
|
|
||||||
setFramerate(100);
|
setFramerate(100);
|
||||||
|
|
||||||
@ -54,6 +79,9 @@ void XimeaImager::openImger()
|
|||||||
|
|
||||||
m_iImagerState = 101;
|
m_iImagerState = 101;
|
||||||
emit ximeaImageStatus(m_iImagerState);
|
emit ximeaImageStatus(m_iImagerState);
|
||||||
|
|
||||||
|
m_ximeaTemperatureCSVPath = "/home/rock/programRunLog/ximeaTemperature.csv";
|
||||||
|
emit recordXimeaTemperatureSignal(m_ximeaTemperatureCSVPath);
|
||||||
}
|
}
|
||||||
catch(int xiApiErrorCodes)
|
catch(int xiApiErrorCodes)
|
||||||
{
|
{
|
||||||
@ -69,6 +97,8 @@ void XimeaImager::openImger()
|
|||||||
|
|
||||||
void XimeaImager::closeImger()
|
void XimeaImager::closeImger()
|
||||||
{
|
{
|
||||||
|
m_ximeaTemperature->stopRecordTemperature();
|
||||||
|
|
||||||
if(m_iImagerState==100)
|
if(m_iImagerState==100)
|
||||||
{
|
{
|
||||||
emit ximeaImageStatus(m_iImagerState);
|
emit ximeaImageStatus(m_iImagerState);
|
||||||
@ -88,6 +118,8 @@ void XimeaImager::closeImger()
|
|||||||
std::cout<<"XimeaImager::closeImger-------------------!"<<std::endl;
|
std::cout<<"XimeaImager::closeImger-------------------!"<<std::endl;
|
||||||
processXiApiErrorCodes(xiApiErrorCodes);
|
processXiApiErrorCodes(xiApiErrorCodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void XimeaImager::setFramerate(double framerate)
|
void XimeaImager::setFramerate(double framerate)
|
||||||
@ -359,9 +391,15 @@ int XimeaImager::getMaxValueOfOneFrame(unsigned short * data, int numberOfPixel)
|
|||||||
unsigned short maxValue=0;
|
unsigned short maxValue=0;
|
||||||
for(int i=0;i<numberOfPixel;i++)
|
for(int i=0;i<numberOfPixel;i++)
|
||||||
{
|
{
|
||||||
if (data[i]>maxValue)
|
// std::cout<<"像素值为:"<< *(data + i) <<std::endl;
|
||||||
|
if (*(data + i)>maxValue)
|
||||||
{
|
{
|
||||||
maxValue=data[i];
|
//std::cout<<"像素值为:"<< *(data + i) <<std::endl;
|
||||||
|
maxValue=*(data + i);
|
||||||
|
}
|
||||||
|
if (*(data + i)==65535)
|
||||||
|
{
|
||||||
|
int a=0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf("本帧最大值为: %d.\n",maxValue);
|
printf("本帧最大值为: %d.\n",maxValue);
|
||||||
@ -376,6 +414,7 @@ int XimeaImager::getImagerState() const
|
|||||||
|
|
||||||
void XimeaImager::startRecord(double TimeDifferenceBetweensOSAndSbg,QString baseFileName)
|
void XimeaImager::startRecord(double TimeDifferenceBetweensOSAndSbg,QString baseFileName)
|
||||||
{
|
{
|
||||||
|
m_ximeaTemperature->stopRecordTemperature();//开始采集影像前,停止获取相机的温度,以免降低帧率;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if(m_iImagerState <= 99 || m_iImagerState==100 || m_iImagerState==104)
|
if(m_iImagerState <= 99 || m_iImagerState==100 || m_iImagerState==104)
|
||||||
@ -424,6 +463,8 @@ void XimeaImager::startRecord(double TimeDifferenceBetweensOSAndSbg,QString base
|
|||||||
|
|
||||||
m_iFrameCounter+=1;
|
m_iFrameCounter+=1;
|
||||||
|
|
||||||
|
// if(m_iFrameCounter==100)
|
||||||
|
// break;
|
||||||
|
|
||||||
double sbgTime=getSbgTime(TimeDifferenceBetweensOSAndSbg);
|
double sbgTime=getSbgTime(TimeDifferenceBetweensOSAndSbg);
|
||||||
|
|
||||||
@ -453,11 +494,13 @@ void XimeaImager::startRecord(double TimeDifferenceBetweensOSAndSbg,QString base
|
|||||||
double frameLossRate=frameLossed / frameInTheory;
|
double frameLossRate=frameLossed / frameInTheory;
|
||||||
|
|
||||||
std::cout<<"当前采集文件为: "<<baseFileName.toStdString()<<std::endl;
|
std::cout<<"当前采集文件为: "<<baseFileName.toStdString()<<std::endl;
|
||||||
std::cout<<"采集时间为: "<<runTime<<std::endl;
|
std::cout<<"采集时间为: "<<runTime<< "s" <<std::endl;
|
||||||
|
std::cout<<"当前帧率为: "<<getFramerate() << "hz" <<std::endl;
|
||||||
|
std::cout<<"每秒数据量为: "<<getFramerate()*m_iFrameSizeInByte/(1024*1024)<<"MB"<<std::endl;
|
||||||
std::cout<<"理论采集帧数为: "<<frameInTheory<<std::endl;
|
std::cout<<"理论采集帧数为: "<<frameInTheory<<std::endl;
|
||||||
std::cout<<"实际采集帧数为:"<<m_iFrameCounter<<std::endl;
|
std::cout<<"实际采集帧数为:"<<m_iFrameCounter<<std::endl;
|
||||||
std::cout<<"丢失帧数为: "<<frameLossed<<std::endl;
|
std::cout<<"丢失帧数为: "<<frameLossed<<std::endl;
|
||||||
std::cout<<"丢帧率为: "<<frameLossRate<<std::endl;
|
std::cout<<"丢帧率为: "<<frameLossRate * 100<< "%" <<std::endl;
|
||||||
|
|
||||||
fclose(hFile);
|
fclose(hFile);
|
||||||
fclose(hHimesFile);
|
fclose(hHimesFile);
|
||||||
@ -472,6 +515,8 @@ void XimeaImager::startRecord(double TimeDifferenceBetweensOSAndSbg,QString base
|
|||||||
emit ximeaImageStatus(m_iImagerState);
|
emit ximeaImageStatus(m_iImagerState);
|
||||||
|
|
||||||
emit recordFinished();
|
emit recordFinished();
|
||||||
|
|
||||||
|
emit recordXimeaTemperatureSignal(m_ximeaTemperatureCSVPath);//停止采集影像后,继续获取传感器温度;
|
||||||
}
|
}
|
||||||
catch(int xiApiErrorCodes)
|
catch(int xiApiErrorCodes)
|
||||||
{
|
{
|
||||||
@ -594,6 +639,12 @@ void XimeaImager::processXiApiErrorCodes(int xiApiErrorCodes)
|
|||||||
m_iImagerState=xiApiErrorCodes;
|
m_iImagerState=xiApiErrorCodes;
|
||||||
emit ximeaImageStatus(m_iImagerState);
|
emit ximeaImageStatus(m_iImagerState);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 12:
|
||||||
|
std::cout<<"XimeaImager::processXiApiErrorCodes-----------:Not supported!"<<std::endl;
|
||||||
|
m_iImagerState=xiApiErrorCodes;
|
||||||
|
emit ximeaImageStatus(m_iImagerState);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 15:
|
case 15:
|
||||||
std::cout<<"XimeaImager::processXiApiErrorCodes-----------:Memory allocation error!"<<std::endl;
|
std::cout<<"XimeaImager::processXiApiErrorCodes-----------:Memory allocation error!"<<std::endl;
|
||||||
@ -639,3 +690,39 @@ int XimeaImager::getFrameCounter()
|
|||||||
{
|
{
|
||||||
return m_iFrameCounter;
|
return m_iFrameCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RecordXimeaTemperature::RecordXimeaTemperature(Iris::IrisXimeaImager * imager)
|
||||||
|
{
|
||||||
|
m_imager = imager;
|
||||||
|
m_bIsRecord = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RecordXimeaTemperature::stopRecordTemperature()
|
||||||
|
{
|
||||||
|
m_bIsRecord = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RecordXimeaTemperature::recordTemperature(QString filePath= nullptr)
|
||||||
|
{
|
||||||
|
if(filePath== nullptr)
|
||||||
|
filePath="ximeaTemperature.csv";
|
||||||
|
ofstream ximeaTemperatureFile(filePath.toStdString().c_str(),ios::app);
|
||||||
|
|
||||||
|
while(m_bIsRecord)
|
||||||
|
{
|
||||||
|
float temp = m_imager->getTemperature();
|
||||||
|
|
||||||
|
QDateTime curDateTime = QDateTime::currentDateTime();
|
||||||
|
QString currentTime = curDateTime.toString("yyyy/MM/dd hh:mm:ss");
|
||||||
|
|
||||||
|
ximeaTemperatureFile << currentTime.toStdString() << "," << temp << "\n";
|
||||||
|
|
||||||
|
// std::cout<<"RecordXimeaTemperature::recordTemperature----------------:ximea Temperature is "<< temp <<std::endl;
|
||||||
|
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_bIsRecord = true;
|
||||||
|
|
||||||
|
ximeaTemperatureFile.close();
|
||||||
|
}
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
全名:Tang, chao
|
全名:Tang, chao
|
||||||
邮件地址:chao.tang@servirst.com
|
邮件地址:chao.tang@servirst.com
|
||||||
box密码:Tangchao123456,
|
box密码:Tangchao123456,
|
||||||
|
|
||||||
|
1、ximea的bin是软件bin不是硬件bin,所以,bin2需要电脑进行计算,这会导致帧率降低;
|
||||||
|
2、ximea出现错误的处理方法:
|
||||||
|
(1)错误代码为15,重新拔插相机就能解决此问题;
|
||||||
|
Reference in New Issue
Block a user