diff --git a/Cigarette/CaptureThreadHIK.cpp b/Cigarette/CaptureThreadHIK.cpp index 2eb66b2..000fc37 100644 --- a/Cigarette/CaptureThreadHIK.cpp +++ b/Cigarette/CaptureThreadHIK.cpp @@ -231,7 +231,7 @@ void CaptureThreadHIK::process( void ) nRet = MV_CC_RegisterExceptionCallBack(CamHandle, LossCallBack[Local_Num], this); if (nRet) { std::cout << "can not register loss callback" << std::endl; nnRet = nRet; } -#ifdef IMM_FEED_BACK ///不打开无反馈等( 延后一次两次用ifndef // 不延后用ifdef) +//#ifdef IMM_FEED_BACK ///不打开无反馈等( 延后一次两次用ifndef // 不延后用ifdef) nRet = MV_CC_SetEnumValueByString(CamHandle, "EventSelector", "Line0FallingEdge"); if (nRet) { std::cout << "can not set EventSelector" << std::endl; nnRet = nRet; } @@ -249,7 +249,7 @@ void CaptureThreadHIK::process( void ) nRet = MV_CC_RegisterEventCallBackEx(CamHandle, "Line0RisingEdge", RisingGpioEvent[Local_Num], this); if (nRet) { std::cout << "can not register GPIO callback" << std::endl; nnRet = nRet; } -#endif +//#endif m_Timer = new QTimer(); connect(m_Timer, SIGNAL(timeout()), this, SLOT(fpsTimeout())); diff --git a/Cigarette/alg_jd.cpp b/Cigarette/alg_jd.cpp index ce56d5b..3798ef1 100644 --- a/Cigarette/alg_jd.cpp +++ b/Cigarette/alg_jd.cpp @@ -303,6 +303,7 @@ void AlgJd::post_process_batch(std::vector& vec_frame, std::vectorsetVisible(false); } + + m_sendMsg_delay->setSingleShot(true); + m_sendMsg_delay->start(1000); } void Cigarette::Exit() @@ -686,6 +693,7 @@ void Cigarette::on_btn_pause_released() } g_op_time = OP_TIME; } + //锁定/解锁按钮 void Cigarette::on_btn_lock_released() { @@ -770,7 +778,7 @@ void Cigarette::TestImgs() std::cout << "srcDirPath=" << srcDirPath.toStdString() << std::endl; srcDirPath += "/"; //获取该路径下的所有文件 - getFiles(srcDirPath.toStdString() + "*.jpg", files); + getFiles(srcDirPath.toStdString() + "*.bmp", files); if (files.size() == 0) { QMessageBox::StandardButton result = QMessageBox::information(NULL, QStringLiteral("提示"), QStringLiteral("没有找到图片")); @@ -847,6 +855,67 @@ void Cigarette::enable_shift() ui.pushButton_clear->setEnabled(true); } +void Cigarette::sendLatestData() { + // 连接UDP发送最新的数据 + int dataport = g_sys_conf.MonitorPort; + _UDPSendInfo UDPSendInfo; + //UDP_Info_queue->take(UDPSendInfo); + + for (int i = 0; i < NumberOfSupportedCameras; i++) + { + UDPSendInfo.index = i; + + UDPSendInfo.FrameID = ok_frame; + UDPSendInfo.ok[i] = ok[i]; + //sThread.sendData("4_999", dataport + UDPSendInfo.index); + sThread.sendData(("4_" + to_string(ok[i])).c_str(), dataport + UDPSendInfo.index); + //std::cout << "ok[" << i << "] is " << to_string(ok[i]) << std::endl; + //std::cout << ("4_" + to_string(ok[i])).c_str() << std::endl; + //UDP_Info_queue->put(UDPSendInfo); + + UDPSendInfo.FrameID = ng_frame; + UDPSendInfo.ng[i] = ng[i]; + sThread.sendData(("5_" + to_string(ng[i])).c_str(), dataport + UDPSendInfo.index); + + UDPSendInfo.FrameID = total_frame; + UDPSendInfo.Total = production_number[i]; + sThread.sendData(("7_" + to_string(production_number[i])).c_str(), dataport + UDPSendInfo.index); + } + + //while (isLoop) { + //switch (UDPSendInfo.FrameID) { + // case info_frame: { + // sThread.sendData(&UDPSendInfo, dataport); + // break; + // } + // case speed_frame: { + // sThread.sendSpeed(&UDPSendInfo, dataport); + // break; + // } + // case kick_frame: { + // sThread.sendKick(&UDPSendInfo, dataport); + // break; + // } + // case ok_frame: { + // sThread.sendOK(&UDPSendInfo, dataport); + // break; + // } + // case ng_frame: { + // sThread.sendNG(&UDPSendInfo, dataport); + // break; + // } + // case total_frame: { + // sThread.sendTotal(&UDPSendInfo, dataport); + // break; + // } + // case image_frame: { + // //sThread.sendImage(&UDPSendInfo, imageport); + // break; + // } + //} + //} +} + void Cigarette::OnRotateReleasedHub(int Num)//旋转按钮 { QString str = "Start to rotate picture " + QString::number(90 * ((rotationAngle[Num] + 1) % 4)) + " degrees of camera " + QString::number(Num) + "."; @@ -856,7 +925,6 @@ void Cigarette::OnRotateReleasedHub(int Num)// rotationAngle[Num] = (rotationAngle[Num] + 1) % 4; save_rotate_message(); } - } //打开/关闭相机 @@ -1220,7 +1288,7 @@ void Cigarette::OnOKHub(int Num) _UDPSendInfo UDPSendInfo; UDPSendInfo.FrameID = ok_frame; UDPSendInfo.index = Num; - UDPSendInfo.ok = ok[Num]; + UDPSendInfo.ok[Num] = ok[Num]; #ifdef __UDPSend UDP_Info_queue->put(UDPSendInfo); #endif @@ -1235,7 +1303,7 @@ void Cigarette::OnNGHub(int Num) _UDPSendInfo UDPSendInfo; UDPSendInfo.FrameID = ng_frame; UDPSendInfo.index = Num; - UDPSendInfo.ng = ng[Num]; + UDPSendInfo.ng[Num] = ng[Num]; #ifdef __UDPSend UDP_Info_queue->put(UDPSendInfo); #endif @@ -1247,7 +1315,6 @@ void Cigarette::OnNGHub(int Num) void Cigarette::updateStatisticsHub(const QString& statisticalData, int Num) { label_cap_speed_mat[Num]->setText(statisticalData + QStringLiteral("个/秒")); - _UDPSendInfo UDPSendInfo; UDPSendInfo.FrameID = speed_frame; UDPSendInfo.index = Num; @@ -1972,12 +2039,12 @@ void Cigarette::on_pushButton_clear_released()// UDPSendInfo.index = i; UDPSendInfo.FrameID = ok_frame; - UDPSendInfo.ok = ok[i]; + UDPSendInfo.ok[i] = ok[i]; #ifdef __UDPSend UDP_Info_queue->put(UDPSendInfo); #endif UDPSendInfo.FrameID = ng_frame; - UDPSendInfo.ok = ng[i]; + UDPSendInfo.ng[i] = ng[i]; #ifdef __UDPSend UDP_Info_queue->put(UDPSendInfo); #endif @@ -3443,7 +3510,6 @@ void Cigarette::EnableDebugMode() else if(SingleCamInfo[i].CamClass == BaslerClassID) { bool nRet = false; - nRet = BaslerCamHandle[i]->AcquisitionFrameRate.TrySetValue(10); if (!nRet) { std::cout << "can not set Basler's AcquisitionFrameRate" << std::endl; } nRet = BaslerCamHandle[i]->AcquisitionFrameRateEnable.TrySetValue(true); @@ -3676,6 +3742,7 @@ void Cigarette::record_output_statistic(qint64 quantity, int shift) void Cigarette::recMsgFromUdp(QString data) { + //std::cout << data.toStdString() << std::endl; #ifdef __UDPSend if (data == "START") { @@ -3743,8 +3810,6 @@ void Cigarette::recMsgFromUdp(QString data) { OnRotateReleasedHub(7); } - - else if (data == "LOCK") { if (!g_admin_mode) @@ -4012,6 +4077,7 @@ void Cigarette::recMsgFromUdp(QString data) str += QString::number(g_sys_conf.no[i][0]) + '_' + QString::number(g_sys_conf.no[i][1]) + '_' + QString::number(g_sys_conf.no[i][2]) + '_'; } sThread.sendData(str, g_sys_conf.FeedbackPort); + //std::cout << "=> to UDP: " << str.toStdString() << std::endl; } else if (dataList[0] == "UPDSETTING") { diff --git a/Cigarette/cigarette.h b/Cigarette/cigarette.h index 215cfe5..a185b06 100644 --- a/Cigarette/cigarette.h +++ b/Cigarette/cigarette.h @@ -80,6 +80,7 @@ public: private slots : void on_btn_start_released(); void on_btn_pause_released(); + //void on_btn_pause_clicked(bool checked); void on_btn_lock_released(); void on_btn_setup_released(); void on_checkBox_debug_clicked(bool checked); @@ -88,6 +89,7 @@ private slots : void on_toolButton_alarm_released(); void on_pushButton_clear_released(); void enable_shift(); + void sendLatestData(); void OnNotifyHub(int Num, int Cnt, cv::Mat m); void OnDisplayTimeCostHub(int Num, int ms); void OnDisplayCheckNumberHub(int Num, long no); @@ -163,6 +165,7 @@ public: QTimer *m_pTimer; QTimer *m_delay; //鎹㈢彮闃叉杩炲嚮 + QTimer* m_sendMsg_delay; // 鍋滄宸ヤ綔鍚庡彂閫佹渶鏂版暟鎹粰杩滅▼绔 QTimer *m_op_delay; //鎿嶄綔鍛樻潈闄愬墿浣欐椂闂 QTimer *m_admin_delay; //鎿嶄綔鍛樻潈闄愬墿浣欐椂闂 QTimer *clean_pTimer; //瀹氭椂娓呯悊浠诲姟 diff --git a/Cigarette/cigarette.ui b/Cigarette/cigarette.ui index 895c16f..0682856 100644 --- a/Cigarette/cigarette.ui +++ b/Cigarette/cigarette.ui @@ -1188,7 +1188,7 @@ 220 20 - 50 + 61 20 @@ -1248,7 +1248,7 @@ 360 20 - 50 + 61 20 @@ -1552,10 +1552,10 @@ - 880 + 830 10 - 191 - 21 + 210 + 20 @@ -1570,16 +1570,16 @@ color:white - Tel:87907256(0532) + <html><head/><body><p> Tel:87907256(0532)</p></body></html> - 1080 + 1090 10 - 81 - 21 + 80 + 20 @@ -1600,10 +1600,10 @@ - 920 - 30 - 211 - 31 + 830 + 35 + 210 + 20 @@ -1618,7 +1618,7 @@ color:white - 2020-10-10 13:15:39 + <html><head/><body><p>2020-10-10 13:15:39</p></body></html> Qt::AlignCenter @@ -1933,7 +1933,7 @@ 220 20 - 50 + 61 20 @@ -1993,7 +1993,7 @@ 360 20 - 50 + 61 20 @@ -2321,7 +2321,7 @@ 220 20 - 50 + 61 20 @@ -2381,7 +2381,7 @@ 360 20 - 50 + 61 20 @@ -2602,7 +2602,7 @@ 220 20 - 50 + 61 20 @@ -2662,7 +2662,7 @@ 360 20 - 50 + 61 20 @@ -3216,7 +3216,7 @@ 220 20 - 50 + 61 20 @@ -3276,7 +3276,7 @@ 360 20 - 50 + 61 20 @@ -3436,7 +3436,7 @@ 220 20 - 50 + 61 20 @@ -3496,7 +3496,7 @@ 360 20 - 50 + 61 20 @@ -3608,7 +3608,7 @@ 220 20 - 50 + 61 20 @@ -3668,7 +3668,7 @@ 360 20 - 50 + 61 20 @@ -3876,7 +3876,7 @@ 220 20 - 50 + 61 20 @@ -3936,7 +3936,7 @@ 360 20 - 50 + 61 20 @@ -4394,10 +4394,10 @@ - 1180 - 10 - 81 - 21 + 1090 + 35 + 161 + 20 diff --git a/Cigarette/common.h b/Cigarette/common.h index 9f3ce22..5e7ac6a 100644 --- a/Cigarette/common.h +++ b/Cigarette/common.h @@ -9,7 +9,7 @@ //#define __DEBUG //debug信息输出功能 #define __UDPSend //网络发送功能 #define USB_BASLER_NEW_FW //使用basler定制固件 -#define IMM_PROCESS //拍照后立马处理,不等校验信号 +//#define IMM_PROCESS //拍照后立马处理,不等校验信号 #define IMM_FEED_BACK //处理完后立马反馈,不等校验信号 //#define ONE_TIME_SHIFT //错开一拍发送反馈(默认错开两次) #define AI_WARM_UP //AI识别开始前的热身动作 diff --git a/Cigarette/debugthread.h b/Cigarette/debugthread.h index ea9bd12..f31d2ca 100644 --- a/Cigarette/debugthread.h +++ b/Cigarette/debugthread.h @@ -52,7 +52,7 @@ protected: p_debug_queue->take(image); if (image.data) { - cv::cvtColor(image, image, CV_BGR2RGB); //鐏板害鍥惧儚杞负褰╄壊鍥惧儚 + //cv::cvtColor(image, image, CV_BGR2RGB); //鐏板害鍥惧儚杞负褰╄壊鍥惧儚 if (isNeedRotate[local_camera_number]) { if(rotationAngle[local_camera_number] != (cv::ROTATE_90_COUNTERCLOCKWISE + 1)) { diff --git a/Cigarette/dialogsetup.cpp b/Cigarette/dialogsetup.cpp index 49cd405..233ed49 100644 --- a/Cigarette/dialogsetup.cpp +++ b/Cigarette/dialogsetup.cpp @@ -668,7 +668,7 @@ void DialogSetup::on_pushButton_change_released() connect(this, &DialogSetup::sendMsgToShift, m_change_shift, &change_shift::recMsgFromDialogSetup); m_change_shift->show(); m_change_shift->move(this->geometry().center() - m_change_shift->rect().center()); - emit sendMsgToShift(g_sys_conf.shiftA, g_sys_conf.shiftB, g_sys_conf.shiftC); + emit sendMsgToShift (g_sys_conf.shiftA, g_sys_conf.shiftB, g_sys_conf.shiftC); } void DialogSetup::on_pushButton_statistic_released() { diff --git a/Cigarette/threadSend.cpp b/Cigarette/threadSend.cpp index 0fb1144..3feaaa9 100644 --- a/Cigarette/threadSend.cpp +++ b/Cigarette/threadSend.cpp @@ -115,7 +115,7 @@ void threadSend::sendOK(_UDPSendInfo *UDPSendInfo,int port) { QString res = QString("%1_%2") .arg(QString::number(UDPSendInfo->FrameID)) - .arg(QString::number(UDPSendInfo->ok)); + .arg(QString::number(UDPSendInfo->ok[UDPSendInfo->index])); mSocket.writeDatagram(res.toUtf8(), QHostAddress(ip), port + UDPSendInfo->index); } @@ -123,7 +123,7 @@ void threadSend::sendNG(_UDPSendInfo *UDPSendInfo,int port) { QString res = QString("%1_%2") .arg(QString::number(UDPSendInfo->FrameID)) - .arg(QString::number(UDPSendInfo->ng)); + .arg(QString::number(UDPSendInfo->ng[UDPSendInfo->index])); mSocket.writeDatagram(res.toUtf8(), QHostAddress(ip), port + UDPSendInfo->index); } diff --git a/Cigarette/threadSend.h b/Cigarette/threadSend.h index fa52929..ac4ff34 100644 --- a/Cigarette/threadSend.h +++ b/Cigarette/threadSend.h @@ -32,8 +32,8 @@ public: long Total; QString JD; QString timecost; - int ok; - int ng; + int ok[NumberOfSupportedCameras]; + int ng[NumberOfSupportedCameras]; QString speed; int Kick[NumberOfSupportedCameras]; @@ -45,8 +45,8 @@ public: Total = 0; JD = QString("0,0,0"); timecost = QString("0ms");; - ok = false; - ng = false; + for (int i = 0; i < NumberOfSupportedCameras; i++)ok[i] = 0; + for (int i = 0; i < NumberOfSupportedCameras; i++)ng[i] = 0; speed = QString(" "); for(int i=0;i