添加入库拍照和返回图像

master
zhou.mengjia 2 years ago
parent 3e52f705f7
commit b76b783ea6

Binary file not shown.

Binary file not shown.

@ -155,12 +155,12 @@ void SmokeBoxIdentification::saveImage(const cv::Mat& imgMat, const QString& fil
qDebug() << "Save image: " << filePath;
}
void SmokeBoxIdentification::saveImage(ILImagePtr image, const cv::Mat& imgMat3D, const QString& filePath)
QString SmokeBoxIdentification::saveImage(ILImagePtr image, const cv::Mat& imgMat3D, const QString& filePath)
{
if (image->Void())
{
qWarning() << "Image is empty";
return;
return "";
}
std::wstring path = filePath.toStdWString();
@ -179,23 +179,15 @@ void SmokeBoxIdentification::saveImage(ILImagePtr image, const cv::Mat& imgMat3D
//QFile::copy("C:\\Users\\LENOVO\\Downloads\\30t.pcd",pclPath);
QFile::rename(".\\Cache\\1.pcd", pclPath);
qDebug() << "Save 3D image: " << filePath;
qDebug() << "Save 3D image: " << pclPath;
return pclPath;
}
else // 2DÏà»úÊý¾Ý
{
image->Save(path.c_str(), nullptr);
qDebug() << "Save 2D image: " << filePath;
}
if (!imgMat3D.empty())
{
int lastPos = filePath.lastIndexOf('.');
QString pclPath = filePath.left(lastPos);
pclPath.append(".pcd");
cv::imwrite(filePath.toStdString(), imgMat3D);
qDebug() << "Save PointCould: " << filePath;
return filePath;
}
}
@ -204,8 +196,18 @@ void SmokeBoxIdentification::saveImage(const QVector<ImageInfo>& vecImageInfo, i
QString dataSaveFolderPath;
#if IMAGEDRAWING==LPV
if (m_currtIntoStockInfo.taskNum == '0')
{
dataSaveFolderPath = QString("%1\\%2\\%3").arg(FILE_INPUTSTORE_PATH)
.arg(m_currtIntoStockInfo.streetName).arg(m_currtIntoStockInfo.Floor).arg(m_currtIntoStockInfo.row);
}
else
{
dataSaveFolderPath = QString("%1\\%2\\%3").arg(FILE_STORAGE_PATH)/*.arg(ORIGIN_IMAGE_FOLDER)*/
.arg(m_currtIntoStockInfo.taskNum).arg(m_currtIntoStockInfo.id);
}
#elif IMAGEDRAWING==OPENCV
switch (workMode)
{
@ -243,7 +245,12 @@ void SmokeBoxIdentification::saveImage(const QVector<ImageInfo>& vecImageInfo, i
#if IMAGEDRAWING == LPV
QString filePath = QString("%1\\%2").arg(dataSaveFolderPath).arg(fileInfo.name);
saveImage(vecImageInfo.at(i).imageOrigin, vecImageInfo.at(i).image3D, filePath);
QString imgPath = saveImage(vecImageInfo.at(i).imageOrigin, vecImageInfo.at(i).image3D, filePath);
if (workMode == WorkMode::IntoStock && imgPath!="")
{
m_currtIntoStockInfo.imagesPathList.push_back(imgPath);
}
#elif IMAGEDRAWING == OPENCV
if (workMode == WorkMode::IntoStock)
@ -396,14 +403,24 @@ Q_SLOT void SmokeBoxIdentification::onDecodeMsg(const QString& msg)
qDebug() << "strlist length: " << strList.length() << " head: " << strList.at(0);
if (strList.at(0) == START_CAPTURE && strList.length() == 7)
{
qDebug() << "µ½Î»È¡Í¼¿ªÊ¼";
//m_workMode = WorkMode::Capture;
m_currtIntoStockInfo.taskNum = strList.at(3);
if (m_currtIntoStockInfo.taskNum == '0')
{
qDebug() << "入库取图开始";
}
else
{
qDebug() << "到位取图开始";
}
QStringList streetInfo = strList.at(1).split("/");
m_currtIntoStockInfo.streetName = streetInfo.at(0);
m_currtIntoStockInfo.Floor = streetInfo.at(1).toInt();
m_currtIntoStockInfo.row = streetInfo.at(2).toInt();
m_currtIntoStockInfo.id = strList.at(2);
m_currtIntoStockInfo.taskNum = strList.at(3);
m_currtIntoStockInfo.stockLocation = strList.at(4);
m_currtIntoStockInfo.smokeTypeNum = strList.at(5);
m_currtIntoStockInfo.smokeQuantity = strList.at(6);
@ -529,6 +546,7 @@ void SmokeBoxIdentification::calculate(int stocketID)
depthImagePath.append(".PNG");
m_stocketList[stocketID].imagesPathList.append(depthImagePath.right(depthImagePath.length() - 1));
m_stocketList[stocketID].pcdSrc = pclPath;
}
else
{
@ -550,14 +568,14 @@ void SmokeBoxIdentification::calculate(int stocketID)
m_stocketList[stocketID].smokeQuantityRlt = m_stocketList[stocketID].smokeQuantity;
//QFile::copy("C:\\Users\\LENOVO\\Downloads\\30t.pcd",pclPath);
QFile::rename(".\\Cache\\1.pcd", pclPath);
//QFile::rename(".\\Cache\\1.pcd", pclPath);
}
else
{
CameraControl* cameraCon = CameraControl::instance();
m_stocketList[stocketID].pcdSrc = pclPath.replace(".", "").append("\\").append(QString::number((cameraCon->getDeviceId(imgInfo.cameraSn)))).append(".pcd");
qDebug() << "pcdSrc:" << m_stocketList[stocketID].pcdSrc;
//CameraControl* cameraCon = CameraControl::instance();
//m_stocketList[stocketID].pcdSrc = pclPath.replace(".", "").append("\\").append(QString::number((cameraCon->getDeviceId(imgInfo.cameraSn)))).append(".pcd");
//qDebug() << "pcdSrc:" << m_stocketList[stocketID].pcdSrc;
QString str = QString("[%1]:Pre 2D Camera don't Match. Now Camera %2.").arg(stocket.id).arg(imgInfo.cameraSn);
qDebug() << str;
}
@ -693,7 +711,8 @@ void SmokeBoxIdentification::sendResults(int mode, int id)
break;
case eCommunicationRules::emSJZ:
resultInfoMsg.append(RETURN_CALCULATE).append(SPLIT_RULE)
.append(m_stocketList.value(id).streetName).append("/").append(QString::number(m_stocketList.value(id).Floor)).append(SPLIT_RULE)
.append(m_stocketList.value(id).streetName).append("/").append(QString::number(m_stocketList.value(id).Floor))
.append("/").append(QString::number(m_stocketList.value(id).row)).append(SPLIT_RULE)
.append(m_stocketList.value(id).id).append(SPLIT_RULE)
.append(m_stocketList.value(id).taskNum).append(SPLIT_RULE)
.append(m_stocketList.value(id).stockLocation).append(SPLIT_RULE)
@ -731,12 +750,14 @@ void SmokeBoxIdentification::sendResults(int mode, int id)
case eCommunicationRules::emSJZ:
{
resultInfoMsg.append(END_CAPTURE).append(SPLIT_RULE)
.append(m_currtIntoStockInfo.streetName).append("/").append(QString::number(m_currtIntoStockInfo.Floor)).append(SPLIT_RULE)
.append(m_currtIntoStockInfo.streetName).append("/").append(QString::number(m_currtIntoStockInfo.Floor))
.append("/").append(QString::number(m_currtIntoStockInfo.row)).append(SPLIT_RULE)
.append(m_currtIntoStockInfo.id).append(SPLIT_RULE)
.append(m_currtIntoStockInfo.taskNum).append(SPLIT_RULE)
.append(m_currtIntoStockInfo.stockLocation).append(SPLIT_RULE)
.append(m_currtIntoStockInfo.smokeTypeNum).append(SPLIT_RULE)
.append(m_currtIntoStockInfo.smokeQuantity).append(END_SYMBOL);
.append(m_currtIntoStockInfo.smokeQuantity).append(SPLIT_RULE)
.append(m_currtIntoStockInfo.imagesPathList.join(";")).append(END_SYMBOL);
break;
}
default:

@ -98,7 +98,7 @@ private:
void captureSide(int cameraID, int floor);
void saveImage(const QVector<ImageInfo>& vecImageInfo, int workMode);
void saveImage(const cv::Mat& imgMat, const QString& filePath);
void saveImage(ILImagePtr image, const cv::Mat& imgMat3D, const QString& filePath);
QString saveImage(ILImagePtr image, const cv::Mat& imgMat3D, const QString& filePath);
bool decodeSmokeInfoCsv(const QString& filePath);
bool matchSmokeNameAndTemplateFolderName(const QString& folderPath);

@ -36,6 +36,7 @@
#define SMOKEINFO_XLSX_CONFIG "\\user\\smokeInfo.xlsx"
#define FILE_STORAGE_PATH ".\\fileData"
#define FILE_INPUTSTORE_PATH ".\\storeData"
#define INTOSTOCK_IMAGE_FOLDER "intoStock"
#define ORIGIN_IMAGE_FOLDER "Origin"
#define TYPE_TEMPLATE_PATH ".\\templateImg"
@ -153,6 +154,7 @@ struct IntoStockInfo
QString smokeTypeNum; //上位机发送的品规号37010106
QString smokeQuantity; //上位机发送的数量30
int Floor = 1; //层数,表示现在拍的货物在高架库的第几层
int row = 0; //列数,表示现在拍的货物在高架库的第几列
QStringList imagesPathList;
@ -191,6 +193,7 @@ struct StockCheckInfo
QString pcdSrc; //盘点识别文件
int Floor = 1; //层数,表示现在拍的货物在高架库的第几层
int row = 0; //列数,表示现在拍的货物在高架库的第几列
//void clear()
//{
// streetName.clear();

@ -28,11 +28,11 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<Import Project="$(QtMsBuild)\qt_defaults.props" Condition="Exists('$(QtMsBuild)\qt_defaults.props')" />
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<QtInstall>msvc2017_64-5.9.4</QtInstall>
<QtInstall>5.9.4_msvc2017_64</QtInstall>
<QtModules>core;gui;network;quickwidgets;serialport;websockets;widgets;winextras</QtModules>
</PropertyGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<QtInstall>msvc2017_64-5.9.4</QtInstall>
<QtInstall>5.9.4_msvc2017_64</QtInstall>
<QtModules>core;network;gui;widgets;serialport;websockets;winextras;quickwidgets</QtModules>
</PropertyGroup>
<Target Name="QtMsBuildNotFound" BeforeTargets="CustomBuild;ClCompile" Condition="!Exists('$(QtMsBuild)\qt.targets') OR !Exists('$(QtMsBuild)\Qt.props')">
@ -54,12 +54,12 @@
<TargetName>smokeBoxd</TargetName>
<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>
<LibraryPath>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>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutDir>$(SolutionDir)..\runner17\$(Configuration)\</OutDir>
<TargetName>smokeBox</TargetName>
<LibraryPath>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>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">

@ -10,9 +10,9 @@
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<QtLastBackgroundBuild>2024-02-21T09:18:16.3023274Z</QtLastBackgroundBuild>
<QtLastBackgroundBuild>2024-04-18T09:37:16.2684852Z</QtLastBackgroundBuild>
</PropertyGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<QtLastBackgroundBuild>2024-02-25T01:36:44.5600966Z</QtLastBackgroundBuild>
<QtLastBackgroundBuild>2024-04-18T09:37:16.3134853Z</QtLastBackgroundBuild>
</PropertyGroup>
</Project>
Loading…
Cancel
Save