合成3D部分,调整返回的msg

master
zhou.mengjia 2 years ago
parent 0ea065e0c4
commit fb118399e5

@ -0,0 +1,16 @@
#pragma once
#include <iostream>
#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);

Binary file not shown.

@ -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
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -168,8 +168,8 @@ QString SmokeBoxIdentification::saveImage(ILImagePtr image, const cv::Mat& imgMa
{ {
cv::imwrite(filePath.toStdString(), imgMat3D); cv::imwrite(filePath.toStdString(), imgMat3D);
int lastPos = filePath.lastIndexOf('.'); int lastPos = filePath.lastIndexOf('.');
QString pclPath = filePath.left(lastPos); QString prePath = filePath.left(lastPos);
pclPath.append(".pcd"); QString pclPath = prePath + ".pcd";
if (QFile(pclPath).exists()) if (QFile(pclPath).exists())
{ {
QFile::remove(pclPath); QFile::remove(pclPath);
@ -180,7 +180,7 @@ QString SmokeBoxIdentification::saveImage(ILImagePtr image, const cv::Mat& imgMa
QFile::rename(".\\Cache\\1.pcd", pclPath); QFile::rename(".\\Cache\\1.pcd", pclPath);
qDebug() << "Save 3D image: " << pclPath; qDebug() << "Save 3D image: " << pclPath;
return pclPath; return prePath + ".PNG";
} }
else // 2D相机数据 else // 2D相机数据
@ -196,9 +196,9 @@ void SmokeBoxIdentification::saveImage(const QVector<ImageInfo>& vecImageInfo, i
QString dataSaveFolderPath; QString dataSaveFolderPath;
#if IMAGEDRAWING==LPV #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); .arg(m_currtIntoStockInfo.streetName).arg(m_currtIntoStockInfo.Floor).arg(m_currtIntoStockInfo.row);
} }
else else
@ -246,8 +246,8 @@ void SmokeBoxIdentification::saveImage(const QVector<ImageInfo>& vecImageInfo, i
#if IMAGEDRAWING == LPV #if IMAGEDRAWING == LPV
QString filePath = QString("%1\\%2").arg(dataSaveFolderPath).arg(fileInfo.name); QString filePath = QString("%1\\%2").arg(dataSaveFolderPath).arg(fileInfo.name);
QString imgPath = saveImage(vecImageInfo.at(i).imageOrigin, vecImageInfo.at(i).image3D, filePath); QString imgPath = saveImage(vecImageInfo.at(i).imageOrigin, vecImageInfo.at(i).image3D, filePath);
m_currtIntoStockInfo.correctness = 1;
if (workMode == WorkMode::IntoStock && imgPath!="") if (!vecImageInfo.at(i).image3D.empty())
{ {
m_currtIntoStockInfo.imagesPathList.push_back(imgPath); m_currtIntoStockInfo.imagesPathList.push_back(imgPath);
} }
@ -406,7 +406,7 @@ Q_SLOT void SmokeBoxIdentification::onDecodeMsg(const QString& msg)
//m_workMode = WorkMode::Capture; //m_workMode = WorkMode::Capture;
m_currtIntoStockInfo.taskNum = strList.at(3); m_currtIntoStockInfo.taskNum = strList.at(3);
if (m_currtIntoStockInfo.taskNum == '0') if (m_currtIntoStockInfo.taskNum == "0")
{ {
qDebug() << "入库取图开始"; qDebug() << "入库取图开始";
} }
@ -433,6 +433,8 @@ Q_SLOT void SmokeBoxIdentification::onDecodeMsg(const QString& msg)
QStringList streetInfo = strList.at(1).split("/"); QStringList streetInfo = strList.at(1).split("/");
m_currtStockCheckInfo.streetName = streetInfo.at(0); m_currtStockCheckInfo.streetName = streetInfo.at(0);
m_currtStockCheckInfo.Floor = streetInfo.at(1).toInt(); m_currtStockCheckInfo.Floor = streetInfo.at(1).toInt();
m_currtStockCheckInfo.row = streetInfo.at(2).toInt();
m_currtStockCheckInfo.id = strList.at(2); m_currtStockCheckInfo.id = strList.at(2);
m_currtStockCheckInfo.taskNum = strList.at(3); m_currtStockCheckInfo.taskNum = strList.at(3);
m_currtStockCheckInfo.stockLocation = strList.at(4); m_currtStockCheckInfo.stockLocation = strList.at(4);
@ -457,6 +459,7 @@ void SmokeBoxIdentification::calculate(int stocketID)
QtConcurrent::run([=] { QtConcurrent::run([=] {
bool bRlt = false; bool bRlt = false;
bool bRlt3D = false;
StockCheckInfo stocket = m_stocketList.value(stocketID); StockCheckInfo stocket = m_stocketList.value(stocketID);
if (!m_stocketList.contains(stocketID)) if (!m_stocketList.contains(stocketID))
{ {
@ -529,41 +532,71 @@ void SmokeBoxIdentification::calculate(int stocketID)
FileInfo fileInfo = imgInfo.saveImgInfo; FileInfo fileInfo = imgInfo.saveImgInfo;
//根据相机编号对应找到3D基准文件去计算层高 //根据相机编号对应找到3D基准文件去计算层高
pclPath.append(QString("*.pcd").arg(fileInfo.strId)); pclPath.append("\\");
pclPath.append(imgInfo.saveImgInfo.name);
QDir dir(pclPath); QString pclPath2 = QString("%1\\%2\\%3\\%4").arg(FILE_INPUTSTORE_PATH)
QFileInfoList fileList = dir.entryInfoList(QStringList() << "*.pcd", QDir::Files | QDir::NoDotAndDotDot); .arg(m_currtIntoStockInfo.streetName).arg(m_currtIntoStockInfo.Floor).arg(m_currtIntoStockInfo.row);
if (fileList.length() > 0) pclPath2.append("\\");
{ pclPath2.append(imgInfo.saveImgInfo.name);
//盘点时候的点云地址pclPath
pclPath = fileList[0].absolutePath();
//入库时的点云地址:.\\storeData\\巷道号\\层高\\列数\\*.pcd
// FILE_INPUTSTORE_PATH \\ m_stocketList[stocketID].streetName\\m_stocketList[stocketID].Floor\\m_stocketList[stocketID].row\\ *.pcd;
str = QString("[%1]:3DCamera %2 -- PointCould = %3").arg(stocket.id) QFile pclFile(pclPath);
.arg(imgInfo.cameraSn).arg(pclPath); QFile pclFile2(pclPath);
qInfo() << str;
if (pclFile.exists())
{
int lastPos = pclPath.lastIndexOf('.'); int lastPos = pclPath.lastIndexOf('.');
QString depthImagePath = pclPath.left(lastPos); QString depthImagePath = pclPath.left(lastPos);
depthImagePath.append(".PNG"); depthImagePath.append(".PNG");
m_stocketList[stocketID].imagesPathList.append(depthImagePath.right(depthImagePath.length() - 1)); m_stocketList[stocketID].imagesPathList.append(depthImagePath);
m_stocketList[stocketID].pcdSrc = pclPath; m_stocketList[stocketID].pcdSrc = pclPath;
} }
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;
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 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) str = QString("[%1]:3DCamera %2 -- PointCould[%3] can't Find!").arg(stocket.id)
.arg(imgInfo.cameraSn).arg(pclPath); .arg(imgInfo.cameraSn).arg(pclPath);
qWarning() << str; }
else
{
str = QString("[%1]:3DCamera %2 -- PointCould[%3; %4] can't Find!").arg(stocket.id)
.arg(imgInfo.cameraSn).arg(pclPath).arg(pclPath2);
} }
qWarning() << str;
}
//数量计算
m_stocketList[stocketID].smokeQuantityRlt = m_stocketList[stocketID].smokeQuantity;
} }
else else
@ -581,6 +614,15 @@ void SmokeBoxIdentification::calculate(int stocketID)
m_stocketList[stocketID].imagesPathList = set.toList(); // 将 QSet 转换为 QStringList 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) if (!bRlt)
{ {
m_stocketList[stocketID].smokeTypeNumRlt = "0"; 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.stockLocation).append(SPLIT_RULE)
.append(m_currtIntoStockInfo.smokeTypeNum).append(SPLIT_RULE) .append(m_currtIntoStockInfo.smokeTypeNum).append(SPLIT_RULE)
.append(m_currtIntoStockInfo.smokeQuantity).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); .append(m_currtIntoStockInfo.imagesPathList.join(";")).append(END_SYMBOL);
break; break;
} }

@ -22,6 +22,8 @@
#include "HeightCalculate.h" #include "HeightCalculate.h"
#include "ui_SmokeBoxIdentification.h" #include "ui_SmokeBoxIdentification.h"
#include "tobaccoAlgorithm.h"
enum MsgType enum MsgType

@ -159,7 +159,7 @@ struct IntoStockInfo
QString pcdSrc; //盘点识别文件 QString pcdSrc; //盘点识别文件
bool correctness =1; //拍照成功 bool correctness = 0; //拍照是否成功
}; };
struct EmptyCheckInfo struct EmptyCheckInfo

@ -55,17 +55,19 @@
<IncludePath>D:\Qt\5.9.4\msvc2017_64\include;$(IncludePath)</IncludePath> <IncludePath>D:\Qt\5.9.4\msvc2017_64\include;$(IncludePath)</IncludePath>
<ExecutablePath>D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\lib\x64;$(ExecutablePath)</ExecutablePath> <ExecutablePath>D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\lib\x64;$(ExecutablePath)</ExecutablePath>
<LibraryPath>C:\Qt\Qt5.9.4\5.9.4\msvc2017_64\lib;D:\Qt\5.9.4\msvc2017_64\lib;$(LibraryPath)</LibraryPath> <LibraryPath>C:\Qt\Qt5.9.4\5.9.4\msvc2017_64\lib;D:\Qt\5.9.4\msvc2017_64\lib;$(LibraryPath)</LibraryPath>
<ReferencePath>$(SolutionDir)..\3rdparty\include;$(ReferencePath)</ReferencePath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutDir>$(SolutionDir)..\runner17\$(Configuration)\</OutDir> <OutDir>$(SolutionDir)..\runner17\$(Configuration)\</OutDir>
<TargetName>smokeBox</TargetName> <TargetName>smokeBox</TargetName>
<LibraryPath>C:\Qt\Qt5.9.4\5.9.4\msvc2017_64\lib;D:\Qt\5.9.4\msvc2017_64\lib;$(LibraryPath)</LibraryPath> <LibraryPath>C:\Qt\Qt5.9.4\5.9.4\msvc2017_64\lib;D:\Qt\5.9.4\msvc2017_64\lib;$(LibraryPath)</LibraryPath>
<IncludePath>$(IncludePath)</IncludePath> <IncludePath>$(IncludePath)</IncludePath>
<ReferencePath>$(SolutionDir)..\3rdparty\include;$(ReferencePath)</ReferencePath>
</PropertyGroup> </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile> <ClCompile>
<PreprocessorDefinitions>UNICODE;_UNICODE;WIN32;WIN64;QT_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>UNICODE;_UNICODE;WIN32;WIN64;QT_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<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);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <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)</AdditionalIncludeDirectories>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
@ -98,7 +100,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile> <ClCompile>
<PreprocessorDefinitions>UNICODE;_UNICODE;WIN32;WIN64;QT_DLL;QT_NO_DEBUG;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>UNICODE;_UNICODE;WIN32;WIN64;QT_DLL;QT_NO_DEBUG;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<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);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <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)</AdditionalIncludeDirectories>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType> <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
@ -109,7 +111,7 @@
<OutputFile>$(OutDir)smokeBox.exe</OutputFile> <OutputFile>$(OutDir)smokeBox.exe</OutputFile>
<AdditionalLibraryDirectories>$(MVCAM_COMMON_RUNENV)\Libraries\win64;$(SolutionDir)..\3rdparty\lib;$(SolutionDir)$(Platform)\$(Configuration)\;$(SolutionDir)..\3rdparty\opencv\lib;$(SolutionDir)..\3rdparty\qxlsx\lib;$(SolutionDir)..\tpvs17\x64\Release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(MVCAM_COMMON_RUNENV)\Libraries\win64;$(SolutionDir)..\3rdparty\lib;$(SolutionDir)$(Platform)\$(Configuration)\;$(SolutionDir)..\3rdparty\opencv\lib;$(SolutionDir)..\3rdparty\qxlsx\lib;$(SolutionDir)..\tpvs17\x64\Release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>Qt5Xlsx.lib;opencv_world341.lib;MvCameraControl.lib;numStatisticAlgo.lib;lpSerial.lib;libzkq.lib;LxCameraApi.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>Qt5Xlsx.lib;opencv_world341.lib;MvCameraControl.lib;numStatisticAlgo.lib;lpSerial.lib;libzkq.lib;LxCameraApi.lib;tobaccoAlgorithm.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link> </Link>
<QtMoc> <QtMoc>
<ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription> <ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>
@ -163,6 +165,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<QtMoc Include="..\..\src\CodeScanStation.h" /> <QtMoc Include="..\..\src\CodeScanStation.h" />
<ClInclude Include="..\..\3rdparty\include\tobaccoAlgorithm.h" />
<ClInclude Include="..\..\src\common\commonDefine.h" /> <ClInclude Include="..\..\src\common\commonDefine.h" />
<ClInclude Include="..\..\src\common\log.h" /> <ClInclude Include="..\..\src\common\log.h" />
<ClInclude Include="..\..\src\common\QZkJsonParser.h" /> <ClInclude Include="..\..\src\common\QZkJsonParser.h" />

@ -191,5 +191,8 @@
<ClInclude Include="..\..\src\lxCamera\lx_camera_define.h"> <ClInclude Include="..\..\src\lxCamera\lx_camera_define.h">
<Filter>Header Files\lxCamera</Filter> <Filter>Header Files\lxCamera</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\3rdparty\include\tobaccoAlgorithm.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
</Project> </Project>
Loading…
Cancel
Save