diff --git a/3rdparty/include/tobaccoAlgorithm.h b/3rdparty/include/tobaccoAlgorithm.h new file mode 100644 index 0000000..3876b6e --- /dev/null +++ b/3rdparty/include/tobaccoAlgorithm.h @@ -0,0 +1,16 @@ +#pragma once + +#include + +#ifndef EXPORT +#ifdef _WIN32 +#define EXPORT _declspec(dllexport) +#else +#define EXPORT +#endif +#endif // !EXPORT + +//通过比较路径 cloudPath1 和 cloudPath2 指向的点云来判断烟垛是否发生明显变化 +//paramPath 为算法参数路径(json 文件) +//返回 true 表示无变化(烟垛基本一致),返回 false 表示发生明显变化 +EXPORT bool compare(const std::string& cloudPath1, const std::string& cloudPath2, const std::string& paramPath); diff --git a/3rdparty/lib/tobaccoAlgorithm.lib b/3rdparty/lib/tobaccoAlgorithm.lib new file mode 100644 index 0000000..1ed0104 Binary files /dev/null and b/3rdparty/lib/tobaccoAlgorithm.lib differ diff --git a/runner17/Release/config/param3d.json b/runner17/Release/config/param3d.json new file mode 100644 index 0000000..aa3f9a0 --- /dev/null +++ b/runner17/Release/config/param3d.json @@ -0,0 +1,16 @@ +{ + "rotation": [ + -1.19209e-07, + 1, + 0, + -0.945519, + -1.19209e-07, + 0.325568, + 0.325568, + 0, + 0.945519 + ], + "min_pt": [-520, 150, 1050], + "max_pt": [680, 2020, 1550], + "floorHeight": 300 +} \ No newline at end of file diff --git a/runner17/Release/opencv_world450.dll b/runner17/Release/opencv_world450.dll new file mode 100644 index 0000000..4643f8a Binary files /dev/null and b/runner17/Release/opencv_world450.dll differ diff --git a/runner17/Release/pcl_world.dll b/runner17/Release/pcl_world.dll new file mode 100644 index 0000000..de1f113 Binary files /dev/null and b/runner17/Release/pcl_world.dll differ diff --git a/runner17/Release/smokeBox.exe b/runner17/Release/smokeBox.exe index f225158..8098383 100644 Binary files a/runner17/Release/smokeBox.exe and b/runner17/Release/smokeBox.exe differ diff --git a/runner17/Release/smokeBox.pdb b/runner17/Release/smokeBox.pdb index 910fc86..de8e63f 100644 Binary files a/runner17/Release/smokeBox.pdb and b/runner17/Release/smokeBox.pdb differ diff --git a/runner17/Release/tobaccoAlgorithm.dll b/runner17/Release/tobaccoAlgorithm.dll new file mode 100644 index 0000000..5e45265 Binary files /dev/null and b/runner17/Release/tobaccoAlgorithm.dll differ diff --git a/src/SmokeBoxIdentification.cpp b/src/SmokeBoxIdentification.cpp index 557257f..b8d716e 100644 --- a/src/SmokeBoxIdentification.cpp +++ b/src/SmokeBoxIdentification.cpp @@ -168,8 +168,8 @@ QString SmokeBoxIdentification::saveImage(ILImagePtr image, const cv::Mat& imgMa { cv::imwrite(filePath.toStdString(), imgMat3D); int lastPos = filePath.lastIndexOf('.'); - QString pclPath = filePath.left(lastPos); - pclPath.append(".pcd"); + QString prePath = filePath.left(lastPos); + QString pclPath = prePath + ".pcd"; if (QFile(pclPath).exists()) { QFile::remove(pclPath); @@ -180,7 +180,7 @@ QString SmokeBoxIdentification::saveImage(ILImagePtr image, const cv::Mat& imgMa QFile::rename(".\\Cache\\1.pcd", pclPath); qDebug() << "Save 3D image: " << pclPath; - return pclPath; + return prePath + ".PNG"; } else // 2D相机数据 @@ -196,9 +196,9 @@ void SmokeBoxIdentification::saveImage(const QVector& vecImageInfo, i QString dataSaveFolderPath; #if IMAGEDRAWING==LPV - if (m_currtIntoStockInfo.taskNum == '0') + if (m_currtIntoStockInfo.taskNum == "0") { - dataSaveFolderPath = QString("%1\\%2\\%3").arg(FILE_INPUTSTORE_PATH) + dataSaveFolderPath = QString("%1\\%2\\%3\\%4").arg(FILE_INPUTSTORE_PATH) .arg(m_currtIntoStockInfo.streetName).arg(m_currtIntoStockInfo.Floor).arg(m_currtIntoStockInfo.row); } else @@ -246,8 +246,8 @@ void SmokeBoxIdentification::saveImage(const QVector& vecImageInfo, i #if IMAGEDRAWING == LPV QString filePath = QString("%1\\%2").arg(dataSaveFolderPath).arg(fileInfo.name); QString imgPath = saveImage(vecImageInfo.at(i).imageOrigin, vecImageInfo.at(i).image3D, filePath); - - if (workMode == WorkMode::IntoStock && imgPath!="") + m_currtIntoStockInfo.correctness = 1; + if (!vecImageInfo.at(i).image3D.empty()) { m_currtIntoStockInfo.imagesPathList.push_back(imgPath); } @@ -406,7 +406,7 @@ Q_SLOT void SmokeBoxIdentification::onDecodeMsg(const QString& msg) //m_workMode = WorkMode::Capture; m_currtIntoStockInfo.taskNum = strList.at(3); - if (m_currtIntoStockInfo.taskNum == '0') + if (m_currtIntoStockInfo.taskNum == "0") { qDebug() << "入库取图开始"; } @@ -433,6 +433,8 @@ Q_SLOT void SmokeBoxIdentification::onDecodeMsg(const QString& msg) QStringList streetInfo = strList.at(1).split("/"); m_currtStockCheckInfo.streetName = streetInfo.at(0); m_currtStockCheckInfo.Floor = streetInfo.at(1).toInt(); + m_currtStockCheckInfo.row = streetInfo.at(2).toInt(); + m_currtStockCheckInfo.id = strList.at(2); m_currtStockCheckInfo.taskNum = strList.at(3); m_currtStockCheckInfo.stockLocation = strList.at(4); @@ -457,6 +459,7 @@ void SmokeBoxIdentification::calculate(int stocketID) QtConcurrent::run([=] { bool bRlt = false; + bool bRlt3D = false; StockCheckInfo stocket = m_stocketList.value(stocketID); if (!m_stocketList.contains(stocketID)) { @@ -529,41 +532,71 @@ void SmokeBoxIdentification::calculate(int stocketID) FileInfo fileInfo = imgInfo.saveImgInfo; //根据相机编号,对应找到3D基准文件去计算层高 - pclPath.append(QString("*.pcd").arg(fileInfo.strId)); + pclPath.append("\\"); + pclPath.append(imgInfo.saveImgInfo.name); - QDir dir(pclPath); - QFileInfoList fileList = dir.entryInfoList(QStringList() << "*.pcd", QDir::Files | QDir::NoDotAndDotDot); - if (fileList.length() > 0) - { - //盘点时候的点云地址pclPath - pclPath = fileList[0].absolutePath(); - - //入库时的点云地址:.\\storeData\\巷道号\\层高\\列数\\*.pcd - // FILE_INPUTSTORE_PATH \\ m_stocketList[stocketID].streetName\\m_stocketList[stocketID].Floor\\m_stocketList[stocketID].row\\ *.pcd; + QString pclPath2 = QString("%1\\%2\\%3\\%4").arg(FILE_INPUTSTORE_PATH) + .arg(m_currtIntoStockInfo.streetName).arg(m_currtIntoStockInfo.Floor).arg(m_currtIntoStockInfo.row); + pclPath2.append("\\"); + pclPath2.append(imgInfo.saveImgInfo.name); - str = QString("[%1]:3DCamera %2 -- PointCould = %3").arg(stocket.id) - .arg(imgInfo.cameraSn).arg(pclPath); - qInfo() << str; + QFile pclFile(pclPath); + QFile pclFile2(pclPath); + + if (pclFile.exists()) + { int lastPos = pclPath.lastIndexOf('.'); QString depthImagePath = pclPath.left(lastPos); depthImagePath.append(".PNG"); - m_stocketList[stocketID].imagesPathList.append(depthImagePath.right(depthImagePath.length() - 1)); + m_stocketList[stocketID].imagesPathList.append(depthImagePath); m_stocketList[stocketID].pcdSrc = pclPath; } - else - { - str = QString("[%1]:3DCamera %2 -- PointCould[%3] can't Find!").arg(stocket.id) - .arg(imgInfo.cameraSn).arg(pclPath); - qWarning() << str; - } + if (pclFile.exists() && pclFile2.exists()) + { + str = QString("[%1]:3DCamera %2 -- PointCould = %3; Store PointCloud = %4").arg(stocket.id) + .arg(imgInfo.cameraSn).arg(pclPath).arg(pclPath2); + qInfo() << str; + + //入库时的点云地址:.\\storeData\\巷道号\\层高\\列数\\*.pcd + // FILE_INPUTSTORE_PATH \\ m_stocketList[stocketID].streetName\\m_stocketList[stocketID].Floor\\m_stocketList[stocketID].row\\ *.pcd; - //数量计算 - m_stocketList[stocketID].smokeQuantityRlt = m_stocketList[stocketID].smokeQuantity; + QString jsonPath = QCoreApplication::applicationDirPath() + "\\config\\param3d.json"; + try + { + bRlt3D = compare(pclPath2.toStdString(), pclPath.toStdString(), jsonPath.toStdString()); + str = QString("[%1]:3DCamera %2 -- 3D compare Result = %3").arg(stocket.id) + .arg(imgInfo.cameraSn).arg(QString::number(bRlt3D)); + qInfo() << str; + } + catch (const std::exception& e) + { + qWarning() << e.what(); + } + } + else + { + if (pclFile.exists()) + { + str = QString("[%1]:3DCamera %2 -- PointCould[%3] can't Find!").arg(stocket.id) + .arg(imgInfo.cameraSn).arg(pclPath2); + } + else if(pclFile2.exists()) + { + str = QString("[%1]:3DCamera %2 -- PointCould[%3] can't Find!").arg(stocket.id) + .arg(imgInfo.cameraSn).arg(pclPath); + } + else + { + str = QString("[%1]:3DCamera %2 -- PointCould[%3; %4] can't Find!").arg(stocket.id) + .arg(imgInfo.cameraSn).arg(pclPath).arg(pclPath2); + } + qWarning() << str; + } } else @@ -581,6 +614,15 @@ void SmokeBoxIdentification::calculate(int stocketID) m_stocketList[stocketID].imagesPathList = set.toList(); // 将 QSet 转换为 QStringList + if (bRlt3D) + { + m_stocketList[stocketID].smokeQuantityRlt = m_stocketList[stocketID].smokeQuantity; + } + else + { + m_stocketList[stocketID].smokeQuantityRlt = "0"; + } + if (!bRlt) { m_stocketList[stocketID].smokeTypeNumRlt = "0"; @@ -749,6 +791,7 @@ void SmokeBoxIdentification::sendResults(int mode, int id) .append(m_currtIntoStockInfo.stockLocation).append(SPLIT_RULE) .append(m_currtIntoStockInfo.smokeTypeNum).append(SPLIT_RULE) .append(m_currtIntoStockInfo.smokeQuantity).append(SPLIT_RULE) + .append(QString::number(m_currtIntoStockInfo.correctness)).append(SPLIT_RULE) .append(m_currtIntoStockInfo.imagesPathList.join(";")).append(END_SYMBOL); break; } diff --git a/src/SmokeBoxIdentification.h b/src/SmokeBoxIdentification.h index b0f52c0..7b94b1d 100644 --- a/src/SmokeBoxIdentification.h +++ b/src/SmokeBoxIdentification.h @@ -22,6 +22,8 @@ #include "HeightCalculate.h" #include "ui_SmokeBoxIdentification.h" +#include "tobaccoAlgorithm.h" + enum MsgType diff --git a/src/common/commonDefine.h b/src/common/commonDefine.h index 6080432..2b4dd11 100644 --- a/src/common/commonDefine.h +++ b/src/common/commonDefine.h @@ -159,7 +159,7 @@ struct IntoStockInfo QString pcdSrc; //盘点识别文件 - bool correctness =1; //拍照成功 + bool correctness = 0; //拍照是否成功 }; struct EmptyCheckInfo diff --git a/tpvs17/SmokeBoxIdentification/SmokeBoxIdentification.vcxproj b/tpvs17/SmokeBoxIdentification/SmokeBoxIdentification.vcxproj index 2b079d8..08b8fa6 100644 --- a/tpvs17/SmokeBoxIdentification/SmokeBoxIdentification.vcxproj +++ b/tpvs17/SmokeBoxIdentification/SmokeBoxIdentification.vcxproj @@ -55,17 +55,19 @@ D:\Qt\5.9.4\msvc2017_64\include;$(IncludePath) D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\lib\x64;$(ExecutablePath) C:\Qt\Qt5.9.4\5.9.4\msvc2017_64\lib;D:\Qt\5.9.4\msvc2017_64\lib;$(LibraryPath) + $(SolutionDir)..\3rdparty\include;$(ReferencePath) $(SolutionDir)..\runner17\$(Configuration)\ smokeBox C:\Qt\Qt5.9.4\5.9.4\msvc2017_64\lib;D:\Qt\5.9.4\msvc2017_64\lib;$(LibraryPath) $(IncludePath) + $(SolutionDir)..\3rdparty\include;$(ReferencePath) UNICODE;_UNICODE;WIN32;WIN64;QT_DLL;%(PreprocessorDefinitions) - .;.\GeneratedFiles;..\..\src;..\..\src\libzkq;..\..\src\lpSerial;..\..\src\lpSerial\include;..\..\src\numStatisticAlgo;..\..\src\MVCameraDriver;..\..\src\common;..\..\src\lpv;..\..\3rdparty\opencv\include;..\..\3rdparty\opencv\include\opencv;..\..\3rdparty\opencv\include\opencv2;.\GeneratedFiles\$(ConfigurationName);%(AdditionalIncludeDirectories) + .;.\GeneratedFiles;..\..\src;..\..\src\libzkq;..\..\src\lpSerial;..\..\src\lpSerial\include;..\..\src\numStatisticAlgo;..\..\src\MVCameraDriver;..\..\src\common;..\..\src\lpv;..\..\3rdparty\opencv\include;..\..\3rdparty\opencv\include\opencv;..\..\3rdparty\opencv\include\opencv2;.\GeneratedFiles\$(ConfigurationName);..\..\3rdparty\include;%(AdditionalIncludeDirectories) Disabled ProgramDatabase MultiThreadedDebugDLL @@ -98,7 +100,7 @@ UNICODE;_UNICODE;WIN32;WIN64;QT_DLL;QT_NO_DEBUG;NDEBUG;%(PreprocessorDefinitions) - .;.\GeneratedFiles;..\..\src;..\..\src\libzkq;..\..\src\lpSerial;..\..\src\lpSerial\include;..\..\src\numStatisticAlgo;..\..\src\MVCameraDriver;..\..\src\common;..\..\src\lpv;..\..\3rdparty\opencv\include;..\..\3rdparty\opencv\include\opencv;..\..\3rdparty\opencv\include\opencv2;.\GeneratedFiles\$(ConfigurationName);%(AdditionalIncludeDirectories) + .;.\GeneratedFiles;..\..\src;..\..\src\libzkq;..\..\src\lpSerial;..\..\src\lpSerial\include;..\..\src\numStatisticAlgo;..\..\src\MVCameraDriver;..\..\src\common;..\..\src\lpv;..\..\3rdparty\opencv\include;..\..\3rdparty\opencv\include\opencv;..\..\3rdparty\opencv\include\opencv2;.\GeneratedFiles\$(ConfigurationName);..\..\3rdparty\include;%(AdditionalIncludeDirectories) ProgramDatabase MultiThreadedDLL true @@ -109,7 +111,7 @@ $(OutDir)smokeBox.exe $(MVCAM_COMMON_RUNENV)\Libraries\win64;$(SolutionDir)..\3rdparty\lib;$(SolutionDir)$(Platform)\$(Configuration)\;$(SolutionDir)..\3rdparty\opencv\lib;$(SolutionDir)..\3rdparty\qxlsx\lib;$(SolutionDir)..\tpvs17\x64\Release;%(AdditionalLibraryDirectories) true - Qt5Xlsx.lib;opencv_world341.lib;MvCameraControl.lib;numStatisticAlgo.lib;lpSerial.lib;libzkq.lib;LxCameraApi.lib;%(AdditionalDependencies) + Qt5Xlsx.lib;opencv_world341.lib;MvCameraControl.lib;numStatisticAlgo.lib;lpSerial.lib;libzkq.lib;LxCameraApi.lib;tobaccoAlgorithm.lib;%(AdditionalDependencies) Moc'ing %(Identity)... @@ -163,6 +165,7 @@ + diff --git a/tpvs17/SmokeBoxIdentification/SmokeBoxIdentification.vcxproj.filters b/tpvs17/SmokeBoxIdentification/SmokeBoxIdentification.vcxproj.filters index 6349890..b14d40c 100644 --- a/tpvs17/SmokeBoxIdentification/SmokeBoxIdentification.vcxproj.filters +++ b/tpvs17/SmokeBoxIdentification/SmokeBoxIdentification.vcxproj.filters @@ -191,5 +191,8 @@ Header Files\lxCamera + + Header Files + \ No newline at end of file