From 4323f75315d15c2169274932ccf57e0999e21fc9 Mon Sep 17 00:00:00 2001 From: 18661908385 Date: Mon, 4 Sep 2023 17:11:52 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=A5=E7=89=88=E6=9C=AC=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=BA=86=E8=BE=83=E5=A4=9A=E5=8A=9F=E8=83=BD=EF=BC=9A=201.?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=83=A8=E5=88=86=E8=B7=AF=E5=BE=84=E5=90=8D?= =?UTF-8?q?=EF=BC=9B=202.=E4=BF=AE=E6=94=B9=E9=80=89=E6=8B=A9=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=E8=B7=AF=E5=BE=84=E5=8A=9F=E8=83=BD=EF=BC=9B=203.?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8A=A5=E8=AD=A6=E5=8A=9F=E8=83=BD=EF=BC=9B?= =?UTF-8?q?=204.=E4=BF=AE=E6=94=B9=E6=8D=A2=E7=8F=AD=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=EF=BC=9B=205.=E4=BF=AE=E6=94=B9=E8=B0=83=E8=AF=95=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=9B=206.=E4=BF=AE=E6=94=B9=E7=94=BB=E6=A1=86?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cigarette/alg_jd.cpp | 38 +++++----- Cigarette/alg_jd.h | 2 +- Cigarette/change_shift.cpp | 2 + Cigarette/cigarette.cpp | 144 ++++++++++++++++++++++++++++++------- Cigarette/cigarette.h | 1 + Cigarette/common.h | 22 +++--- Cigarette/debugthread.h | 12 ++++ Cigarette/dialogsetup.cpp | 80 ++++++++++++++++++--- Cigarette/dialogsetup.hpp | 1 + Cigarette/main.cpp | 2 +- Cigarette/plcsetup.cpp | 2 +- 11 files changed, 241 insertions(+), 65 deletions(-) diff --git a/Cigarette/alg_jd.cpp b/Cigarette/alg_jd.cpp index e78a034..ca7e78c 100644 --- a/Cigarette/alg_jd.cpp +++ b/Cigarette/alg_jd.cpp @@ -22,18 +22,24 @@ static int inpHeight = 416; // Height of network's input image static std::vector classes; -bool AlgJd::init(QString path_model, QString path_jpg) +bool AlgJd::init(QString path_model, QString model_name) { // Load names of classes - std::string classesFile = "../model/jd.names"; - // Give the configuration and weight files for the model - cv::String modelConfiguration = "../model/jd.cfg"; - cv::String modelWeights = "../model/jd.weights"; + std::string classesFile; + cv::String modelConfiguration; + cv::String modelWeights; - if (path_model.length() > 0) { - classesFile = path_model.toStdString() + "/jd.names"; + if (path_model.length() > 0 && model_name.length() > 0) { + // 拼凑的模型文件路径 + modelWeights = path_model.toStdString() + "/" + model_name.toStdString(); modelConfiguration = path_model.toStdString() + "/jd.cfg"; - modelWeights = path_model.toStdString() + "/jd.weights"; + classesFile = path_model.toStdString() + "/jd.names"; + } + else { + modelWeights = "D:/model/jd.weights"; + classesFile = "D:/model/jd.names"; + // Give the configuration and weight files for the model + modelConfiguration = "D:/model/jd.cfg"; } std::ifstream classNamesFile(classesFile.c_str()); @@ -53,14 +59,14 @@ bool AlgJd::init(QString path_model, QString path_jpg) net.setPreferableBackend(cv::dnn::DNN_BACKEND_CUDA); net.setPreferableTarget(cv::dnn::DNN_TARGET_CUDA); - //cv::Mat image = cv::imread("alg_jd.jpg"); - cv::Mat image; - if (path_jpg.length() > 0) { - image = cv::imread(path_jpg.toStdString()); - } - else { - image = cv::imread("alg_jd.bmp"); - } + cv::Mat image = cv::imread("alg_jd.bmp"); + //cv::Mat image; + //if (path_jpg.length() > 0) { + // image = cv::imread(path_jpg.toStdString()); + //} + //else { + // image = cv::imread("D:/Release/alg_jd.bmp"); + //} //识别一张图,测试模型是否正确,并且完成GPU数据加载 if (!image.data) return false; //判断测试图片是否正常读取 diff --git a/Cigarette/alg_jd.h b/Cigarette/alg_jd.h index 61c572d..a86e80f 100644 --- a/Cigarette/alg_jd.h +++ b/Cigarette/alg_jd.h @@ -12,7 +12,7 @@ class AlgJd { public: - bool init(QString path_model, QString path_jpg); + bool init(QString path_model, QString model_name); bool test_detect(); bool test_detect_batcht(int shoot); int detect(cv::Mat& in, cv::Mat &out, std::vector > &results); diff --git a/Cigarette/change_shift.cpp b/Cigarette/change_shift.cpp index 9e80062..6950b51 100644 --- a/Cigarette/change_shift.cpp +++ b/Cigarette/change_shift.cpp @@ -41,6 +41,7 @@ void change_shift::on_pushButton_apply_released() if (ui.radioButton_auto->isChecked()) { /// 已隐藏 g_sys_conf.auto_shift = 1; g_sys_conf.timing_shift = 0; + g_sys_conf.shift_byhand = 0; timeA.setHMS(ui.A_hour->minimum(), ui.A_minute->minimum(), 0); timeB.setHMS(ui.B_hour->minimum(), ui.B_minute->minimum(), 0); @@ -60,6 +61,7 @@ void change_shift::on_pushButton_apply_released() //this->close(); } else if (ui.radioButton_byhand->isChecked()) { + g_sys_conf.auto_shift = 0; g_sys_conf.timing_shift = 0; g_sys_conf.shift_byhand = 1; diff --git a/Cigarette/cigarette.cpp b/Cigarette/cigarette.cpp index 95753ad..6ddfa06 100644 --- a/Cigarette/cigarette.cpp +++ b/Cigarette/cigarette.cpp @@ -192,6 +192,7 @@ Cigarette::Cigarette(QWidget *parent) ng[i] = 0; g_display_label_conf[i].g_last_mat[0] = cv::Mat::zeros(20, 20, CV_8UC3); g_display_label_conf[i].g_last_mat[1] = cv::Mat::zeros(20, 20, CV_8UC3); + DrawRect_init(i); } ui.lcdNumber_total_no->display(0); ui.lcdNumber_total_no_last->display(0); @@ -204,14 +205,38 @@ Cigarette::Cigarette(QWidget *parent) read_sys_config(g_sys_conf); //初始化系统配置 - g_modbus_conf.kick1 = 0; - g_modbus_conf.kick2 = 0; - g_modbus_conf.kick3 = 0; - g_modbus_conf.kick4 = 0; - g_modbus_conf.kick5 = 0; - g_modbus_conf.kick6 = 0; - g_modbus_conf.kick7 = 0; - g_modbus_conf.kick8 = 0; + //g_modbus_conf.kick1 = 0; + //g_modbus_conf.kick2 = 0; + //g_modbus_conf.kick3 = 0; + //g_modbus_conf.kick4 = 0; + //g_modbus_conf.kick5 = 0; + //g_modbus_conf.kick6 = 0; + //g_modbus_conf.kick7 = 0; + //g_modbus_conf.kick8 = 0; +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>0) + g_modbus_conf.kick1 = 0; //1#通道剔除个数地址 +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>1) + g_modbus_conf.kick2 = 0; //2#通道剔除个数地址 +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>2) + g_modbus_conf.kick3 = 0; //3#通道剔除个数地址 +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>3) + g_modbus_conf.kick4 = 0; //4#通道剔除个数地址 +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>4) + g_modbus_conf.kick5 = 0; //1#通道剔除个数地址 +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>5) + g_modbus_conf.kick6 = 0; //2#通道剔除个数地址 +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>6) + g_modbus_conf.kick7 = 0; //3#通道剔除个数地址 +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>7) + g_modbus_conf.kick8 = 0; //4#通道剔除个数地址 +#endif g_modbus_conf.quantity = 0; g_modbus_conf.shift = 0; g_modbus_conf.work = 0; @@ -289,7 +314,7 @@ Cigarette::Cigarette(QWidget *parent) { if(SingleCamInfo[i].Detect){ cam_status_mat[i]->setStyleSheet(tr("background-color: rgb(0, 170, 0);")); - if (!alg_jd[i].init(g_sys_conf.path_model,g_sys_conf.path_jpg)) + if (!alg_jd[i].init(g_sys_conf.path_model,g_sys_conf.model_name)) { QMessageBox::information(NULL, QStringLiteral("系统自检失败"), QStringLiteral("AI模型1初始化失败,请检查程序完整性"), QMessageBox::Ok); exit(-1); @@ -523,6 +548,7 @@ void Cigarette::on_btn_start_released() } } g_op_time = OP_TIME; + ui.checkBox_debug->setEnabled(true); //使能相机调试checkBox } void Cigarette::pause_work() @@ -590,7 +616,7 @@ void Cigarette::Exit() } -//暂停按钮 +//停止工作按钮 void Cigarette::on_btn_pause_released() { emit sengMsgToClog("Pause the application."); @@ -1001,6 +1027,48 @@ void Cigarette::OnDBClickHub(int Num_Cnt) } OnNotifyHub(Num,Cnt,g_display_label_conf[Num].g_last_mat[Cnt]); } + +void Cigarette::DrawRect_init(int Num_Cnt) { + //int Num = Num_Cnt >> 4; + //int Cnt = Num_Cnt & 0x0f; + + int Num = Num_Cnt & 0x0f; + int Cnt = Num_Cnt >> 4; + if (g_display_label_conf[Num].Flag[Cnt] & DisplayLabel_Type_Bit) + { + g_display_label_conf[Num].Flag[Cnt] &= ~DisplayLabel_Type_Bit; + g_display_label_conf[Num].Flag[Cnt] &= ~DisplayLabel_Conf_Bit; + } + else { + g_display_label_conf[Num].Flag[Cnt] |= DisplayLabel_Type_Bit; + std::fstream cfg_file; + char buf[256]; + memset(buf, 0, 256); + sprintf(buf, SELECT_RECTS_FILE, Num, Cnt); + cfg_file.open(buf); + if (!cfg_file.is_open()) + { + std::cout << "Error: Open config file SelectRects.txt" << std::endl; + return; + } + while (!cfg_file.eof()) + { + char tmp[256] = ""; + cfg_file.getline(tmp, 256); + QString line = QString::fromStdString(std::string(tmp)); + QStringList dataList = line.split(','); + if (dataList.length() == 4) + { + RectRatio m_RectRatio = RectRatio( + cv::Point2f(dataList[0].toFloat(), dataList[1].toFloat()), + cv::Point2f(dataList[2].toFloat(), dataList[3].toFloat()) + ); + g_display_label_conf[Num].RectVet[Cnt].push_back(m_RectRatio); + } + } + } +} + void Cigarette::OnTPClickHub(int Num_Cnt) { int Num = Num_Cnt >> 4; @@ -1205,8 +1273,9 @@ void Cigarette::on_checkBox_debug_clicked(bool checked) { if (g_working) { - QMessageBox::information(NULL, QStringLiteral("操作顺序检查 "), QStringLiteral("请先点击‘暂停工作’按钮,才能进入调试模式"), QMessageBox::Ok); + QMessageBox::information(NULL, QStringLiteral("操作顺序检查 "), QStringLiteral("请先点击‘停止工作’按钮,才能进入调试模式"), QMessageBox::Ok); ui.checkBox_debug->setChecked(false); + return; } else { @@ -1222,8 +1291,9 @@ void Cigarette::on_checkBox_debug_clicked(bool checked) { emit sengMsgToClog("Exit debug mode."); DisableDebugMode(); - on_pushButton_clear_released(); //换班 + //on_pushButton_clear_released(); //换班 ui.checkBox_debug->setChecked(false); + ui.checkBox_debug->setEnabled(true); #ifdef __UDPSend sThread.sendData("DebugDis", g_sys_conf.FeedbackPort); #endif @@ -1351,7 +1421,7 @@ void Cigarette::handleTimeout() if (quantity_stop_count == STOP_SECONDS) //触发一次换班 { g_op_mode = true; //激活操作员模式 - on_btn_pause_released(); //暂停 + on_btn_pause_released(); //停止工作 on_pushButton_clear_released(); //换班 on_btn_start_released(); //开始 g_op_mode = false; //退出操作员模式 @@ -1367,7 +1437,7 @@ void Cigarette::handleTimeout() if (secA == 0) { g_op_mode = true; //激活操作员模式 - on_btn_pause_released(); //暂停 + on_btn_pause_released(); //停止工作 record_output_statistic(cur_quantity, 0); on_pushButton_clear_released(); //换班 on_btn_start_released(); //开始 @@ -1376,7 +1446,7 @@ void Cigarette::handleTimeout() else if (secB == 0) { g_op_mode = true; //激活操作员模式 - on_btn_pause_released(); //暂停 + on_btn_pause_released(); //停止工作 record_output_statistic(cur_quantity, 1); on_pushButton_clear_released(); //换班 on_btn_start_released(); //开始 @@ -1385,7 +1455,7 @@ void Cigarette::handleTimeout() else if (secC == 0) { g_op_mode = true; //激活操作员模式 - on_btn_pause_released(); //暂停 + on_btn_pause_released(); //停止工作 record_output_statistic(cur_quantity, 2); on_pushButton_clear_released(); //换班 on_btn_start_released(); //开始 @@ -1554,6 +1624,7 @@ void Cigarette::handleTimeout() } } //相机掉线检测 +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>0) if (SingleCamInfo[0].OffLine) //1#相机掉线 { //SingleCamInfo[0] = false; @@ -1568,6 +1639,8 @@ void Cigarette::handleTimeout() if (ret > 0) SingleCamInfo[0].OffLine = false; } } +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>1) if (SingleCamInfo[1].OffLine) //2#相机掉线 { //SingleCamInfo[1] = false; @@ -1582,6 +1655,8 @@ void Cigarette::handleTimeout() if(ret > 0) SingleCamInfo[1].OffLine = false; } } +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>2) if (SingleCamInfo[2].OffLine) //3#相机掉线 { //SingleCamInfo[2] = false; @@ -1596,7 +1671,8 @@ void Cigarette::handleTimeout() if (ret > 0) SingleCamInfo[2].OffLine = false; } } - +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>3) if (SingleCamInfo[3].OffLine) //4#相机掉线 { //SingleCamInfo[3] = false; @@ -1611,6 +1687,8 @@ void Cigarette::handleTimeout() if (ret > 0) SingleCamInfo[3].OffLine = false; } } +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>4) if (SingleCamInfo[4].OffLine) //5#相机掉线 { //SingleCamInfo[4] = false; @@ -1625,6 +1703,8 @@ void Cigarette::handleTimeout() if (ret > 0) SingleCamInfo[4].OffLine = false; } } +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>5) if (SingleCamInfo[5].OffLine) //6#相机掉线 { //SingleCamInfo[5] = false; @@ -1639,6 +1719,8 @@ void Cigarette::handleTimeout() if (ret > 0) SingleCamInfo[5].OffLine = false; } } +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>6) if (SingleCamInfo[6].OffLine) //7#相机掉线 { //SingleCamInfo[6] = false; @@ -1653,6 +1735,8 @@ void Cigarette::handleTimeout() if (ret > 0) SingleCamInfo[6].OffLine = false; } } +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>7) if (SingleCamInfo[7].OffLine) //8#相机掉线 { //SingleCamInfo[7] = false; @@ -1667,6 +1751,7 @@ void Cigarette::handleTimeout() if (ret > 0) SingleCamInfo[7].OffLine = false; } } +#endif //读取报警信息 if (m_PLCDevice->g_plc_ok) @@ -1691,7 +1776,12 @@ void Cigarette::handleTimeout() { g_vec_alarm.push_back(alarm_info); g_last_alarm_code = alarm_info.alarm_code; - + } + else { + if (g_vec_alarm.empty()) { + g_vec_alarm.push_back(alarm_info); + g_last_alarm_code = alarm_info.alarm_code; + } } } else if (alarm_info.alarm_code == 0) { @@ -1735,9 +1825,9 @@ void Cigarette::handleTimeout() void Cigarette::on_pushButton_reset_released()///复位按钮 { int ret = m_PLCDevice->write_bit_2_plc(g_modbus_conf.reset, 1); - Sleep(1000); - if(g_modbus_conf.reset>0) - int ret = m_PLCDevice->write_bit_2_plc(g_modbus_conf.reset, 0); + //Sleep(1000); + if (g_modbus_conf.reset > 0) + int ret = m_PLCDevice->write_bit_2_plc(g_modbus_conf.reset, 0); } void Cigarette::OnCancelAlarm() //双击消警 { @@ -1818,7 +1908,7 @@ void Cigarette::on_pushButton_clear_released()// } if(g_working) { - QMessageBox::information(NULL, QStringLiteral("状态检查"), QStringLiteral("请先点击“暂停工作”按钮,进入暂停模式,才可以进行换班操作 "), QMessageBox::Ok); + QMessageBox::information(NULL, QStringLiteral("状态检查"), QStringLiteral("请先点击“停止工作”按钮,才可以进行换班操作 "), QMessageBox::Ok); return; } ui.pushButton_clear->setEnabled(false); @@ -1872,7 +1962,7 @@ void Cigarette::on_pushButton_clear_released()// { uint16_t dest16[2]; int ret = m_PLCDevice->read_short_from_plc( g_modbus_conf.quantity, 2, dest16); - std::cout << ret << std::endl; + //std::cout << ret << std::endl; if (ret > 0) { int cur_quantity = dest16[0] + (dest16[1] << 16); @@ -1901,7 +1991,7 @@ void Cigarette::on_pushButton_clear_released()// QString Cigarette::read_pswd() { std::fstream cfg_file; - cfg_file.open("pswd.txt"); + cfg_file.open("D:/Release/pswd.txt"); if (!cfg_file.is_open()) { std::cout << "Error: Open config file pswd.txt"<< std::endl; @@ -1933,7 +2023,7 @@ QString Cigarette::read_pswd() QString Cigarette::read_op_pswd() { std::fstream cfg_file; - cfg_file.open("pswd_op.txt"); + cfg_file.open("D:/Release/pswd_op.txt"); if (!cfg_file.is_open()) { std::cout << "Error: Open config file pswd_op.txt" << std::endl; @@ -2057,6 +2147,10 @@ bool Cigarette::read_sys_config(SysConf &conf) { conf.path_model = line.substr(pos + 1).c_str(); } + else if (tmp_key == "MODELNAME") + { + conf.model_name = line.substr(pos + 1).c_str(); + } else if (tmp_key == "JPGPATH") { conf.path_jpg = line.substr(pos + 1).c_str(); diff --git a/Cigarette/cigarette.h b/Cigarette/cigarette.h index a8a1e24..00d705b 100644 --- a/Cigarette/cigarette.h +++ b/Cigarette/cigarette.h @@ -99,6 +99,7 @@ private slots : void OnToolButtonCamReleasedHub(int Num); void OpenCamTimeoutHub(int Num); void OnDBClickHub(int Num_Cnt); + void DrawRect_init(int Num_Cnt); void OnTPClickHub(int Num_Cnt); void OnDBClickNGHub(int Num); void ReconnectCamHub(int Num); diff --git a/Cigarette/common.h b/Cigarette/common.h index bdfd736..c5cf2e3 100644 --- a/Cigarette/common.h +++ b/Cigarette/common.h @@ -33,13 +33,13 @@ #endif // 主界面基本参数配置文件 -#define CONFIGURE_FILE "../conf/conf.txt" +#define CONFIGURE_FILE "D:/conf/conf.txt" // 相机旋转角度配置文件 -#define ROTATE_FILE "../conf/rotate.txt" -#define MODBUS_CONFIGURE_FILE "../conf/modbus.txt" -#define PLC_CONFIG_FILE "../conf/plc.txt" -#define SELECT_RECTS_FILE "../conf/SelectRects%d%d.txt" -#define STATISTIC_FILE "../conf/camera%d_statistic.txt" +#define ROTATE_FILE "D:/conf/rotate.txt" +#define MODBUS_CONFIGURE_FILE "D:/conf/modbus.txt" +#define PLC_CONFIG_FILE "D:/conf/plc.txt" +#define SELECT_RECTS_FILE "D:/conf/SelectRects%d%d.txt" +#define STATISTIC_FILE "D:/conf/camera%d_statistic.txt" #define ALARM_RECORD_FILE "alarm.txt" #define OUTPUT_HIGH_WIDTH 20000 //输出信号的脉冲宽度,微秒 @@ -75,6 +75,7 @@ public: QTime shiftC; //C换班时间 QString location; // 所在地 QString path_model; // 模型路径 + QString model_name; // 模型名 QString path_jpg; // 图片路径 int timing_shift; //是否定时换班,0否,1是 int expo[NumberOfSupportedCameras]; //相机曝光时间,单位微秒 @@ -103,10 +104,11 @@ public: auto_open=1; //是否自动打开相机,0否,1是 auto_work=1; //是否自动开始工作,0否,1是 auto_shift=0; //是否自动换班,0否,1是 - shift_byhand = 1; - timing_shift=0; //是否定时换班,0否,1是 + shift_byhand = 1; //是否手动换班,0否,1是 + timing_shift = 0; //是否定时换班,0否,1是 location = ""; path_model = ""; + model_name = ""; path_jpg = ""; shiftA.setHMS(0, 0, 0); shiftB.setHMS(0, 0, 0); @@ -158,7 +160,7 @@ public: #endif int quantity; //当班产量地址 int shift; //换班地址 - int work; //开始/暂停 + int work; //开始/停止 int no_kick; //只拍照不剔除模式 int debug; //调试模式,PLC产生模拟的line4信号 int reset; //复位 @@ -192,7 +194,7 @@ public: #endif quantity=0; //当班产量地址 shift=0; //换班地址 - work=0; //开始/暂停 + work=0; //开始/停止 no_kick=0; //只拍照不剔除模式 debug=0; //调试模式,PLC产生模拟的line4信号 reset=0; //复位 diff --git a/Cigarette/debugthread.h b/Cigarette/debugthread.h index 74098f6..6a0efcb 100644 --- a/Cigarette/debugthread.h +++ b/Cigarette/debugthread.h @@ -9,6 +9,7 @@ #include "basecamera.h" #include "common.h" extern SyncQueue *g_debug_queue[NumberOfSupportedCameras]; //鐩告満璋冭瘯妯″紡鍥惧儚闃熷垪 +extern DisplayLabelConf g_display_label_conf[NumberOfSupportedCameras]; extern int rotationAngle[NumberOfSupportedCameras]; //鍥剧墖鏃嬭浆瑙掑害 extern bool isNeddRotate[NumberOfSupportedCameras]; @@ -60,6 +61,16 @@ protected: } emit notify(local_camera_number,0,image); } + std::lock_guard locker2(g_display_label_conf[local_camera_number].lock); + local_DisplayLabelConf.leftButtonDownFlag = g_display_label_conf[local_camera_number].leftButtonDownFlag; + local_DisplayLabelConf.Flag[0] = g_display_label_conf[local_camera_number].Flag[0]; + local_DisplayLabelConf.Flag[1] = g_display_label_conf[local_camera_number].Flag[1]; + local_DisplayLabelConf.originalPoint = g_display_label_conf[local_camera_number].originalPoint; + local_DisplayLabelConf.processPoint = g_display_label_conf[local_camera_number].processPoint; + local_DisplayLabelConf.RectVet[0] = g_display_label_conf[local_camera_number].RectVet[0]; + local_DisplayLabelConf.RectVet[1] = g_display_label_conf[local_camera_number].RectVet[1]; + + DrawSelectRects(image, local_DisplayLabelConf, 0); } } public: @@ -67,6 +78,7 @@ public: int local_classid; bool b_quit; SyncQueue *p_debug_queue; + DisplayLabelConf local_DisplayLabelConf; }; #endif //end of _DEBUGTHREAD_H diff --git a/Cigarette/dialogsetup.cpp b/Cigarette/dialogsetup.cpp index 39c76d9..bd1eec3 100644 --- a/Cigarette/dialogsetup.cpp +++ b/Cigarette/dialogsetup.cpp @@ -54,7 +54,35 @@ DialogSetup::DialogSetup(QWidget * parent) : QDialog(parent) { else { ui.checkBox_auto_work->setChecked(false); } - // + + if (!g_sys_conf.path_model.isEmpty()) { + // 濡傛灉鏇剧粡閫夋嫨杩囨ā鍨嬫枃浠跺す + // 鏌ョ湅dir_path璺緞涓嬫枃浠跺す璇︽儏 + QDir* dirinfo = new QDir(g_sys_conf.path_model); + if (!dirinfo->exists()) + delete dirinfo, dirinfo = nullptr; + dirinfo->setNameFilters(QStringList("*.weights")); // 璁剧疆杩囨护鍣 + QStringList fileList = dirinfo->entryList(QDir::Files); + fileList.removeOne("."); + fileList.removeOne(".."); + ui.comboBox->clear(); + ui.comboBox->addItems(fileList); + if (!g_sys_conf.model_name.isEmpty()) { + // 濡傛灉鏇鹃夋嫨杩囨ā鍨嬶紝鍒欏湪comboBox鏄剧ず閫夋嫨妯″瀷鐨勬枃浠跺悕 + ui.comboBox->setCurrentText(g_sys_conf.model_name); + } + // 鏇存崲妯″瀷浜嬩欢 + connect(ui.comboBox, 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); + } + } + switch (g_sys_conf.save) { case 0: @@ -80,6 +108,14 @@ DialogSetup::~DialogSetup() { } +void DialogSetup::onComboBoxSelect(int index) { + // 鑾峰彇comboBox褰撳墠鍐呭 + QString ct = ui.comboBox->currentText(); + /// QMessageBox::information(this, QStringLiteral("鎻愮ず"), QStringLiteral("鎮ㄩ夋嫨鐨勯」涓")+ct, NULL); + // 淇濆瓨鍒伴厤缃枃浠朵腑 + g_sys_conf.model_name = ct; +} + void DialogSetup::on_toolButton_keyboard_released() { std::thread osk_thread = std::thread(task_osk); @@ -253,17 +289,36 @@ void DialogSetup::on_pushButton_clear_pic_released() } void DialogSetup::on_toolButton_choose_path_released() { - //QString srcDirPath = QFileDialog::getExistingDirectory(this, "choose src Directory", "./"); - QString WeightsPath = QFileDialog::getOpenFileName(this, "閫夋嫨weights鏂囦欢", "/", "Weights files(*.weights)"); - if (WeightsPath.isEmpty()) { + // 鐐瑰嚮娴忚鏂囦欢鎸夐挳鍚庤Е鍙戠殑浜嬩欢 + QString dirName = QFileDialog::getExistingDirectory(this, QStringLiteral("璇烽夋嫨妯″瀷鎵鍦ㄦ枃浠跺す"), "./"); + //std::cout << "dirName is " << dirName.toStdString().c_str() << std::endl; + //std::cout << "g_sys_conf.dir_path is " << g_sys_conf.dir_path.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()) { + dirName = g_sys_conf.path_model; + ui.comboBox->setCurrentText(g_sys_conf.model_name); return; } - else { - if (ui.comboBox->findText(WeightsPath) == -1) { - ui.comboBox->addItem(WeightsPath); // 鍦╟omboBox涓樉绀烘枃浠惰矾寰 - g_sys_conf.path_model = WeightsPath; // 灏嗛夋嫨鐨勮矾寰勫啓鍏onf閰嶇疆鏂囦欢涓 - } + QDir* dirinfo = new QDir(dirName); + if (!dirinfo->exists()) { + delete dirinfo, dirinfo = nullptr; } + dirinfo->setNameFilters(QStringList("*.weights")); + + QStringList fileList = dirinfo->entryList(QDir::Files); + if (fileList.count() == 0) + g_sys_conf.path_model = "D:/model"; + else + g_sys_conf.path_model = dirName; + + fileList.removeOne("."); + fileList.removeOne(".."); + + ui.comboBox->clear(); + ui.comboBox->addItems(fileList); + + delete dirinfo, dirinfo = nullptr; } void DialogSetup::on_toolButton_choose_path_jpg_released() { @@ -282,7 +337,7 @@ void DialogSetup::on_toolButton_choose_path_jpg_released() { void DialogSetup::write_pswd() { std::fstream cfg_file; - cfg_file.open("pswd.txt", std::ios::out | std::ios::trunc); + cfg_file.open("D:/Release/pswd.txt", std::ios::out | std::ios::trunc); if (cfg_file.good()) { char buf[256]; @@ -295,7 +350,7 @@ void DialogSetup::write_pswd() void DialogSetup::write_pswd_op() { std::fstream cfg_file; - cfg_file.open("pswd_op.txt", std::ios::out | std::ios::trunc); + cfg_file.open("D:/Release/pswd_op.txt", std::ios::out | std::ios::trunc); if (cfg_file.good()) { char buf[256]; @@ -361,6 +416,9 @@ void DialogSetup::write_config() sprintf(buf, "MODELPATH=%s\n", g_sys_conf.path_model.toStdString().c_str()); cfg_file.write(buf, strlen(buf)); memset(buf, 0, 256); + 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.path_jpg.toStdString().c_str()); cfg_file.write(buf, strlen(buf)); memset(buf, 0, 256); diff --git a/Cigarette/dialogsetup.hpp b/Cigarette/dialogsetup.hpp index 9e39c27..c1033cd 100644 --- a/Cigarette/dialogsetup.hpp +++ b/Cigarette/dialogsetup.hpp @@ -42,6 +42,7 @@ private slots : void recMsgFromDialogConfig(int ptr[][3]); void recMsgFromChangeShift(QTime timeA, QTime timeB, QTime timeC); + void onComboBoxSelect(int index); #ifdef __DEBUG void on_pushButton_testimg_released(); void on_pushButton_testimgs_released(); diff --git a/Cigarette/main.cpp b/Cigarette/main.cpp index a1eb3da..05627df 100644 --- a/Cigarette/main.cpp +++ b/Cigarette/main.cpp @@ -16,7 +16,7 @@ int main(int argc, char *argv[]) #endif qRegisterMetaType("cv::Mat"); QApplication a(argc, argv); - QPixmap pixmap("splash.jpg"); + QPixmap pixmap("D:/Release/splash.jpg"); QSplashScreen splash(pixmap); splash.show(); a.processEvents(); diff --git a/Cigarette/plcsetup.cpp b/Cigarette/plcsetup.cpp index 67c73d3..38fb142 100644 --- a/Cigarette/plcsetup.cpp +++ b/Cigarette/plcsetup.cpp @@ -8,7 +8,7 @@ #include #include #include "PLCDevice.h" -#define PLC_ITEM_FILE "../conf/plc.txt" +#define PLC_ITEM_FILE "D:/conf/plc.txt" extern PLCDevice * m_PLCDevice;