diff --git a/Doc/AOI手动å¤�ä½�SOP.pptx b/Doc/AOI手动å¤�ä½�SOP.pptx new file mode 100644 index 00000000..9830d6fb Binary files /dev/null and b/Doc/AOI手动å¤�ä½�SOP.pptx differ diff --git a/Doc/AOI检测软件SOP-2024-8-21.pptx b/Doc/AOI检测软件SOP-2024-8-21.pptx new file mode 100644 index 00000000..5dbdb35d Binary files /dev/null and b/Doc/AOI检测软件SOP-2024-8-21.pptx differ diff --git a/HanddleAI/HandleAiUi-new/algo/ALGO_Correction.h b/HanddleAI/HandleAiUi-new/algo/ALGO_Correction.h index 71bafd2d..223fe2b7 100644 --- a/HanddleAI/HandleAiUi-new/algo/ALGO_Correction.h +++ b/HanddleAI/HandleAiUi-new/algo/ALGO_Correction.h @@ -4,6 +4,7 @@ #include struct CorrectionPoints { + double OriginZ, OriginX, OriginY; std::vector Origin;//X Y Z std::vector Result_X;//X Y Z std::vector Result_Y;//X Y Z @@ -300,10 +301,41 @@ double doubleLmit(double input, int num) out << std::fixed << std::setprecision(num) << input; return std::stod(out.str()); } +bool simpleCorrection(correctionStruct* correctionData, CorrectionPoints& result) +{ + //Z + { + double sum = 0; + for (auto zData : correctionData->in_Z_X0Y) + sum += zData; + for (auto zData : correctionData->in_Z_X0Y_Value) + sum += zData; + result.OriginZ = sum / 3; + } + //X + { + double sum = 0; + for (auto xData : correctionData->in_X_Y0Z) + sum += xData; + for (auto xData : correctionData->in_X_Y0Z_Value) + sum += xData; + result.OriginX = sum / 3; + } + //Y + { + double sum = 0; + for (auto yData : correctionData->in_Y_X0Z) + sum += yData; + for (auto yData : correctionData->in_Y_X0Z_Value) + sum += yData; + result.OriginY = sum / 3; + } + return true; +} void ALGO_Correction(std::shared_ptr data) { CorrectionPoints resultPoints; - if (HalconCorrection(&data->laserData, resultPoints) == false) + if (simpleCorrection(&data->laserData, resultPoints) == false) { data->writeBack("short", 274, "1"); return; @@ -315,38 +347,38 @@ void ALGO_Correction(std::shared_ptr data) qDebug() << "productIndex:"<< data->productType <<"ox:" << resultPoints.Origin[0] << "oy : " << resultPoints.Origin[1] << "oz : " << resultPoints.Origin[2]; qDebug() << "Rx:" << point.x << "Ry:" << point.y << "Rz:" << point.z; - double baseOffsetX = data->_productDataStruct.basePos[0] - resultPoints.Origin[0]; - double baseOffsetY = data->_productDataStruct.basePos[1] - resultPoints.Origin[1]; - double baseOffsetZ = data->_productDataStruct.basePos[2] - resultPoints.Origin[2]; + double baseOffsetX = data->_productDataStruct.basePos[0] - resultPoints.OriginX; + double baseOffsetY = data->_productDataStruct.basePos[1] - resultPoints.OriginY; + double baseOffsetZ = data->_productDataStruct.basePos[2] - resultPoints.OriginZ; - double offsetRx = data->_productDataStruct.baseRad[0] - point.x; - double offsetRy = data->_productDataStruct.baseRad[1] - point.y; - double offsetRz = data->_productDataStruct.baseRad[2] - point.z; + //double offsetRx = data->_productDataStruct.baseRad[0] - point.x; + //double offsetRy = data->_productDataStruct.baseRad[1] - point.y; + //double offsetRz = data->_productDataStruct.baseRad[2] - point.z; - cv::Vec3d radIn1({ 0,0,0 }); - cv::Vec3d radIn2({ degToRad(offsetRx),degToRad(offsetRy),degToRad(offsetRz) }); - cv::Mat coords = (cv::Mat_(3, 1) << data->_productDataStruct.basePos[0], data->_productDataStruct.basePos[1], data->_productDataStruct.basePos[2]); - cv::Mat newCoords = transform_coordinates(coords, radIn1, radIn2); - cv::Mat coordsOffset = (cv::Mat_(3, 1) << coords.at(0, 0) - newCoords.at(0, 0), coords.at(1, 0) - newCoords.at(1, 0), coords.at(2, 0) - newCoords.at(2, 0)); + //cv::Vec3d radIn1({ 0,0,0 }); + //cv::Vec3d radIn2({ degToRad(offsetRx),degToRad(offsetRy),degToRad(offsetRz) }); + //cv::Mat coords = (cv::Mat_(3, 1) << data->_productDataStruct.basePos[0], data->_productDataStruct.basePos[1], data->_productDataStruct.basePos[2]); + //cv::Mat newCoords = transform_coordinates(coords, radIn1, radIn2); + //cv::Mat coordsOffset = (cv::Mat_(3, 1) << coords.at(0, 0) - newCoords.at(0, 0), coords.at(1, 0) - newCoords.at(1, 0), coords.at(2, 0) - newCoords.at(2, 0)); - double offsetX = doubleLmit(coordsOffset.at(0, 0) + baseOffsetX,3); - double offsetY = doubleLmit(coordsOffset.at(1, 0) + baseOffsetY,3); - double offsetZ = doubleLmit(coordsOffset.at(2, 0) + baseOffsetZ,3); + //double offsetX = doubleLmit(coordsOffset.at(0, 0) + baseOffsetX,3); + //double offsetY = doubleLmit(coordsOffset.at(1, 0) + baseOffsetY,3); + //double offsetZ = doubleLmit(coordsOffset.at(2, 0) + baseOffsetZ,3); - offsetRx = doubleLmit(offsetRx, 3); - offsetRy = doubleLmit(offsetRy, 3); - offsetRz = doubleLmit(offsetRz, 3); + //offsetRx = doubleLmit(offsetRx, 3); + //offsetRy = doubleLmit(offsetRy, 3); + //offsetRz = doubleLmit(offsetRz, 3); - std::cout << "offsetX:" << offsetX << "offsetY:" << offsetY << "offsetZ:" << offsetZ << std::endl; - std::cout << "offsetRx:" << offsetRx << "offsetRy:" << offsetRy << "offsetRz:" << offsetRz << std::endl; + std::cout << "offsetX:" << baseOffsetX << "offsetY:" << baseOffsetY << "offsetZ:" << baseOffsetZ << std::endl; + //std::cout << "offsetRx:" << offsetRx << "offsetRy:" << offsetRy << "offsetRz:" << offsetRz << std::endl; - createModbusStrs(310, offsetX,data); - createModbusStrs(313, offsetY, data); - createModbusStrs(316, offsetZ, data); + createModbusStrs(310, baseOffsetX,data); + createModbusStrs(313, baseOffsetY, data); + createModbusStrs(316, baseOffsetZ, data); - createModbusStrs(319, offsetRx, data); - createModbusStrs(322, offsetRy, data); - createModbusStrs(325, offsetRz, data); + //createModbusStrs(319, offsetRx, data); + //createModbusStrs(322, offsetRy, data); + //createModbusStrs(325, offsetRz, data); data->writeBack("short", 274, "1"); } \ No newline at end of file diff --git a/HanddleAI/HandleAiUi-new/algo/ALGO_Inspection.h b/HanddleAI/HandleAiUi-new/algo/ALGO_Inspection.h index 2429e69f..32a155c8 100644 --- a/HanddleAI/HandleAiUi-new/algo/ALGO_Inspection.h +++ b/HanddleAI/HandleAiUi-new/algo/ALGO_Inspection.h @@ -8,6 +8,7 @@ #include #include #include +#include cv::Mat pinHandleAiEvaluate(std::shared_ptr data, cv::Mat& src, handleAiModelSeg* segPtr, handleAiModelCls* clsPtr); bool pinHalconEvaluate(std::shared_ptr data, cv::Rect& Result, cv::Mat& src, cv::Mat& out, int productType); @@ -19,6 +20,7 @@ std::vector pinDetEvaluate(std::shared_ptr data, cv:: handleAiModelDet* detPtr = _handleAiModelManager->getDetModel("connectorDet.BHD"); if (detPtr == nullptr) return std::vector(); + src = rotateImage(src, cv::Point2f(src.cols / 2, src.rows / 2), -1, 1); detPtr->Evaluate(src, result); return result; } diff --git a/HanddleAI/HandleAiUi-new/algo/templateAlgo.h b/HanddleAI/HandleAiUi-new/algo/templateAlgo.h new file mode 100644 index 00000000..e2dd3752 --- /dev/null +++ b/HanddleAI/HandleAiUi-new/algo/templateAlgo.h @@ -0,0 +1,56 @@ +#include +double templateMatchAndAngle(const cv::Mat& img, const cv::Mat& templ) { + // ´´½¨´æ´¢Æ¥Åä½á¹ûµÄ¾ØÕó + cv::Mat result; + int result_cols = img.cols - templ.cols + 1; + int result_rows = img.rows - templ.rows + 1; + result.create(result_rows, result_cols, CV_32FC1); + + // Ö´ÐÐÄ£°åÆ¥Åä + cv::matchTemplate(img, templ, result, cv::TM_CCOEFF_NORMED); + + // ͨ¹ý minMaxLoc ²éÕÒ×î¼ÑÆ¥ÅäλÖà + double minVal, maxVal; + cv::Point minLoc, maxLoc; + cv::minMaxLoc(result, &minVal, &maxVal, &minLoc, &maxLoc); + + // ʹÓà ORB ½øÐÐÌØÕ÷µãÌáÈ¡ + std::vector keypoints_img, keypoints_templ; + cv::Mat descriptors_img, descriptors_templ; + cv::Ptr orb = cv::ORB::create(); + orb->detectAndCompute(img, cv::noArray(), keypoints_img, descriptors_img); + orb->detectAndCompute(templ, cv::noArray(), keypoints_templ, descriptors_templ); + + // ʹÓà BFMatcher ½øÐÐÌØÕ÷µãÆ¥Åä + cv::BFMatcher matcher(cv::NORM_HAMMING); + std::vector matches; + matcher.match(descriptors_img, descriptors_templ, matches); + + // ¼ÆËãÆ¥Åäµã¼äµÄ½Ç¶ÈÆ«ÒÆ + double angle_sum = 0; + int count = 0; + for (const auto& match : matches) { + cv::Point2f pt_img = keypoints_img[match.queryIdx].pt; + cv::Point2f pt_templ = keypoints_templ[match.trainIdx].pt; + + // ¼ÆËãÏòÁ¿µÄ½Ç¶È + double angle = atan2(pt_img.y - pt_templ.y, pt_img.x - pt_templ.x) * 180 / CV_PI; + angle_sum += angle; + count++; + } + + // ¼ÆËãÆ½¾ù½Ç¶È + double average_angle = count > 0 ? angle_sum / count : 0; + + return average_angle; +} +cv::Mat rotateImage(const cv::Mat& img, const cv::Point2f& center, double angle, double scale) { + // »ñÈ¡Ðýת¾ØÕó + cv::Mat rotation_matrix = cv::getRotationMatrix2D(center, angle, scale); + + // ´´½¨ÐýתºóµÄͼÏñ + cv::Mat rotated_img; + cv::warpAffine(img, rotated_img, rotation_matrix, img.size()); + + return rotated_img; +} \ No newline at end of file diff --git a/HanddleAI/HandleAiUi-new/appConfig/sqlManager/sqlBase.h b/HanddleAI/HandleAiUi-new/appConfig/sqlManager/sqlBase.h index 8b539604..b2110c9d 100644 --- a/HanddleAI/HandleAiUi-new/appConfig/sqlManager/sqlBase.h +++ b/HanddleAI/HandleAiUi-new/appConfig/sqlManager/sqlBase.h @@ -44,8 +44,8 @@ public: virtual bool Update( std::string tableName, std::vector selectStr, - std::string Where = "", - std::string equal = "") + std::string Where, + std::string equal) { return true; }; private: diff --git a/HanddleAI/HandleAiUi-new/appConfig/sqlManager/sqlManager.cpp b/HanddleAI/HandleAiUi-new/appConfig/sqlManager/sqlManager.cpp index 2cd41a60..c16ff3e8 100644 --- a/HanddleAI/HandleAiUi-new/appConfig/sqlManager/sqlManager.cpp +++ b/HanddleAI/HandleAiUi-new/appConfig/sqlManager/sqlManager.cpp @@ -134,7 +134,22 @@ void sqlManager::initialization(appConfig* _appConfig,std::string dataBasePath, std::vector input=getTableList(); mutex.unlock(); } - +bool sqlManager::updateData(std::string SN,sqlRowDatas data) +{ + mutex.lock(); + sqlTableDatas selectResult; + dbPtr->Select(getCurrentDate(), {}, selectResult, "SN", SN); + if (selectResult.rowDatas.size() == 0)//无指定数æ�® 查找å‰�一天 + { + dbPtr->Update(getPreviousDate(), data, "SN", SN); + } + else + { + dbPtr->Update(getCurrentDate(), data, "SN", SN); + } + mutex.unlock(); + +} //将数æ�®å­˜å…¥æ•°æ�®åº“ bool sqlManager::addData(std::string SN,std::vector data) { diff --git a/HanddleAI/HandleAiUi-new/appConfig/sqlManager/sqlManager.h b/HanddleAI/HandleAiUi-new/appConfig/sqlManager/sqlManager.h index 8f82ac63..e2ffb299 100644 --- a/HanddleAI/HandleAiUi-new/appConfig/sqlManager/sqlManager.h +++ b/HanddleAI/HandleAiUi-new/appConfig/sqlManager/sqlManager.h @@ -35,6 +35,7 @@ public: std::vector getTableList();//»ñÈ¡ËùÓÐÁÐÃû void initialization(appConfig* _appConfig, std::string dataBasePath = sqlDefaultDatabasePath,bool backUp=true); bool addData(std::string SN, std::vector data); + bool updateData(std::string SN,sqlRowDatas data); void uninitlize(); sqlite3* db; diff --git a/HanddleAI/HandleAiUi-new/appCoreQtFunction.h b/HanddleAI/HandleAiUi-new/appCoreQtFunction.h index e6bd99cd..3f01141a 100644 --- a/HanddleAI/HandleAiUi-new/appCoreQtFunction.h +++ b/HanddleAI/HandleAiUi-new/appCoreQtFunction.h @@ -20,7 +20,7 @@ signals: void uiModuleLocationMap_ResetToDefault(); void uiModuleLocationMap_SetProductSignStatus(int pos, int status);//ÉèÖòúƷʾÒâͼָ¶¨Î»ÖõÄ״̬ - void uiModuleImageDoubleCheckQdialog_ShowWindows(QPixmap); + void uiModuleImageDoubleCheckQdialog_ShowWindows(imageDoubleCheckPack); void uiModuleSummaryDataManager_SetSummaryResultText(QString text, Qt::GlobalColor color); void uiModuleSummaryDataManager_Reset(); diff --git a/HanddleAI/HandleAiUi-new/detProcess.hpp b/HanddleAI/HandleAiUi-new/detProcess.hpp index 1db924e1..8baf4bad 100644 --- a/HanddleAI/HandleAiUi-new/detProcess.hpp +++ b/HanddleAI/HandleAiUi-new/detProcess.hpp @@ -88,6 +88,7 @@ public: manualDetThread _manualDetThread;//ÊÖ¶¯´¥·¢Ïß³Ì /////////////////////////////// + QMutex detMutex; std::string currentSn; void detProcessCallbackRegister() { @@ -105,7 +106,7 @@ public: int backArmIndex = -1; bool currentBack = false; //¼¤¹âУ׼Êý¾Ý»º´æ //SN Êý¾Ý - correctionStruct laserDataCache; + correctionStruct laserDataCache; //×ÜÁ÷³Ì¿ªÊ¼£¬»úÆ÷ÈË·¢ËÍ1ÖÁ¼Ä´æÆ÷259 //ÉÏλ»úÈ·ÈÏOKÖ®ºó£¬ÇåÁã¼Ä´æÆ÷259£¬²¢·¢ËÍ1ÖÁ¼Ä´æÆ÷260 //Èç²úÆ·ÐͺÅΪProduct_1ÇÒΪÕýÃæ£¬ÔòÉÏλ»ú·¢ËÍ1ÖÁ¼Ä´æÆ÷256£¬·¢ËÍ0ÖÁ¼Ä´æÆ÷257 @@ -133,7 +134,7 @@ public: int armPos = _triggerManager.getValue(264, byteArray); int xValue1 = _triggerManager.getValue(265, byteArray); - int xValue2 = _triggerManager.getValue(266, byteArray); + int xValue2 = _triggerManager.getValue(266, byteArray); int xValue3 = _triggerManager.getValue(267, byteArray); int yValue1 = _triggerManager.getValue(268, byteArray); @@ -194,19 +195,20 @@ public: laserDataCache.in_Z_X0Y_Value.push_back(rangeData); } else if (armPos <= 6) - { - laserDataCache.in_X_X0Z.push_back(xValue); - laserDataCache.in_Y_X0Z.push_back(yValue); - laserDataCache.in_Z_X0Z.push_back(zValue); - laserDataCache.in_Y_X0Z_Value.push_back(rangeData); - } - else if (armPos <= 9) { laserDataCache.in_X_Y0Z.push_back(xValue); laserDataCache.in_Y_Y0Z.push_back(yValue); laserDataCache.in_Z_Y0Z.push_back(zValue); laserDataCache.in_X_Y0Z_Value.push_back(rangeData); } + else if (armPos <= 9) + { + laserDataCache.in_X_X0Z.push_back(xValue); + laserDataCache.in_Y_X0Z.push_back(yValue); + laserDataCache.in_Z_X0Z.push_back(zValue); + laserDataCache.in_Y_X0Z_Value.push_back(rangeData); + } + _triggerManager.sendFinsMsg("write_short_261_0");//ÇåÁã _triggerManager.sendFinsMsg("write_short_262_1"); _triggerManager.sendFinsMsg("write_short_263_1"); @@ -225,6 +227,7 @@ public: //ÅÄÕÕ²¢¼ì²â 300 void captureImageAndDetection(QByteArray& byteArray) { + detMutex.lock(); _lightSourceManager.getLightSourcePtr("COM9")->setValue(lightSourceChannel::DChannel, 255); QThread::msleep(2000);//ÑÓʱµÈ´ý»úе±ÛÍ£ÎÈ _triggerManager.sendFinsMsg("write_short_300_0");//´¥·¢ÐźÅÇåÁã @@ -249,6 +252,7 @@ public: QThread::msleep(1000);//ÑÓʱһÃëÍê³ÉÅÄÕÕ£¬ºóÐø¸Ä³ÉÅÄÍêÖ±½Ó·¢ËÍ _triggerManager.sendFinsMsg("write_short_302_1");//¿ªÊ¼¼ì²âÐźŠ+ detMutex.unlock(); } //»úе±Û״̬Çл» 361 1 ¿ÕÏÐ void detectionSwitch1(QByteArray& byteArray) @@ -291,11 +295,38 @@ public: _triggerManager.sendFinsMsg("write_short_362_0"); auto productData = _core._productDataCache.get(currentSn); productData->writeProductData(currentSn, _core._appConfig.productDatas[_core._detGlobalData.productType]); - productData->saveData("D://CCD//result.xlsx"); - if(productData->ngPinCount >0 || productData->ngCount>0) + + QDateTime currentDateTime = QDateTime::currentDateTime(); + std::string dateDirStr = currentDateTime.toString("yyyy-MM-dd").toStdString(); + + productData->saveData("D://CCD//Result//" + dateDirStr + "//result.xlsx"); + + //ÏȲéѯÊý¾Ý¿â + auto sqlData = _core._appConfig._sqlManager.selectRowData(currentSn); + bool result = true; + if (sqlData.rowDatas.size() > 1) + for (auto data : sqlData.rowDatas[0]) + if (!data.key.compare("detResult")) + if (!data.value.compare("NG")) + result = false; + //Êý¾Ý¿â½á¹ûΪfalseʱ ²»¸ù¾Ýµ±Ç°ÅÜÁÏÊý¾ÝÅÐ¶Ï + if(result == false) + { emit _core._qtFunc.uiModuleSummaryDataManager_SetSummaryResultText("NG", Qt::red); + return; + } + + //Êý¾Ý¿â½á¹ûΪtrue»òÕßûÓвéѯµ½Êý¾Ýʱʱ ¼ÌÐøÅÐ¶Ï + if(productData->ngPinCount >0 || productData->ngCount>0)//NG + { + emit _core._qtFunc.uiModuleSummaryDataManager_SetSummaryResultText("NG", Qt::red); + _core._appConfig._sqlManager.updateData(currentSn, {{"detResult","NG"}}); + } else + { emit _core._qtFunc.uiModuleSummaryDataManager_SetSummaryResultText("OK", Qt::green); + _core._appConfig._sqlManager.updateData(currentSn, { {"detResult","OK"} }); + } std::cout << "detprocess runEnd" << std::endl; } @@ -334,21 +365,33 @@ public: //·¢Ëͼì²â½á¹û·¢Ë͵½½çÃæ if (data->armPos != -1) { - emit _core._qtFunc.addDashBoardData(0, data->halconOK); - emit _core._qtFunc.addDashBoardData(1, data->aiDetOK); - emit _core._qtFunc.uiModuleLocationMap_SetProductSignStatus(data->armPos, - (data->halconOK==true&& data->aiDetOK==true)?2:3); + //Èç¹ûΪNG£¬ÔòµÈµ½°´Ï°´Å¥Ê±ÔÚ·¢ËÍ bool finalOk = (data->halconOK == true && data->aiDetOK == true); - if(finalOk == false) + + if (data->aiDetOK == true) + emit _core._qtFunc.addDashBoardData(1, data->aiDetOK); + else if (data->resultImgs.size() >= 1) { - for (auto& showMat : data->resultImgs) - { - QPixmap pixmap; - cvMatToQPixMap(showMat, pixmap); - //showImgPack* pack = new showImgPack(); - emit _core._qtFunc.uiModuleImageDoubleCheckQdialog_ShowWindows(pixmap); - } + imageDoubleCheckPack pack; + pack.armPos = data->armPos; + cvMatToQPixMap(data->resultImgs[0], pack.img); + emit _core._qtFunc.uiModuleImageDoubleCheckQdialog_ShowWindows(pack); + pack.type = 2; } + if(data->halconOK == true) + emit _core._qtFunc.addDashBoardData(0, data->halconOK); + + else if (data->resultImgs.size() >= 2) + { + imageDoubleCheckPack pack; + pack.armPos = data->armPos; + cvMatToQPixMap(data->resultImgs[1], pack.img); + emit _core._qtFunc.uiModuleImageDoubleCheckQdialog_ShowWindows(pack); + pack.type = 1; + } + if (finalOk == true) + emit _core._qtFunc.uiModuleLocationMap_SetProductSignStatus(data->armPos,2); + auto productData = _core._productDataCache.get(currentSn); if (finalOk == false) productData->ngCount++; @@ -413,10 +456,26 @@ public slots: _triggerManager.sendFinsMsg("write_short_350_" + QString::number(_core._appConfig.productDatas[productTypeIn].indexOfArm)); _triggerManager.sendFinsMsg("write_short_351_1"); } - //È˹¤¸´Å̰´ÏÂNG - void uiModuleImageDoubleCheckQdialog_pressNG() + //È˹¤¸´Åа´ÏÂNG + void uiModuleImageDoubleCheckQdialog_pressNG(int armPos,int type)//1 halcon 2ai { + if(type == 1) + emit _core._qtFunc.addDashBoardData(0, false); + else if (type == 2) + emit _core._qtFunc.addDashBoardData(1, false); + emit _core._qtFunc.uiModuleLocationMap_SetProductSignStatus(armPos, 3); _triggerManager.sendFinsMsg("write_short_363_1"); + detMutex.unlock(); + } + //È˹¤¸´Åа´ÏÂOK + void uiModuleImageDoubleCheckQdialog_pressOK(int armPos, int type)//1 halcon 2ai + { + if (type == 1) + emit _core._qtFunc.addDashBoardData(0, true); + else if (type == 2) + emit _core._qtFunc.addDashBoardData(1, true); + emit _core._qtFunc.uiModuleLocationMap_SetProductSignStatus(armPos, 2); + detMutex.unlock(); } }; #pragma once \ No newline at end of file diff --git a/HanddleAI/HandleAiUi-new/globalStruct.h b/HanddleAI/HandleAiUi-new/globalStruct.h index e3c4aa3f..082cc6d8 100644 --- a/HanddleAI/HandleAiUi-new/globalStruct.h +++ b/HanddleAI/HandleAiUi-new/globalStruct.h @@ -55,6 +55,12 @@ struct historyPack std::shared_ptrfilePath; std::vectortext; }; +struct imageDoubleCheckPack +{ + QPixmap img; + int armPos; + int type;//1 halcon 2ai +}; static QImage cvMatToQImage(cv::Mat& src) { if (src.channels() == 1) { // if grayscale image @@ -141,4 +147,5 @@ Q_DECLARE_METATYPE(cv::Mat) Q_DECLARE_METATYPE(std::string) Q_DECLARE_METATYPE(historyPack) Q_DECLARE_METATYPE(Qt::GlobalColor) +Q_DECLARE_METATYPE(imageDoubleCheckPack) #pragma once \ No newline at end of file diff --git a/HanddleAI/HandleAiUi-new/main.cpp b/HanddleAI/HandleAiUi-new/main.cpp index 1cb89108..035d5375 100644 --- a/HanddleAI/HandleAiUi-new/main.cpp +++ b/HanddleAI/HandleAiUi-new/main.cpp @@ -109,9 +109,11 @@ void connectSignalAndSlots(MainWindow* front, appCore* _core, detProcess* _detPr front, &MainWindow::uiModuleLocationMapSetProductSignStatus); //uiModuleImageDoubleCheckQdialog QObject::connect(&_core->_qtFunc, &qtFunction::uiModuleImageDoubleCheckQdialog_ShowWindows, - front, [=](QPixmap map) {front->_imageDoubleCheckQdialog->showAndSetImg(map); }); + front, [=](imageDoubleCheckPack pack) {front->_imageDoubleCheckQdialog->showAndSetImg(pack); }); QObject::connect(front->_imageDoubleCheckQdialog,&imageDoubleCheckQdialog::ngSignal, _detProcess, &detProcess::uiModuleImageDoubleCheckQdialog_pressNG); + QObject::connect(front->_imageDoubleCheckQdialog, &imageDoubleCheckQdialog::okSignal, + _detProcess, &detProcess::uiModuleImageDoubleCheckQdialog_pressOK); //uiModuleSummaryDataManager QObject::connect(&_core->_qtFunc, &qtFunction::uiModuleSummaryDataManager_SetSummaryResultText, front, [=](QString text, Qt::GlobalColor color) @@ -177,6 +179,8 @@ int main(int argc, char* argv[]) qRegisterMetaType("stdString"); qRegisterMetaType("historyPack"); qRegisterMetaType("QtGlobalColor"); + qRegisterMetaType("imageDoubleCheckPack"); + //_core.initTimer(); MainWindow w; w.show(); diff --git a/HanddleAI/HandleAiUi-new/uiModule/uiModule_imageDoubleCheckQdialog.h b/HanddleAI/HandleAiUi-new/uiModule/uiModule_imageDoubleCheckQdialog.h index 3d966ba1..699a3629 100644 --- a/HanddleAI/HandleAiUi-new/uiModule/uiModule_imageDoubleCheckQdialog.h +++ b/HanddleAI/HandleAiUi-new/uiModule/uiModule_imageDoubleCheckQdialog.h @@ -7,7 +7,6 @@ #include #include #include - class imageDoubleCheckQdialog :public QDialog { Q_OBJECT @@ -18,7 +17,8 @@ public: fancyButtonText* okBtn = new fancyButtonText(120, 40, "OK", "¼ÌÐø"); fancyButtonText* ngBtn = new fancyButtonText(120, 40, "NG", "¼ÌÐø"); QMutex mutex; - QQueue< QPixmap>imgqueue; + QQueue< imageDoubleCheckPack>imgqueue; + imageDoubleCheckPack currentPack; imageDoubleCheckQdialog() { QPalette paletteWhite, paletteRed, paletteGreen; @@ -83,7 +83,7 @@ public: menuBarLayoutRight->addWidget(closeBtn); QObject::connect(closeBtn, &QPushButton::clicked, this, &QDialog::close); - + closeBtn->hide();//Òþ²Ø¹Ø±Õ°´Å¥ QHBoxLayout* imageViewLayout = new QHBoxLayout(); imageViewLayout->addWidget(_ImageWidgetManager); @@ -105,34 +105,35 @@ public: this->setWindowFlags(this->windowFlags() | Qt::WindowStaysOnTopHint); //this->show(); } - void showAndSetImg(QPixmap img) + void showAndSetImg(imageDoubleCheckPack pack) { mutex.lock(); std::cout << isShowing<<"-" << imgqueue.size()<< std::endl; if (isShowing == false && imgqueue.size() == 0) { - _ImageWidgetManager->showImg(img, imgWidgetShowType::imgWidgetOri, 0); + currentPack = pack; + _ImageWidgetManager->showImg(pack.img, imgWidgetShowType::imgWidgetOri, 0); this->show(); isShowing = true; } else { - imgqueue.enqueue(img); + imgqueue.enqueue(pack); } mutex.unlock(); } signals: - void okSignal(); - void ngSignal(); + void okSignal(int armPos, int type); + void ngSignal(int armPos, int type); private: void pressOK() { mutex.lock(); - emit okSignal(); + emit okSignal(currentPack.armPos , currentPack.type); if (imgqueue.size() > 0) { - QPixmap img = imgqueue.dequeue(); - _ImageWidgetManager->showImg(img, imgWidgetShowType::imgWidgetOri, 0); + currentPack = imgqueue.dequeue(); + _ImageWidgetManager->showImg(currentPack.img, imgWidgetShowType::imgWidgetOri, 0); } else { @@ -144,11 +145,11 @@ private: void pressNG() { mutex.lock(); - emit ngSignal(); + emit ngSignal(currentPack.armPos, currentPack.type); if (imgqueue.size() > 0) { - QPixmap img = imgqueue.dequeue(); - _ImageWidgetManager->showImg(img, imgWidgetShowType::imgWidgetOri, 0); + currentPack = imgqueue.dequeue(); + _ImageWidgetManager->showImg(currentPack.img, imgWidgetShowType::imgWidgetOri, 0); } else { diff --git a/lib/Hd_3DCameraLMI_module_PointLazer.exp b/lib/Hd_3DCameraLMI_module_PointLazer.exp index 97d8b87b..b70953a7 100644 Binary files a/lib/Hd_3DCameraLMI_module_PointLazer.exp and b/lib/Hd_3DCameraLMI_module_PointLazer.exp differ diff --git a/lib/Hd_3DCameraLMI_module_PointLazer.lib b/lib/Hd_3DCameraLMI_module_PointLazer.lib index 36c75b14..b506c2ad 100644 Binary files a/lib/Hd_3DCameraLMI_module_PointLazer.lib and b/lib/Hd_3DCameraLMI_module_PointLazer.lib differ diff --git a/lib/Hd_DalsaCamera_module.exp b/lib/Hd_DalsaCamera_module.exp index ab118790..9c60276f 100644 Binary files a/lib/Hd_DalsaCamera_module.exp and b/lib/Hd_DalsaCamera_module.exp differ diff --git a/lib/Hd_DalsaCamera_module.lib b/lib/Hd_DalsaCamera_module.lib index cc2d36e5..c271a24e 100644 Binary files a/lib/Hd_DalsaCamera_module.lib and b/lib/Hd_DalsaCamera_module.lib differ diff --git a/lib/Hd_FinsTcp_module.exp b/lib/Hd_FinsTcp_module.exp index 05dc8bab..2ba9e5fa 100644 Binary files a/lib/Hd_FinsTcp_module.exp and b/lib/Hd_FinsTcp_module.exp differ diff --git a/lib/Hd_FinsTcp_module.lib b/lib/Hd_FinsTcp_module.lib index a50e177e..e7784b3e 100644 Binary files a/lib/Hd_FinsTcp_module.lib and b/lib/Hd_FinsTcp_module.lib differ diff --git a/lib/Hd_MvCamera_module_GENTL.exp b/lib/Hd_MvCamera_module_GENTL.exp index cd7a0985..5b9c4dde 100644 Binary files a/lib/Hd_MvCamera_module_GENTL.exp and b/lib/Hd_MvCamera_module_GENTL.exp differ diff --git a/lib/Hd_MvCamera_module_GENTL.lib b/lib/Hd_MvCamera_module_GENTL.lib index a65c613a..4010f0a3 100644 Binary files a/lib/Hd_MvCamera_module_GENTL.lib and b/lib/Hd_MvCamera_module_GENTL.lib differ diff --git a/lib/Hd_MvCamera_module_GIGE.exp b/lib/Hd_MvCamera_module_GIGE.exp index 564b8062..f1841164 100644 Binary files a/lib/Hd_MvCamera_module_GIGE.exp and b/lib/Hd_MvCamera_module_GIGE.exp differ diff --git a/lib/Hd_MvCamera_module_GIGE.lib b/lib/Hd_MvCamera_module_GIGE.lib index b1396b9b..110ae8d7 100644 Binary files a/lib/Hd_MvCamera_module_GIGE.lib and b/lib/Hd_MvCamera_module_GIGE.lib differ diff --git a/lib/Hd_ResultsSummary_module.exp b/lib/Hd_ResultsSummary_module.exp index 1880b09b..4426c915 100644 Binary files a/lib/Hd_ResultsSummary_module.exp and b/lib/Hd_ResultsSummary_module.exp differ diff --git a/lib/Hd_ResultsSummary_module.lib b/lib/Hd_ResultsSummary_module.lib index a61fbd40..8baafc1c 100644 Binary files a/lib/Hd_ResultsSummary_module.lib and b/lib/Hd_ResultsSummary_module.lib differ diff --git a/lib/Hd_SocketModule_ModbusTcp.exp b/lib/Hd_SocketModule_ModbusTcp.exp index f9780641..e9596cc0 100644 Binary files a/lib/Hd_SocketModule_ModbusTcp.exp and b/lib/Hd_SocketModule_ModbusTcp.exp differ diff --git a/lib/Hd_SocketModule_ModbusTcp.lib b/lib/Hd_SocketModule_ModbusTcp.lib index 5ec47732..b3ff8f19 100644 Binary files a/lib/Hd_SocketModule_ModbusTcp.lib and b/lib/Hd_SocketModule_ModbusTcp.lib differ