增加标定模板添加和删除功能

master
bob.pan 5 years ago
parent 7bec299f00
commit d26d44f21a

@ -1,355 +0,0 @@
/********************************************************************************
** Form generated from reading UI file 'MainFrame.ui'
**
** Created by: Qt User Interface Compiler version 5.9.4
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef UI_MAINFRAME_H
#define UI_MAINFRAME_H
#include <QtCore/QVariant>
#include <QtWidgets/QAction>
#include <QtWidgets/QApplication>
#include <QtWidgets/QButtonGroup>
#include <QtWidgets/QFrame>
#include <QtWidgets/QGridLayout>
#include <QtWidgets/QGroupBox>
#include <QtWidgets/QHBoxLayout>
#include <QtWidgets/QHeaderView>
#include <QtWidgets/QLabel>
#include <QtWidgets/QMainWindow>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QSpacerItem>
#include <QtWidgets/QSplitter>
#include <QtWidgets/QStatusBar>
#include <QtWidgets/QTableWidget>
#include <QtWidgets/QTextEdit>
#include <QtWidgets/QToolBar>
#include <QtWidgets/QWidget>
#include "lpTreeWidget.h"
#include "lpimgviewer.h"
QT_BEGIN_NAMESPACE
class Ui_MainFrame
{
public:
QAction *actionadd;
QAction *actiondel;
QAction *actionsave;
QWidget *centralwidget;
QGridLayout *gridLayout_2;
QHBoxLayout *horizontalLayout_2;
QPushButton *m_pbSaveBtn;
QLabel *label_SaveStatus;
QSpacerItem *horizontalSpacer;
QSplitter *splitter_3;
LpTreeWidget *treeWidget;
QSplitter *splitter_2;
QFrame *frame;
QGridLayout *gridLayout_3;
QSplitter *splitter;
QWidget *layoutWidget;
QHBoxLayout *horizontalLayout_4;
lpImgViewer *gv_input;
lpImgViewer *gv_output;
QWidget *layoutWidget1;
QHBoxLayout *horizontalLayout_5;
QGroupBox *groupBox_3;
QGridLayout *gridLayout_7;
QTextEdit *textEdit;
QHBoxLayout *horizontalLayout_6;
QPushButton *m_pbLoadImage;
QSpacerItem *horizontalSpacer_2;
QPushButton *pushButton_5;
QLabel *label_pixel_info;
QFrame *frame_2;
QHBoxLayout *horizontalLayout_7;
QGroupBox *groupBox_2;
QGridLayout *gridLayout_5;
QTableWidget *tableWidget_2;
QGroupBox *groupBox_4;
QGridLayout *gridLayout_4;
QTableWidget *tableWidget;
QStatusBar *statusBar;
QToolBar *toolBar;
void setupUi(QMainWindow *MainFrame)
{
if (MainFrame->objectName().isEmpty())
MainFrame->setObjectName(QStringLiteral("MainFrame"));
MainFrame->setWindowModality(Qt::ApplicationModal);
MainFrame->resize(1050, 755);
actionadd = new QAction(MainFrame);
actionadd->setObjectName(QStringLiteral("actionadd"));
actiondel = new QAction(MainFrame);
actiondel->setObjectName(QStringLiteral("actiondel"));
actionsave = new QAction(MainFrame);
actionsave->setObjectName(QStringLiteral("actionsave"));
centralwidget = new QWidget(MainFrame);
centralwidget->setObjectName(QStringLiteral("centralwidget"));
gridLayout_2 = new QGridLayout(centralwidget);
gridLayout_2->setSpacing(5);
gridLayout_2->setObjectName(QStringLiteral("gridLayout_2"));
gridLayout_2->setContentsMargins(5, 5, 5, 5);
horizontalLayout_2 = new QHBoxLayout();
horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
m_pbSaveBtn = new QPushButton(centralwidget);
m_pbSaveBtn->setObjectName(QStringLiteral("m_pbSaveBtn"));
QFont font;
font.setPointSize(11);
m_pbSaveBtn->setFont(font);
QIcon icon;
icon.addFile(QStringLiteral(":/img/resource/save.png"), QSize(), QIcon::Normal, QIcon::Off);
m_pbSaveBtn->setIcon(icon);
m_pbSaveBtn->setIconSize(QSize(20, 20));
m_pbSaveBtn->setFlat(true);
horizontalLayout_2->addWidget(m_pbSaveBtn);
label_SaveStatus = new QLabel(centralwidget);
label_SaveStatus->setObjectName(QStringLiteral("label_SaveStatus"));
horizontalLayout_2->addWidget(label_SaveStatus);
horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
horizontalLayout_2->addItem(horizontalSpacer);
gridLayout_2->addLayout(horizontalLayout_2, 0, 0, 1, 1);
splitter_3 = new QSplitter(centralwidget);
splitter_3->setObjectName(QStringLiteral("splitter_3"));
QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
sizePolicy.setHorizontalStretch(0);
sizePolicy.setVerticalStretch(0);
sizePolicy.setHeightForWidth(splitter_3->sizePolicy().hasHeightForWidth());
splitter_3->setSizePolicy(sizePolicy);
splitter_3->setOrientation(Qt::Horizontal);
treeWidget = new LpTreeWidget(splitter_3);
treeWidget->setObjectName(QStringLiteral("treeWidget"));
QSizePolicy sizePolicy1(QSizePolicy::Expanding, QSizePolicy::Expanding);
sizePolicy1.setHorizontalStretch(3);
sizePolicy1.setVerticalStretch(0);
sizePolicy1.setHeightForWidth(treeWidget->sizePolicy().hasHeightForWidth());
treeWidget->setSizePolicy(sizePolicy1);
QFont font1;
font1.setFamily(QStringLiteral("Consolas"));
font1.setPointSize(11);
treeWidget->setFont(font1);
splitter_3->addWidget(treeWidget);
splitter_2 = new QSplitter(splitter_3);
splitter_2->setObjectName(QStringLiteral("splitter_2"));
QSizePolicy sizePolicy2(QSizePolicy::Expanding, QSizePolicy::Expanding);
sizePolicy2.setHorizontalStretch(8);
sizePolicy2.setVerticalStretch(0);
sizePolicy2.setHeightForWidth(splitter_2->sizePolicy().hasHeightForWidth());
splitter_2->setSizePolicy(sizePolicy2);
splitter_2->setOrientation(Qt::Vertical);
frame = new QFrame(splitter_2);
frame->setObjectName(QStringLiteral("frame"));
frame->setFrameShape(QFrame::StyledPanel);
frame->setFrameShadow(QFrame::Plain);
gridLayout_3 = new QGridLayout(frame);
gridLayout_3->setObjectName(QStringLiteral("gridLayout_3"));
gridLayout_3->setContentsMargins(2, 2, 2, 2);
splitter = new QSplitter(frame);
splitter->setObjectName(QStringLiteral("splitter"));
splitter->setOrientation(Qt::Vertical);
layoutWidget = new QWidget(splitter);
layoutWidget->setObjectName(QStringLiteral("layoutWidget"));
horizontalLayout_4 = new QHBoxLayout(layoutWidget);
horizontalLayout_4->setSpacing(1);
horizontalLayout_4->setObjectName(QStringLiteral("horizontalLayout_4"));
horizontalLayout_4->setContentsMargins(0, 0, 0, 0);
gv_input = new lpImgViewer(layoutWidget);
gv_input->setObjectName(QStringLiteral("gv_input"));
gv_input->setMinimumSize(QSize(0, 200));
gv_input->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
gv_input->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
gv_input->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents);
horizontalLayout_4->addWidget(gv_input);
gv_output = new lpImgViewer(layoutWidget);
gv_output->setObjectName(QStringLiteral("gv_output"));
gv_output->setMinimumSize(QSize(0, 200));
gv_output->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
gv_output->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
gv_output->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents);
horizontalLayout_4->addWidget(gv_output);
splitter->addWidget(layoutWidget);
layoutWidget1 = new QWidget(splitter);
layoutWidget1->setObjectName(QStringLiteral("layoutWidget1"));
horizontalLayout_5 = new QHBoxLayout(layoutWidget1);
horizontalLayout_5->setSpacing(1);
horizontalLayout_5->setObjectName(QStringLiteral("horizontalLayout_5"));
horizontalLayout_5->setContentsMargins(0, 0, 0, 0);
groupBox_3 = new QGroupBox(layoutWidget1);
groupBox_3->setObjectName(QStringLiteral("groupBox_3"));
gridLayout_7 = new QGridLayout(groupBox_3);
gridLayout_7->setObjectName(QStringLiteral("gridLayout_7"));
gridLayout_7->setContentsMargins(2, 2, 2, 2);
textEdit = new QTextEdit(groupBox_3);
textEdit->setObjectName(QStringLiteral("textEdit"));
gridLayout_7->addWidget(textEdit, 0, 0, 1, 1);
horizontalLayout_6 = new QHBoxLayout();
horizontalLayout_6->setObjectName(QStringLiteral("horizontalLayout_6"));
m_pbLoadImage = new QPushButton(groupBox_3);
m_pbLoadImage->setObjectName(QStringLiteral("m_pbLoadImage"));
horizontalLayout_6->addWidget(m_pbLoadImage);
horizontalSpacer_2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
horizontalLayout_6->addItem(horizontalSpacer_2);
pushButton_5 = new QPushButton(groupBox_3);
pushButton_5->setObjectName(QStringLiteral("pushButton_5"));
horizontalLayout_6->addWidget(pushButton_5);
gridLayout_7->addLayout(horizontalLayout_6, 1, 0, 1, 1);
horizontalLayout_5->addWidget(groupBox_3);
horizontalLayout_5->setStretch(0, 1);
splitter->addWidget(layoutWidget1);
gridLayout_3->addWidget(splitter, 1, 0, 1, 1);
label_pixel_info = new QLabel(frame);
label_pixel_info->setObjectName(QStringLiteral("label_pixel_info"));
gridLayout_3->addWidget(label_pixel_info, 0, 0, 1, 1);
gridLayout_3->setRowStretch(0, 1);
gridLayout_3->setRowStretch(1, 100);
splitter_2->addWidget(frame);
frame_2 = new QFrame(splitter_2);
frame_2->setObjectName(QStringLiteral("frame_2"));
frame_2->setFrameShape(QFrame::StyledPanel);
frame_2->setFrameShadow(QFrame::Plain);
horizontalLayout_7 = new QHBoxLayout(frame_2);
horizontalLayout_7->setSpacing(1);
horizontalLayout_7->setObjectName(QStringLiteral("horizontalLayout_7"));
horizontalLayout_7->setContentsMargins(1, 1, 1, 1);
groupBox_2 = new QGroupBox(frame_2);
groupBox_2->setObjectName(QStringLiteral("groupBox_2"));
gridLayout_5 = new QGridLayout(groupBox_2);
gridLayout_5->setObjectName(QStringLiteral("gridLayout_5"));
gridLayout_5->setContentsMargins(2, 2, 2, 2);
tableWidget_2 = new QTableWidget(groupBox_2);
if (tableWidget_2->columnCount() < 3)
tableWidget_2->setColumnCount(3);
QTableWidgetItem *__qtablewidgetitem = new QTableWidgetItem();
tableWidget_2->setHorizontalHeaderItem(0, __qtablewidgetitem);
QTableWidgetItem *__qtablewidgetitem1 = new QTableWidgetItem();
tableWidget_2->setHorizontalHeaderItem(1, __qtablewidgetitem1);
QTableWidgetItem *__qtablewidgetitem2 = new QTableWidgetItem();
tableWidget_2->setHorizontalHeaderItem(2, __qtablewidgetitem2);
tableWidget_2->setObjectName(QStringLiteral("tableWidget_2"));
tableWidget_2->setFont(font1);
gridLayout_5->addWidget(tableWidget_2, 0, 0, 1, 1);
horizontalLayout_7->addWidget(groupBox_2);
groupBox_4 = new QGroupBox(frame_2);
groupBox_4->setObjectName(QStringLiteral("groupBox_4"));
gridLayout_4 = new QGridLayout(groupBox_4);
gridLayout_4->setObjectName(QStringLiteral("gridLayout_4"));
gridLayout_4->setContentsMargins(2, 2, 2, 2);
tableWidget = new QTableWidget(groupBox_4);
if (tableWidget->columnCount() < 4)
tableWidget->setColumnCount(4);
QTableWidgetItem *__qtablewidgetitem3 = new QTableWidgetItem();
tableWidget->setHorizontalHeaderItem(0, __qtablewidgetitem3);
QTableWidgetItem *__qtablewidgetitem4 = new QTableWidgetItem();
tableWidget->setHorizontalHeaderItem(1, __qtablewidgetitem4);
QTableWidgetItem *__qtablewidgetitem5 = new QTableWidgetItem();
tableWidget->setHorizontalHeaderItem(2, __qtablewidgetitem5);
QTableWidgetItem *__qtablewidgetitem6 = new QTableWidgetItem();
tableWidget->setHorizontalHeaderItem(3, __qtablewidgetitem6);
tableWidget->setObjectName(QStringLiteral("tableWidget"));
tableWidget->setFont(font1);
gridLayout_4->addWidget(tableWidget, 0, 0, 1, 1);
horizontalLayout_7->addWidget(groupBox_4);
splitter_2->addWidget(frame_2);
splitter_3->addWidget(splitter_2);
gridLayout_2->addWidget(splitter_3, 1, 0, 1, 1);
MainFrame->setCentralWidget(centralwidget);
statusBar = new QStatusBar(MainFrame);
statusBar->setObjectName(QStringLiteral("statusBar"));
MainFrame->setStatusBar(statusBar);
toolBar = new QToolBar(MainFrame);
toolBar->setObjectName(QStringLiteral("toolBar"));
MainFrame->addToolBar(Qt::TopToolBarArea, toolBar);
toolBar->addAction(actionadd);
toolBar->addAction(actiondel);
toolBar->addAction(actionsave);
retranslateUi(MainFrame);
QMetaObject::connectSlotsByName(MainFrame);
} // setupUi
void retranslateUi(QMainWindow *MainFrame)
{
MainFrame->setWindowTitle(QApplication::translate("MainFrame", "\346\240\207\345\256\232", Q_NULLPTR));
actionadd->setText(QApplication::translate("MainFrame", "add", Q_NULLPTR));
actiondel->setText(QApplication::translate("MainFrame", "del", Q_NULLPTR));
actionsave->setText(QApplication::translate("MainFrame", "save", Q_NULLPTR));
m_pbSaveBtn->setText(QApplication::translate("MainFrame", "\344\277\235\345\255\230", Q_NULLPTR));
label_SaveStatus->setText(QString());
QTreeWidgetItem *___qtreewidgetitem = treeWidget->headerItem();
___qtreewidgetitem->setText(0, QApplication::translate("MainFrame", "\350\247\243\345\206\263\346\226\271\346\241\210\350\265\204\346\272\220\347\256\241\347\220\206", Q_NULLPTR));
groupBox_3->setTitle(QApplication::translate("MainFrame", "\350\276\223\345\207\272\347\273\223\346\236\234\357\274\232", Q_NULLPTR));
m_pbLoadImage->setText(QApplication::translate("MainFrame", "\345\212\240\350\275\275\345\233\276\345\203\217", Q_NULLPTR));
pushButton_5->setText(QApplication::translate("MainFrame", "\346\270\205\347\251\272\347\273\223\346\236\234", Q_NULLPTR));
label_pixel_info->setText(QApplication::translate("MainFrame", "Pixel info: ...", Q_NULLPTR));
groupBox_2->setTitle(QApplication::translate("MainFrame", "\347\256\227\346\263\225\345\210\227\350\241\250", Q_NULLPTR));
QTableWidgetItem *___qtablewidgetitem = tableWidget_2->horizontalHeaderItem(0);
___qtablewidgetitem->setText(QApplication::translate("MainFrame", "\347\274\226\345\217\267", Q_NULLPTR));
QTableWidgetItem *___qtablewidgetitem1 = tableWidget_2->horizontalHeaderItem(1);
___qtablewidgetitem1->setText(QApplication::translate("MainFrame", "\345\220\215\347\247\260", Q_NULLPTR));
QTableWidgetItem *___qtablewidgetitem2 = tableWidget_2->horizontalHeaderItem(2);
___qtablewidgetitem2->setText(QApplication::translate("MainFrame", "ROI", Q_NULLPTR));
groupBox_4->setTitle(QApplication::translate("MainFrame", "\345\217\202\346\225\260\345\210\227\350\241\250", Q_NULLPTR));
QTableWidgetItem *___qtablewidgetitem3 = tableWidget->horizontalHeaderItem(0);
___qtablewidgetitem3->setText(QApplication::translate("MainFrame", "\347\274\226\345\217\267", Q_NULLPTR));
QTableWidgetItem *___qtablewidgetitem4 = tableWidget->horizontalHeaderItem(1);
___qtablewidgetitem4->setText(QApplication::translate("MainFrame", "\345\220\215\347\247\260", Q_NULLPTR));
QTableWidgetItem *___qtablewidgetitem5 = tableWidget->horizontalHeaderItem(2);
___qtablewidgetitem5->setText(QApplication::translate("MainFrame", "\347\261\273\345\236\213", Q_NULLPTR));
QTableWidgetItem *___qtablewidgetitem6 = tableWidget->horizontalHeaderItem(3);
___qtablewidgetitem6->setText(QApplication::translate("MainFrame", "\345\200\274", Q_NULLPTR));
toolBar->setWindowTitle(QApplication::translate("MainFrame", "toolBar", Q_NULLPTR));
} // retranslateUi
};
namespace Ui {
class MainFrame: public Ui_MainFrame {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_MAINFRAME_H

@ -393,20 +393,6 @@
</layout>
</widget>
<widget class="QStatusBar" name="statusBar"/>
<widget class="QToolBar" name="toolBar">
<property name="windowTitle">
<string>toolBar</string>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="actionadd"/>
<addaction name="actiondel"/>
<addaction name="actionsave"/>
</widget>
<action name="actionadd">
<property name="text">
<string>add</string>

@ -41,19 +41,22 @@ IDetectorSolutionMgr* CDetectorEngine::getSolutionMgr()
bool CDetectorEngine::detect(cv::Mat srcImg, QString modeName, AlgResultCallBack func)
{
QVariantMap rltMap;
QTime mTime;
mTime.start();
IDetectorSolution* pSolution = m_SolutionMgr.GetRunSolution();
if (pSolution)
{
IDetectorTask* pTask = pSolution->GetTaskByName(modeName);
if (pTask)
{
pTask->GetTaskInfo()->detectImg = srcImg;
IDetectorAlgorithm* pAlgo = pTask->GetRunAlgo();
if (pAlgo) {
pAlgo->Exec();
QVariantMap map;
map.clear();
QMap<QString, PLP_ALGORITHM_PARAM> mOutParam = pAlgo->GetAllOutParams();
for (QMap<QString, PLP_ALGORITHM_PARAM>::iterator it = mOutParam.begin(); it != mOutParam.end(); it++)
{
@ -63,19 +66,20 @@ bool CDetectorEngine::detect(cv::Mat srcImg, QString modeName, AlgResultCallBack
map.insert(pOutparam->strName, pOutparam->value);
}
}
QVariantMap rltMap;
rltMap.insert("AlgoResult", map);
rltMap.insert("taskName", pTask->GetTaskName());
rltMap.insert("taskID", pTask->GetID());
rltMap.insert("originImage", EngineBase::convMat2QImage(srcImg));
rltMap.insert("tasktime", pTask->ExecTime());
if (func)
{
func(rltMap);
}
}
}
}
int nTime = mTime.elapsed();
rltMap.insert("tasktime", nTime*1.0/1000);
if (func)
{
func(rltMap);
}
return false;
}

@ -14,6 +14,22 @@ Solution::~Solution()
CleanUp();
}
bool Solution::AddTaskByTemplate(QString strName)
{
IDetectorTask *pTemplateTask = GetTaskByName("template");
if (pTemplateTask)
{
LP_DETECTOR_TASK tTaskInfo;
tTaskInfo.strName = strName;
IDetectorTask* pNewTask = AddAndCopyTask(pTemplateTask, tTaskInfo);
if (pNewTask)
{
return true;
}
}
return false;
}
bool Solution::Initialize(IAlgorithmLibMgr* pAlgoLibMgr)
{
if (!pAlgoLibMgr)
@ -224,7 +240,7 @@ bool Solution::SaveFileEx(const QString& strPath)
dir.mkpath(taskPath);
}
QString strTaskFilePath = taskPath + "/" + /*QString::number(p->GetID()) + "_" + p->GetTaskInfo()->strName +*/ "taskinfo.json";
QString strTaskFilePath = taskPath + "/" + "taskinfo.json";
if (!p->SaveFile(strTaskFilePath))
{
qWarning("save task:%s fail", p->GetTaskInfo()->strName);
@ -236,6 +252,37 @@ bool Solution::SaveFileEx(const QString& strPath)
dir.setSorting(QDir::Size | QDir::Reversed);
QFileInfoList fileList = dir.entryInfoList();
QJsonObject infoObj;
infoObj.insert("solution_name", m_tSolutionInfo.strName);
infoObj.insert("solution_type", m_tSolutionInfo.nType);
infoObj.insert("solution_description", m_tSolutionInfo.strDescription);
infoObj.insert("solution_id", m_nID);
QJsonArray tasklist;
m_tasklist = m_TaskMapByName.keys();
foreach(QString var, m_tasklist)
{
tasklist.append(var);
}
infoObj.insert("tasklist", tasklist);
QString strInfoFile = m_curRootPath + "/info.json";
QJsonDocument document;
document.setObject(infoObj);
QByteArray byteArray = document.toJson();
QFile infoFile(strInfoFile);
if (infoFile.open(QFile::WriteOnly | QFile::Text))
{
infoFile.write(byteArray);
infoFile.flush();
infoFile.close();
return true;
}
/*
for (int i = 0; i < fileList.size(); i++)
{
if (fileList.at(i).fileName() == "." || fileList.at(i).fileName() == "..")
@ -258,6 +305,13 @@ bool Solution::SaveFileEx(const QString& strPath)
}
return true;
*/
}
bool Solution::SaveFileEx()
{
return SaveFileEx(m_curRootPath);
}
/*
@ -280,7 +334,7 @@ bool Solution::LoadFileEx(const QString& strPath)
if (!dir.exists()) {
return false;
}
m_curRootPath = strPath;
QString strInfoFile = strPath + "/info.json";
QFile infoFile(strInfoFile);
@ -363,34 +417,6 @@ bool Solution::SerializeToJson(QJsonObject& jsonObject)
return true;
}
// bool Solution::SerializeFromJson(QJsonObject* pJsonObject)
// {
// if (!pJsonObject)
// return false;
//
// m_tSolutionInfo.strName = pJsonObject->value("solution_name").toString();
// m_tSolutionInfo.nType = pJsonObject->value("solution_type").toInt(0);
// m_tSolutionInfo.strDescription = pJsonObject->value("solution_description").toString();
// m_nID = pJsonObject->value("solution_id").toInt();
//
// int nBaseID = 0;
// QJsonArray TaskArray = pJsonObject->value("taskArray").toArray();
// for (int i = 0; i < TaskArray.size(); i++)
// {
// LP_DETECTOR_TASK Task;
// QJsonObject jsonObject = TaskArray[i].toObject();
//
// CDetectorTask* pTask = (CDetectorTask*)AddTask(&Task);
// if (!pTask->SerializeFromJson(&jsonObject))
// return false;
//
// nBaseID = pTask->GetID() > nBaseID ? pTask->GetID() : nBaseID;
// }
//
// m_nBaseID = nBaseID;
// return true;
// }
IDetectorSolution* Solution::Copy()
{
QMutexLocker locker(&m_mutex);
@ -438,7 +464,6 @@ bool Solution::GetModifyFlag()
return m_bIsModify;
}
bool Solution::Copy(IDetectorSolution* pSrcSolution, bool bRet /* = true */)
{
if (!pSrcSolution)
@ -450,7 +475,6 @@ bool Solution::Copy(IDetectorSolution* pSrcSolution, bool bRet /* = true */)
if (!SetSolutionInfo(pSrcSolution->GetSolutionInfo()))
return false;
m_nBaseID = pSrcSolution->GetTaskBaseID();
return true;
}
@ -521,4 +545,3 @@ QMap<QString, IDetectorTask*> Solution::GetAllTasks()
return m_TaskMapByName;
}

@ -8,6 +8,7 @@ class Solution : public IDetectorSolution
public:
Solution();
virtual ~Solution();
virtual bool AddTaskByTemplate(QString strName);
virtual IDetectorTask* AddTask(const PLP_DETECTOR_TASK pTask);
virtual bool DeleteTask(QString strName);
virtual IDetectorTask* GetTaskByName(QString strName);
@ -30,6 +31,7 @@ public:
virtual IDetectorTask* AddAndCopyTask(IDetectorTask* pSrcTask, LP_DETECTOR_TASK tTaskInfo);
virtual int GetTaskBaseID() const;
virtual bool SaveFileEx();
virtual bool SaveFileEx(const QString& strPath);
virtual bool SaveFileEx(const QString& strPath, QStringList sTaskNames);
virtual bool LoadFileEx(const QString& strPath);
@ -58,6 +60,7 @@ private:
IAlgorithmLibMgr* m_pAlgoLibMgr;
QMutex m_mutex;
QStringList m_tasklist;//task名列表
QString m_curRootPath;//当前solution的目录路径
};
#endif // SOLUTION_H

@ -103,7 +103,7 @@ bool CDetectorSolutionMgr::Save()
if (p->GetSolutionInfo()->nType == SolutionType::LP_EXTRA)
continue;
QString strPath = strExePath + LP_DETECTOR_BUSSINESS_CONFIG_SOLUTION_DIR + QString::number(p->GetID()) + "_" + p->GetSolutionInfo()->strName;
QString strPath = strExePath + LP_DETECTOR_BUSSINESS_CONFIG_SOLUTION_DIR + p->GetSolutionName();
if (!p->SaveFileEx(strPath))
{
qWarning("save solution:%s error", p->GetSolutionInfo()->strName);

@ -165,14 +165,11 @@ void WheelCtrl::addLog(QString msg, int nType)
void WheelCtrl::saveResult(Result2Ui *m_Res)
{
qDebug() << "start thread save Result to DataBase";
Result2Ui* pRes = new Result2Ui();
*pRes = *m_Res;
//m_saveObj.onSaveResult(m_Res);
emit(operate(pRes));//启动线程保存检测结果
}
DataBaseSql *WheelCtrl::getDB() const
//QSqliteGeneral * WheelCtrl::getDB() const
{
return m_db;
}

@ -30,6 +30,7 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<TargetName>$(ProjectName)d</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
@ -61,7 +62,7 @@
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<OutputFile>$(SolutionDir)..\runner17\$(ProjectName).exe</OutputFile>
<OutputFile>$(SolutionDir)..\runner17\$(ProjectName)d.exe</OutputFile>
<AdditionalLibraryDirectories>$(QTDIR)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>qtmaind.lib;Qt5Cored.lib;Qt5Guid.lib;Qt5Widgetsd.lib;Qt5Sqld.lib;%(AdditionalDependencies)</AdditionalDependencies>

@ -226,6 +226,7 @@ Q_SLOT void QModelMgrDlg::onModifyModel()
m_pCtrl->addLog(str, emTypeUseState);
//m_modLib = true;
emit sgShowMsg(tr("修改成功!"));
}
Q_SLOT void QModelMgrDlg::onDelModel()
@ -257,6 +258,7 @@ Q_SLOT void QModelMgrDlg::onDelModel()
QString m_str = QString("%1 %2 %3").arg(tr("")).arg(strFilter.size()).arg(tr("个型号"));
ui.ModelMgr_label_Model_number->setText(m_str);
onClearShow();
emit sgDelOldModel(strModel);
}
Q_SLOT void QModelMgrDlg::onAddModel()
@ -300,6 +302,8 @@ Q_SLOT void QModelMgrDlg::onAddModel()
m_pModelLists->setModelList(strFilter);
QString m_str = QString("%1 %2 %3").arg(tr("")).arg(strFilter.size()).arg(tr("个型号"));
ui.ModelMgr_label_Model_number->setText(m_str);
emit sgAddNewModel(pModel->getModelID());
}
}

@ -47,6 +47,10 @@ signals:
void sgGenalData(QVariant nType, QVariant nData);
void sgModifyModel(QString str);
void sgUpdatedefect();
void sgAddNewModel(QString strName);//Ìí¼ÓÄ£°å
void sgDelOldModel(QString strName);//ɾ³ýÄ£°å
void sgModeModeName(QString strOld, QString strNew);//ÐÞ¸ÄÄ£°åÃû
private:
void updateWidget(QString str);
bool appImage2Widget(QString strPath, QString strModel);

@ -147,7 +147,7 @@ lpMainWin::lpMainWin(QWidget *parent)
{
m_pLbCurrentTime = new QLabel(tr("系统时间"));
m_pLbBanci = new QLabel(tr("班次信息"));
//m_pLbBanci = new QLabel(tr("班次信息"));
m_pLbDetectState = new QLabel(tr("检测状态"));
m_pLbUser = new QLabel(tr("用户:"));
@ -160,9 +160,9 @@ lpMainWin::lpMainWin(QWidget *parent)
m_pLbCurrentTime->setMinimumWidth(200);
m_pLbCurrentTime->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
m_pLbBanci->setMinimumWidth(200);
m_pLbBanci->setFont(m_font);
m_pLbBanci->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
//m_pLbBanci->setMinimumWidth(200);
//m_pLbBanci->setFont(m_font);
//m_pLbBanci->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
m_pLbDetectState->setMinimumWidth(200);
m_pLbDetectState->setFont(m_font);
@ -173,7 +173,7 @@ lpMainWin::lpMainWin(QWidget *parent)
ui.statusBar->addWidget(m_pLbDetectState, 1);
ui.statusBar->addWidget(m_pLbUser, 1);
ui.statusBar->addWidget(m_pLbBanci,1);
//ui.statusBar->addWidget(m_pLbBanci,1);
ui.statusBar->addPermanentWidget(m_pLbCurrentTime);
}
//加载用户管理模块
@ -191,6 +191,16 @@ lpMainWin::lpMainWin(QWidget *parent)
//当某个模板加入训练或者不加入训练时修改原来工作单中的模板信息
connect(m_pModelMgrDlg, SIGNAL(sgModifyModel(QString)), this, SLOT(modWorkMgr(QString)));
connect(m_pModelMgrDlg, SIGNAL(sgUpdatedefect()), this, SLOT(onUpdateDefect()));
/*
void sgAddNewModel(QString strName);//添加模板
void sgDelOldModel(QString strName);//删除模板
void sgModeModeName(QString strOld, QString strNew);//修改模板名
*/
connect(m_pModelMgrDlg, SIGNAL(sgAddNewModel(QString)), this, SLOT(onSlotAddNewModel(QString)));
connect(m_pModelMgrDlg, SIGNAL(sgDelOldModel(QString)), this, SLOT(onSlotDelOldModel(QString)));
m_pDebugDlg = new QDebugDlg();//调试界面
connect(m_pDebugDlg, SIGNAL(sgTriggerCam()), this, SLOT(onTriggerCam()));
m_pDebugDlg->onSetCtrl(m_pCtrl);
@ -219,33 +229,31 @@ lpMainWin::lpMainWin(QWidget *parent)
SendTiskTsk = new QMyThread();
TaskFunc TickFunc = std::bind(&lpMainWin::SendTickTskFun, this);
SendTiskTsk->loadfunc(TickFunc);
m_screen.ShowMsg(tr("系统初始化完成..."));
}
{
onSetModel();
/*网络通信加载*/
// m_pNet = ((WheelCtrl*)m_pCtrl)->getNet();
// connect(m_pNet, SIGNAL(sgShow2UI(QString, bool)), this, SLOT(onTcpConnet(QString, bool)));//net
// connect(m_pNet, SIGNAL(sgClientConnect(QString, bool)), this, SLOT(onClientConnect(QString, bool)));//net
// //connect(m_pNet, SIGNAL(sgRecv(const QString &)), this, SLOT(onTcpRecv(const QString &)));// net显示
// connect(m_pNet, SIGNAL(sgThickness(double)), this, SLOT(onThickness(double)));//xy height
// connect(m_pNet, SIGNAL(sgRecvDetectState(int, int)), this, SLOT(onDetectStateRecv(int, int)));//xy check
// connect(m_pNet, SIGNAL(sgClearRev(bool)), this, SLOT(onClearLibRev(bool)));//xy clearlib
// connect(m_pNet, SIGNAL(sgPulseRev()), this, SLOT(onPulseRev()));
//// connect(m_pNet, SIGNAL(sgResultRev()), this, SLOT(onResultRev()));
// connect(m_pNet, SIGNAL(sgRecvTrigPara()), this, SLOT(onRecvTrigPara()));
// connect(m_pNet, SIGNAL(sgReadDetectState(int, QString)), this, SLOT(onReadDetectState(int, QString)));
// connect(m_pNet, SIGNAL(sgReadDetectStateASK()), this, SLOT(onReadDetectStateASK()));
// connect(m_pNet, SIGNAL(sgCameraTrig(int)), this, SLOT(onTrigRecv(int)));
// connect(m_pNet, SIGNAL(sgServerState(QString, int, bool)), this, SLOT(onServerState(QString, int, bool)));
// connect(m_pNet, SIGNAL(sgShutDownComputer()), this, SLOT(onShutDownComputer()));
// connect(m_pNet, SIGNAL(sgLibRev(bool)), SendModelLibTask, SLOT(WaitSingleIn(bool)));//xy lib
//
//// connect(m_pNet, SIGNAL(sgChangeOnlineState(int)), m_pUi, SLOT(onSwitchOnlineModel(int)));//强制在线 离线
//
// QTimer::singleShot(500, m_pNet, SLOT(onOpenServer()));//延迟2s打开网络TCP服务
m_pNet = ((WheelCtrl*)m_pCtrl)->getNet();
connect(m_pNet, SIGNAL(sgShow2UI(QString, bool)), this, SLOT(onTcpConnet(QString, bool)));//net
connect(m_pNet, SIGNAL(sgClientConnect(QString, bool)), this, SLOT(onClientConnect(QString, bool)));//net
/*connect(m_pNet, SIGNAL(sgRecv(const QString &)), this, SLOT(onTcpRecv(const QString &)));*/ // net显示
connect(m_pNet, SIGNAL(sgThickness(double)), this, SLOT(onThickness(double)));//xy height
connect(m_pNet, SIGNAL(sgRecvDetectState(int, int)), this, SLOT(onDetectStateRecv(int, int)));//xy check
connect(m_pNet, SIGNAL(sgClearRev(bool)), this, SLOT(onClearLibRev(bool)));//xy clearlib
connect(m_pNet, SIGNAL(sgPulseRev()), this, SLOT(onPulseRev()));
/*connect(m_pNet, SIGNAL(sgResultRev()), this, SLOT(onResultRev()));*/
connect(m_pNet, SIGNAL(sgRecvTrigPara()), this, SLOT(onRecvTrigPara()));
connect(m_pNet, SIGNAL(sgReadDetectState(int, QString)), this, SLOT(onReadDetectState(int, QString)));
connect(m_pNet, SIGNAL(sgReadDetectStateASK()), this, SLOT(onReadDetectStateASK()));
connect(m_pNet, SIGNAL(sgCameraTrig(int)), this, SLOT(onTrigRecv(int)));
connect(m_pNet, SIGNAL(sgServerState(QString, int, bool)), this, SLOT(onServerState(QString, int, bool)));
connect(m_pNet, SIGNAL(sgShutDownComputer()), this, SLOT(onShutDownComputer()));
connect(m_pNet, SIGNAL(sgLibRev(bool)), SendModelLibTask, SLOT(WaitSingleIn(bool)));//xy lib
/*connect(m_pNet, SIGNAL(sgChangeOnlineState(int)), m_pUi, SLOT(onSwitchOnlineModel(int)));*///强制在线 离线
QTimer::singleShot(500, m_pNet, SLOT(onOpenServer()));//延迟2s打开网络TCP服务
}
{
connect(&m_PulseTimer, SIGNAL(timeout()), this, SLOT(onPulseTimer()));//心跳包
@ -365,11 +373,11 @@ lpMainWin::~lpMainWin()
delete m_pLbCurrentTime;
m_pLbCurrentTime = nullptr;
}
if (m_pLbBanci)
{
delete m_pLbBanci;
m_pLbBanci = nullptr;
}
//if (m_pLbBanci)
//{
// delete m_pLbBanci;
// m_pLbBanci = nullptr;
//}
if (m_pLbDetectState)
{
delete m_pLbDetectState;
@ -622,24 +630,49 @@ void lpMainWin::IVariantMapToUI(const QString& camKey, const QVariantMap& vMap)
QImage srcImg = vMap.value("srcImage").value<QImage>();
cv::Mat srcMat = QImageToMat(srcImg);
emit(sgShowImgState(tr("显示识别结果")));
Result2Ui *pResult = parseMap(vMap.value("result").toMap());
if (pResult == nullptr)
{
pResult = new Result2Ui();
}
/*
(1);NG退PLC
(2)
*/
if (!pResult->m_strModel.isEmpty())
{
ui.main_value_Result->setText("定位中");
QString strMode = pResult->m_strModel;
AlgResultCallBack func = std::bind(&lpMainWin::IEngineResult, this, std::placeholders::_1);
m_pEngineCtrl->detect(srcMat, strMode, func);
}
else {
/*型号识别失败,*/
// 当没抠出轮毂和NG时自动调整曝光时间重新拍照最多调整的次数为5次
ui.main_value_Result->setText("没有找到相关task");
ui.main_label_angle->setText("-");
ui.main_value_DetectTime->setText("-");
ui.main_value_Score->setText("-");
}
emit(sgShowImgState(tr("显示识别结果")));
if (pResult)
{
onShowResult(pResult);
if (m_pDebugDlg) {
m_pDebugDlg->onShowResult(pResult);
}
saveImage(pResult);
m_pCtrl->saveResult(pResult);
delete pResult;
}
/*当没抠出轮毂和NG时自动调整曝光时间重新拍照最多调整的次数为5次*/
/*
if (m_autoExposureSwitch)
{
if (vMap.contains("noCircle"))
@ -704,6 +737,7 @@ void lpMainWin::IVariantMapToUI(const QString& camKey, const QVariantMap& vMap)
}
}
}
if (vMap.contains("error"))
{
m_exposureTimeCount = 0;
@ -754,6 +788,7 @@ void lpMainWin::IVariantMapToUI(const QString& camKey, const QVariantMap& vMap)
m_pCtrl->saveResult(pResult);
delete pResult;
*/
}
/*多线程获取算法参数*/
@ -805,14 +840,47 @@ QVariant lpMainWin::IGetVariantById(int id)
void lpMainWin::IEngineResult(QVariantMap vMap)
{
QVariantMap algResult = vMap.value("AlgoResult").toMap();
QImage srcImg = vMap.value("originImage").value<QImage>();
double dAngle = algResult.contains("angle") ? algResult.value("angle").toDouble() : 365;
int errorType = algResult.contains("error") ? algResult.value("error").toInt() : 16;
double matchScore = algResult.value("score").toDouble() * 100;
QString str = algResult.value("resultTip").toString();
QString rltmsg = QString("%1 %2 %3").arg(dAngle).arg(errorType).arg(matchScore);
//不包含算法检测结果表示没有相关task
if (!vMap.contains("AlgoResult"))
{
ui.main_value_Result->setText("没有找到相关task");
ui.main_label_angle->setText("-");
ui.main_value_Center_point->setText("-");
ui.main_value_DetectTime->setText("-");
ui.main_value_Score->setText("-");
}
else {
QVariantMap algResult = vMap.value("AlgoResult").toMap();
QImage srcImg = vMap.value("originImage").value<QImage>();
double dAngle = algResult.contains("angle") ? algResult.value("angle").toDouble() : 365;
int errorType = algResult.contains("error") ? algResult.value("error").toInt() : 16;
double matchScore = algResult.value("score").toDouble() * 100;
QImage maskImg = algResult.value("image").value<QImage>();
QString str = algResult.value("resultTip").toString();
QPointF centerPoint = algResult.value("centerPoint").toPointF();
QString rltmsg = QString("%1 %2 %3").arg(dAngle).arg(errorType).arg(matchScore);
QString taskName = vMap.value("taskName").toString();
double taskTime = vMap.value("tasktime").toDouble();
ui.main_label_angle->setText(QString("%1°").arg(dAngle));
if (dAngle >= 361)
{
ui.main_value_Result->setText("找不到气门芯");
ui.main_value_Center_point->setText("-");
ui.main_value_Score->setText(QString("%1").arg(matchScore));
}
else {
ui.main_value_Result->setText("定位成功");
ui.main_value_Center_point->setText(QString("(%1,%2)").arg(centerPoint.x()).arg(centerPoint.y()));
ui.main_value_Score->setText(QString("%1").arg(matchScore));
}
ui.main_value_DetectTime->setText(QString("%1s").arg(taskTime));
if(m_ImgViewer)
m_ImgViewer->setImg(maskImg);
}
/*展示结果*/
}
Q_SLOT void lpMainWin::onLogInOut(QString strName, int level, int state)
@ -1017,8 +1085,8 @@ Q_SLOT void lpMainWin::onButtonClicked()
infobox.setWindowIcon(QIcon(":/image/leaper"));
if (QMessageBox::Cancel != infobox.exec()) {
m_pCtrl->onClear();
ui.main_lb_res_ok_num->setText(QString::number(0));
ui.main_lb_res_ng_num->setText(QString::number(0));
// ui.main_lb_res_ok_num->setText(QString::number(0));
// ui.main_lb_res_ng_num->setText(QString::number(0));
QString str = m_pCtrl->getUserName() + ":" + tr("按下了清零按钮,数据全部清零");
m_pCtrl->addLog(str, emTypeUseState);
}
@ -1074,20 +1142,14 @@ void lpMainWin::timerEvent(QTimerEvent *event)
}
}
if (m_pLbBanci) {
QString show_label;
if (m_pCtrl)
show_label = m_pCtrl->getCurrentBan();
QString strMsg = tr("班次信息:") + (show_label.isEmpty() == true ? tr("该时间段未设置班次") : show_label);
// if (strLanguage != "Chinese")
// {
// strMsg = tr("Classes:")
// + (show_label.isEmpty() == true ? tr("No set Times") : show_label);
// }
m_pLbBanci->setText(strMsg);
m_pLbBanci->setStyleSheet("font: 14px;");
}
//if (m_pLbBanci) {
// QString show_label;
// if (m_pCtrl)
// show_label = m_pCtrl->getCurrentBan();
// QString strMsg = tr("班次信息:") + (show_label.isEmpty() == true ? tr("该时间段未设置班次") : show_label);
// m_pLbBanci->setText(strMsg);
// m_pLbBanci->setStyleSheet("font: 14px;");
//}
if (m_pLbUser) {
QString show_label = m_pCtrl->getUserName();
// if (strLanguage != "Chinese")
@ -1424,6 +1486,15 @@ Q_SLOT void lpMainWin::onShowImgState(QString str)
Q_SLOT void lpMainWin::onGetImg()
{
ui.main_lb_res_model_pic->setStyleSheet(QString("QLabel{border: 1px solid rgb(0,0,0,250);background-color: rgb(200, 200, 200);}"));
ui.main_value_Result->setText("获取到图像");
ui.main_label_angle->setText("-");
ui.main_value_DetectTime->setText("-");
ui.main_lb_res_model_time->setText("-");
ui.main_lb_res_model_id->setText("-");
ui.main_lb_res_model_score->setText("-");
ui.main_value_Center_point->setText("-");
ui.main_value_Score->setText("-");
}
//展示信息
Q_SLOT void lpMainWin::onShowMsg(QString str)
@ -1439,13 +1510,15 @@ Q_SLOT void lpMainWin::onSendDisLib(int nIndex, QString strModel)
{
m_pNet->sendDisLibs(nIndex, strModel);
}
Q_SLOT void lpMainWin::onSendDisLibDone()
{
m_pNet->sendDisLibsDone();
}
Q_SLOT void lpMainWin::onShowChannel(QString str)
{
ui.main_lb_res_Channle_Show->setText(str);
//ui.main_lb_res_Channle_Show->setText(str);
}
Q_SLOT void lpMainWin::onTriggerCam()
@ -1459,8 +1532,8 @@ Q_SLOT void lpMainWin::onTriggerCam()
Q_SLOT void lpMainWin::onChangePLCParam()
{
if(m_pNet)
m_pNet->sendTrigerPara(DetectState::instance()->m_PLC_TrigerFilter, DetectState::instance()->m_PLC_CamTrigDelay, DetectState::instance()->m_PLC_CamTrigPulse, DetectState::instance()->m_PLC_LightDelay, DetectState::instance()->m_PLC_TrigerType, DetectState::instance()->m_PLC_ResHoldTime);
if (m_pNet)
m_pNet->sendTrigerPara(DetectState::instance()->m_PLC_TrigerFilter, DetectState::instance()->m_PLC_CamTrigDelay, DetectState::instance()->m_PLC_CamTrigPulse, DetectState::instance()->m_PLC_LightDelay, DetectState::instance()->m_PLC_TrigerType, DetectState::instance()->m_PLC_ResHoldTime);
}
void lpMainWin::onInitAbout()
@ -1536,7 +1609,7 @@ void lpMainWin::onShowResult(Result2Ui* pRlt)
ui.main_lb_res_model_pic->setStyleSheet(QString("QLabel{border: 5px solid rgb(250,0,0,250);background-color: rgb(200, 200, 200);}"));
pRlt->m_strModel = "NG";
ui.main_lb_res_okng->setText("NG");
ui.main_lb_res_okng->setStyleSheet("background-color: rgb(255, 0, 0);");
ui.main_lb_res_okng->setStyleSheet("font: 75 24pt \"Consolas\";background-color: rgb(255, 0, 0);");
IWheelModel *pModel = m_pCtrl->getModel("NG");
if (pModel) {
pModel->increCount();
@ -1551,7 +1624,7 @@ void lpMainWin::onShowResult(Result2Ui* pRlt)
ui.main_lb_res_model_pic->setPixmap(pix.scaled(scare - 15, scare - 15));
pModel->increCount();
ui.main_lb_res_okng->setText("OK");
ui.main_lb_res_okng->setStyleSheet("background-color: rgb(0, 255, 0);");
ui.main_lb_res_okng->setStyleSheet("font: 75 24pt \"Consolas\";background-color: rgb(0, 255, 0);");
ui.main_lb_res_model_pic->setStyleSheet(QString("QLabel{border: 5px solid rgb(0,250,0,250);background-color: rgb(200, 200, 200);}"));
emit m_pTableCheck->sgValueChange(pModel->getModelID());
}
@ -1559,17 +1632,15 @@ void lpMainWin::onShowResult(Result2Ui* pRlt)
DetectState::instance()->totalDetectNum++;
//show
ui.main_lb_res_ng_num->setText(QString::number(DetectState::instance()->totalUnDetectNum));
ui.main_lb_res_ok_num->setText(QString::number(DetectState::instance()->totalDetectNum));
ui.main_lb_res_model_time->setText(QString::number(pRlt->m_dRunTime, 'f', 2));
ui.main_lb_res_model_thickness->setText(QString::number((int)pRlt->m_dThickness));
ui.main_lb_res_model_diameter->setText(QString::number((int)pRlt->m_dDiameter));
// ui.main_lb_res_ng_num->setText(QString::number(DetectState::instance()->totalUnDetectNum));
// ui.main_lb_res_ok_num->setText(QString::number(DetectState::instance()->totalDetectNum));
ui.main_lb_res_model_time->setText(QString::number(pRlt->m_dRunTime, 'f', 2)+"s");
// ui.main_lb_res_model_thickness->setText(QString::number((int)pRlt->m_dThickness));
// ui.main_lb_res_model_diameter->setText(QString::number((int)pRlt->m_dDiameter));
ui.main_lb_res_model_id->setText(pRlt->m_strModel);
ui.main_lb_res_model_score->setText(QString::number(pRlt->m_dScore * 100, 'f', 1) + "%");
if (m_pixMapList)
{
if (m_pixMapList) {
if (pRlt->m_pixResult.isNull())
m_pixMapList->addItemByLimit(pRlt->m_pixSrc, pRlt->m_strModel);
else
@ -1822,5 +1893,39 @@ Result2Ui *lpMainWin::parseMap(const QVariantMap &vMap)
pRes->m_dThickness = vMap.value("thickness").toDouble();
pRes->m_pixSrc = QPixmap::fromImage(vMap.value("pixSrc").value<QImage>());
pRes->m_pixResult = QPixmap::fromImage(vMap.value("pixResult").value<QImage>());
pRes->m_dRunTime = vMap.value("runTime").toDouble();
return pRes;
}
}
Q_SLOT void lpMainWin::onSlotAddNewModel(QString strName)
{
if (m_pEngineCtrl)
{
IDetectorSolutionMgr* pMgr = m_pEngineCtrl->getSolutionMgr();
if (pMgr)
{
IDetectorSolution* pSolution = pMgr->GetRunSolution();
if (pSolution) {
pSolution->AddTaskByTemplate(strName);
pSolution->SaveFileEx();
}
}
}
}
Q_SLOT void lpMainWin::onSlotDelOldModel(QString strName)
{
if (m_pEngineCtrl)
{
IDetectorSolutionMgr* pMgr = m_pEngineCtrl->getSolutionMgr();
if (pMgr)
{
IDetectorSolution* pSolution = pMgr->GetRunSolution();
if (pSolution) {
pSolution->DeleteTask(strName);
pSolution->SaveFileEx();
}
}
}
}

@ -74,6 +74,8 @@ private:
Q_SLOT void onButtonClicked();
Q_SLOT void onAutoExposure();
Result2Ui *parseMap(const QVariantMap &vMap);
Q_SLOT void onSlotAddNewModel(QString strName);
Q_SLOT void onSlotDelOldModel(QString strName);
protected:
bool onInitCoreCtrl();
@ -152,7 +154,7 @@ private:
RoiImgViewer *m_ImgViewer{ nullptr };//展示检测图像
/*status 状态栏*/
class QLabel* m_pLbCurrentTime{ nullptr };//显示系统时间
class QLabel* m_pLbBanci{ nullptr };//显示班次
//class QLabel* m_pLbBanci{ nullptr };//显示班次
class QLabel* m_pLbDetectState{ nullptr };//显示检测状态
class QLabel *m_pLbUser{ nullptr };//显示登陆用户信息
private:

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1028</width>
<height>745</height>
<width>1026</width>
<height>675</height>
</rect>
</property>
<property name="windowTitle">
@ -185,6 +185,35 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>检测日志</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_7">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QTextEdit" name="textEdit">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
</widget>
</item>
</layout>
@ -288,189 +317,15 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item row="16" column="0">
<widget class="QLabel" name="label_21">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="acceptDrops">
<bool>true</bool>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="styleSheet">
<string notr="true">font: 75 12pt &quot;Consolas&quot;;</string>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="text">
<string>无匹配(个)</string>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item row="14" column="0">
<widget class="QLabel" name="label_20">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="acceptDrops">
<bool>true</bool>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet">
<string notr="true">font: 75 12pt &quot;Consolas&quot;;</string>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="text">
<string>已检测(个)</string>
</property>
<property name="textFormat">
<enum>Qt::AutoText</enum>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_6">
<property name="maximumSize">
<size>
<width>82</width>
<height>16777215</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">font: 75 12pt &quot;Consolas&quot;;</string>
</property>
<property name="text">
<string>匹配值</string>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="label_8">
<property name="minimumSize">
<size>
<width>70</width>
<height>19</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>82</width>
<height>16777215</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">font: 75 12pt &quot;Consolas&quot;;</string>
</property>
<property name="text">
<string>直径(mm)</string>
</property>
</widget>
</item>
<item row="13" column="0">
<widget class="QLabel" name="label_3">
<property name="minimumSize">
<size>
<width>82</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>82</width>
<height>16777215</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">font: 75 12pt &quot;Consolas&quot;;</string>
</property>
<property name="text">
<string>时间(s)</string>
</property>
</widget>
</item>
<item row="17" column="0">
<widget class="QLabel" name="main_lb_res_Channle">
<property name="styleSheet">
<string notr="true">font: 75 12pt &quot;Consolas&quot;;</string>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="text">
<string>通道</string>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item row="13" column="1">
<widget class="QLabel" name="main_lb_res_model_time">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">font: 75 12pt &quot;Consolas&quot;;
background-color: rgb(170, 170, 127);</string>
</property>
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="16" column="1">
<widget class="QLabel" name="main_lb_res_ng_num">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">font: 75 12pt &quot;Consolas&quot;;
background-color: rgb(170, 170, 127);</string>
</property>
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="17" column="1">
<widget class="QLabel" name="main_lb_res_Channle_Show">
<property name="styleSheet">
<string notr="true">font: 75 12pt &quot;Consolas&quot;;
background-color: rgb(170, 170, 127);</string>
<item row="12" column="1">
<widget class="QLabel" name="main_label_angle">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>---------</string>
<string>0.0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
@ -522,26 +377,6 @@ font: 75 24pt &quot;Consolas&quot;;</string>
</property>
</widget>
</item>
<item row="10" column="1">
<widget class="QLabel" name="main_lb_res_model_diameter">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(170, 170, 127);
font: 75 12pt &quot;Consolas&quot;;</string>
</property>
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="0" rowspan="5" colspan="3">
<widget class="QLabel" name="main_lb_res_model_pic">
<property name="minimumSize">
@ -554,7 +389,7 @@ font: 75 12pt &quot;Consolas&quot;;</string>
<string notr="true">background-color: rgb(200, 200, 200);</string>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
<enum>QFrame::NoFrame</enum>
</property>
<property name="text">
<string/>
@ -570,49 +405,42 @@ font: 75 12pt &quot;Consolas&quot;;</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QLabel" name="main_lb_res_model_score">
<item row="8" column="0">
<widget class="QLabel" name="label_6">
<property name="maximumSize">
<size>
<width>82</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<family>Consolas</family>
<pointsize>12</pointsize>
<weight>9</weight>
<italic>false</italic>
<bold>false</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(170, 170, 127);
font: 75 12pt &quot;Consolas&quot;;</string>
<string notr="true"/>
</property>
<property name="text">
<string>0</string>
<string>匹配值</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="14" column="1">
<widget class="QLabel" name="main_lb_res_ok_num">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item row="8" column="1">
<widget class="QLabel" name="main_lb_res_model_score">
<property name="font">
<font>
<family>Consolas</family>
<pointsize>12</pointsize>
<weight>9</weight>
<weight>50</weight>
<italic>false</italic>
<bold>false</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">font: 75 12pt &quot;Consolas&quot;;
background-color: rgb(170, 170, 127);</string>
<string notr="true"/>
</property>
<property name="text">
<string>0</string>
@ -649,17 +477,88 @@ background-color: rgb(170, 170, 127);</string>
</property>
</widget>
</item>
<item row="15" column="1">
<widget class="QLabel" name="main_value_DetectTime">
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="10" column="0" colspan="2">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="12" column="0">
<widget class="QLabel" name="label">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>角度</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="13" column="1">
<widget class="QLabel" name="main_value_Center_point">
<property name="text">
<string>(0.0)</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="13" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>圆心坐标</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="11" column="0" colspan="2">
<widget class="QLabel" name="main_value_Result">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>定位结果</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QLabel" name="main_lb_res_model_thickness">
<widget class="QLabel" name="main_lb_res_model_time">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">font: 75 12pt &quot;Consolas&quot;;
background-color: rgb(170, 170, 127);</string>
<string notr="true"/>
</property>
<property name="text">
<string>0</string>
@ -669,19 +568,62 @@ background-color: rgb(170, 170, 127);</string>
</property>
</widget>
</item>
<item row="15" column="0">
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>定位耗时</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_13">
<widget class="QLabel" name="label_3">
<property name="minimumSize">
<size>
<width>82</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>82</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">font: 75 12pt &quot;Consolas&quot;;</string>
<string notr="true"/>
</property>
<property name="text">
<string>厚度(mm)</string>
<string>识别耗时</string>
</property>
</widget>
</item>
<item row="14" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>分数</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="14" column="1">
<widget class="QLabel" name="main_value_Score">
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
@ -765,6 +707,9 @@ background-color: rgb(170, 170, 127);</string>
<pointsize>11</pointsize>
</font>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="wheel_prop_tableview_header" stdset="0">
<stringlist>
<string>modelID_detect</string>
@ -858,9 +803,9 @@ background-color: rgb(170, 170, 127);</string>
<addaction name="action_Login"/>
<addaction name="action_userManager"/>
<addaction name="action_modelmgr"/>
<addaction name="action_designer"/>
<addaction name="action_connect_mode"/>
<addaction name="action_checkdata"/>
<addaction name="action_designer"/>
<addaction name="separator"/>
</widget>
<widget class="QStatusBar" name="statusBar"/>
@ -898,7 +843,7 @@ background-color: rgb(170, 170, 127);</string>
<normaloff>:/ToolBarPic/ToolBarpic/clipboard109.png</normaloff>:/ToolBarPic/ToolBarpic/clipboard109.png</iconset>
</property>
<property name="text">
<string>模板勾选</string>
<string>检测勾选</string>
</property>
<property name="font">
<font>
@ -1038,7 +983,7 @@ background-color: rgb(170, 170, 127);</string>
<normaloff>:/ToolBarPic/ToolBarpic/app8.png</normaloff>:/ToolBarPic/ToolBarpic/app8.png</iconset>
</property>
<property name="text">
<string>设计</string>
<string>定位标定</string>
</property>
</action>
</widget>

@ -167,6 +167,11 @@ bool algEg::Exec(IDetectorTask *lpTask, IDetectorAlgorithm* lpAlgorithm)
else {
qWarning() << "valve detection: some param is missing";
}
QPointF centerPoint;
centerPoint.setX(paramInput.ptCenter.x);
centerPoint.setY(paramInput.ptCenter.y);
if (lpTask->GetSystemInfoValue("wf_batch_test").toBool()) {
int nAngle = paramOutput.dAngle;
nAngle = nAngle >= paramInput.nMaxAngle ? 0 : nAngle;
@ -196,6 +201,7 @@ bool algEg::Exec(IDetectorTask *lpTask, IDetectorAlgorithm* lpAlgorithm)
lpAlgorithm->SetOutParamValue("score", paramOutput.dScore);
lpAlgorithm->SetOutParamValue("angle", paramOutput.dAngleRes);
lpAlgorithm->SetOutParamValue("error", paramOutput.nErrorType);
lpAlgorithm->SetOutParamValue("centerPoint", centerPoint);
QString cLetter = paramOutput.strResultTip + "/" + QString::number(paramInput.dScoreThres);
lpAlgorithm->SetOutParamValue("resultTip", cLetter);

@ -1546,7 +1546,7 @@ void ValveDetector::drawResult(Mat &img, InputParam &paramIn, OutputParam &param
QString strObj = paramIn.strObj;
QString str = "type: " + (strObj.isEmpty() ? "no type" : strObj);
putText(img, str.toLatin1().data(), Point(10, 100), 3, 3, LP_COLOR_RED, 3);
putText(img, str.toLatin1().data(), Point(10, 100), 3, 2, LP_COLOR_RED, 3);
QString strAngle;
if (!paramOut.bIsFind) {
@ -1555,7 +1555,7 @@ void ValveDetector::drawResult(Mat &img, InputParam &paramIn, OutputParam &param
else {
strAngle = "result: " + QString::number(paramOut.dAngleRes, 'f', 2);
}
putText(img, strAngle.toLatin1().data(), Point(10, 200), 3, 3, LP_COLOR_RED, 3);
putText(img, strAngle.toLatin1().data(), Point(10, 200), 3, 2, LP_COLOR_RED, 3);
QString strScore;
QString strComp = ">";
@ -1564,18 +1564,18 @@ void ValveDetector::drawResult(Mat &img, InputParam &paramIn, OutputParam &param
}
strScore = "score=" + QString::number((paramOut.dScore)*100.0, 'f', 2) + "%" + strComp + QString::number(paramIn.dScoreThres, 'f', 2) + "%";
putText(img, strScore.toLatin1().data(), Point(10, 400), 3, 3, LP_COLOR_RED, 3);
putText(img, strScore.toLatin1().data(), Point(10, 400), 3, 2, LP_COLOR_RED, 3);
str = "time: " + QString::number((int)paramOut.dTime) + "ms";
putText(img, str.toLatin1().data(), Point(10, 300), 3, 3, LP_COLOR_RED, 3);
putText(img, str.toLatin1().data(), Point(10, 300), 3, 2, LP_COLOR_RED, 3);
str = "errorType: " + QString::number(paramOut.nErrorType);
putText(img, str.toLatin1().data(), Point(10, 500), 3, 3, LP_COLOR_RED, 3);
putText(img, str.toLatin1().data(), Point(10, 500), 3, 2, LP_COLOR_RED, 3);
if (paramOut.flag == 1)
{
str = "Attention: center need to be ccalibrated";
putText(img, str.toLatin1().data(), Point(10, 600), 3, 3, LP_COLOR_RED, 3);
putText(img, str.toLatin1().data(), Point(10, 600), 3, 2, LP_COLOR_RED, 3);
}
if (paramOut.nErrorType & 0x16) {
strComp = ">";
@ -1587,7 +1587,7 @@ void ValveDetector::drawResult(Mat &img, InputParam &paramIn, OutputParam &param
if (paramOut.showMatchScore >= 0)
{
str = "model judge score = " + QString::number(paramOut.showMatchScore, 'f', 4) + strComp + QString::number(paramIn.cMatchScore, 'f', 4);
putText(img, str.toLatin1().data(), Point(10, 700), 3, 3, LP_COLOR_RED, 3);
putText(img, str.toLatin1().data(), Point(10, 700), 3, 2, LP_COLOR_RED, 3);
}
if (paramOut.bIsFind) {
@ -1617,7 +1617,6 @@ void ValveDetector::drawResult(Mat &img, InputParam &paramIn, OutputParam &param
{
cv::circle(img, paramIn.originalPoint, 3, LP_COLOR_GREEN, 2);
}
//imwrite("C:\\Users\\Administrator\\Desktop\\1\\1.bmp", img);
}

Loading…
Cancel
Save