Compare commits
4 Commits
447a1aafb1
...
33
Author | SHA1 | Date | |
---|---|---|---|
6fc2680a1c | |||
09d224075a | |||
371c422a34 | |||
b31cd5fc8a |
@ -26,7 +26,7 @@
|
||||
#include <climits>
|
||||
#include <cstddef>
|
||||
|
||||
template <typename T, size_t BlockSize = 16368000>
|
||||
template <typename T, size_t BlockSize = 409200000>
|
||||
class MemoryPool
|
||||
{
|
||||
public:
|
||||
|
@ -16,6 +16,8 @@
|
||||
#include <QCoreApplication>
|
||||
#include <QDir>
|
||||
|
||||
#include "utility_tc.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace libconfig;
|
||||
|
||||
@ -35,6 +37,9 @@ public:
|
||||
bool getGainOffset(float &gain, float &offset);
|
||||
bool getSN(QString &SN);
|
||||
|
||||
bool getBufferPolicy(int &bufferPolicy);
|
||||
bool getAcqBufferSize(int &acqBufferSize);
|
||||
|
||||
bool createConfigFile();
|
||||
bool updateConfigFile();
|
||||
|
||||
|
@ -66,6 +66,8 @@ public slots:
|
||||
void sendSbgAccuracyState(int Accuracy,int SatelliteCounter);
|
||||
|
||||
void sendXimeaImageStatus(int ximeaImageStatus);
|
||||
void sendXimeaAutoExposeMaxValueOfOneFrame(int autoExposeMaxValueOfOneFrame, double exposeTime);
|
||||
void sendXimeaImageFrameRate(double frameRate);
|
||||
void sendCopyFileStatus(int fileStatus);
|
||||
};
|
||||
#endif // UDPSERVER_H
|
||||
|
@ -16,4 +16,8 @@ void bubbleSort(unsigned short * a, int n);
|
||||
|
||||
void swap(unsigned short * a, unsigned short * b);
|
||||
|
||||
bool createDir(QString fullPath);
|
||||
|
||||
QList<QString> getFileInfo(QString file);
|
||||
|
||||
#endif // UTILITY_TC_H
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include <fstream>
|
||||
#include <unistd.h>
|
||||
#include <exception>
|
||||
#include <fcntl.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include <QObject>
|
||||
#include <QDateTime>
|
||||
@ -62,7 +64,7 @@ public:
|
||||
DataBuffer();
|
||||
~DataBuffer();
|
||||
|
||||
unsigned short data[425600];//304*1400=425600,为了兼容所有设置spectral bin和spatial bin
|
||||
unsigned short data[41040000];//1368*300*100=41040000,为了兼容所有设置spectral bin和spatial bin
|
||||
|
||||
private:
|
||||
|
||||
@ -98,12 +100,13 @@ Q_OBJECT
|
||||
|
||||
public:
|
||||
WriteData2Disk();
|
||||
void setParm(queue<DataBuffer *> * q, QString baseFileName, int frameSizeInByte, MemoryPool<DataBuffer> * pool, rgbImage * rgbImage);
|
||||
void setParm(queue<DataBuffer *> * q, QString baseFileName, int frameSizeInByte, int number_WriteDisk, MemoryPool<DataBuffer> * pool, rgbImage * rgbImage);
|
||||
|
||||
private:
|
||||
queue<DataBuffer *> * m_q;
|
||||
QString m_QbaseFileName;
|
||||
int m_iFrameSizeInByte;
|
||||
int m_iNumber_WriteDisk;
|
||||
MemoryPool<DataBuffer> * m_pool;
|
||||
|
||||
rgbImage * m_rgbImage;
|
||||
@ -125,7 +128,7 @@ public:
|
||||
void setFramerate(double framerate);
|
||||
double getFramerate();
|
||||
double setExposureTime(float exposureTime);
|
||||
double wrapSetExposureTime(float exposureTime_in_us);
|
||||
int wrapSetExposureTime(float exposureTime_in_us);
|
||||
double getExposureTime();
|
||||
double autoExposure();
|
||||
void setGain(double gain);
|
||||
@ -139,6 +142,7 @@ public:
|
||||
|
||||
void stopRecord();
|
||||
int getFrameCounter();
|
||||
void writeXiApiErrorCodes(QString filePath, int xiApiErrorCodes);
|
||||
|
||||
int getMaxValueOfOneFrame(unsigned short * data, int numberOfPixel);
|
||||
|
||||
@ -205,5 +209,8 @@ signals:
|
||||
|
||||
void recordXimeaTemperatureSignal(QString);
|
||||
void startWriteDiskSignal();
|
||||
|
||||
void autoExposeMaxValueOfOneFrame(int, double);
|
||||
void frameRateSignal(double);
|
||||
};
|
||||
#endif // XIMEAIMAGER_H
|
||||
|
@ -222,6 +222,50 @@ bool Configfile::getSN(QString &SN)
|
||||
}
|
||||
}
|
||||
|
||||
bool Configfile::getBufferPolicy(int &bufferPolicy)
|
||||
{
|
||||
const Setting& root = cfg.getRoot();
|
||||
const Setting &ximeadll = root["ximeadll"];
|
||||
|
||||
try
|
||||
{
|
||||
if(!(ximeadll.lookupValue("buffer_policy", bufferPolicy)
|
||||
))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch(const SettingNotFoundException &nfex)
|
||||
{
|
||||
cerr << "No 'spectralBin' setting in configuration file." << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Configfile::getAcqBufferSize(int &acqBufferSize)
|
||||
{
|
||||
const Setting& root = cfg.getRoot();
|
||||
const Setting &ximeadll = root["ximeadll"];
|
||||
|
||||
try
|
||||
{
|
||||
if(!(ximeadll.lookupValue("acq_buffer_size", acqBufferSize)
|
||||
))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch(const SettingNotFoundException &nfex)
|
||||
{
|
||||
cerr << "No 'spectralBin' setting in configuration file." << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Configfile::createConfigFile()
|
||||
{
|
||||
using namespace std;
|
||||
@ -279,10 +323,18 @@ bool Configfile::createConfigFile()
|
||||
gainOffsetSpectralBin2.add("offset", Setting::TypeFloat) = -299.46126663407176;
|
||||
|
||||
|
||||
Setting &ximeadll = root.add("ximeadll", Setting::TypeGroup);
|
||||
ximeadll.add("buffer_policy", Setting::TypeInt) = 0;
|
||||
ximeadll.add("acq_buffer_size", Setting::TypeInt) = 400;
|
||||
|
||||
|
||||
// Write out the new configuration.
|
||||
QString output_file = "/media/nvme/300TC/config/ximea.cfg";
|
||||
try
|
||||
{
|
||||
QList<QString> fileInfo = getFileInfo(output_file);
|
||||
bool ret = createDir(fileInfo[0]);
|
||||
|
||||
cfg.writeFile(output_file.toStdString().c_str());
|
||||
cerr << "New configuration successfully written to: " << output_file.toStdString().c_str() << endl;
|
||||
|
||||
|
@ -789,7 +789,7 @@ void sbgtc::SbgRecorder::startRecordSbg()
|
||||
|
||||
m_baseFileName=getFileNameBaseOnTime();
|
||||
|
||||
QString sbgFileName=m_baseFileName+".sbg";
|
||||
QString sbgFileName=m_baseFileName+".bin";
|
||||
|
||||
FILE * fileHandle=fopen(sbgFileName.toStdString().c_str(),"w+b");
|
||||
|
||||
|
@ -50,6 +50,8 @@ UdpServer::UdpServer()
|
||||
connect(m_sbgRecorder, SIGNAL(sbgAccuracySignal(int,int)),this, SLOT(sendSbgAccuracyState(int,int)));
|
||||
|
||||
connect(m_imager, SIGNAL(ximeaImageStatus(int)),this, SLOT(sendXimeaImageStatus(int)));
|
||||
connect(m_imager, SIGNAL(autoExposeMaxValueOfOneFrame(int, double)),this, SLOT(sendXimeaAutoExposeMaxValueOfOneFrame(int, double)));
|
||||
connect(m_imager, SIGNAL(frameRateSignal(double)),this, SLOT(sendXimeaImageFrameRate(double)));
|
||||
connect(m_copyFile, SIGNAL(copyFileStatus(int)),this, SLOT(sendCopyFileStatus(int)));
|
||||
|
||||
|
||||
@ -122,26 +124,19 @@ void UdpServer::processPendingDatagrams()
|
||||
}
|
||||
case 3://系统开始采集高光谱影像
|
||||
{
|
||||
//emit startRecordHyperspectralSignal();//真实的影像开始采集通过惯导中的信号(sbgReady)触发
|
||||
if(m_imager->getImagerState()>=101 && m_imager->getImagerState()<=103)
|
||||
{
|
||||
std::cout<<"3代表系统开始采集高光谱影像!"<<std::endl;
|
||||
m_sbgRecorder->startRecordHyperspectral();
|
||||
|
||||
// if(m_sbgRecorder->getSbgState()==2)//开始采集前还需要判断相机的状态??????????????????????????????????????????
|
||||
// {
|
||||
|
||||
// }
|
||||
// else if(m_sbgRecorder->getSbgState()==3)
|
||||
// {
|
||||
// std::cout<<"系统已经开始采集!"<<std::endl;
|
||||
// }
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 4://系统停止采集高光谱影像
|
||||
{
|
||||
std::cout<<"4代表系统停止采集高光谱影像!"<<std::endl;
|
||||
|
||||
if(m_imager->getImagerState()>=101 && m_imager->getImagerState()<=104)
|
||||
{
|
||||
std::cout<<"4代表系统停止采集高光谱影像!"<<std::endl;
|
||||
m_imager->stopRecord();
|
||||
}
|
||||
|
||||
@ -168,10 +163,13 @@ void UdpServer::processPendingDatagrams()
|
||||
break;
|
||||
}
|
||||
case 7:
|
||||
{
|
||||
if(m_imager->getImagerState()>=101 && m_imager->getImagerState()<=103)
|
||||
{
|
||||
float time = datagramList[1].toFloat();//ms
|
||||
m_imager->wrapSetExposureTime(time*1000);
|
||||
std::cout<<"7,手动设置曝光时间为:" << time <<std::endl;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
@ -299,6 +297,30 @@ void UdpServer::sendXimeaImageStatus(int ximeaImageStatus)
|
||||
m_udpSocket->writeDatagram(datagram2send.data(),datagram2send.size(),m_clientIpAddress, 45455);
|
||||
}
|
||||
|
||||
void UdpServer::sendXimeaAutoExposeMaxValueOfOneFrame(int autoExposeMaxValueOfOneFrame, double exposeTime)
|
||||
{
|
||||
// std::cout<<"UdpServer::sendXimeaAutoExposeMaxValueOfOneFrame---------------------:"<< ximeaImageStatus <<std::endl;
|
||||
|
||||
QByteArray datagram2send;
|
||||
|
||||
QString status = "XimeaAutoExpose," + QString::number(autoExposeMaxValueOfOneFrame) + "," + QString::number(exposeTime, 'f', 2);
|
||||
|
||||
datagram2send.operator =(status.toStdString().c_str());
|
||||
m_udpSocket->writeDatagram(datagram2send.data(),datagram2send.size(),m_clientIpAddress, 45455);
|
||||
}
|
||||
|
||||
void UdpServer::sendXimeaImageFrameRate(double frameRate)
|
||||
{
|
||||
// std::cout<<"UdpServer::sendXimeaImageFrameRate---------------------:"<< ximeaImageStatus <<std::endl;
|
||||
|
||||
QByteArray datagram2send;
|
||||
|
||||
QString status = "XimeaFrameRate," + QString::number(frameRate, 'f', 2);
|
||||
|
||||
datagram2send.operator =(status.toStdString().c_str());
|
||||
m_udpSocket->writeDatagram(datagram2send.data(),datagram2send.size(),m_clientIpAddress, 45455);
|
||||
}
|
||||
|
||||
void UdpServer::sendCopyFileStatus(int fileStatus)
|
||||
{
|
||||
// std::cout<<"UdpServer::sendCopyFileStatus---------------------:"<< fileStatus <<std::endl;
|
||||
|
@ -88,3 +88,36 @@ void swap(unsigned short * a, unsigned short * b)
|
||||
*a=*b;
|
||||
*b=tmp;
|
||||
}
|
||||
|
||||
|
||||
bool createDir(QString fullPath)
|
||||
{
|
||||
QDir dir(fullPath);
|
||||
if (dir.exists()) {
|
||||
return true;
|
||||
} else {
|
||||
bool ok = dir.mkpath(fullPath);//创建多级目录
|
||||
return ok;
|
||||
}
|
||||
}
|
||||
|
||||
QList<QString> getFileInfo(QString file)
|
||||
{
|
||||
QFileInfo fileInfo = QFileInfo(file);
|
||||
|
||||
QString fileName, fileSuffix, filePath;
|
||||
filePath = fileInfo.absolutePath();//绝对路径
|
||||
fileName = fileInfo.fileName();//文件名
|
||||
fileSuffix = fileInfo.suffix();//文件后缀
|
||||
|
||||
// qDebug() << fileName <<endl
|
||||
// << fileSuffix<< endl
|
||||
// << filePath<< endl;
|
||||
|
||||
QList<QString> result;
|
||||
result.append(filePath);
|
||||
result.append(fileName);
|
||||
result.append(fileSuffix);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -89,6 +89,18 @@ void XimeaImager::openImger()
|
||||
// m_imager.setEffectiveWindowRoi(offsetx_roi, width_roi);
|
||||
// }
|
||||
|
||||
int bufferPolicy, acqBufferSize;
|
||||
ret1 = m_configfile.getBufferPolicy(bufferPolicy);
|
||||
if (ret1)
|
||||
{
|
||||
m_imager.setBufferPolicy(bufferPolicy);
|
||||
}
|
||||
ret1 = m_configfile.getAcqBufferSize(acqBufferSize);
|
||||
if (ret1)
|
||||
{
|
||||
m_imager.setAcqBufferSize(acqBufferSize);
|
||||
}
|
||||
|
||||
setFramerate(100);
|
||||
|
||||
//经验证:frameSizeManual和frameSizeAuto相等
|
||||
@ -160,6 +172,8 @@ void XimeaImager::setFramerate(double framerate)
|
||||
|
||||
m_iImagerState=102;
|
||||
emit ximeaImageStatus(m_iImagerState);
|
||||
|
||||
emit frameRateSignal(framerate);
|
||||
}
|
||||
catch(int xiApiErrorCodes)
|
||||
{
|
||||
@ -216,12 +230,22 @@ double XimeaImager::setExposureTime(float exposureTime_in_us)
|
||||
}
|
||||
}
|
||||
|
||||
double XimeaImager::wrapSetExposureTime(float exposureTime_in_us)
|
||||
int XimeaImager::wrapSetExposureTime(float exposureTime_in_us)
|
||||
{
|
||||
setExposureTime(exposureTime_in_us);
|
||||
double exposureTime = setExposureTime(exposureTime_in_us);
|
||||
|
||||
m_imager.start();
|
||||
m_imager.get_frame(m_buffer);
|
||||
m_imager.stop();
|
||||
|
||||
int maxValueOfOneFrame = getMaxValueOfOneFrame((short unsigned int*)m_imager.m_image.bp,m_imager.get_band_count()*m_imager.get_sample_count());
|
||||
|
||||
m_iImagerState=103;
|
||||
emit ximeaImageStatus(m_iImagerState);
|
||||
|
||||
emit autoExposeMaxValueOfOneFrame(maxValueOfOneFrame, exposureTime/1000);
|
||||
|
||||
return maxValueOfOneFrame;
|
||||
}
|
||||
|
||||
double XimeaImager::autoExposure()
|
||||
@ -247,6 +271,7 @@ double XimeaImager::autoExposure()
|
||||
m_imager.stop();
|
||||
|
||||
maxValueOfOneFrame=getMaxValueOfOneFrame((short unsigned int*)m_imager.m_image.bp,m_imager.get_band_count()*m_imager.get_sample_count());
|
||||
printf("本帧最大值为: %d.\n",maxValueOfOneFrame);
|
||||
|
||||
if(maxValueOfOneFrame <= suitableMaxValue)
|
||||
{
|
||||
@ -281,6 +306,7 @@ double XimeaImager::autoExposure()
|
||||
|
||||
m_iImagerState=103;
|
||||
emit ximeaImageStatus(m_iImagerState);
|
||||
emit autoExposeMaxValueOfOneFrame(maxValueOfOneFrame, exposureTime/1000);
|
||||
|
||||
std::cout<<"自动曝光完成!"<<std::endl;
|
||||
return exposureTime;
|
||||
@ -438,7 +464,6 @@ int XimeaImager::getMaxValueOfOneFrame(unsigned short * data, int numberOfPixel)
|
||||
int a=0;
|
||||
}
|
||||
}
|
||||
printf("本帧最大值为: %d.\n",maxValue);
|
||||
|
||||
return maxValue;
|
||||
}
|
||||
@ -477,14 +502,20 @@ void XimeaImager::startRecord(double TimeDifferenceBetweensOSAndSbg,QString base
|
||||
|
||||
QString timesFileName=m_baseFileName+".times";
|
||||
FILE *hHimesFile=fopen(timesFileName.toStdString().c_str(),"w+");
|
||||
// ofstream timesFile(timesFileName.toStdString());
|
||||
|
||||
std::cout << "曝光时间为:" << getExposureTime()/1000 << "ms" <<std::endl;
|
||||
|
||||
using namespace std;
|
||||
// ofstream timesFileHandle(timesFileName.toStdString()+"_ofstream");
|
||||
|
||||
writeData2Disk->setParm(q,m_baseFileName,m_iFrameSizeInByte, m_pool, m_rgbImage);
|
||||
int number_WriteDisk = 100;
|
||||
writeData2Disk->setParm(q,m_baseFileName,m_iFrameSizeInByte, number_WriteDisk, m_pool, m_rgbImage);
|
||||
emit startWriteDiskSignal();
|
||||
|
||||
int indexofbuff;
|
||||
DataBuffer * buffer;
|
||||
|
||||
m_imager.start();
|
||||
struct timeval timeStart, timeEnd;
|
||||
double runTime=0;
|
||||
@ -492,6 +523,7 @@ void XimeaImager::startRecord(double TimeDifferenceBetweensOSAndSbg,QString base
|
||||
while (m_bRecordControl)
|
||||
{
|
||||
unsigned short *x=m_imager.get_frame(m_buffer);
|
||||
m_iFrameCounter+=1;
|
||||
|
||||
//fwrite(m_buffer,2,getBandCount()*getSampleCount(),hFile);
|
||||
// fwrite(m_imager.m_image.bp,static_cast<int>(m_imager.m_image.bp_size),1,hFile);
|
||||
@ -499,56 +531,66 @@ void XimeaImager::startRecord(double TimeDifferenceBetweensOSAndSbg,QString base
|
||||
//sync();//强制系统将系统文件缓冲的内容写入磁盘
|
||||
|
||||
|
||||
indexofbuff = m_iFrameCounter % number_WriteDisk;
|
||||
|
||||
if (indexofbuff == 1)
|
||||
{
|
||||
r_qtx.lock();
|
||||
DataBuffer * buffer = m_pool->newElement();
|
||||
buffer = m_pool->newElement();
|
||||
r_qtx.unlock();
|
||||
// m_pool->construct(buffer);
|
||||
}
|
||||
|
||||
// memcpy(buffer->data,(unsigned short *)m_imager.m_image.bp,m_iFrameSizeInByte/2);
|
||||
memcpy((void *)buffer->data,m_imager.m_image.bp,m_iFrameSizeInByte);
|
||||
if (indexofbuff == 0)
|
||||
{
|
||||
memcpy((void *)buffer->data + (number_WriteDisk - 1) * m_iFrameSizeInByte,m_imager.m_image.bp,m_iFrameSizeInByte);
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy((void *)buffer->data + (indexofbuff - 1) * m_iFrameSizeInByte,m_imager.m_image.bp,m_iFrameSizeInByte);
|
||||
}
|
||||
|
||||
if (indexofbuff == 0)
|
||||
{
|
||||
r_qtx.lock();
|
||||
q->push(buffer);
|
||||
r_qtx.unlock();//
|
||||
|
||||
// std::cout<<"XimeaImager::startRecord,队列长度为:"<< q->size() <<std::endl;//
|
||||
|
||||
// fwrite(buffer,1,m_iFrameSizeInByte,hFile);
|
||||
|
||||
m_iFrameCounter+=1;
|
||||
r_qtx.unlock();
|
||||
}
|
||||
|
||||
double sbgTime=getSbgTime(TimeDifferenceBetweensOSAndSbg);
|
||||
|
||||
fprintf(hHimesFile,"%f\n",sbgTime);
|
||||
// fwrite(&sbgTime,sizeof(double),1,hHimesFile);
|
||||
// timesFile<<sbgTime<< "\n";
|
||||
|
||||
// timesFileHandle << sbgTime << "\n";
|
||||
// std::cout<<"XimeaImager::startRecord---std::cout: "<<sbgTime<<std::endl;
|
||||
|
||||
// unsigned char pixel = *(unsigned char*)image.bp;//Default value: XI_MONO8
|
||||
// unsigned short pixel =*(unsigned short*)image.bp;//XI_RAW16
|
||||
// printf("Image %d (%dx%d) received from camera. First pixel value: %d\n", m_iFrameCounter, (int)image.width, (int)image.height, pixel);
|
||||
}
|
||||
gettimeofday(&timeEnd, NULL);
|
||||
runTime = (timeEnd.tv_sec - timeStart.tv_sec ) + (double)(timeEnd.tv_usec -timeStart.tv_usec)/1000000;
|
||||
m_imager.stop();
|
||||
|
||||
double frameInTheory=runTime * getFramerate();
|
||||
double frameLossed=frameInTheory - m_iFrameCounter;
|
||||
double frameLossRate=frameLossed / frameInTheory;
|
||||
m_iFrameCounter = m_iFrameCounter - indexofbuff;
|
||||
if (indexofbuff != 0)
|
||||
{
|
||||
m_pool->deleteElement(buffer);
|
||||
}
|
||||
|
||||
double frameInTheory=runTime * getFramerate() - indexofbuff;
|
||||
|
||||
double frameLossed=m_imager.m_image.acq_nframe - indexofbuff - m_iFrameCounter;
|
||||
double frameLossRate=frameLossed / (m_imager.m_image.acq_nframe - indexofbuff);
|
||||
|
||||
std::cout<<"当前采集文件为: "<<baseFileName.toStdString()<<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<<"理论采集帧数为: "<<m_imager.m_image.acq_nframe - indexofbuff<<std::endl;
|
||||
std::cout<<"实际采集帧数为:"<<m_iFrameCounter<<std::endl;
|
||||
std::cout<<"丢失帧数为: "<<frameLossed<<std::endl;
|
||||
std::cout<<"丢帧率为: "<<frameLossRate * 100<< "%" <<std::endl;
|
||||
|
||||
fclose(hHimesFile);
|
||||
// timesFileHandle.close();
|
||||
// timesFile.close();
|
||||
|
||||
timeStr = formatTimeStr(timeFormat);
|
||||
printf("停止采集:%s!\n", timeStr.toStdString().c_str());
|
||||
@ -688,6 +730,18 @@ void XimeaImager::processXiApiErrorCodes(int xiApiErrorCodes)
|
||||
m_iImagerState=xiApiErrorCodes;
|
||||
emit ximeaImageStatus(m_iImagerState);
|
||||
|
||||
break;
|
||||
case 10:
|
||||
std::cout<<"XimeaImager::processXiApiErrorCodes-----------:Timeout!"<<std::endl;
|
||||
m_iImagerState=xiApiErrorCodes;
|
||||
emit ximeaImageStatus(m_iImagerState);
|
||||
|
||||
break;
|
||||
case 11:
|
||||
std::cout<<"XimeaImager::processXiApiErrorCodes-----------:Invalid arguments supplied!"<<std::endl;
|
||||
m_iImagerState=xiApiErrorCodes;
|
||||
emit ximeaImageStatus(m_iImagerState);
|
||||
|
||||
break;
|
||||
case 12:
|
||||
std::cout<<"XimeaImager::processXiApiErrorCodes-----------:Not supported!"<<std::endl;
|
||||
@ -714,20 +768,26 @@ void XimeaImager::processXiApiErrorCodes(int xiApiErrorCodes)
|
||||
|
||||
break;
|
||||
default:
|
||||
QString ximeaError="ximeaError.txt";
|
||||
ofstream ximeaErrorFile(ximeaError.toStdString().c_str(),ios::app);
|
||||
|
||||
ximeaErrorFile<< xiApiErrorCodes << "\n";
|
||||
std::cout<<"XimeaImager::processXiApiErrorCodes-----------:未处理ximea异常代码:"<< xiApiErrorCodes <<std::endl;
|
||||
|
||||
ximeaErrorFile.close();
|
||||
|
||||
|
||||
|
||||
m_iImagerState=99;
|
||||
emit ximeaImageStatus(m_iImagerState);
|
||||
break;
|
||||
}
|
||||
|
||||
writeXiApiErrorCodes("/media/nvme/300TC/ximeaError.txt", xiApiErrorCodes);
|
||||
}
|
||||
|
||||
void XimeaImager::writeXiApiErrorCodes(QString filePath, int xiApiErrorCodes)
|
||||
{
|
||||
ofstream ximeaErrorFile(filePath.toStdString().c_str(),ios::app);
|
||||
|
||||
char * timeFormat="%Y%m%d_%H%M%S";
|
||||
QString timeStr = formatTimeStr(timeFormat);
|
||||
|
||||
ximeaErrorFile<< timeStr.toStdString().c_str() << ": " << xiApiErrorCodes << "\n";
|
||||
|
||||
std::cout<<"XimeaImager::writeXiApiErrorCodes-----------:xiApiErrorCodes: "<<timeStr.toStdString().c_str()<< ": " << xiApiErrorCodes<<std::endl;
|
||||
|
||||
ximeaErrorFile.close();
|
||||
}
|
||||
|
||||
void XimeaImager::stopRecord()
|
||||
@ -796,7 +856,7 @@ void WriteData2Disk::write2Disk()
|
||||
|
||||
int sleepCounters=1;
|
||||
int frameCounter = 0;
|
||||
unsigned short * dataBuffer = new unsigned short[m_iFrameSizeInByte/2];
|
||||
unsigned short * dataBuffer = new unsigned short[m_iFrameSizeInByte/2*m_iNumber_WriteDisk];
|
||||
while(true)
|
||||
{
|
||||
r_qtx.lock();
|
||||
@ -804,7 +864,7 @@ void WriteData2Disk::write2Disk()
|
||||
r_qtx.unlock();
|
||||
if(bempty)
|
||||
{
|
||||
QThread::msleep(sleepCounters * sleepCounters * 10);
|
||||
QThread::msleep(sleepCounters * sleepCounters * m_iNumber_WriteDisk);
|
||||
// std::cout<<"WriteData2Disk::write2Disk-----------------------队列第几次为空:" << sleepCounters <<std::endl;
|
||||
sleepCounters++;
|
||||
|
||||
@ -820,31 +880,33 @@ void WriteData2Disk::write2Disk()
|
||||
|
||||
r_qtx.lock();
|
||||
DataBuffer * buffer = m_q->front();
|
||||
memcpy(dataBuffer,buffer->data,m_iFrameSizeInByte);
|
||||
memcpy(dataBuffer,buffer->data,m_iFrameSizeInByte*m_iNumber_WriteDisk);
|
||||
// m_pool->destroy(m_q->front());
|
||||
m_pool->deleteElement(buffer);
|
||||
m_q->pop();
|
||||
r_qtx.unlock();
|
||||
|
||||
//构造rgb图像,用于推流到m300遥控器
|
||||
m_rgbImage->FillRgbImage(dataBuffer);
|
||||
// m_rgbImage->FillRgbImage(dataBuffer);
|
||||
|
||||
|
||||
// std::cout<<"WriteData2Disk::write2Disk-----------------------正在写磁盘!" << m_pool->max_size() <<std::endl;//
|
||||
fwrite(dataBuffer,1,m_iFrameSizeInByte, hFile);
|
||||
fwrite(dataBuffer,1,m_iFrameSizeInByte*m_iNumber_WriteDisk, hFile);
|
||||
frameCounter++;
|
||||
}
|
||||
m_rgbImage->m_VideoWriter.release();
|
||||
fclose(hFile);
|
||||
|
||||
std::cout<<"WriteData2Disk::write2Disk-----------------------写磁盘线程将退出,内存池可达到的最多元素数:" << m_pool->max_size() <<std::endl;
|
||||
std::cout<<"WriteData2Disk::write2Disk-----------------------写磁盘线程将退出,共写帧数:" << frameCounter <<std::endl;
|
||||
std::cout<<"WriteData2Disk::write2Disk-----------------------写磁盘线程将退出,共写帧数:" << frameCounter*m_iNumber_WriteDisk <<std::endl;
|
||||
}
|
||||
|
||||
void WriteData2Disk::setParm(queue<DataBuffer *> * q, QString baseFileName, int frameSizeInByte, MemoryPool<DataBuffer> * pool, rgbImage * rgbImage)
|
||||
void WriteData2Disk::setParm(queue<DataBuffer *> * q, QString baseFileName, int frameSizeInByte, int number_WriteDisk, MemoryPool<DataBuffer> * pool, rgbImage * rgbImage)
|
||||
{
|
||||
m_q = q;
|
||||
m_QbaseFileName = baseFileName;
|
||||
m_iFrameSizeInByte = frameSizeInByte;
|
||||
m_iNumber_WriteDisk = number_WriteDisk;
|
||||
|
||||
m_pool = pool;
|
||||
|
||||
|
Reference in New Issue
Block a user