后端算法池更新新逻辑,未完善
This commit is contained in:
@@ -41,6 +41,8 @@ endforeach()
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /openmp")
|
||||
|
||||
FILE(GLOB ALGO_HEAD_FILES "./algo/*.h" )
|
||||
FILE(GLOB ALGO_SRC_FILES "./algo/*.cpp")
|
||||
FILE(GLOB HANDLEAI_HEAD_FILES "./handleAi/*.h" )
|
||||
FILE(GLOB HANDLEAI_SRC_FILES "./handleAi/*.cpp")
|
||||
FILE(GLOB UIMODULE_HEAD_FILES "./uiModule/*.h" )
|
||||
@@ -77,6 +79,8 @@ if(ANDROID)
|
||||
${UIMODULE_SRC_FILES}
|
||||
${HANDLEAI_HEAD_FILES}
|
||||
${HANDLEAI_SRC_FILES}
|
||||
${ALGO_HEAD_FILES}
|
||||
${ALGO_SRC_FILES}
|
||||
${UI_FILES}
|
||||
)
|
||||
else()
|
||||
@@ -96,6 +100,8 @@ else()
|
||||
${UIMODULE_SRC_FILES}
|
||||
${HANDLEAI_HEAD_FILES}
|
||||
${HANDLEAI_SRC_FILES}
|
||||
${ALGO_HEAD_FILES}
|
||||
${ALGO_SRC_FILES}
|
||||
${UI_FILES} "ff.rc" "icon.qrc" )
|
||||
else()
|
||||
add_executable( ${CURRENT_FOLDER} WIN32
|
||||
@@ -113,7 +119,9 @@ else()
|
||||
${UIMODULE_SRC_FILES}
|
||||
${HANDLEAI_HEAD_FILES}
|
||||
${HANDLEAI_SRC_FILES}
|
||||
${UI_FILES})
|
||||
${ALGO_HEAD_FILES}
|
||||
${ALGO_SRC_FILES}
|
||||
${UI_FILES} "ff.rc" "icon.qrc" )
|
||||
|
||||
endif()
|
||||
endif()
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
#include <algorithmThread.h>
|
||||
#include <algo/algorithmThread.h>
|
||||
#include "FrontendBackendBridge.h"
|
||||
#include <myTools.h>
|
||||
|
||||
-1
@@ -736,7 +736,6 @@ public:
|
||||
void getAllFiles(std::string path, std::vector<std::string>& files, std::string format);
|
||||
void Init(threadManager* threadManager) {
|
||||
tManager = threadManager;
|
||||
//modelPtr = &threadManager->models;
|
||||
sql = threadManager->sql;
|
||||
snDatas = &threadManager->snDatas;
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
#include <back/threadPoolManager.h>
|
||||
|
||||
void pinAioEvalute(std::shared_ptr <detData> data)
|
||||
{
|
||||
auto start_time = std::chrono::high_resolution_clock::now();
|
||||
if (data->imgs.size() < 1)
|
||||
{
|
||||
qDebug() << __FUNCDNAME__ << __LINE__ << "camera Mat size is Error!";
|
||||
return;
|
||||
}
|
||||
///////////////////ȡͼ///ÉùÃ÷/////////////////////
|
||||
//ngNoteCls Note;
|
||||
cv::Mat src;
|
||||
cv::Mat Paint;
|
||||
int CCD1OK = 1;
|
||||
double CCD1height = -1;
|
||||
double dmCodeWidth = 0, dmCodeHeight = 0;
|
||||
double pixAccX = 0.013502052, pixAccY = 0.014005423575;
|
||||
double camera1Width = 1, camera1Height = 2;
|
||||
QFuture<void> future1;
|
||||
if (data->imgs.size() == 1)
|
||||
{
|
||||
src = data->imgs[0];
|
||||
if (Paint.channels() == 1)
|
||||
cv::cvtColor(src, Paint, cv::COLOR_GRAY2BGR);
|
||||
else
|
||||
src.copyTo(Paint);
|
||||
}
|
||||
|
||||
|
||||
//}
|
||||
if (CCD1OK == 2)
|
||||
cv::putText(Paint, "NG", cv::Point(150, 600), 1, 10, cv::Scalar(0, 0, 255), 30);
|
||||
else
|
||||
cv::putText(Paint, "OK", cv::Point(150, 600), 1, 10, cv::Scalar(0, 255, 0), 30);
|
||||
|
||||
///////////////////ÎÞSN×èÈû///////////////////////
|
||||
//if (!data->SNcode.compare(snDatas->snErrorsnError))
|
||||
// data->SNcode = snDatas->waitForSn(data->timeCode);
|
||||
cv::putText(Paint, data->SNcode, cv::Point(150, 800), 1, 10, cv::Scalar(0, 255, 0), 10);
|
||||
/////////////////////SQL////////////////////////
|
||||
data->sqlVec.push_back({ "Camera1Result", CCD1OK });
|
||||
data->sqlVec.push_back({ "Camera1_Width", camera1Width });
|
||||
data->sqlVec.push_back({ "Camera1_Height", camera1Height });
|
||||
////////////////////½á¹û±£´æ//////////////////
|
||||
cv::resize(Paint, Paint, cv::Size(Paint.cols / 2, Paint.rows / 2));
|
||||
data->resultImgs.push_back(Paint);
|
||||
//////////////CSV/////////////////////////////
|
||||
std::string OKNG("OK");
|
||||
if (CCD1OK == 2)OKNG = "NG";
|
||||
qDebug() << "[Debug]algo1 end:" << QString::fromStdString(data->SNcode);
|
||||
std::cout << "algo1 end:" << QString::fromStdString(data->SNcode).toStdString() << endl;
|
||||
}
|
||||
@@ -19,11 +19,11 @@ public:
|
||||
//数据类
|
||||
jsonConfiguration* _jsonConfiguration = nullptr;
|
||||
detDataManager* _detDataManager = nullptr;
|
||||
handleAiModelManager* _handleAiModelManager;
|
||||
//线程类
|
||||
triggerManager* _triggerManager = nullptr;//触发器
|
||||
cameraManager* _cameraManager = nullptr;//
|
||||
threadManager* _threadManager = nullptr;
|
||||
handleAiModelManager* _handleAiModelManager;
|
||||
backEndManager();
|
||||
~backEndManager();
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <threadPoolManager.h>
|
||||
#include <FrontendBackendBridge.h>
|
||||
#include <algorithmThread.h>
|
||||
#include <algo/algorithmThread.h>
|
||||
#include <algo/pinAioEvalute.h>
|
||||
/// <summary>
|
||||
/// 检查目标文件夹是否存在,不存在则创建
|
||||
/// </summary>
|
||||
@@ -42,86 +43,66 @@ threadManager::threadManager(QObject* parent) : QThread(parent)
|
||||
//辅助线程初始化
|
||||
//oriSaveThread->oriThread = true;
|
||||
//oriSaveThread->Init(this);
|
||||
this->start();
|
||||
}
|
||||
|
||||
//resSaveThread->Init(this);
|
||||
threadAmount = bridge.back.json.algoThreads.algoDataMap.size();
|
||||
for (int i = 0; i < threadAmount; i++)
|
||||
void threadManager::process()
|
||||
{
|
||||
#pragma region 检查队列是否有新的数据
|
||||
queueMutex.lock();
|
||||
while (insertQueue.size() > 0)
|
||||
processData.push_back(std::make_pair(progress::waitImg,insertQueue.dequeue()));
|
||||
queueMutex.unlock();
|
||||
#pragma endregion
|
||||
#pragma region 检测状态并处理
|
||||
for (auto& data : processData)
|
||||
{
|
||||
algoThread* aT = new algoThread();
|
||||
aT->Init(this);
|
||||
//QObject::connect(aT, &algoThread::subThreadStart, [&]() {
|
||||
// supportThread->start();
|
||||
// });
|
||||
algoThreadList.push_back(aT);
|
||||
std::shared_ptr <detData> detDataPtr = data.second;
|
||||
switch (data.first)
|
||||
{
|
||||
case waitImg:
|
||||
if (detDataPtr->imgs.size() >= detDataPtr->imgAmountMin)
|
||||
{
|
||||
futures.insert(std::make_pair(detDataPtr->timeCode,std::async(std::launch::async, pinAioEvalute, detDataPtr)));
|
||||
data.first = processing;
|
||||
}
|
||||
break;
|
||||
case processing:
|
||||
auto futrue = futures.find(detDataPtr->timeCode);
|
||||
if (futrue == futures.end())
|
||||
{
|
||||
std::cout << "???????" << std::endl;
|
||||
}
|
||||
if (futrue->second.valid())
|
||||
{
|
||||
//processData
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma endregion
|
||||
}
|
||||
|
||||
void threadManager::run()
|
||||
{
|
||||
|
||||
while(1)
|
||||
{
|
||||
process();
|
||||
QThread::msleep(1);
|
||||
}
|
||||
}
|
||||
void threadManager::addTask(std::shared_ptr <detData> data)
|
||||
{
|
||||
//cout << __LINE__ << "insert Data " << data ->timeCode<< endl;
|
||||
{
|
||||
algoThreadCls::datastruct _struct = bridge.back.json.algoThreads.getData(data->algoThreadName);
|
||||
data->algoThreadIndex = _struct.threadIndex;
|
||||
data->resShowIndex = _struct.showIndex;
|
||||
data->imgAmountMin = _struct.imgAmountMin;
|
||||
}
|
||||
{
|
||||
CameraListCls::datastruct _struct = bridge.back.json.camera.getData(data->cameraKeyName);
|
||||
data->oriShowIndex = _struct.showIndex;
|
||||
}
|
||||
//{
|
||||
// CameraListCls::datastruct _struct = bridge.back.json.camera.getData(data->cameraKeyName);
|
||||
// data->oriShowIndex = _struct.showIndex;
|
||||
//}
|
||||
insertQueueMutex.lock();
|
||||
//insertQueue.push_back(data);
|
||||
int threadId = data->algoThreadIndex;
|
||||
if (threadId == -1)
|
||||
{
|
||||
cout << "threadId return -1 ,algoName " << data->algoThreadName.toStdString() << endl;
|
||||
return;
|
||||
}
|
||||
algoThreadList[threadId]->addDetTask(data);
|
||||
insertQueue.enqueue(data);
|
||||
insertQueueMutex.unlock();
|
||||
//this->start();
|
||||
}
|
||||
bool threadManager::addTaskFreeThread(std::shared_ptr <detData> data)
|
||||
{
|
||||
#if 0
|
||||
int index = 0;
|
||||
for (index = 0; index < threadPoolList.size(); index++)
|
||||
{
|
||||
if (threadPoolList[index]->isRunning() == false)
|
||||
{
|
||||
threadPoolList[index]->addDetTask(data);
|
||||
threadPoolList[index]->start();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
for (index = 0; index < threadPoolList.size(); index++)
|
||||
{
|
||||
if (threadPoolList[index]->nextObj.isEmpty() == true)
|
||||
{
|
||||
threadPoolList[index]->addDetTask(data);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
|
||||
}
|
||||
threadManager::~threadManager()
|
||||
{
|
||||
for (auto thread : algoThreadList)
|
||||
{
|
||||
thread->m_runFlag = false;
|
||||
thread->terminate();
|
||||
while (thread->isRunning() == true);
|
||||
}
|
||||
for (auto thread : algoThreadList)
|
||||
{
|
||||
delete thread;
|
||||
}
|
||||
}
|
||||
////////////////DET//DATA//////////////////
|
||||
sncodeCls::sncodeCls()
|
||||
|
||||
@@ -226,16 +226,20 @@ class threadManager : public QThread
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum progress
|
||||
{
|
||||
waitImg,
|
||||
processing
|
||||
};
|
||||
|
||||
explicit threadManager(QObject* parent = nullptr);
|
||||
QMutex queueMutex;
|
||||
QQueue<std::shared_ptr <detData>> detDataQueue;
|
||||
sqlManager* sql;
|
||||
//handleAiModel models;//初始化模型
|
||||
autoDelete* autoDeleteThread;
|
||||
|
||||
QMutex insertQueueMutex;
|
||||
QQueue<std::shared_ptr <detData>>insertQueue;
|
||||
std::vector<algoThread*>algoThreadList;
|
||||
|
||||
|
||||
void run();
|
||||
void stop()
|
||||
{
|
||||
@@ -244,9 +248,16 @@ public:
|
||||
}
|
||||
|
||||
void addTask(std::shared_ptr <detData>);
|
||||
bool addTaskFreeThread(std::shared_ptr <detData>);
|
||||
sncodeCls snDatas;
|
||||
~threadManager();
|
||||
|
||||
QMutex queueMutex;
|
||||
|
||||
QMutex insertQueueMutex;
|
||||
QQueue<std::shared_ptr <detData>>insertQueue;
|
||||
std::vector<std::pair<progress,std::shared_ptr <detData>>> processData;
|
||||
std::unordered_map<unsigned long long,std::future<void>> futures;
|
||||
void process();
|
||||
private:
|
||||
bool runFlag = true;
|
||||
QList<std::shared_ptr <detData>>imgWaitList;
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
#include <QWidget>
|
||||
class sqlControlWidget :public QWidget
|
||||
{
|
||||
public:
|
||||
enum logType
|
||||
{
|
||||
stdConsle,
|
||||
qtConsle
|
||||
};
|
||||
QVBoxLayout* Layout = new QVBoxLayout(this);
|
||||
QHBoxLayout* btnLayout = new QHBoxLayout(this);
|
||||
std::vector<gradientButton*>btns;
|
||||
QLabel* icon, * Title;
|
||||
QStackedWidget* widgets = new QStackedWidget();
|
||||
|
||||
QLabel* disconnnectedLabel = new QLabel("·þÎñÒÑÀëÏß");
|
||||
sqlControlWidget()
|
||||
{
|
||||
QPalette palette;
|
||||
palette.setColor(QPalette::WindowText, Qt::white);
|
||||
QFont font("΢ÈíÑźÚ", 24, QFont::Bold);
|
||||
QFont font2("΢ÈíÑźÚ", 108, QFont::Bold);
|
||||
|
||||
widgets->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
widgets->setMaximumSize(9999, 9999);
|
||||
|
||||
this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
this->setMaximumSize(9999, 9999);
|
||||
this->setObjectName("sqlControlWidget");
|
||||
|
||||
Layout->setContentsMargins(0, 0, 0, 0);
|
||||
Layout->setAlignment(Qt::AlignLeft | Qt::AlignTop);
|
||||
|
||||
Title = new QLabel(u8"SQL²Ù×÷½çÃæ");
|
||||
Title->setFont(font);
|
||||
Title->setPalette(palette);
|
||||
Title->setAlignment(Qt::AlignLeft);
|
||||
|
||||
disconnnectedLabel->setFont(font2);
|
||||
disconnnectedLabel->setPalette(palette);
|
||||
disconnnectedLabel->setAlignment(Qt::AlignCenter);
|
||||
|
||||
Layout->addWidget(Title);
|
||||
|
||||
btnLayout->setContentsMargins(0, 0, 0, 0);
|
||||
btnLayout->setAlignment(Qt::AlignLeft);
|
||||
|
||||
btnLayout->addWidget(disconnnectedLabel);
|
||||
|
||||
Layout->addLayout(btnLayout);
|
||||
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
#pragma once
|
||||
#pragma once
|
||||
@@ -221,8 +221,8 @@ void MainWindow::leftBarInit()
|
||||
defaultHeight,
|
||||
QIcon(":/topBar/icon/sql.png"),
|
||||
u8"SQL可视化");
|
||||
//_logWidget = new logWidget();
|
||||
//pageWidgets.addWidget(_logWidget);
|
||||
_sqlControlWidget = new sqlControlWidget();
|
||||
pageWidgets.addWidget(_sqlControlWidget);
|
||||
pageBtns.push_back(sqlBtn);
|
||||
|
||||
for (int index = 0; index < pageBtns.size(); index++)
|
||||
|
||||
@@ -15,13 +15,17 @@
|
||||
#include <qpushbutton.h>
|
||||
#include <unordered_map>
|
||||
#include <uiModule/components/toolBarButton.h>
|
||||
#include <pages/displayPageWidget.h>
|
||||
#include <pages/configSettingWidget.h>
|
||||
#include <QStackedWidget>
|
||||
#include <pages/logPageWidget.h>
|
||||
#include <LoginWindow.h>
|
||||
#include <QPropertyAnimation>
|
||||
#include <loadingWidget.h>
|
||||
|
||||
#include <pages/displayPageWidget.h>
|
||||
#include <pages/configSettingWidget.h>
|
||||
#include <pages/logPageWidget.h>
|
||||
#include <pages/sqlControlWidget.h>
|
||||
|
||||
#define disableBackEndCheck 1
|
||||
#pragma execution_character_set("utf-8")
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
@@ -45,6 +49,7 @@ public:
|
||||
displayWidget* _displayWidget;
|
||||
configSettingWidget* _configSettingWidget;
|
||||
logWidget* _logWidget;
|
||||
sqlControlWidget* _sqlControlWidget;
|
||||
private:
|
||||
Ui::MainWindow* ui;
|
||||
//动画效果
|
||||
@@ -92,7 +97,14 @@ public slots:
|
||||
{
|
||||
if (input == true)
|
||||
{
|
||||
if (backEndInit == true)
|
||||
#if disableBackEndCheck == 0
|
||||
if (backEndInit == false)
|
||||
{
|
||||
isLogin = true;
|
||||
loading(true);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
blurEffectAnimation->setStartValue(0);
|
||||
blurEffectAnimation->setEndValue(20);
|
||||
@@ -102,11 +114,6 @@ public slots:
|
||||
blurEffectAnimation->setEndValue(0);
|
||||
blurEffectAnimation->start();
|
||||
}
|
||||
else
|
||||
{
|
||||
isLogin = true;
|
||||
loading(true);
|
||||
}
|
||||
}
|
||||
else if (input == false)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user