You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
smokeboxidentification/src/SmokeBoxIdentification.h

159 lines
4.2 KiB
C++

#ifndef SMOKE_IDENTIFICATION_H
#define SMOKE_IDENTIFICATION_H
#include <fstream>
#include <QtWidgets/QMainWindow>
#include <QtConcurrent/QtConcurrent>
#include"xlsxdocument.h"
#include "xlsxworkbook.h"
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
#include "CameraControl.h"
#include "NetControl.h"
#include "ADModule.h"
#include "CategoryMatcher.h"
#include "lpSerialStation.h"
#include "CodeScanStation.h"
#include "dataPreprocessing.h"
#include "QNumTemplateBuild.h"
#include "ui_SmokeBoxIdentification.h"
enum MsgType
{
EmptyCheckResult = 0,
DataCollectionEndSC,
StockCheckResult,
IntoStockResult
};
enum WorkMode
{
Idle = 0,
EmptyCheck,
StockCheck,
IntoStock
};
struct IntoStockInfo
{
QString streetName;
QString taskNum;
QString stockNum;
QStringList imagesPathList;
};
struct EmptyCheckInfo
{
QString streetName;
QString taskNum;
};
struct StockCheckInfo
{
QString streetName;
QString taskNum;
QString stockNum;
QString smokeTypeNum; //上位机发送的品规号
QString smokeQuantity; //上位机发送的数量
QString smokeTypeNumRlt; //盘点识别的品规号
QString smokeQuantityRlt; //盘点识别的数量
bool correctness; //盘点结果是否与上位机一致
//void clear()
//{
// streetName.clear();
// taskNum.clear();
// stockNum.clear();
// smokeTypeNum.clear();
// smokeQuantity.clear();
// smokeTypeNumRlt.clear();
// smokeQuantityRlt.clear();
// correctness = false;
//}
//StockCheckInfo &operator = (const StockCheckInfo& obj)
//{
// this->streetName = obj.streetName;
// this->taskNum = obj.taskNum;
// this->stockNum = obj.stockNum;
// this->smokeTypeNum = obj.smokeTypeNum;
// this->smokeQuantity = obj.smokeQuantity;
// this->smokeTypeNumRlt = obj.smokeTypeNumRlt;
// this->smokeQuantityRlt = obj.smokeQuantityRlt;
// this->correctness = obj.correctness;
// return *this;
//}
};
class SmokeBoxIdentification : public QMainWindow
{
Q_OBJECT
public:
SmokeBoxIdentification(QWidget *parent = Q_NULLPTR);
~SmokeBoxIdentification();
signals:
void sgCapture(int cameraLocation);
void sgCategoryMatchFinished(QString smokeNum);
void sgShowImage(QLabel* labelPtr, const QImage& qImage);
//void sgSendData2AndAlgo();
//void sgSaveSensorData2Local(QString filePath);
void sgNumDataCollectStart(int sideId);
void sgNumDataCollectStop();
//void sgSendResults(int mode);
void sgStartEmptyPlaceCheck(QString streetName);
void sgStopEmptyPlaceCheck();
void sgControlSideLight(int);
void sgSendMsg(QString msg);
private:
Q_SLOT void onDecodeMsg(const QString& msg);
Q_SLOT void onCapturedImage(const QVector<ImageInfo>& vecImageInfo, int camearLocation);
Q_SLOT void onNumStatistic(QString typeNum);
Q_SLOT void onShowImage(QLabel* labelPtr, const QImage& qImage);
Q_SLOT void onMonitorSensorTriggerStart(int);
Q_SLOT void onMonitorSensorTriggerStop(int);
Q_SLOT void onActionClicked();
Q_SLOT void onSendEmptyCheckResults(const QMap<QString, int>&);
Q_SLOT void onNewNumData(const QVector<QVector<double>>& vec, const QVector<QString>& strVec, int side);
void sendResults(int mode);
void saveData2File(const QVector<QString>& strVec, QString folderPath, int side);
void captureTop();
void captureSide();
void saveImage(const QVector<ImageInfo>& vecImageInfo, int workMode);
void saveImage(const cv::Mat& imgMat, const QString& filePath);
bool decodeSmokeInfoCsv(const QString& filePath);
bool matchSmokeNameAndTemplateFolderName(const QString& folderPath);
bool m_bEmptyCheckStart{ false };
//bool m_bStockCheckStart{ false };
bool m_bCaptureFinish{ false };
bool m_bDataCollection{ false };
//bool m_bCamerasInit{ false };
QMap<QString, QString> m_mapSmokeCode2Name;
QMap<QString, QString> m_mapSmokeName2TemplateFolderName;
QString m_currLeftRightJudge;
QVector<QString> m_vecStrHeightLeft;
QVector<QString> m_vecStrHeightRight;
std::shared_ptr<dataPreProcessing> m_pDataProcess;
WorkMode m_workMode;
NetControl* m_pNetControl;
CategoryMatcher* m_pCategoryMatcher;
IntoStockInfo m_currtIntoStockInfo;
StockCheckInfo m_currtStockCheckInfo;
EmptyCheckInfo m_currtEmptyCheckInfo;
QNumTemplateBuild* m_pNumTemplateBuild{ nullptr };
QThread* m_pTcpClientThread;
//QLabel* m_pShowRltImgLabel;
Ui::SmokeBoxIdentificationClass ui;
};
#endif // !SMOKE_IDENTIFICATION_H