82 lines
2.2 KiB
C++
82 lines
2.2 KiB
C++
#include <QThread>
|
|
#include <QObject>
|
|
#include <opencv.hpp>
|
|
#include <threadPoolManager.h>
|
|
#include <detData.h>
|
|
#include <appConfig/appConfig.h>
|
|
#include <appCore.hpp>
|
|
|
|
class detProcess;
|
|
class manualDetThread :public QThread
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
detDataManager* _detDataManager;
|
|
detThreadManager* _threadManager;
|
|
appConfig* _appConfig;
|
|
//检测参数
|
|
std::string imgPathStr = "";
|
|
int algoIndex = 0;
|
|
int Pos = 0;
|
|
manualDetThread()
|
|
{
|
|
_appConfig = &_core._appConfig;
|
|
}
|
|
void initialization(detProcess* _appCore);
|
|
void run()
|
|
{
|
|
emit _core._qtFunc.uiModuleHistoryListWidget_reset();
|
|
std::vector<std::shared_ptr<cv::Mat>> mats;
|
|
std::vector<std::string>files;
|
|
fileManager::getAllFiles(imgPathStr, files, "jpg");
|
|
for (auto file : files)
|
|
{
|
|
std::shared_ptr <detData> data = _detDataManager->insertDetData("Manual", "Manual", 0, 1);
|
|
data->productType = algoIndex;
|
|
data->armPos = Pos;
|
|
data->resShowIndex = 0;
|
|
data->oriImgMutex.lock();
|
|
data->oriImgs.push_back(cv::imread(file, -1));
|
|
data->oriImgMutex.unlock();
|
|
data->_productDataStruct = _appConfig->productDatas[algoIndex];
|
|
_threadManager->addTask(data);//添加任务
|
|
emit _core._qtFunc.uiModuleLocationMap_SetProductSignStatus(Pos, 1);
|
|
Pos++;
|
|
QThread::msleep(500);
|
|
}
|
|
files.clear();
|
|
fileManager::getAllFiles(imgPathStr, files, "bmp");
|
|
for (auto file : files)
|
|
{
|
|
std::shared_ptr <detData> data = _detDataManager->insertDetData("Manual", "Manual", 0, 1);
|
|
data->productType = algoIndex;
|
|
data->armPos = Pos;
|
|
data->resShowIndex = 0;
|
|
data->oriImgMutex.lock();
|
|
data->oriImgs.push_back(cv::imread(file, -1));
|
|
data->oriImgMutex.unlock();
|
|
data->_productDataStruct = _appConfig->productDatas[algoIndex];
|
|
_threadManager->addTask(data);//添加任务
|
|
emit _core._qtFunc.uiModuleLocationMap_SetProductSignStatus(Pos, 1);
|
|
Pos++;
|
|
QThread::msleep(500);
|
|
}
|
|
emit finishImgReadSignal();
|
|
}
|
|
void startDet(std::string path,int index)
|
|
{
|
|
Pos = 0;
|
|
emit _core._qtFunc.uiModuleLocationMap_ResetToDefault();
|
|
imgPathStr = path;
|
|
algoIndex = index;
|
|
this->start();
|
|
}
|
|
public slots:
|
|
void startManualDetSlot(std::string path, int index)
|
|
{
|
|
startDet(path, index);
|
|
}
|
|
signals:
|
|
void finishImgReadSignal();
|
|
};
|
|
#pragma once |