|
|
|
@ -16,6 +16,7 @@
|
|
|
|
|
#include <QThread>
|
|
|
|
|
#include "Cleanthread.h"
|
|
|
|
|
|
|
|
|
|
extern ConfPath g_conf_path;
|
|
|
|
|
extern SysConf g_sys_conf; //系统配置参数
|
|
|
|
|
extern QString g_admin_pswd; //管理员密码
|
|
|
|
|
extern QString g_op_pswd; //操作员密码
|
|
|
|
@ -28,7 +29,7 @@ void task_osk()
|
|
|
|
|
DialogSetup::DialogSetup(QWidget * parent) : QDialog(parent) {
|
|
|
|
|
ui.setupUi(this);
|
|
|
|
|
InitPtrMat();
|
|
|
|
|
//this->setWindowFlags(Qt::FramelessWindowHint);//窗口可移动
|
|
|
|
|
this->setWindowFlags(Qt::FramelessWindowHint);//窗口可移动
|
|
|
|
|
|
|
|
|
|
for(int i=0;i<NumberOfSupportedCameras;i++)
|
|
|
|
|
{
|
|
|
|
@ -55,6 +56,39 @@ DialogSetup::DialogSetup(QWidget * parent) : QDialog(parent) {
|
|
|
|
|
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()) {
|
|
|
|
|
// 如果曾经选择过模型文件夹
|
|
|
|
|
// 查看model_path路径下文件夹详情
|
|
|
|
@ -65,24 +99,49 @@ DialogSetup::DialogSetup(QWidget * parent) : QDialog(parent) {
|
|
|
|
|
QStringList fileList = dirinfo->entryList(QDir::Files);
|
|
|
|
|
fileList.removeOne(".");
|
|
|
|
|
fileList.removeOne("..");
|
|
|
|
|
ui.comboBox->clear();
|
|
|
|
|
ui.comboBox->addItems(fileList);
|
|
|
|
|
ui.comboBox_model_path->clear();
|
|
|
|
|
ui.comboBox_model_path->addItems(fileList);
|
|
|
|
|
if (!g_sys_conf.model_name.isEmpty()) {
|
|
|
|
|
// 如果曾选择过模型,则在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;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// 如果未曾选择过模型文件夹
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
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) {
|
|
|
|
|
// 获取comboBox当前内容
|
|
|
|
|
QString ct = ui.comboBox->currentText();
|
|
|
|
|
/// QMessageBox::information(this, QStringLiteral("提示"), QStringLiteral("您选择的项为")+ct, NULL);
|
|
|
|
|
QString ct = ui.comboBox_model_path->currentText();
|
|
|
|
|
// 保存到配置文件中
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
write_conf_path();
|
|
|
|
|
write_config();
|
|
|
|
|
QMessageBox::information(NULL, QStringLiteral("提示"), QStringLiteral("保存参数成功,部分配置需要重启程序后生效"), QMessageBox::Ok);
|
|
|
|
|
}
|
|
|
|
@ -288,7 +359,47 @@ void DialogSetup::on_pushButton_clear_pic_released()
|
|
|
|
|
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("请选择模型所在文件夹"), "./");
|
|
|
|
|
//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;
|
|
|
|
|
|
|
|
|
|
if (dirName.isEmpty()) {
|
|
|
|
|
dirName = g_sys_conf.model_path;
|
|
|
|
|
ui.comboBox->setCurrentText(g_sys_conf.model_name);
|
|
|
|
|
return;
|
|
|
|
|
if (g_sys_conf.model_path.isEmpty())
|
|
|
|
|
dirName = "D:/model";
|
|
|
|
|
else
|
|
|
|
|
dirName = g_sys_conf.model_path;
|
|
|
|
|
|
|
|
|
|
ui.comboBox_model_path->addItem(dirName);
|
|
|
|
|
g_sys_conf.model_path = dirName;
|
|
|
|
|
g_sys_conf.model_name = "jd.weights";
|
|
|
|
|
}
|
|
|
|
|
QDir* dirinfo = new QDir(dirName);
|
|
|
|
|
if (!dirinfo->exists()) {
|
|
|
|
|
if (!dirinfo->exists())
|
|
|
|
|
delete dirinfo, dirinfo = nullptr;
|
|
|
|
|
}
|
|
|
|
|
dirinfo->setNameFilters(QStringList("*.weights"));
|
|
|
|
|
|
|
|
|
|
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_name = "jd.weights";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
g_sys_conf.model_path = dirName;
|
|
|
|
|
|
|
|
|
|
fileList.removeOne(".");
|
|
|
|
|
fileList.removeOne("..");
|
|
|
|
|
|
|
|
|
|
ui.comboBox->clear();
|
|
|
|
|
ui.comboBox->addItems(fileList);
|
|
|
|
|
ui.comboBox_model_path->clear();
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
@ -329,7 +473,7 @@ void DialogSetup::on_toolButton_choose_path_jpg_released() {
|
|
|
|
|
else {
|
|
|
|
|
if (ui.comboBox_2->findText(JpgPath) == -1) {
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
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()
|
|
|
|
|
{
|
|
|
|
|
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())
|
|
|
|
|
{
|
|
|
|
|
char buf[256];
|
|
|
|
@ -419,7 +581,7 @@ void DialogSetup::write_config()
|
|
|
|
|
sprintf(buf, "MODELNAME=%s\n", g_sys_conf.model_name.toStdString().c_str());
|
|
|
|
|
cfg_file.write(buf, strlen(buf));
|
|
|
|
|
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));
|
|
|
|
|
memset(buf, 0, 256);
|
|
|
|
|
sprintf(buf, "*****************************************\n");
|
|
|
|
|