增加选择配置文件路径、存图路径的功能;

修改清理图片功能,不再清除ng文件夹只清除ALL文件夹。
main
seiyu 1 year ago
parent 805cdc855c
commit 9fc16465ed

@ -2,11 +2,11 @@
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup /> <PropertyGroup />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<QTDIR>C:\Qt\5.15.2\msvc2019_64</QTDIR> <QTDIR>D:\Qt\5.15.2\msvc2019_64</QTDIR>
<LocalDebuggerEnvironment>PATH=$(QTDIR)\bin%3bD:\Qt\5.15.2\msvc2019_64\bin%3b$(PATH)</LocalDebuggerEnvironment> <LocalDebuggerEnvironment>PATH=$(QTDIR)\bin%3bD:\Qt\5.15.2\msvc2019_64\bin%3b$(PATH)</LocalDebuggerEnvironment>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<QTDIR>C:\Qt\5.15.2\msvc2019_64</QTDIR> <QTDIR>D:\Qt\5.15.2\msvc2019_64</QTDIR>
<LocalDebuggerEnvironment>PATH=$(QTDIR)\bin%3bD:\Qt\5.15.2\msvc2019_64\bin%3b$(PATH)</LocalDebuggerEnvironment> <LocalDebuggerEnvironment>PATH=$(QTDIR)\bin%3bD:\Qt\5.15.2\msvc2019_64\bin%3b$(PATH)</LocalDebuggerEnvironment>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

@ -8,6 +8,8 @@
#include <QIntValidator> #include <QIntValidator>
#include "common.h"/// #include "common.h"///
extern SysConf g_sys_conf;/// extern SysConf g_sys_conf;///
extern ConfPath g_conf_path;
CleanWorkThread::CleanWorkThread(QObject* parent) : QObject(parent) CleanWorkThread::CleanWorkThread(QObject* parent) : QObject(parent)
{ {
} }
@ -34,11 +36,20 @@ void CleanWorkThread::doWork()
{ {
qint64 spaceSize; qint64 spaceSize;
qint64 dirSize; qint64 dirSize;
QString iDriver = "D:/"; QString dirPath = g_conf_path.save_pics_path;
//QString iDriver = "D:/";
char drive[_MAX_DRIVE];
char dir_1[_MAX_DIR];
char fname[_MAX_FNAME];
char ext[_MAX_EXT];
_splitpath(dirPath.toStdString().c_str(), drive, dir_1, fname, ext);
QString iDriver = drive + QString("/");
LPCWSTR strDriver = (LPCWSTR)iDriver.utf16(); LPCWSTR strDriver = (LPCWSTR)iDriver.utf16();
ULARGE_INTEGER freeDiskSpaceAvailable, totalDiskSpace, totalFreeDiskSpace; ULARGE_INTEGER freeDiskSpaceAvailable, totalDiskSpace, totalFreeDiskSpace;
qint64 gb = (1024 * 1024 * 1024); qint64 gb = (1024 * 1024 * 1024);
QString dir("D:/image"); //QString dir("D:/image");
QString dir(g_conf_path.save_pics_path + "/ALL");
if (delSelection == 2) if (delSelection == 2)
{ {
@ -53,8 +64,8 @@ void CleanWorkThread::doWork()
GetDiskFreeSpaceEx(strDriver, &freeDiskSpaceAvailable, &totalDiskSpace, &totalFreeDiskSpace); GetDiskFreeSpaceEx(strDriver, &freeDiskSpaceAvailable, &totalDiskSpace, &totalFreeDiskSpace);
spaceSize = ((qint64)totalFreeDiskSpace.QuadPart * (100/freeSize)) / (qint64)totalDiskSpace.QuadPart; spaceSize = ((qint64)totalFreeDiskSpace.QuadPart * (100/freeSize)) / (qint64)totalDiskSpace.QuadPart;
dirSize = DirFileSize(dir) / gb; dirSize = DirFileSize(dir) / gb;
delDays = g_sys_conf.save_days;
while ((spaceSize < 1) && (delDays > 1)) { //磁盘剩余空间小于百分之十 while ((spaceSize < 1) && (delDays >= 0)) { //磁盘剩余空间小于百分之十
CleanImageFile(dir, delDays--); CleanImageFile(dir, delDays--);
GetDiskFreeSpaceEx(strDriver, &freeDiskSpaceAvailable, &totalDiskSpace, &totalFreeDiskSpace); GetDiskFreeSpaceEx(strDriver, &freeDiskSpaceAvailable, &totalDiskSpace, &totalFreeDiskSpace);
spaceSize = ((qint64)totalFreeDiskSpace.QuadPart * (100 / freeSize)) / (qint64)totalDiskSpace.QuadPart; spaceSize = ((qint64)totalFreeDiskSpace.QuadPart * (100 / freeSize)) / (qint64)totalDiskSpace.QuadPart;

@ -50,8 +50,8 @@ bool AlgJd::init(QString model_path, QString model_name)
//cv::Mat image = cv::imread("alg_jd.bmp"); //cv::Mat image = cv::imread("alg_jd.bmp");
cv::Mat image; cv::Mat image;
if (g_sys_conf.jpg_path.length() > 0) { if (g_sys_conf.model_jpg_path.length() > 0) {
image = cv::imread(g_sys_conf.jpg_path.toStdString()); image = cv::imread(g_sys_conf.model_jpg_path.toStdString());
} }
else { else {
image = cv::imread("D:/Release/alg_jd.bmp"); image = cv::imread("D:/Release/alg_jd.bmp");

@ -6,6 +6,7 @@
#include <PLCDevice.h> #include <PLCDevice.h>
#include <QtCore\qcryptographichash.h> #include <QtCore\qcryptographichash.h>
#include <QtCore\qprocess.h> #include <QtCore\qprocess.h>
#include <filesystem>
#include "exportData.h" #include "exportData.h"
int g_op_time; //操作员权限时长默认300秒 int g_op_time; //操作员权限时长默认300秒
@ -16,8 +17,10 @@ bool isNeedRotate[NumberOfSupportedCameras];
DisplayLabelConf g_display_label_conf[NumberOfSupportedCameras]; DisplayLabelConf g_display_label_conf[NumberOfSupportedCameras];
ConfPath g_conf_path;
SysConf g_sys_conf; //系统配置参数 SysConf g_sys_conf; //系统配置参数
ModbusConf g_modbus_conf; //modbus地址参数 ModbusConf g_modbus_conf; //modbus地址参数
PLCDevice * m_PLCDevice; PLCDevice * m_PLCDevice;
bool g_plc_dialog_open; //是否打开plc配置对话框 bool g_plc_dialog_open; //是否打开plc配置对话框
@ -99,6 +102,29 @@ Cigarette::Cigarette(QWidget *parent)
{ {
ui.setupUi(this); ui.setupUi(this);
InitPtrMat(); InitPtrMat();
read_conf(g_conf_path);
if (!g_conf_path.config_path.isEmpty()) {
// 如果非空
QDir* dirinfo = new QDir(g_conf_path.config_path);
if (!dirinfo->exists()) {
// 如果文件夹信息不存在
delete dirinfo, dirinfo = nullptr;
g_conf_path.config_path = "D:/conf";
g_conf_path.config_name = "conf.txt";
}
if (g_conf_path.config_name.isEmpty()) {
g_conf_path.config_name = "conf.txt";
}
delete dirinfo, dirinfo = nullptr;
}
else {
// 如果路径空
g_conf_path.config_path = "D:/conf";
if (g_conf_path.config_name.isEmpty())
g_conf_path.config_name = "conf.txt";
}
bool update_rotate = false; bool update_rotate = false;
if (!read_rotate_message()) { if (!read_rotate_message()) {
update_rotate = true; update_rotate = true;
@ -201,7 +227,13 @@ Cigarette::Cigarette(QWidget *parent)
quantity_stop_count = 0; quantity_stop_count = 0;
g_seconds = 0; g_seconds = 0;
read_sys_config(g_sys_conf); //łőĘźťŻĎľÍłĹäÖĂ QString config_path;
if (g_conf_path.config_path.isEmpty() || g_conf_path.config_name.isEmpty()) {
g_conf_path.config_path = "D:/conf";
g_conf_path.config_name = "conf.txt";
}
config_path = g_conf_path.config_path + "/" + g_conf_path.config_name;
read_sys_config(g_sys_conf, config_path); //初始化系统配置
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>0) #if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>0)
g_modbus_conf.kick1 = 0; //1#通道剔除个数地址 g_modbus_conf.kick1 = 0; //1#通道剔除个数地址
@ -741,6 +773,7 @@ void Cigarette::on_btn_setup_released()
dialog_setup->setModal(true); dialog_setup->setModal(true);
dialog_setup->show(); dialog_setup->show();
dialog_setup->move((this->width() - dialog_setup->width()) / 2, (this->height() - dialog_setup->height()) / 2); dialog_setup->move((this->width() - dialog_setup->width()) / 2, (this->height() - dialog_setup->height()) / 2);
} }
else { else {
QMessageBox::information(NULL, QStringLiteral("权限检查"), QStringLiteral("请先点击解锁按钮,进入管理员模式"), QMessageBox::Ok); QMessageBox::information(NULL, QStringLiteral("权限检查"), QStringLiteral("请先点击解锁按钮,进入管理员模式"), QMessageBox::Ok);
@ -983,7 +1016,7 @@ void Cigarette::OnKey(QKeyEvent* event)
char buf[256]; char buf[256];
memset(buf, 0, 256); memset(buf, 0, 256);
sprintf(buf, SELECT_RECTS_FILE, Num,Cnt); sprintf(buf, SELECT_RECTS_FILE, Num,Cnt);
cfg_file.open(buf, ios::trunc | ofstream::out); cfg_file.open(g_conf_path.config_path.toStdString() + "/" + buf, ios::trunc | ofstream::out);
if (!cfg_file.is_open()) if (!cfg_file.is_open())
{ {
std::cout << "Error: Open config file SelectRects.txt" << std::endl; std::cout << "Error: Open config file SelectRects.txt" << std::endl;
@ -1130,7 +1163,7 @@ void Cigarette::DrawRect_init(int Num_Cnt) {
char buf[256]; char buf[256];
memset(buf, 0, 256); memset(buf, 0, 256);
sprintf(buf, SELECT_RECTS_FILE, Num, Cnt); sprintf(buf, SELECT_RECTS_FILE, Num, Cnt);
cfg_file.open(buf); cfg_file.open(g_conf_path.config_path.toStdString() + "/" + buf);
if (!cfg_file.is_open()) if (!cfg_file.is_open())
{ {
std::cout << "Error: Open config file SelectRects"<<Num<<Cnt<<".txt" << std::endl; std::cout << "Error: Open config file SelectRects"<<Num<<Cnt<<".txt" << std::endl;
@ -1176,7 +1209,7 @@ void Cigarette::OnTPClickHub(int Num_Cnt)
char buf[256]; char buf[256];
memset(buf, 0, 256); memset(buf, 0, 256);
sprintf(buf, SELECT_RECTS_FILE, Num, Cnt); sprintf(buf, SELECT_RECTS_FILE, Num, Cnt);
cfg_file.open(buf); cfg_file.open(g_conf_path.config_path.toStdString() + "/" + buf);
if (!cfg_file.is_open()) if (!cfg_file.is_open())
{ {
std::cout << "Error: Open config file SelectRects.txt" << std::endl; std::cout << "Error: Open config file SelectRects.txt" << std::endl;
@ -1205,8 +1238,11 @@ void Cigarette::OnDBClickNGHub(int Num)
emit sengMsgToClog("Double click NG."); emit sengMsgToClog("Double click NG.");
QDateTime now_ts = QDateTime::currentDateTime(); QDateTime now_ts = QDateTime::currentDateTime();
std::ostringstream ostr; std::ostringstream ostr;
ostr << "explorer D:\\image\\" << (now_ts.toString("yyyy-MM-dd")).toStdString()<< "\\" << Num+1 << "\\ng_result"; std::string file_path = g_conf_path.save_pics_path.toStdString();
std::replace(file_path.begin(), file_path.end(), '/', '\\');
ostr << "explorer "<< file_path << "\\ng\\" << (now_ts.toString("yyyy-MM-dd")).toStdString()<< "\\" << Num+1 << "\\" << 1;
std::string str = ostr.str(); std::string str = ostr.str();
std::cout << "===>" << str << std::endl;
system(str.c_str()); system(str.c_str());
} }
@ -2281,13 +2317,42 @@ QString Cigarette::read_op_pswd()
cfg_file.close(); cfg_file.close();
} }
bool Cigarette::read_sys_config(SysConf &conf) bool Cigarette::read_conf(ConfPath &conf_path) {
std::fstream conf_file;
conf_file.open(CONFPATH);
if (!conf_file.is_open()) {
std::cout << "Error: Open conf path file " << CONFPATH << std::endl;
return false;
}
while (!conf_file.eof()) {
char tmp[256] = "";
conf_file.getline(tmp, 256);
std::string line(tmp);
if (line.length() > 0) {
size_t pos = line.find('=');
std::string tmp_key = line.substr(0, pos);
if (tmp_key == "CONF_PATH") {
conf_path.config_path = line.substr(pos + 1).c_str();
}
else if (tmp_key == "CONF_NAME") {
conf_path.config_name = line.substr(pos + 1).c_str();
}
else if (tmp_key == "SAVE_PICS_PATH") {
conf_path.save_pics_path = line.substr(pos + 1).c_str();
}
}
}
conf_file.close();
return true;
}
bool Cigarette::read_sys_config(SysConf &conf, QString conf_path)
{ {
std::fstream cfg_file; std::fstream cfg_file;
cfg_file.open(CONFIGURE_FILE); cfg_file.open(conf_path.toStdString());
if (!cfg_file.is_open()) if (!cfg_file.is_open())
{ {
std::cout << "Error: Open config file " << CONFIGURE_FILE << std::endl; std::cout << "Error: Open config file " << conf_path.toStdString() << std::endl;
return false; return false;
} }
while (!cfg_file.eof()) while (!cfg_file.eof())
@ -2383,7 +2448,7 @@ bool Cigarette::read_sys_config(SysConf &conf)
} }
else if (tmp_key == "JPGPATH") else if (tmp_key == "JPGPATH")
{ {
conf.jpg_path = line.substr(pos + 1).c_str(); conf.model_jpg_path = line.substr(pos + 1).c_str();
} }
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>0) #if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>0)
else if (tmp_key == "EXPO1") else if (tmp_key == "EXPO1")
@ -2670,7 +2735,7 @@ bool Cigarette::read_sys_config(SysConf &conf)
bool Cigarette::read_modbus_config(ModbusConf &conf) bool Cigarette::read_modbus_config(ModbusConf &conf)
{ {
std::fstream cfg_file; std::fstream cfg_file;
cfg_file.open(MODBUS_CONFIGURE_FILE); cfg_file.open(g_conf_path.config_path.toStdString() + "/" + MODBUS_CONFIGURE_FILE);
if (!cfg_file.is_open()) if (!cfg_file.is_open())
{ {
std::cout << "Error: Open config file " << MODBUS_CONFIGURE_FILE << std::endl; std::cout << "Error: Open config file " << MODBUS_CONFIGURE_FILE << std::endl;
@ -2775,7 +2840,8 @@ bool Cigarette::read_modbus_config(ModbusConf &conf)
bool Cigarette::read_rotate_message() bool Cigarette::read_rotate_message()
{ {
std::fstream cfg_file; std::fstream cfg_file;
cfg_file.open(ROTATE_FILE); QString rotate_file = g_conf_path.config_path + "/" + ROTATE_FILE;
cfg_file.open(rotate_file.toStdString());
if (!cfg_file.is_open()) if (!cfg_file.is_open())
{ {
std::cout << "Error: Open config file rotate.txt" << std::endl; std::cout << "Error: Open config file rotate.txt" << std::endl;
@ -2811,7 +2877,8 @@ bool Cigarette::read_rotate_message()
bool Cigarette::save_rotate_message() bool Cigarette::save_rotate_message()
{ {
std::fstream cfg_file; std::fstream cfg_file;
cfg_file.open(ROTATE_FILE, ios::trunc | ofstream::out); QString rotate_file = g_conf_path.config_path + "/" + ROTATE_FILE;
cfg_file.open(rotate_file.toStdString(), ios::trunc | ofstream::out);
if (!cfg_file.is_open()) if (!cfg_file.is_open())
{ {
std::cout << "Error: Open config file rotate.txt" << std::endl; std::cout << "Error: Open config file rotate.txt" << std::endl;
@ -2893,7 +2960,7 @@ QImage Cigarette::cvMatToQImage(const cv::Mat& mat)
void Cigarette::read_plc_items() void Cigarette::read_plc_items()
{ {
std::fstream cfg_file; std::fstream cfg_file;
cfg_file.open(PLC_CONFIG_FILE); cfg_file.open(g_conf_path.config_path.toStdString() + "/" + PLC_CONFIG_FILE);
if (!cfg_file.is_open()) if (!cfg_file.is_open())
{ {
std::cout << "Error: Open production file " << PLC_CONFIG_FILE << std::endl; std::cout << "Error: Open production file " << PLC_CONFIG_FILE << std::endl;
@ -3736,9 +3803,14 @@ void Cigarette::record_output_statistic(qint64 quantity, int Kick[NumberOfSuppor
{ {
if (SingleCamInfo[i].IsOpen && quantity > 0) { if (SingleCamInfo[i].IsOpen && quantity > 0) {
std::fstream cfg_file; std::fstream cfg_file;
char str[256];
memset(str, 0, 256);
sprintf(str, STATISTIC_FILE, i);
char buf[256]; char buf[256];
memset(buf, 0, 256); memset(buf, 0, 256);
sprintf(buf, STATISTIC_FILE, i); sprintf(buf, "%s/%s", g_conf_path.config_path, str);
std::cout<<"===buf>"<<buf<<std::endl;
cfg_file.open(buf, std::ios::app); cfg_file.open(buf, std::ios::app);
if (cfg_file.good()) if (cfg_file.good())
{ {
@ -3941,7 +4013,7 @@ void Cigarette::recMsgFromUdp(QString data)
} }
else if (data == "GETCONF") else if (data == "GETCONF")
{ {
sThread.sendFile(CONFIGURE_FILE,g_sys_conf.FilePort); sThread.sendFile(g_conf_path.config_path, g_sys_conf.FilePort);
for(int i=0;i<NumberOfSupportedCameras;i++) for(int i=0;i<NumberOfSupportedCameras;i++)
{ {
char buf[256]; char buf[256];

@ -62,7 +62,8 @@ public:
QString read_pswd(); QString read_pswd();
QString read_op_pswd(); QString read_op_pswd();
bool read_sys_config(SysConf &conf); bool read_conf(ConfPath &conf_path);
bool read_sys_config(SysConf &conf, QString conf_path);
bool read_modbus_config(ModbusConf &conf); bool read_modbus_config(ModbusConf &conf);
void read_plc_items(); void read_plc_items();
bool save_rotate_message(); bool save_rotate_message();

@ -34,13 +34,14 @@
#endif #endif
// 主界面基本参数配置文件 // 主界面基本参数配置文件
#define CONFIGURE_FILE "D:/conf/conf.txt" #define CONFPATH "conf_path.txt"
//#define CONFIGURE_FILE "D:/conf/conf.txt"
// 相机旋转角度配置文件 // 相机旋转角度配置文件
#define ROTATE_FILE "D:/conf/rotate.txt" #define ROTATE_FILE "rotate.txt"
#define MODBUS_CONFIGURE_FILE "D:/conf/modbus.txt" #define MODBUS_CONFIGURE_FILE "modbus.txt"
#define PLC_CONFIG_FILE "D:/conf/plc.txt" #define PLC_CONFIG_FILE "plc.txt"
#define SELECT_RECTS_FILE "D:/conf/SelectRects%d%d.txt" #define SELECT_RECTS_FILE "SelectRects%d%d.txt"
#define STATISTIC_FILE "D:/conf/camera%d_statistic.txt" #define STATISTIC_FILE "camera%1_statistic.txt"
#define ALARM_RECORD_FILE "alarm.txt" #define ALARM_RECORD_FILE "alarm.txt"
#define OUTPUT_HIGH_WIDTH 20000 //输出信号的脉冲宽度,微秒 #define OUTPUT_HIGH_WIDTH 20000 //输出信号的脉冲宽度,微秒
@ -57,6 +58,19 @@ void getFiles(std::string path, std::vector<std::string>& files);
std::string SelectDirBRI(); std::string SelectDirBRI();
std::string SelectFileOFN(); std::string SelectFileOFN();
std::string SelectDirIFD(); std::string SelectDirIFD();
class ConfPath {
public:
QString config_path; // 配置文件路径
QString config_name; // 配置文件名
QString save_pics_path; // 保存图片存储路径
ConfPath(){
config_path = "";
config_name = "";
save_pics_path = "";
}
};
class SysConf class SysConf
{ {
public: public:
@ -77,7 +91,7 @@ public:
QString location; // 所在地 QString location; // 所在地
QString model_path; // 模型文件夹路径 QString model_path; // 模型文件夹路径
QString model_name; // 模型名 QString model_name; // 模型名
QString jpg_path; // ͼƬ·¾¶ QString model_jpg_path; // 模型图片路径
int timing_shift; //是否定时换班0否1是 int timing_shift; //是否定时换班0否1是
int expo[NumberOfSupportedCameras]; //相机曝光时间,单位微秒 int expo[NumberOfSupportedCameras]; //相机曝光时间,单位微秒
int gain[NumberOfSupportedCameras]; //相机模拟增益范围0~64 int gain[NumberOfSupportedCameras]; //相机模拟增益范围0~64
@ -110,7 +124,7 @@ public:
location = ""; location = "";
model_path = ""; model_path = "";
model_name = ""; model_name = "";
jpg_path = ""; model_jpg_path = "";
shiftA.setHMS(0, 0, 0); shiftA.setHMS(0, 0, 0);
shiftB.setHMS(0, 0, 0); shiftB.setHMS(0, 0, 0);
shiftC.setHMS(0, 0, 0); shiftC.setHMS(0, 0, 0);

@ -16,6 +16,7 @@
#include <QThread> #include <QThread>
#include "Cleanthread.h" #include "Cleanthread.h"
extern ConfPath g_conf_path;
extern SysConf g_sys_conf; //系统配置参数 extern SysConf g_sys_conf; //系统配置参数
extern QString g_admin_pswd; //管理员密码 extern QString g_admin_pswd; //管理员密码
extern QString g_op_pswd; //操作员密码 extern QString g_op_pswd; //操作员密码
@ -28,7 +29,7 @@ void task_osk()
DialogSetup::DialogSetup(QWidget * parent) : QDialog(parent) { DialogSetup::DialogSetup(QWidget * parent) : QDialog(parent) {
ui.setupUi(this); ui.setupUi(this);
InitPtrMat(); InitPtrMat();
//this->setWindowFlags(Qt::FramelessWindowHint);//窗口可移动 this->setWindowFlags(Qt::FramelessWindowHint);//窗口可移动
for(int i=0;i<NumberOfSupportedCameras;i++) for(int i=0;i<NumberOfSupportedCameras;i++)
{ {
@ -55,6 +56,39 @@ DialogSetup::DialogSetup(QWidget * parent) : QDialog(parent) {
ui.checkBox_auto_work->setChecked(false); ui.checkBox_auto_work->setChecked(false);
} }
if (!g_conf_path.config_path.isEmpty()) {
QDir* dirinfo = new QDir(g_conf_path.config_path);
if (!dirinfo->exists())
delete dirinfo, dirinfo = nullptr;
dirinfo->setNameFilters(QStringList("*.txt"));
QStringList fileList = dirinfo->entryList(QDir::Files);
fileList.removeOne(".");
fileList.removeOne("..");
ui.comboBox_config_path->clear();
ui.comboBox_config_path->addItems(fileList);
if (!g_conf_path.config_name.isEmpty())
ui.comboBox_config_path->setCurrentText(g_conf_path.config_name);
else {
g_conf_path.config_name = "conf.txt";
ui.comboBox_config_path->setCurrentText(g_conf_path.config_name);
}
// 更换选择文件
connect(ui.comboBox_config_path, SIGNAL(currentIndexChanged(int)), this, SLOT(onComboBoxConfSelect(int)));
delete dirinfo, dirinfo = nullptr;
}
else {
// 如果路径空
g_conf_path.config_path = "D:/conf";
if (!g_conf_path.config_name.isEmpty()) {
ui.comboBox_model_path->setCurrentText(g_conf_path.config_name);
}
else {
g_conf_path.config_name = "conf.txt";
ui.comboBox_model_path->addItem(g_conf_path.config_name);
}
}
if (!g_sys_conf.model_path.isEmpty()) { if (!g_sys_conf.model_path.isEmpty()) {
// 如果曾经选择过模型文件夹 // 如果曾经选择过模型文件夹
// 查看model_path路径下文件夹详情 // 查看model_path路径下文件夹详情
@ -65,24 +99,49 @@ DialogSetup::DialogSetup(QWidget * parent) : QDialog(parent) {
QStringList fileList = dirinfo->entryList(QDir::Files); QStringList fileList = dirinfo->entryList(QDir::Files);
fileList.removeOne("."); fileList.removeOne(".");
fileList.removeOne(".."); fileList.removeOne("..");
ui.comboBox->clear(); ui.comboBox_model_path->clear();
ui.comboBox->addItems(fileList); ui.comboBox_model_path->addItems(fileList);
if (!g_sys_conf.model_name.isEmpty()) { if (!g_sys_conf.model_name.isEmpty()) {
// 如果曾选择过模型则在comboBox显示选择模型的文件名 // 如果曾选择过模型则在comboBox显示选择模型的文件名
ui.comboBox->setCurrentText(g_sys_conf.model_name); ui.comboBox_model_path->setCurrentText(g_sys_conf.model_name);
} }
// 更换模型事件 // 更换模型事件
connect(ui.comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onComboBoxSelect(int))); connect(ui.comboBox_model_path, SIGNAL(currentIndexChanged(int)), this, SLOT(onComboBoxSelect(int)));
delete dirinfo, dirinfo = nullptr; delete dirinfo, dirinfo = nullptr;
} }
else { else {
// 如果未曾选择过模型文件夹 // 如果未曾选择过模型文件夹
if (!g_sys_conf.model_name.isEmpty()) { if (!g_sys_conf.model_name.isEmpty()) {
// 如果曾经选择过模型文件 // 如果曾经选择过模型文件
ui.comboBox->addItem(g_sys_conf.model_name); ui.comboBox_model_path->addItem(g_sys_conf.model_name);
} }
} }
if (!g_conf_path.save_pics_path.isEmpty()) {
// 如果配置文件里保存图片路径非空
QDir* dirinfo = new QDir(g_conf_path.save_pics_path);
if (!dirinfo->exists()) {
//delete dirinfo, dirinfo = nullptr;
dirinfo->mkdir(g_conf_path.save_pics_path);
}
ui.comboBox_save_pics_path->clear();
ui.comboBox_save_pics_path->addItem(g_conf_path.save_pics_path);
// 更换选择文件
connect(ui.comboBox_save_pics_path, SIGNAL(currentIndexChanged(int)), this, SLOT(onComboBoxPicsPathSelect(int)));
delete dirinfo, dirinfo = nullptr;
}
else {
QString dirPath = "D:/image";
QDir *dirinfo = new QDir(dirPath);
if (!dirinfo->exists())
delete dirinfo, dirinfo = nullptr;
ui.comboBox_save_pics_path->clear();
ui.comboBox_save_pics_path->setCurrentText(dirPath);
g_conf_path.save_pics_path = dirPath;
}
switch (g_sys_conf.save) switch (g_sys_conf.save)
{ {
case 0: case 0:
@ -108,10 +167,21 @@ DialogSetup::~DialogSetup() {
} }
void DialogSetup::onComboBoxPicsPathSelect(int index) {
QString cp = ui.comboBox_save_pics_path->currentText();
//QMessageBox::information(this, QStringLiteral("提示"), QStringLiteral("您选择的项为") + cp, NULL);
g_conf_path.save_pics_path = cp;
}
void DialogSetup::onComboBoxConfSelect(int index) {
QString cp = ui.comboBox_config_path->currentText();
//QMessageBox::information(this, QStringLiteral("提示"), QStringLiteral("您选择的项为") + cp, NULL);
g_conf_path.config_name = cp;
}
void DialogSetup::onComboBoxSelect(int index) { void DialogSetup::onComboBoxSelect(int index) {
// 获取comboBox当前内容 // 获取comboBox当前内容
QString ct = ui.comboBox->currentText(); QString ct = ui.comboBox_model_path->currentText();
/// QMessageBox::information(this, QStringLiteral("提示"), QStringLiteral("您选择的项为")+ct, NULL);
// 保存到配置文件中 // 保存到配置文件中
g_sys_conf.model_name = ct; g_sys_conf.model_name = ct;
} }
@ -264,6 +334,7 @@ void DialogSetup::on_pushButton_save_released()
g_sys_conf.filter[i] = (lineEdit_filter_mat[i]->text()).toInt(); g_sys_conf.filter[i] = (lineEdit_filter_mat[i]->text()).toInt();
} }
write_conf_path();
write_config(); write_config();
QMessageBox::information(NULL, QStringLiteral("提示"), QStringLiteral("保存参数成功,部分配置需要重启程序后生效"), QMessageBox::Ok); QMessageBox::information(NULL, QStringLiteral("提示"), QStringLiteral("保存参数成功,部分配置需要重启程序后生效"), QMessageBox::Ok);
} }
@ -288,7 +359,47 @@ void DialogSetup::on_pushButton_clear_pic_released()
handleThread->start(); handleThread->start();
} }
void DialogSetup::on_toolButton_choose_path_released() { void DialogSetup::on_toolButton_choose_config_path_released() {
QString dirName = QFileDialog::getExistingDirectory(this, QStringLiteral("请选择配置文件所在文件夹"), "./");
if (dirName.isEmpty()) {
// 点击取消按钮
if (g_conf_path.config_path.isEmpty())
dirName = "D:/conf";
else
dirName = g_conf_path.config_path;
ui.comboBox_config_path->addItem(dirName);
g_conf_path.config_path = dirName;
g_conf_path.config_name = "conf.txt";
}
QDir* dirinfo = new QDir(dirName);
if (!dirinfo->exists())
delete dirinfo, dirinfo = nullptr;
dirinfo->setNameFilters(QStringList("*.txt"));
QStringList fileList = dirinfo->entryList(QDir::Files);
if (fileList.count() == 0) {
g_conf_path.config_path = "D:/conf";
g_conf_path.config_name = "conf.txt";
}
else {
g_conf_path.config_path = dirName;
g_conf_path.config_name = ui.comboBox_config_path->currentText();
}
fileList.removeOne(".");
fileList.removeOne("..");
ui.comboBox_config_path->clear();
ui.comboBox_config_path->addItems(fileList);
connect(ui.comboBox_config_path, SIGNAL(currentIndexChanged(int)), this, SLOT(onComboBoxConfSelect(int)));
delete dirinfo, dirinfo = nullptr;
}
void DialogSetup::on_toolButton_choose_model_path_released() {
// 点击浏览文件按钮后触发的事件 // 点击浏览文件按钮后触发的事件
QString dirName = QFileDialog::getExistingDirectory(this, QStringLiteral("请选择模型所在文件夹"), "./"); QString dirName = QFileDialog::getExistingDirectory(this, QStringLiteral("请选择模型所在文件夹"), "./");
//std::cout << "dirName is " << dirName.toStdString().c_str() << std::endl; //std::cout << "dirName is " << dirName.toStdString().c_str() << std::endl;
@ -296,27 +407,60 @@ void DialogSetup::on_toolButton_choose_path_released() {
//std::cout << "g_sys_conf.model_name is " << g_sys_conf.model_name.toStdString().c_str() << std::endl; //std::cout << "g_sys_conf.model_name is " << g_sys_conf.model_name.toStdString().c_str() << std::endl;
if (dirName.isEmpty()) { if (dirName.isEmpty()) {
if (g_sys_conf.model_path.isEmpty())
dirName = "D:/model";
else
dirName = g_sys_conf.model_path; dirName = g_sys_conf.model_path;
ui.comboBox->setCurrentText(g_sys_conf.model_name);
return; ui.comboBox_model_path->addItem(dirName);
g_sys_conf.model_path = dirName;
g_sys_conf.model_name = "jd.weights";
} }
QDir* dirinfo = new QDir(dirName); QDir* dirinfo = new QDir(dirName);
if (!dirinfo->exists()) { if (!dirinfo->exists())
delete dirinfo, dirinfo = nullptr; delete dirinfo, dirinfo = nullptr;
}
dirinfo->setNameFilters(QStringList("*.weights")); dirinfo->setNameFilters(QStringList("*.weights"));
QStringList fileList = dirinfo->entryList(QDir::Files); QStringList fileList = dirinfo->entryList(QDir::Files);
if (fileList.count() == 0) if (fileList.count() == 0) {
g_sys_conf.model_path = "D:/model"; g_sys_conf.model_path = "D:/model";
g_sys_conf.model_name = "jd.weights";
}
else else
g_sys_conf.model_path = dirName; g_sys_conf.model_path = dirName;
fileList.removeOne("."); fileList.removeOne(".");
fileList.removeOne(".."); fileList.removeOne("..");
ui.comboBox->clear(); ui.comboBox_model_path->clear();
ui.comboBox->addItems(fileList); ui.comboBox_model_path->addItems(fileList);
//g_sys_conf.model_name = ui.comboBox_model_path->currentText();
connect(ui.comboBox_model_path, SIGNAL(currentIndexChanged(int)), this, SLOT(onComboBoxSelect(int)));
delete dirinfo, dirinfo = nullptr;
}
void DialogSetup::on_toolButton_choose_save_pics_path_released() {
// 改变图片的存储路径
QString dirName = QFileDialog::getExistingDirectory(this, QStringLiteral("请选择图片存储路径"), "./");
// 如果没有选择路径
if (dirName.isEmpty()) {
if (g_conf_path.save_pics_path.isEmpty())
dirName = "D:/image";
else
dirName = g_conf_path.save_pics_path;
ui.comboBox_save_pics_path->addItem(dirName);
//return;
}
QDir* dirinfo = new QDir(dirName);
if (!dirinfo->exists())
delete dirinfo, dirinfo = nullptr;
ui.comboBox_save_pics_path->clear();
ui.comboBox_save_pics_path->addItem(dirName);
//g_conf_path.save_pics_path = dirName;
connect(ui.comboBox_save_pics_path, SIGNAL(currentIndexChanged(int)), this, SLOT(onComboBoxPicsPathSelect(int)));
delete dirinfo, dirinfo = nullptr; delete dirinfo, dirinfo = nullptr;
} }
@ -329,7 +473,7 @@ void DialogSetup::on_toolButton_choose_path_jpg_released() {
else { else {
if (ui.comboBox_2->findText(JpgPath) == -1) { if (ui.comboBox_2->findText(JpgPath) == -1) {
ui.comboBox_2->addItem(JpgPath); // 在comboBox中显示文件路径 ui.comboBox_2->addItem(JpgPath); // 在comboBox中显示文件路径
g_sys_conf.jpg_path = JpgPath; // 将选择的路径写入conf配置文件中 g_sys_conf.model_jpg_path = JpgPath; // 将选择的路径写入conf配置文件中
} }
} }
} }
@ -360,10 +504,28 @@ void DialogSetup::write_pswd_op()
} }
cfg_file.close(); cfg_file.close();
} }
void DialogSetup::write_conf_path() {
std::fstream cfg_file;
cfg_file.open(CONFPATH, std::ios::out | std::ios::trunc);
if (cfg_file.good()) {
char buf[256];
memset(buf, 0, 256);
sprintf(buf, "CONF_PATH=%s\n", g_conf_path.config_path.toStdString().c_str());
cfg_file.write(buf, strlen(buf));
memset(buf, 0, 256);
sprintf(buf, "CONF_NAME=%s\n", g_conf_path.config_name.toStdString().c_str());
cfg_file.write(buf, strlen(buf));
memset(buf, 0, 256);
sprintf(buf, "SAVE_PICS_PATH=%s\n", g_conf_path.save_pics_path.toStdString().c_str());
cfg_file.write(buf, strlen(buf));
}
cfg_file.close();
}
void DialogSetup::write_config() void DialogSetup::write_config()
{ {
std::fstream cfg_file; std::fstream cfg_file;
cfg_file.open("D:/conf/conf.txt", std::ios::out | std::ios::trunc); QString cfg_path = g_conf_path.config_path + "/" + g_conf_path.config_name;
cfg_file.open(cfg_path.toStdString().c_str(), std::ios::out | std::ios::trunc);
if (cfg_file.good()) if (cfg_file.good())
{ {
char buf[256]; char buf[256];
@ -419,7 +581,7 @@ void DialogSetup::write_config()
sprintf(buf, "MODELNAME=%s\n", g_sys_conf.model_name.toStdString().c_str()); sprintf(buf, "MODELNAME=%s\n", g_sys_conf.model_name.toStdString().c_str());
cfg_file.write(buf, strlen(buf)); cfg_file.write(buf, strlen(buf));
memset(buf, 0, 256); memset(buf, 0, 256);
sprintf(buf, "JPGPATH=%s\n", g_sys_conf.jpg_path.toStdString().c_str()); sprintf(buf, "JPGPATH=%s\n", g_sys_conf.model_jpg_path.toStdString().c_str());
cfg_file.write(buf, strlen(buf)); cfg_file.write(buf, strlen(buf));
memset(buf, 0, 256); memset(buf, 0, 256);
sprintf(buf, "*****************************************\n"); sprintf(buf, "*****************************************\n");

@ -23,8 +23,10 @@ private slots :
void on_pushButton_exit_released(); void on_pushButton_exit_released();
void on_pushButton_save_released(); void on_pushButton_save_released();
void on_pushButton_close_released(); void on_pushButton_close_released();
void on_toolButton_choose_path_released(); void on_toolButton_choose_config_path_released();
void on_toolButton_choose_model_path_released();
void on_toolButton_choose_path_jpg_released(); void on_toolButton_choose_path_jpg_released();
void on_toolButton_choose_save_pics_path_released();
void on_pushButton_desktop_released(); void on_pushButton_desktop_released();
void on_pushButton_image_released(); void on_pushButton_image_released();
void on_pushButton_pswd_released(); void on_pushButton_pswd_released();
@ -43,6 +45,8 @@ private slots :
void recMsgFromDialogConfig(int ptr[][3]); void recMsgFromDialogConfig(int ptr[][3]);
void recMsgFromChangeShift(QTime timeA, QTime timeB, QTime timeC); void recMsgFromChangeShift(QTime timeA, QTime timeB, QTime timeC);
void onComboBoxSelect(int index); void onComboBoxSelect(int index);
void onComboBoxConfSelect(int index);
void onComboBoxPicsPathSelect(int index);
#ifdef __DEBUG #ifdef __DEBUG
void on_pushButton_testimg_released(); void on_pushButton_testimg_released();
void on_pushButton_testimgs_released(); void on_pushButton_testimgs_released();
@ -57,6 +61,7 @@ public:
static void write_pswd(); static void write_pswd();
static void write_pswd_op(); static void write_pswd_op();
static void write_config(); static void write_config();
static void write_conf_path();
public: public:
camera_glue *m_camera_glue=NULL; camera_glue *m_camera_glue=NULL;

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>690</width> <width>660</width>
<height>830</height> <height>992</height>
</rect> </rect>
</property> </property>
<property name="font"> <property name="font">
@ -29,8 +29,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>690</width> <width>661</width>
<height>830</height> <height>1000</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -52,9 +52,9 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>-72</y> <y>0</y>
<width>675</width> <width>670</width>
<height>900</height> <height>977</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -136,7 +136,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>10</x>
<y>510</y> <y>610</y>
<width>641</width> <width>641</width>
<height>81</height> <height>81</height>
</rect> </rect>
@ -1027,7 +1027,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>10</x>
<y>670</y> <y>770</y>
<width>641</width> <width>641</width>
<height>148</height> <height>148</height>
</rect> </rect>
@ -1509,8 +1509,8 @@
<widget class="QPushButton" name="pushButton_save"> <widget class="QPushButton" name="pushButton_save">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>120</x> <x>110</x>
<y>820</y> <y>930</y>
<width>131</width> <width>131</width>
<height>51</height> <height>51</height>
</rect> </rect>
@ -1552,7 +1552,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>10</x>
<y>590</y> <y>690</y>
<width>641</width> <width>641</width>
<height>81</height> <height>81</height>
</rect> </rect>
@ -1728,8 +1728,8 @@
<widget class="QPushButton" name="pushButton_close"> <widget class="QPushButton" name="pushButton_close">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>380</x> <x>370</x>
<y>820</y> <y>930</y>
<width>131</width> <width>131</width>
<height>51</height> <height>51</height>
</rect> </rect>
@ -1815,7 +1815,7 @@
<widget class="QPushButton" name="pushButton_config"> <widget class="QPushButton" name="pushButton_config">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>40</x>
<y>460</y> <y>460</y>
<width>101</width> <width>101</width>
<height>41</height> <height>41</height>
@ -1836,9 +1836,9 @@
<widget class="QPushButton" name="pushButton_change"> <widget class="QPushButton" name="pushButton_change">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>120</x> <x>40</x>
<y>460</y> <y>560</y>
<width>111</width> <width>101</width>
<height>41</height> <height>41</height>
</rect> </rect>
</property> </property>
@ -1857,9 +1857,9 @@
<widget class="QPushButton" name="pushButton_statistic"> <widget class="QPushButton" name="pushButton_statistic">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>240</x> <x>40</x>
<y>460</y> <y>510</y>
<width>91</width> <width>101</width>
<height>41</height> <height>41</height>
</rect> </rect>
</property> </property>
@ -1875,13 +1875,13 @@
<string>产量统计</string> <string>产量统计</string>
</property> </property>
</widget> </widget>
<widget class="QToolButton" name="toolButton_choose_path"> <widget class="QToolButton" name="toolButton_choose_model_path">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>620</x> <x>620</x>
<y>470</y> <y>470</y>
<width>27</width> <width>27</width>
<height>26</height> <height>25</height>
</rect> </rect>
</property> </property>
<property name="font"> <property name="font">
@ -1893,19 +1893,19 @@
<string>...</string> <string>...</string>
</property> </property>
</widget> </widget>
<widget class="QLabel" name="label_path"> <widget class="QLabel" name="label_model_path">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>340</x> <x>190</x>
<y>470</y> <y>470</y>
<width>101</width> <width>171</width>
<height>21</height> <height>30</height>
</rect> </rect>
</property> </property>
<property name="font"> <property name="font">
<font> <font>
<family>微软雅黑</family> <family>微软雅黑</family>
<pointsize>10</pointsize> <pointsize>12</pointsize>
<weight>75</weight> <weight>75</weight>
<bold>true</bold> <bold>true</bold>
</font> </font>
@ -1913,19 +1913,23 @@
<property name="text"> <property name="text">
<string>模型存储路径</string> <string>模型存储路径</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget> </widget>
<widget class="QComboBox" name="comboBox"> <widget class="QComboBox" name="comboBox_model_path">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>450</x> <x>370</x>
<y>470</y> <y>470</y>
<width>161</width> <width>241</width>
<height>25</height> <height>30</height>
</rect> </rect>
</property> </property>
<property name="font"> <property name="font">
<font> <font>
<family>微软雅黑</family> <family>微软雅黑</family>
<pointsize>10</pointsize>
</font> </font>
</property> </property>
</widget> </widget>
@ -1933,7 +1937,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>340</x> <x>340</x>
<y>970</y> <y>1020</y>
<width>91</width> <width>91</width>
<height>21</height> <height>21</height>
</rect> </rect>
@ -1953,7 +1957,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>440</x> <x>440</x>
<y>970</y> <y>1020</y>
<width>171</width> <width>171</width>
<height>25</height> <height>25</height>
</rect> </rect>
@ -1968,7 +1972,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>620</x> <x>620</x>
<y>970</y> <y>1020</y>
<width>27</width> <width>27</width>
<height>26</height> <height>26</height>
</rect> </rect>
@ -2006,8 +2010,8 @@
<widget class="QPushButton" name="pushButton_testimg"> <widget class="QPushButton" name="pushButton_testimg">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>530</x> <x>520</x>
<y>820</y> <y>930</y>
<width>131</width> <width>131</width>
<height>21</height> <height>21</height>
</rect> </rect>
@ -2026,8 +2030,8 @@
<widget class="QPushButton" name="pushButton_testimgs"> <widget class="QPushButton" name="pushButton_testimgs">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>530</x> <x>520</x>
<y>850</y> <y>960</y>
<width>131</width> <width>131</width>
<height>21</height> <height>21</height>
</rect> </rect>
@ -2043,6 +2047,122 @@
<string>测试多张图片</string> <string>测试多张图片</string>
</property> </property>
</widget> </widget>
<widget class="QLabel" name="label_conf_path">
<property name="geometry">
<rect>
<x>190</x>
<y>520</y>
<width>171</width>
<height>30</height>
</rect>
</property>
<property name="font">
<font>
<family>微软雅黑</family>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>配置文件存储路径</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QComboBox" name="comboBox_config_path">
<property name="geometry">
<rect>
<x>370</x>
<y>520</y>
<width>241</width>
<height>30</height>
</rect>
</property>
<property name="font">
<font>
<family>微软雅黑</family>
<pointsize>10</pointsize>
</font>
</property>
</widget>
<widget class="QToolButton" name="toolButton_choose_config_path">
<property name="geometry">
<rect>
<x>620</x>
<y>520</y>
<width>27</width>
<height>25</height>
</rect>
</property>
<property name="font">
<font>
<family>微软雅黑</family>
</font>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
<widget class="QLabel" name="label_save_pics_path">
<property name="geometry">
<rect>
<x>190</x>
<y>570</y>
<width>171</width>
<height>30</height>
</rect>
</property>
<property name="font">
<font>
<family>微软雅黑</family>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>图片存储路径</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QComboBox" name="comboBox_save_pics_path">
<property name="geometry">
<rect>
<x>370</x>
<y>570</y>
<width>241</width>
<height>30</height>
</rect>
</property>
<property name="font">
<font>
<family>微软雅黑</family>
<pointsize>10</pointsize>
</font>
</property>
</widget>
<widget class="QToolButton" name="toolButton_choose_save_pics_path">
<property name="geometry">
<rect>
<x>620</x>
<y>570</y>
<width>27</width>
<height>25</height>
</rect>
</property>
<property name="font">
<font>
<family>微软雅黑</family>
</font>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</widget> </widget>
</widget> </widget>
</widget> </widget>

@ -4,6 +4,7 @@
#include<string> #include<string>
extern SyncQueue<_ExportDataInfo>* export_Data_Info_queue; extern SyncQueue<_ExportDataInfo>* export_Data_Info_queue;
extern ConfPath g_conf_path;
ExportDataThread::ExportDataThread(QObject* parent) : QThread(parent) ExportDataThread::ExportDataThread(QObject* parent) : QThread(parent)
{ {
@ -13,15 +14,17 @@ ExportDataThread::ExportDataThread(QObject* parent) : QThread(parent)
XMLError error; XMLError error;
pDocument[index] = new XMLDocument(); pDocument[index] = new XMLDocument();
memset(xmlPath, 0, 256); memset(xmlPath, 0, 256);
sprintf(xmlPath, EXPORTDATA_FILE, index); QString xmlPath = QString(EXPORTDATA_FILE).arg(index);
error = pDocument[index]->LoadFile(xmlPath); //sprintf(xmlPath, EXPORTDATA_FILE, index);
QString filePath = g_conf_path.config_path + "/" + xmlPath;
error = pDocument[index]->LoadFile(filePath.toStdString().c_str());
if (error != XML_SUCCESS) if (error != XML_SUCCESS)
{ {
XMLDeclaration* declaration = pDocument[index]->NewDeclaration(); XMLDeclaration* declaration = pDocument[index]->NewDeclaration();
pDocument[index]->InsertFirstChild(declaration); pDocument[index]->InsertFirstChild(declaration);
XMLElement* root = pDocument[0]->NewElement("Root"); XMLElement* root = pDocument[0]->NewElement("Root");
pDocument[0]->InsertEndChild(root); pDocument[0]->InsertEndChild(root);
pDocument[index]->SaveFile(xmlPath); pDocument[index]->SaveFile(filePath.toStdString().c_str());
} }
/* /*
_ExportDataInfo data; _ExportDataInfo data;
@ -53,15 +56,16 @@ void ExportDataThread::stop()
bool _ExportDataInfo::getAverageData(map<string, float> &averageData, int index) bool _ExportDataInfo::getAverageData(map<string, float> &averageData, int index)
{ {
XMLDocument doc; XMLDocument doc;
char xmlPath[256]; //char xmlPath[256];
XMLError error; XMLError error;
map<string, float> data; map<string, float> data;
//memset(xmlPath, 0, 256);
memset(xmlPath, 0, 256); QString xmlPath = QString(EXPORTDATA_FILE).arg(index);
sprintf(xmlPath, EXPORTDATA_FILE, index); //sprintf(xmlPath, EXPORTDATA_FILE, index);
error = doc.LoadFile(xmlPath); QString filePath = g_conf_path.config_path + "/" + xmlPath;
error = doc.LoadFile(filePath.toStdString().c_str());
if (error != XML_SUCCESS) if (error != XML_SUCCESS)
if (doc.LoadFile(xmlPath) != 0) if (doc.LoadFile(filePath.toStdString().c_str()) != 0)
{ {
cout << "load xml file failed" << endl; cout << "load xml file failed" << endl;
return false; return false;
@ -144,7 +148,9 @@ void ExportDataThread::run()
if (element.cameraId != -1) { if (element.cameraId != -1) {
char buf[256]; char buf[256];
memset(buf, 0, 256); memset(buf, 0, 256);
sprintf(buf, EXPORTDATA_FILE, element.cameraId); QString xmlPath = QString(EXPORTDATA_FILE).arg(element.cameraId);
QString filePath = g_conf_path.config_path + "/" + xmlPath;
sprintf(buf, filePath.toStdString().c_str(), element.cameraId);
insertXMLNode(buf, element); insertXMLNode(buf, element);
} }
} }

@ -8,9 +8,9 @@
#include <qthread.h> #include <qthread.h>
#include "basecamera.h" #include "basecamera.h"
#include "tinyxml2.h" #include "tinyxml2.h"
#include "common.h"
#define EXPORTDATA_FILE "camera%1_data_info.xml"
#define EXPORTDATA_FILE "D:/conf/camera%d_data_info.xml"
using namespace tinyxml2; using namespace tinyxml2;

@ -21,8 +21,8 @@ int main(int argc, char *argv[])
splash.show(); splash.show();
a.processEvents(); a.processEvents();
Cigarette w; Cigarette w;
w.show(); //w.show();
//w.showFullScreen(); w.showFullScreen();
splash.finish(&w); splash.finish(&w);
return a.exec(); return a.exec();
} }

@ -2,14 +2,43 @@
#include "QtCore\qfile.h" #include "QtCore\qfile.h"
#include "QtCore\qtextstream.h" #include "QtCore\qtextstream.h"
#include "exportData.h" #include "exportData.h"
#include "common.h"
#include <map> #include <map>
extern ConfPath g_conf_path;
#define output_init(a, b)\
textBrowser_mat[a] = ui.textBrowser_##b;
output_statistic::output_statistic(QDialog *parent) output_statistic::output_statistic(QDialog *parent)
: QDialog(parent) : QDialog(parent)
{ {
ui.setupUi(this); ui.setupUi(this);
this->setWindowFlags(windowFlags()&~Qt::WindowContextHelpButtonHint); this->setWindowFlags(windowFlags()&~Qt::WindowContextHelpButtonHint);
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras > 0)
output_init(0, 1);
#endif
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras > 1)
output_init(1, 2);
#endif
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras > 2)
output_init(2, 3);
#endif
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras > 3)
output_init(3, 4);
#endif
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras > 4)
output_init(4, 5);
#endif
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras > 5)
output_init(5, 6);
#endif
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras > 6)
output_init(6, 7);
#endif
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras > 7)
output_init(7, 8);
#endif
} }
output_statistic::~output_statistic() output_statistic::~output_statistic()
@ -48,62 +77,21 @@ void output_statistic::recMsgFromDialogSetup()
} }
#else #else
QFile file("D:/conf/camera0_statistic.txt"); QString file_path, file_name;
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) QFile file;
{ for (int i = 0; i < NumberOfSupportedCameras; i++) {
QTextStream in(&file); file_name = QString(STATISTIC_FILE).arg(i);
ui.textBrowser_1->setText(in.readAll()); file_path = g_conf_path.config_path + "/" + file_name;
} //std::cout << "===>" << file_path.toStdString() << std::endl;
file.close(); file.setFileName(file_path);
file.setFileName("D:/conf/camera1_statistic.txt");
if (file.open(QIODevice::ReadOnly | QIODevice::Text))
{
QTextStream in(&file);
ui.textBrowser_2->setText(in.readAll());
}
file.close();
file.setFileName("D:/conf/camera2_statistic.txt");
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) if (file.open(QIODevice::ReadOnly | QIODevice::Text))
{ {
QTextStream in(&file); QTextStream in(&file);
ui.textBrowser_3->setText(in.readAll()); textBrowser_mat[i]->setText(in.readAll());
} }
file.close(); file.close();
file.setFileName("D:/conf/camera3_statistic.txt"); this->show();
if (file.open(QIODevice::ReadOnly | QIODevice::Text))
{
QTextStream in(&file);
ui.textBrowser_4->setText(in.readAll());
}
file.close();
file.setFileName("D:/conf/camera4_statistic.txt");
if (file.open(QIODevice::ReadOnly | QIODevice::Text))
{
QTextStream in(&file);
ui.textBrowser_5->setText(in.readAll());
}
file.close();
file.setFileName("D:/conf/camera5_statistic.txt");
if (file.open(QIODevice::ReadOnly | QIODevice::Text))
{
QTextStream in(&file);
ui.textBrowser_6->setText(in.readAll());
}
file.close();
file.setFileName("D:/conf/camera6_statistic.txt");
if (file.open(QIODevice::ReadOnly | QIODevice::Text))
{
QTextStream in(&file);
ui.textBrowser_7->setText(in.readAll());
}
file.close();
file.setFileName("D:/conf/camera7_statistic.txt");
if (file.open(QIODevice::ReadOnly | QIODevice::Text))
{
QTextStream in(&file);
ui.textBrowser_8->setText(in.readAll());
} }
file.close();
#endif #endif
this->show(); //this->show();
} }

@ -1,6 +1,7 @@
#pragma once #pragma once
#include <QDialog> #include <QDialog>
#include "common.h"
#include "ui_output_statistic.h" #include "ui_output_statistic.h"
class output_statistic : public QDialog class output_statistic : public QDialog
@ -13,6 +14,7 @@ public:
private: private:
Ui::output_statistic ui; Ui::output_statistic ui;
QTextBrowser* textBrowser_mat[NumberOfSupportedCameras];
public slots: public slots:
void recMsgFromDialogSetup(); void recMsgFromDialogSetup();

@ -8,10 +8,10 @@
#include <qmessagebox.h> #include <qmessagebox.h>
#include <QIntValidator> #include <QIntValidator>
#include "PLCDevice.h" #include "PLCDevice.h"
#define PLC_ITEM_FILE "D:/conf/plc.txt" #define PLC_ITEM_FILE "plc.txt"
extern PLCDevice * m_PLCDevice; extern PLCDevice * m_PLCDevice;
extern ConfPath g_conf_path;
extern bool g_plc_dialog_open; //是否打开plc配置对话框 extern bool g_plc_dialog_open; //是否打开plc配置对话框
void task_osk_() void task_osk_()
@ -244,7 +244,7 @@ void PlcSetup::handleTimeout()
void PlcSetup::read_plc_items() void PlcSetup::read_plc_items()
{ {
std::fstream cfg_file; std::fstream cfg_file;
cfg_file.open(PLC_ITEM_FILE); cfg_file.open(g_conf_path.config_path.toStdString() + "/" + PLC_ITEM_FILE);
if (!cfg_file.is_open()) if (!cfg_file.is_open())
{ {
std::cout << "Error: Open production file " << PLC_ITEM_FILE << std::endl; std::cout << "Error: Open production file " << PLC_ITEM_FILE << std::endl;
@ -277,7 +277,7 @@ void PlcSetup::read_plc_items()
void PlcSetup::save_plc_items() void PlcSetup::save_plc_items()
{ {
std::fstream cfg_file; std::fstream cfg_file;
cfg_file.open(PLC_ITEM_FILE, std::ios::out | std::ios::trunc); cfg_file.open(g_conf_path.config_path.toStdString() + "/" + PLC_ITEM_FILE, std::ios::out | std::ios::trunc);
if (cfg_file.good()) if (cfg_file.good())
{ {
for (int i = 0; i < m_plc_items.size(); i++) for (int i = 0; i < m_plc_items.size(); i++)

@ -8,7 +8,7 @@
#include "exportData.h" #include "exportData.h"
extern AlgJd alg_jd[NumberOfSupportedCameras]; //检测胶点的AI算法 extern AlgJd alg_jd[NumberOfSupportedCameras]; //检测胶点的AI算法
extern ConfPath g_conf_path;
extern SysConf g_sys_conf; //系统配置参数 extern SysConf g_sys_conf; //系统配置参数
extern DisplayLabelConf g_display_label_conf[NumberOfSupportedCameras]; extern DisplayLabelConf g_display_label_conf[NumberOfSupportedCameras];
@ -157,12 +157,11 @@ void WorkThread::run()
if (local_SysConf.save == 2)//三张照片分别存储 if (local_SysConf.save == 2)//三张照片分别存储
{ {
cv::Mat m = vec_in[index].clone(); cv::Mat m = vec_in[index].clone();
QString file_name = "D:/image/" + QString file_name = g_conf_path.save_pics_path + "/ALL/" +
now_ts.toString("yyyy-MM-dd") + now_ts.toString("yyyy-MM-dd") + "/"
"/" + QString::number(local_camera_number + 1) + + QString::number(local_camera_number + 1) + "/" + QString::number(index + 1) + "/" +
"/ALL/" +
now_ts.toString("yyyy-MM-dd_HH-mm-ss_zzz_") + QString::number(local_camera_number + 1) + now_ts.toString("yyyy-MM-dd_HH-mm-ss_zzz_") + QString::number(local_camera_number + 1) +
"#" + "_" + QString::number(index + 1) + ".bmp"; "#" + "_" + QString::number(index + 1) + ".jpg";
g_save_queue->put(std::make_pair(file_name.toStdString(), m)); g_save_queue->put(std::make_pair(file_name.toStdString(), m));
} }
} }
@ -213,19 +212,18 @@ void WorkThread::run()
for(int index=0;index<unit_count;index++) for(int index=0;index<unit_count;index++)
{ {
cv::Mat m = vec_in[index].clone(); cv::Mat m = vec_in[index].clone();
QString file_name = "D:/image/" + QString file_name = g_conf_path.save_pics_path + "/ng/" +
now_ts.toString("yyyy-MM-dd") + now_ts.toString("yyyy-MM-dd") + "/"
"/" + QString::number(local_camera_number + 1) + + QString::number(local_camera_number + 1) + "/" + QString::number(index + 1) + "/" +
"/ng/" + QString::number(index) + "/" + now_ts.toString("yyyy-MM-dd_HH-mm-ss_zzz_") + QString::number(local_camera_number + 1) +
now_ts.toString("yyyy-MM-dd_HH-mm-ss_zzz_") + "_" + QString::number(index) + ".bmp"; "#" + "_" + QString::number(index + 1) + ".jpg";
g_save_queue->put(std::make_pair(file_name.toStdString(), m));
m = vec_out[index].clone(); /*m = vec_out[index].clone();
file_name = "D:/image/" + file_name = "D:/image/" +
now_ts.toString("yyyy-MM-dd") + now_ts.toString("yyyy-MM-dd") +
"/" + QString::number(local_camera_number + 1) + "/" + QString::number(local_camera_number + 1) +
"/ng_result/" + QString::number(index) + "/" + "/ng_result/" + QString::number(index) + "/" +
now_ts.toString("yyyy-MM-dd_HH-mm-ss_zzz_") + "_" + QString::number(index) + ".bmp"; now_ts.toString("yyyy-MM-dd_HH-mm-ss_zzz_") + "_" + QString::number(index) + ".bmp";*/
g_save_queue->put(std::make_pair(file_name.toStdString(), m)); g_save_queue->put(std::make_pair(file_name.toStdString(), m));
} }
} }

Loading…
Cancel
Save