Files
ximeaAirborneSystem/Source_Files/utility_tc.cpp
tangchao0503 447a1aafb1 1. 最大曝光时间乘以0.95,目的:避免曝光时间超过最大,而造成帧率降低;
2. 去掉多余的std::out,避免采集log过于杂乱;
3. 通过OpenCV从高光谱影像中提取rgb影像;
4. 在log中记录开始采集时间和停止采集时间;
5. 添加手动设置曝光时间的功能:127.0.0.1 7,2;
6. 头文件中写入仪器序列号;
2023-03-19 16:44:12 +08:00

91 lines
2.4 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "Header_Files/utility_tc.h"
#include <QDir>
QString formatTimeStr(char * format)
{
//获取系统时间
time_t timer;//time_t就是long int 类型
struct tm *tblock;
timer = time(NULL);//返回秒数(精度为秒)从1970-1-1,00:00:00 可以当成整型输出或用于其它函数
tblock = localtime(&timer);
//printf("Local time is: %s\n", asctime(tblock));
//格式化时间为需要的格式
char timeStr_tmp[256] = { 0 };
strftime(timeStr_tmp, sizeof(timeStr_tmp), format, tblock);//
QString timeStr2(timeStr_tmp);
// qDebug() << "time is:" << timeStr2;
return timeStr2;
}
QString getFileNameBaseOnTime()
{
using namespace std;
//获取系统时间
time_t timer;//time_t就是long int 类型
struct tm *tblock;
timer = time(NULL);//返回秒数(精度为秒)从1970-1-1,00:00:00 可以当成整型输出或用于其它函数
tblock = localtime(&timer);
//printf("Local time is: %s\n", asctime(tblock));
//格式化时间为需要的格式
char fileNameTmp[256] = { 0 };
char dirNameTmp[256] = { 0 };
strftime(fileNameTmp, sizeof(fileNameTmp), "%Y%m%d_%H%M%S", tblock);
strftime(dirNameTmp, sizeof(dirNameTmp), "%Y%m%d", tblock);
QString fileName(fileNameTmp);
QString dirName(dirNameTmp);
// QString fileName=QString::number(tblock->tm_year+1900)+QString::number(tblock->tm_mon+1)+QString::number(tblock->tm_mday)+"_"+QString::number(tblock->tm_hour)+QString::number(tblock->tm_min);//
//设置文件绝对路径
QDir path("/media/nvme");
if(!path.exists(dirName))
{
path.mkdir(dirName);
}
path.cd(dirName);
QString absoluteFilePath=path.path()+"/"+fileName;
// printf("absoluteFilePath is: %s\n", absoluteFilePath.c_str());
// qDebug() << "absoluteFilePath is:" << absoluteFilePath;
return absoluteFilePath;
}
void bubbleSort(unsigned short * a, int n)
{
// //排序实现1
// for(int i=0;i<numberOfPixel;i++)
// for(int j=1;j<numberOfPixel-i;j++)
// if(a[j-1]>a[j])
// swap(a+j-1,a+j);
//排序实现2
int j,k,flag;
flag = n;
while(flag>0)
{
k=flag;
flag=0;
for(j=1;j<k;j++)
if(a[j-1]>a[j])
{
swap(a+j-1,a+j);
flag=j;
}
}
}
void swap(unsigned short * a, unsigned short * b)
{
int tmp;
tmp=*a;
*a=*b;
*b=tmp;
}