加入了思科算法,连接上了存图
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
#include <threadPoolManager.h>
|
||||
#include <FrontendBackendBridge.h>
|
||||
#include <algo/algorithmThread.h>
|
||||
#include <algo/pinAioEvalute.h>
|
||||
/// <summary>
|
||||
/// 检查目标文件夹是否存在,不存在则创建
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
#include <sqlManager/sqlManager.h>
|
||||
#include <imgSaveThreadManager.h>
|
||||
|
||||
#include <algo/ALGO_Test.h>
|
||||
#include <algo/ALGO_Correction.h>
|
||||
#include <algo/ALGO_Inspection.h>
|
||||
|
||||
using namespace std;
|
||||
void createDirectoryIfNotExists_2(const std::string& path) {
|
||||
// 检查路径是否存在
|
||||
@@ -31,21 +32,26 @@ std::string getCurrentDateTime_2() {
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
int threadAmount = 0;
|
||||
int maxThread = 16;
|
||||
|
||||
////////////THREAD//Manager////////////////////////
|
||||
threadManager::threadManager(QObject* parent) : QThread(parent)
|
||||
threadManager::threadManager()
|
||||
{
|
||||
//sql初始化
|
||||
sql = new sqlManager;
|
||||
sql->initPara();
|
||||
//sql = new sqlManager;
|
||||
//sql->initPara();
|
||||
//辅助线程初始化
|
||||
//oriSaveThread->oriThread = true;
|
||||
//oriSaveThread->Init(this);
|
||||
this->start();
|
||||
//this->start();
|
||||
}
|
||||
|
||||
void threadManager::init(backEndManager* _backEndManagerIn)
|
||||
{
|
||||
_backEndManager = _backEndManagerIn;
|
||||
sql = &_backEndManager->_sqlManager;
|
||||
_imgSaveThreadManager = _backEndManagerIn->_imgSaveThreadManager;
|
||||
this->start();
|
||||
}
|
||||
void threadManager::process()
|
||||
{
|
||||
|
||||
@@ -59,11 +65,12 @@ void threadManager::process()
|
||||
for (auto it = waitImgData.begin(); it != waitImgData.end();)
|
||||
{
|
||||
std::shared_ptr<detData> ptr = *it;
|
||||
if (ptr->imgs.size() >= ptr->imgAmountMin)
|
||||
if (ptr->oriImgs.size() >= ptr->imgAmountMin)
|
||||
{
|
||||
futures.insert(std::make_pair(ptr->timeCode, std::async(std::launch::async, pinAioEvalute, ptr)));
|
||||
it = waitImgData.erase(it);
|
||||
algoFutures.insert(std::make_pair(ptr->timeCode, std::async(std::launch::async, ALGO_Inspection, ptr)));
|
||||
processData.push_back(ptr);
|
||||
|
||||
it = waitImgData.erase(it);
|
||||
}
|
||||
else
|
||||
++it;
|
||||
@@ -73,12 +80,29 @@ void threadManager::process()
|
||||
for (auto it = processData.begin(); it != processData.end();)
|
||||
{
|
||||
std::shared_ptr<detData> ptr = *it;
|
||||
futrueIte = futures.find(ptr->timeCode);
|
||||
if (futrueIte->second.valid())
|
||||
futrueIte = algoFutures.find(ptr->timeCode);
|
||||
if (futrueIte->second.wait_for(zeroSec)== std::future_status::ready)
|
||||
{
|
||||
it = processData.erase(it); // 删除元素后,更新迭代器
|
||||
futures.erase(futrueIte);
|
||||
std::async(std::launch::async, &threadManager::resultHandle, this, ptr);
|
||||
resultData.push_back(ptr);
|
||||
resultFutures.insert(std::make_pair(ptr->timeCode, std::async(std::launch::async, &threadManager::resultHandle, this, ptr)));
|
||||
|
||||
it = processData.erase(it);
|
||||
algoFutures.erase(futrueIte);
|
||||
}
|
||||
else
|
||||
++it;
|
||||
}
|
||||
#pragma endregion
|
||||
#pragma region 等待结果并执行显示图片等操作
|
||||
for (auto it = resultData.begin(); it != resultData.end();)
|
||||
{
|
||||
std::shared_ptr<detData> ptr = *it;
|
||||
futrueIte = resultFutures.find(ptr->timeCode);
|
||||
if (futrueIte->second.wait_for(zeroSec) == std::future_status::ready)
|
||||
{
|
||||
|
||||
it = resultData.erase(it);
|
||||
resultFutures.erase(futrueIte);
|
||||
}
|
||||
else
|
||||
++it;
|
||||
@@ -86,9 +110,28 @@ void threadManager::process()
|
||||
#pragma endregion
|
||||
|
||||
}
|
||||
void threadManager::resultHandle(std::shared_ptr <detData>)
|
||||
void threadManager::resultHandle(std::shared_ptr <detData> data)
|
||||
{
|
||||
//储存结果图
|
||||
_imgSaveThreadManager->resSaveThread->imgDataQueue.append(data);
|
||||
//发送图片
|
||||
QPixmap pixmap;
|
||||
cvMatToQPixMap(data->resultImgs[0], pixmap);
|
||||
showImgPack* pack = new showImgPack();
|
||||
pack->img = pixmap;
|
||||
pack->type = imgWidgetRes;
|
||||
pack->index = data->oriShowIndex;
|
||||
emit _backEndManager->sendPixmapImageWidget(pack);
|
||||
|
||||
//SQL
|
||||
std::vector<sqlData> sqlDatas;
|
||||
for (auto sqlData : data->sqlVec)
|
||||
sqlDatas.push_back({ sqlData.first, std::to_string(sqlData.second) });
|
||||
sql->addData(data->SNcode, sqlDatas);
|
||||
|
||||
//提交清理申请
|
||||
detDataManager* dManager = data->dManager;
|
||||
data->dManager->deleteDetData(data->timeCode);
|
||||
}
|
||||
void threadManager::run()
|
||||
{
|
||||
@@ -115,7 +158,7 @@ threadManager::~threadManager()
|
||||
this->stop();
|
||||
this->terminate();
|
||||
processData.clear();
|
||||
futures.clear();
|
||||
algoFutures.clear();
|
||||
}
|
||||
////////////////DET//DATA//////////////////
|
||||
sncodeCls::sncodeCls()
|
||||
|
||||
Reference in New Issue
Block a user