该版本修改了较多功能:

1.修改部分路径名;
2.修改选择模型路径功能;
3.修改报警功能;
4.修改换班功能;
5.修改调试功能;
6.修改画框功能。
main
18661908385 1 year ago
parent 1e9c49ec92
commit 4323f75315

@ -22,18 +22,24 @@ static int inpHeight = 416; // Height of network's input image
static std::vector<std::string> classes; static std::vector<std::string> classes;
bool AlgJd::init(QString path_model, QString path_jpg) bool AlgJd::init(QString path_model, QString model_name)
{ {
// Load names of classes // Load names of classes
std::string classesFile = "../model/jd.names"; std::string classesFile;
// Give the configuration and weight files for the model cv::String modelConfiguration;
cv::String modelConfiguration = "../model/jd.cfg"; cv::String modelWeights;
cv::String modelWeights = "../model/jd.weights";
if (path_model.length() > 0) { if (path_model.length() > 0 && model_name.length() > 0) {
classesFile = path_model.toStdString() + "/jd.names"; // Æ´´ÕµÄÄ£ÐÍÎļþ·¾¶
modelWeights = path_model.toStdString() + "/" + model_name.toStdString();
modelConfiguration = path_model.toStdString() + "/jd.cfg"; 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()); 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.setPreferableBackend(cv::dnn::DNN_BACKEND_CUDA);
net.setPreferableTarget(cv::dnn::DNN_TARGET_CUDA); net.setPreferableTarget(cv::dnn::DNN_TARGET_CUDA);
//cv::Mat image = cv::imread("alg_jd.jpg"); cv::Mat image = cv::imread("alg_jd.bmp");
cv::Mat image; //cv::Mat image;
if (path_jpg.length() > 0) { //if (path_jpg.length() > 0) {
image = cv::imread(path_jpg.toStdString()); // image = cv::imread(path_jpg.toStdString());
} //}
else { //else {
image = cv::imread("alg_jd.bmp"); // image = cv::imread("D:/Release/alg_jd.bmp");
} //}
//识别一张图测试模型是否正确并且完成GPU数据加载 //识别一张图测试模型是否正确并且完成GPU数据加载
if (!image.data) return false; //判断测试图片是否正常读取 if (!image.data) return false; //判断测试图片是否正常读取

@ -12,7 +12,7 @@
class AlgJd class AlgJd
{ {
public: public:
bool init(QString path_model, QString path_jpg); bool init(QString path_model, QString model_name);
bool test_detect(); bool test_detect();
bool test_detect_batcht(int shoot); bool test_detect_batcht(int shoot);
int detect(cv::Mat& in, cv::Mat &out, std::vector<std::pair<int, cv::Rect> > &results); int detect(cv::Mat& in, cv::Mat &out, std::vector<std::pair<int, cv::Rect> > &results);

@ -41,6 +41,7 @@ void change_shift::on_pushButton_apply_released()
if (ui.radioButton_auto->isChecked()) { /// ŇŃŇţ˛Ř if (ui.radioButton_auto->isChecked()) { /// ŇŃŇţ˛Ř
g_sys_conf.auto_shift = 1; g_sys_conf.auto_shift = 1;
g_sys_conf.timing_shift = 0; g_sys_conf.timing_shift = 0;
g_sys_conf.shift_byhand = 0;
timeA.setHMS(ui.A_hour->minimum(), ui.A_minute->minimum(), 0); timeA.setHMS(ui.A_hour->minimum(), ui.A_minute->minimum(), 0);
timeB.setHMS(ui.B_hour->minimum(), ui.B_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(); //this->close();
} }
else if (ui.radioButton_byhand->isChecked()) { else if (ui.radioButton_byhand->isChecked()) {
g_sys_conf.auto_shift = 0;
g_sys_conf.timing_shift = 0; g_sys_conf.timing_shift = 0;
g_sys_conf.shift_byhand = 1; g_sys_conf.shift_byhand = 1;

@ -192,6 +192,7 @@ Cigarette::Cigarette(QWidget *parent)
ng[i] = 0; 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[0] = cv::Mat::zeros(20, 20, CV_8UC3);
g_display_label_conf[i].g_last_mat[1] = 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->display(0);
ui.lcdNumber_total_no_last->display(0); ui.lcdNumber_total_no_last->display(0);
@ -204,14 +205,38 @@ Cigarette::Cigarette(QWidget *parent)
read_sys_config(g_sys_conf); //初始化系统配置 read_sys_config(g_sys_conf); //初始化系统配置
g_modbus_conf.kick1 = 0; //g_modbus_conf.kick1 = 0;
g_modbus_conf.kick2 = 0; //g_modbus_conf.kick2 = 0;
g_modbus_conf.kick3 = 0; //g_modbus_conf.kick3 = 0;
g_modbus_conf.kick4 = 0; //g_modbus_conf.kick4 = 0;
g_modbus_conf.kick5 = 0; //g_modbus_conf.kick5 = 0;
g_modbus_conf.kick6 = 0; //g_modbus_conf.kick6 = 0;
g_modbus_conf.kick7 = 0; //g_modbus_conf.kick7 = 0;
g_modbus_conf.kick8 = 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.quantity = 0;
g_modbus_conf.shift = 0; g_modbus_conf.shift = 0;
g_modbus_conf.work = 0; g_modbus_conf.work = 0;
@ -289,7 +314,7 @@ Cigarette::Cigarette(QWidget *parent)
{ {
if(SingleCamInfo[i].Detect){ if(SingleCamInfo[i].Detect){
cam_status_mat[i]->setStyleSheet(tr("background-color: rgb(0, 170, 0);")); 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); QMessageBox::information(NULL, QStringLiteral("系统自检失败"), QStringLiteral("AI模型1初始化失败请检查程序完整性"), QMessageBox::Ok);
exit(-1); exit(-1);
@ -523,6 +548,7 @@ void Cigarette::on_btn_start_released()
} }
} }
g_op_time = OP_TIME; g_op_time = OP_TIME;
ui.checkBox_debug->setEnabled(true); //使能相机调试checkBox
} }
void Cigarette::pause_work() void Cigarette::pause_work()
@ -590,7 +616,7 @@ void Cigarette::Exit()
} }
//停按钮 //止工作按钮
void Cigarette::on_btn_pause_released() void Cigarette::on_btn_pause_released()
{ {
emit sengMsgToClog("Pause the application."); 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]); 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) void Cigarette::OnTPClickHub(int Num_Cnt)
{ {
int Num = Num_Cnt >> 4; int Num = Num_Cnt >> 4;
@ -1205,8 +1273,9 @@ void Cigarette::on_checkBox_debug_clicked(bool checked)
{ {
if (g_working) if (g_working)
{ {
QMessageBox::information(NULL, QStringLiteral("操作顺序检查 "), QStringLiteral("请先点击‘停工作’按钮,才能进入调试模式"), QMessageBox::Ok); QMessageBox::information(NULL, QStringLiteral("操作顺序检查 "), QStringLiteral("请先点击‘工作’按钮,才能进入调试模式"), QMessageBox::Ok);
ui.checkBox_debug->setChecked(false); ui.checkBox_debug->setChecked(false);
return;
} }
else else
{ {
@ -1222,8 +1291,9 @@ void Cigarette::on_checkBox_debug_clicked(bool checked)
{ {
emit sengMsgToClog("Exit debug mode."); emit sengMsgToClog("Exit debug mode.");
DisableDebugMode(); DisableDebugMode();
on_pushButton_clear_released(); //换班 //on_pushButton_clear_released(); //换班
ui.checkBox_debug->setChecked(false); ui.checkBox_debug->setChecked(false);
ui.checkBox_debug->setEnabled(true);
#ifdef __UDPSend #ifdef __UDPSend
sThread.sendData("DebugDis", g_sys_conf.FeedbackPort); sThread.sendData("DebugDis", g_sys_conf.FeedbackPort);
#endif #endif
@ -1351,7 +1421,7 @@ void Cigarette::handleTimeout()
if (quantity_stop_count == STOP_SECONDS) //触发一次换班 if (quantity_stop_count == STOP_SECONDS) //触发一次换班
{ {
g_op_mode = true; //激活操作员模式 g_op_mode = true; //激活操作员模式
on_btn_pause_released(); // on_btn_pause_released(); //止工作
on_pushButton_clear_released(); //换班 on_pushButton_clear_released(); //换班
on_btn_start_released(); //开始 on_btn_start_released(); //开始
g_op_mode = false; //退出操作员模式 g_op_mode = false; //退出操作员模式
@ -1367,7 +1437,7 @@ void Cigarette::handleTimeout()
if (secA == 0) if (secA == 0)
{ {
g_op_mode = true; //激活操作员模式 g_op_mode = true; //激活操作员模式
on_btn_pause_released(); // on_btn_pause_released(); //止工作
record_output_statistic(cur_quantity, 0); record_output_statistic(cur_quantity, 0);
on_pushButton_clear_released(); //换班 on_pushButton_clear_released(); //换班
on_btn_start_released(); //开始 on_btn_start_released(); //开始
@ -1376,7 +1446,7 @@ void Cigarette::handleTimeout()
else if (secB == 0) else if (secB == 0)
{ {
g_op_mode = true; //激活操作员模式 g_op_mode = true; //激活操作员模式
on_btn_pause_released(); // on_btn_pause_released(); //止工作
record_output_statistic(cur_quantity, 1); record_output_statistic(cur_quantity, 1);
on_pushButton_clear_released(); //换班 on_pushButton_clear_released(); //换班
on_btn_start_released(); //开始 on_btn_start_released(); //开始
@ -1385,7 +1455,7 @@ void Cigarette::handleTimeout()
else if (secC == 0) else if (secC == 0)
{ {
g_op_mode = true; //激活操作员模式 g_op_mode = true; //激活操作员模式
on_btn_pause_released(); // on_btn_pause_released(); //止工作
record_output_statistic(cur_quantity, 2); record_output_statistic(cur_quantity, 2);
on_pushButton_clear_released(); //换班 on_pushButton_clear_released(); //换班
on_btn_start_released(); //开始 on_btn_start_released(); //开始
@ -1554,6 +1624,7 @@ void Cigarette::handleTimeout()
} }
} }
//相机掉线检测 //相机掉线检测
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>0)
if (SingleCamInfo[0].OffLine) //1#相机掉线 if (SingleCamInfo[0].OffLine) //1#相机掉线
{ {
//SingleCamInfo[0] = false; //SingleCamInfo[0] = false;
@ -1568,6 +1639,8 @@ void Cigarette::handleTimeout()
if (ret > 0) SingleCamInfo[0].OffLine = false; if (ret > 0) SingleCamInfo[0].OffLine = false;
} }
} }
#endif
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>1)
if (SingleCamInfo[1].OffLine) //2#相机掉线 if (SingleCamInfo[1].OffLine) //2#相机掉线
{ {
//SingleCamInfo[1] = false; //SingleCamInfo[1] = false;
@ -1582,6 +1655,8 @@ void Cigarette::handleTimeout()
if(ret > 0) SingleCamInfo[1].OffLine = false; if(ret > 0) SingleCamInfo[1].OffLine = false;
} }
} }
#endif
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>2)
if (SingleCamInfo[2].OffLine) //3#相机掉线 if (SingleCamInfo[2].OffLine) //3#相机掉线
{ {
//SingleCamInfo[2] = false; //SingleCamInfo[2] = false;
@ -1596,7 +1671,8 @@ void Cigarette::handleTimeout()
if (ret > 0) SingleCamInfo[2].OffLine = false; if (ret > 0) SingleCamInfo[2].OffLine = false;
} }
} }
#endif
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>3)
if (SingleCamInfo[3].OffLine) //4#相机掉线 if (SingleCamInfo[3].OffLine) //4#相机掉线
{ {
//SingleCamInfo[3] = false; //SingleCamInfo[3] = false;
@ -1611,6 +1687,8 @@ void Cigarette::handleTimeout()
if (ret > 0) SingleCamInfo[3].OffLine = false; if (ret > 0) SingleCamInfo[3].OffLine = false;
} }
} }
#endif
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>4)
if (SingleCamInfo[4].OffLine) //5#相机掉线 if (SingleCamInfo[4].OffLine) //5#相机掉线
{ {
//SingleCamInfo[4] = false; //SingleCamInfo[4] = false;
@ -1625,6 +1703,8 @@ void Cigarette::handleTimeout()
if (ret > 0) SingleCamInfo[4].OffLine = false; if (ret > 0) SingleCamInfo[4].OffLine = false;
} }
} }
#endif
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>5)
if (SingleCamInfo[5].OffLine) //6#相机掉线 if (SingleCamInfo[5].OffLine) //6#相机掉线
{ {
//SingleCamInfo[5] = false; //SingleCamInfo[5] = false;
@ -1639,6 +1719,8 @@ void Cigarette::handleTimeout()
if (ret > 0) SingleCamInfo[5].OffLine = false; if (ret > 0) SingleCamInfo[5].OffLine = false;
} }
} }
#endif
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>6)
if (SingleCamInfo[6].OffLine) //7#相机掉线 if (SingleCamInfo[6].OffLine) //7#相机掉线
{ {
//SingleCamInfo[6] = false; //SingleCamInfo[6] = false;
@ -1653,6 +1735,8 @@ void Cigarette::handleTimeout()
if (ret > 0) SingleCamInfo[6].OffLine = false; if (ret > 0) SingleCamInfo[6].OffLine = false;
} }
} }
#endif
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>7)
if (SingleCamInfo[7].OffLine) //8#相机掉线 if (SingleCamInfo[7].OffLine) //8#相机掉线
{ {
//SingleCamInfo[7] = false; //SingleCamInfo[7] = false;
@ -1667,6 +1751,7 @@ void Cigarette::handleTimeout()
if (ret > 0) SingleCamInfo[7].OffLine = false; if (ret > 0) SingleCamInfo[7].OffLine = false;
} }
} }
#endif
//读取报警信息 //读取报警信息
if (m_PLCDevice->g_plc_ok) if (m_PLCDevice->g_plc_ok)
@ -1691,7 +1776,12 @@ void Cigarette::handleTimeout()
{ {
g_vec_alarm.push_back(alarm_info); g_vec_alarm.push_back(alarm_info);
g_last_alarm_code = alarm_info.alarm_code; 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) { else if (alarm_info.alarm_code == 0) {
@ -1735,9 +1825,9 @@ void Cigarette::handleTimeout()
void Cigarette::on_pushButton_reset_released()///复位按钮 void Cigarette::on_pushButton_reset_released()///复位按钮
{ {
int ret = m_PLCDevice->write_bit_2_plc(g_modbus_conf.reset, 1); int ret = m_PLCDevice->write_bit_2_plc(g_modbus_conf.reset, 1);
Sleep(1000); //Sleep(1000);
if(g_modbus_conf.reset>0) if (g_modbus_conf.reset > 0)
int ret = m_PLCDevice->write_bit_2_plc(g_modbus_conf.reset, 0); int ret = m_PLCDevice->write_bit_2_plc(g_modbus_conf.reset, 0);
} }
void Cigarette::OnCancelAlarm() //双击消警 void Cigarette::OnCancelAlarm() //双击消警
{ {
@ -1818,7 +1908,7 @@ void Cigarette::on_pushButton_clear_released()//
} }
if(g_working) if(g_working)
{ {
QMessageBox::information(NULL, QStringLiteral("状态检查"), QStringLiteral("请先点击“停工作”按钮,进入暂停模式,才可以进行换班操作 "), QMessageBox::Ok); QMessageBox::information(NULL, QStringLiteral("状态检查"), QStringLiteral("请先点击“工作”按钮,才可以进行换班操作 "), QMessageBox::Ok);
return; return;
} }
ui.pushButton_clear->setEnabled(false); ui.pushButton_clear->setEnabled(false);
@ -1872,7 +1962,7 @@ void Cigarette::on_pushButton_clear_released()//
{ {
uint16_t dest16[2]; uint16_t dest16[2];
int ret = m_PLCDevice->read_short_from_plc( g_modbus_conf.quantity, 2, dest16); 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) if (ret > 0)
{ {
int cur_quantity = dest16[0] + (dest16[1] << 16); int cur_quantity = dest16[0] + (dest16[1] << 16);
@ -1901,7 +1991,7 @@ void Cigarette::on_pushButton_clear_released()//
QString Cigarette::read_pswd() QString Cigarette::read_pswd()
{ {
std::fstream cfg_file; std::fstream cfg_file;
cfg_file.open("pswd.txt"); cfg_file.open("D:/Release/pswd.txt");
if (!cfg_file.is_open()) if (!cfg_file.is_open())
{ {
std::cout << "Error: Open config file pswd.txt"<< std::endl; std::cout << "Error: Open config file pswd.txt"<< std::endl;
@ -1933,7 +2023,7 @@ QString Cigarette::read_pswd()
QString Cigarette::read_op_pswd() QString Cigarette::read_op_pswd()
{ {
std::fstream cfg_file; std::fstream cfg_file;
cfg_file.open("pswd_op.txt"); cfg_file.open("D:/Release/pswd_op.txt");
if (!cfg_file.is_open()) if (!cfg_file.is_open())
{ {
std::cout << "Error: Open config file pswd_op.txt" << std::endl; 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(); 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") else if (tmp_key == "JPGPATH")
{ {
conf.path_jpg = line.substr(pos + 1).c_str(); conf.path_jpg = line.substr(pos + 1).c_str();

@ -99,6 +99,7 @@ private slots :
void OnToolButtonCamReleasedHub(int Num); void OnToolButtonCamReleasedHub(int Num);
void OpenCamTimeoutHub(int Num); void OpenCamTimeoutHub(int Num);
void OnDBClickHub(int Num_Cnt); void OnDBClickHub(int Num_Cnt);
void DrawRect_init(int Num_Cnt);
void OnTPClickHub(int Num_Cnt); void OnTPClickHub(int Num_Cnt);
void OnDBClickNGHub(int Num); void OnDBClickNGHub(int Num);
void ReconnectCamHub(int Num); void ReconnectCamHub(int Num);

@ -33,13 +33,13 @@
#endif #endif
// 主界面基本参数配置文件 // 主界面基本参数配置文件
#define CONFIGURE_FILE "../conf/conf.txt" #define CONFIGURE_FILE "D:/conf/conf.txt"
// 相机旋转角度配置文件 // 相机旋转角度配置文件
#define ROTATE_FILE "../conf/rotate.txt" #define ROTATE_FILE "D:/conf/rotate.txt"
#define MODBUS_CONFIGURE_FILE "../conf/modbus.txt" #define MODBUS_CONFIGURE_FILE "D:/conf/modbus.txt"
#define PLC_CONFIG_FILE "../conf/plc.txt" #define PLC_CONFIG_FILE "D:/conf/plc.txt"
#define SELECT_RECTS_FILE "../conf/SelectRects%d%d.txt" #define SELECT_RECTS_FILE "D:/conf/SelectRects%d%d.txt"
#define STATISTIC_FILE "../conf/camera%d_statistic.txt" #define STATISTIC_FILE "D:/conf/camera%d_statistic.txt"
#define ALARM_RECORD_FILE "alarm.txt" #define ALARM_RECORD_FILE "alarm.txt"
#define OUTPUT_HIGH_WIDTH 20000 //输出信号的脉冲宽度,微秒 #define OUTPUT_HIGH_WIDTH 20000 //输出信号的脉冲宽度,微秒
@ -75,6 +75,7 @@ public:
QTime shiftC; //C换班时间 QTime shiftC; //C换班时间
QString location; // 所在地 QString location; // 所在地
QString path_model; // 模型路径 QString path_model; // 模型路径
QString model_name; // 模型名
QString path_jpg; // 图片路径 QString path_jpg; // 图片路径
int timing_shift; //是否定时换班0否1是 int timing_shift; //是否定时换班0否1是
int expo[NumberOfSupportedCameras]; //相机曝光时间,单位微秒 int expo[NumberOfSupportedCameras]; //相机曝光时间,单位微秒
@ -103,10 +104,11 @@ public:
auto_open=1; //是否自动打开相机0否1是 auto_open=1; //是否自动打开相机0否1是
auto_work=1; //是否自动开始工作0否1是 auto_work=1; //是否自动开始工作0否1是
auto_shift=0; //是否自动换班0否1是 auto_shift=0; //是否自动换班0否1是
shift_byhand = 1; shift_byhand = 1; //是否手动换班0否1是
timing_shift=0; //是否定时换班0否1是 timing_shift = 0; //是否定时换班0否1是
location = ""; location = "";
path_model = ""; path_model = "";
model_name = "";
path_jpg = ""; path_jpg = "";
shiftA.setHMS(0, 0, 0); shiftA.setHMS(0, 0, 0);
shiftB.setHMS(0, 0, 0); shiftB.setHMS(0, 0, 0);
@ -158,7 +160,7 @@ public:
#endif #endif
int quantity; //当班产量地址 int quantity; //当班产量地址
int shift; //换班地址 int shift; //换班地址
int work; //开始/ int work; //开始/
int no_kick; //只拍照不剔除模式 int no_kick; //只拍照不剔除模式
int debug; //调试模式PLC产生模拟的line4信号 int debug; //调试模式PLC产生模拟的line4信号
int reset; //复位 int reset; //复位
@ -192,7 +194,7 @@ public:
#endif #endif
quantity=0; //当班产量地址 quantity=0; //当班产量地址
shift=0; //换班地址 shift=0; //换班地址
work=0; //开始/ work=0; //开始/
no_kick=0; //只拍照不剔除模式 no_kick=0; //只拍照不剔除模式
debug=0; //调试模式PLC产生模拟的line4信号 debug=0; //调试模式PLC产生模拟的line4信号
reset=0; //复位 reset=0; //复位

@ -9,6 +9,7 @@
#include "basecamera.h" #include "basecamera.h"
#include "common.h" #include "common.h"
extern SyncQueue<cv::Mat> *g_debug_queue[NumberOfSupportedCameras]; //相机调试模式图像队列 extern SyncQueue<cv::Mat> *g_debug_queue[NumberOfSupportedCameras]; //相机调试模式图像队列
extern DisplayLabelConf g_display_label_conf[NumberOfSupportedCameras];
extern int rotationAngle[NumberOfSupportedCameras]; //图片旋转角度 extern int rotationAngle[NumberOfSupportedCameras]; //图片旋转角度
extern bool isNeddRotate[NumberOfSupportedCameras]; extern bool isNeddRotate[NumberOfSupportedCameras];
@ -60,6 +61,16 @@ protected:
} }
emit notify(local_camera_number,0,image); emit notify(local_camera_number,0,image);
} }
std::lock_guard<std::mutex> 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: public:
@ -67,6 +78,7 @@ public:
int local_classid; int local_classid;
bool b_quit; bool b_quit;
SyncQueue<cv::Mat> *p_debug_queue; SyncQueue<cv::Mat> *p_debug_queue;
DisplayLabelConf local_DisplayLabelConf;
}; };
#endif //end of _DEBUGTHREAD_H #endif //end of _DEBUGTHREAD_H

@ -54,7 +54,35 @@ DialogSetup::DialogSetup(QWidget * parent) : QDialog(parent) {
else { else {
ui.checkBox_auto_work->setChecked(false); 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) switch (g_sys_conf.save)
{ {
case 0: 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() void DialogSetup::on_toolButton_keyboard_released()
{ {
std::thread osk_thread = std::thread(task_osk); 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() { void DialogSetup::on_toolButton_choose_path_released() {
//QString srcDirPath = QFileDialog::getExistingDirectory(this, "choose src Directory", "./"); // 点击浏览文件按钮后触发的事件
QString WeightsPath = QFileDialog::getOpenFileName(this, "选择weights文件", "/", "Weights files(*.weights)"); QString dirName = QFileDialog::getExistingDirectory(this, QStringLiteral("请选择模型所在文件夹"), "./");
if (WeightsPath.isEmpty()) { //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; return;
} }
else { QDir* dirinfo = new QDir(dirName);
if (ui.comboBox->findText(WeightsPath) == -1) { if (!dirinfo->exists()) {
ui.comboBox->addItem(WeightsPath); // 在comboBox中显示文件路径 delete dirinfo, dirinfo = nullptr;
g_sys_conf.path_model = WeightsPath; // 将选择的路径写入conf配置文件中
}
} }
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() { void DialogSetup::on_toolButton_choose_path_jpg_released() {
@ -282,7 +337,7 @@ void DialogSetup::on_toolButton_choose_path_jpg_released() {
void DialogSetup::write_pswd() void DialogSetup::write_pswd()
{ {
std::fstream cfg_file; 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()) if (cfg_file.good())
{ {
char buf[256]; char buf[256];
@ -295,7 +350,7 @@ void DialogSetup::write_pswd()
void DialogSetup::write_pswd_op() void DialogSetup::write_pswd_op()
{ {
std::fstream cfg_file; 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()) if (cfg_file.good())
{ {
char buf[256]; char buf[256];
@ -361,6 +416,9 @@ void DialogSetup::write_config()
sprintf(buf, "MODELPATH=%s\n", g_sys_conf.path_model.toStdString().c_str()); sprintf(buf, "MODELPATH=%s\n", g_sys_conf.path_model.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, "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()); sprintf(buf, "JPGPATH=%s\n", g_sys_conf.path_jpg.toStdString().c_str());
cfg_file.write(buf, strlen(buf)); cfg_file.write(buf, strlen(buf));
memset(buf, 0, 256); memset(buf, 0, 256);

@ -42,6 +42,7 @@ 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);
#ifdef __DEBUG #ifdef __DEBUG
void on_pushButton_testimg_released(); void on_pushButton_testimg_released();
void on_pushButton_testimgs_released(); void on_pushButton_testimgs_released();

@ -16,7 +16,7 @@ int main(int argc, char *argv[])
#endif #endif
qRegisterMetaType<cv::Mat>("cv::Mat"); qRegisterMetaType<cv::Mat>("cv::Mat");
QApplication a(argc, argv); QApplication a(argc, argv);
QPixmap pixmap("splash.jpg"); QPixmap pixmap("D:/Release/splash.jpg");
QSplashScreen splash(pixmap); QSplashScreen splash(pixmap);
splash.show(); splash.show();
a.processEvents(); a.processEvents();

@ -8,7 +8,7 @@
#include <qmessagebox.h> #include <qmessagebox.h>
#include <QIntValidator> #include <QIntValidator>
#include "PLCDevice.h" #include "PLCDevice.h"
#define PLC_ITEM_FILE "../conf/plc.txt" #define PLC_ITEM_FILE "D:/conf/plc.txt"
extern PLCDevice * m_PLCDevice; extern PLCDevice * m_PLCDevice;

Loading…
Cancel
Save