update ui

newClassify
bobpan 5 years ago
parent c6e52ce189
commit 05eab23c82

@ -1,4 +1,4 @@
#include "ModelMgrUi.h"
/*#include "ModelMgrUi.h"
#include "qlistwidget.h"
#include "ModelTableView.h"
#include "ModelManager.h"
@ -388,7 +388,7 @@ Q_SLOT void ModelMgrUi::onModifyModel()
templatepath += strModel;
templatepath += "\\model.yml";
std::string strS = templatepath.toLocal8Bit().toStdString();
pModel->getImageComModel()->save2file(strS/*string((const char *)templatepath.toLocal8Bit())*/);
pModel->getImageComModel()->save2file(strS);
m_pModelMgr->modModel(strModel);
m_pModelMgr->saveModel(strModel);
QString str = m_pCtrl->getUserName() + ":" + QString("%1:%2 %3").arg(tr("修改了模板")).arg(strModel).arg(tr("的参数"));
@ -592,9 +592,6 @@ void ModelMgrUi::updateWidget(QString str)
m_pListWgtImages->setViewMode(QListView::IconMode);
m_pListWgtImages->clear();
m_pListWgtImages->setProperty("model", str);
/*
*/
m_pListWgtImages->setIconSize(QSize(WS_PICSIZELIST_ITEM, WS_PICSIZELIST_ITEM));
m_pListWgtImages->setAcceptDrops(false);
std::vector<TempImageInfo*> imgTemplateLib = m_pModelMgr->getTmpImage(str)->getVectors();
@ -864,17 +861,17 @@ void ModelMgrUi::TrainAllTskFunc()
m_compareModel->setIsEnableCache(true);
if (m_trainAllTsk->getStopFlag())
break;
/*if (pModel->getDiameter() && pModel->getThickness())
{
m_compareModel->setRealWidth(pModel->getDiameter());
m_compareModel->setRealHeight(pModel->getThickness());
}*/
//if (pModel->getDiameter() && pModel->getThickness())
//{
// m_compareModel->setRealWidth(pModel->getDiameter());
// m_compareModel->setRealHeight(pModel->getThickness());
//}
//for (int h = 0; h < m_modelInfo.size(); h++)
//{
//const vector<Mat>& vectorMats = m_modelInfo[h].mpAllImage;
/*double md_diameter = m_modelInfo[h].md_diameter;
double md_height = m_modelInfo[h].md_height;*/
//double md_diameter = m_modelInfo[h].md_diameter;
//double md_height = m_modelInfo[h].md_height;
m_compareModel->computeDisThre(falseSamples, NULL);
//}
@ -882,13 +879,13 @@ void ModelMgrUi::TrainAllTskFunc()
break;
double m_double = m_compareModel->getDisThre();
qWarning() << m_modelName << ":" << "disthre" << m_double;
/******************************************************************/
QString templatepath = m_pCtrl->appRoot() + "\\pattern\\template\\";
templatepath += m_modelName;
templatepath += "\\model.yml";
std::string strS = templatepath.toLocal8Bit().toStdString();
m_compareModel->save2file(strS/*string((const char *)templatepath.toLocal8Bit())*/);
m_compareModel->save2file(strS);
cv::Mat dst = m_compareModel->getM8uMaskImg();
QImage img(dst.data, dst.cols, dst.rows, dst.cols, QImage::Format_Indexed8);
QPixmap pix = QPixmap::fromImage(img);
@ -988,7 +985,6 @@ void ModelMgrUi::TrainOneTskFunc()
}
if (m_trainOneTsk->getStopFlag())
return;
/*这里需要加载提示 说明模板正在训练*/
emit sgPrograssShow(tr("模板训练进度"), str, 1, emPross_SetValue);
ImageCompareModel *m_compareModel = pModel->getImageComModel();
@ -1044,7 +1040,7 @@ void ModelMgrUi::TrainOneTskFunc()
templatepath += "\\model.yml";
m_compareModel->setName(m_strTrainModel.toLatin1().data());
std::string strS = templatepath.toLocal8Bit().toStdString();
m_compareModel->save2file(strS/*string((const char *)templatepath.toLocal8Bit())*/);//////////////////////////////save params
m_compareModel->save2file(strS);//////////////////////////////save params
if (pModel->getPicPath().isEmpty())
{
QString modelName = pModel->getModelID();
@ -1071,12 +1067,10 @@ void ModelMgrUi::TrainOneTskFunc()
//for (int h = 0; h < m_modelInfo.size(); h++)
//{
//const vector<Mat>& vectorMats = m_modelInfo[h].mpAllImage;
/*double md_diameter = m_modelInfo[h].md_diameter;
double md_height = m_modelInfo[h].md_height;*/
m_compareModel->computeDisThre(falseSamples, NULL);
//}
strS = templatepath.toLocal8Bit().toStdString();
m_compareModel->save2file(strS/*string((const char *)templatepath.toLocal8Bit())*/);
m_compareModel->save2file(strS);
if (m_trainOneTsk->getStopFlag())
return;
emit sgPrograssShow(tr("模板训练进度"), str, 6, emPross_SetValue);
@ -1187,3 +1181,4 @@ bool ModelMgrUi::onMessageBox(QMessageBox::Icon ntype, QString strTitle, QString
return (infobox.exec() == QMessageBox::Ok);
}
*/

@ -1,4 +1,4 @@
#pragma once
/*#pragma once
#include "qlistwidget.h"
#include "IWheelUi.h"
#include "QObjectCleanupHandler"
@ -93,3 +93,4 @@ private:
bool m_modLib;
};
*/

@ -5,13 +5,16 @@
#include "qcoreapplication.h"
#pragma execution_character_set("utf-8")
ProgressView::ProgressView()
ProgressView::ProgressView(QWidget* parent)
{
nCancel = false;
m_pProgressDialog = new QProgressDialog;
m_pProgressDialog->setWindowFlags(Qt::Dialog);
m_pProgressDialog->setWindowFlags(Qt::WindowCloseButtonHint);
m_pProgressDialog = new QProgressDialog(parent);
connect(m_pProgressDialog, SIGNAL(canceled()), this, SIGNAL(cancel()));
m_pProgressDialog->setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
m_pProgressDialog->setWindowIcon(QIcon(":/resource/logo-8.png"));
m_pProgressDialog->setWindowModality(Qt::ApplicationModal);
m_pProgressDialog->setAttribute(Qt::WA_ShowModal, true);
}
ProgressView::ProgressView(QString strTitle, QString strLabel, int nMax, QString strIcon)
@ -20,6 +23,7 @@ ProgressView::ProgressView(QString strTitle, QString strLabel, int nMax, QString
m_pProgressDialog = new QProgressDialog;
m_pProgressDialog->setWindowFlags(Qt::Dialog);
connect(m_pProgressDialog, SIGNAL(canceled()), this, SIGNAL(cancel()));
m_pProgressDialog->hide();
show(strTitle, strLabel, nMax, strIcon);
}
@ -40,6 +44,8 @@ ProgressView::~ProgressView()
bool ProgressView::show(QString strTitle, QString strLabel, int nMax, QString strIcon)
{
m_pProgressDialog->setWindowTitle(strTitle);
m_pProgressDialog->setWindowIcon(QIcon(strIcon));
m_pProgressDialog->setLabelText(strLabel);
@ -47,7 +53,6 @@ bool ProgressView::show(QString strTitle, QString strLabel, int nMax, QString st
if (nCancel==false)
m_pProgressDialog->setCancelButton(0);
m_pProgressDialog->setCancelButtonText(tr("取消"));
m_pProgressDialog->setWindowModality(Qt::ApplicationModal);
m_pProgressDialog->show();
return true;
}
@ -70,7 +75,7 @@ bool ProgressView::finish()
// m_pProgressDialog->deleteLater();
// m_pProgressDialog = NULL;
}
qApp->processEvents();
//qApp->processEvents();
return true;
}
@ -96,6 +101,13 @@ void ProgressView::setRange(int nMax, int nMin /*= 0*/)
}
}
void ProgressView::hide()
{
if (m_pProgressDialog) {
m_pProgressDialog->hide();
}
}
QStringList FileOper::selectFiles(QString strTitle, QString strFilter, QString strDir)
{
QFileDialog fileDialog;

@ -6,7 +6,7 @@ class ProgressView:public QObject
{
Q_OBJECT
public:
ProgressView();
ProgressView(QWidget* parent);
ProgressView(QString strTitle, QString strLabel, int nMax, QString strIcon);
~ProgressView();
@ -17,6 +17,7 @@ public:
void setLabel(QString strText);
void setRange(int nMax, int nMin = 0);
void setUseCancel(bool m_cancel){ nCancel = m_cancel; };
void hide();
signals:
void cancel();
private:

@ -20,7 +20,7 @@ WheelUis::WheelUis(IWheelCtrl *pCtrl)
{
m_mpUis.insert(WHEEL_UI_DEVELOP, new DevelopUi(WHEEL_UI_DEVELOP, m_pCtrl));
m_mpUis.insert(WHEEL_UI_CHANNEL, new CHannelUI(WHEEL_UI_CHANNEL, m_pCtrl));
m_mpUis.insert(WHEEL_UI_MODELMGR, new ModelMgrUi(WHEEL_UI_MODELMGR, m_pCtrl));
// m_mpUis.insert(WHEEL_UI_MODELMGR, new ModelMgrUi(WHEEL_UI_MODELMGR, m_pCtrl));
m_mpUis.insert(WHEEL_UI_CONMODE, new ConnectModeUi(WHEEL_UI_CONMODE, m_pCtrl));
m_mpUis.insert(WHEEL_UI_MAINWINDOW, new MainUi(WHEEL_UI_MAINWINDOW, m_pCtrl));
m_mpUis.insert(WHEEL_UI_TIMEMGR, new TimeMgrUi(WHEEL_UI_TIMEMGR, m_pCtrl));

@ -17,10 +17,20 @@
#define MODEL_UI_ICON_NONE ":/image/none.jpg"
#define MODEL_UI_ICON_LEAPER ":/image/leaper"
enum EM_TYPE_PROCESSMODEL
{
emPross_Init = 0,
emPross_SetValue,
emPross_SetLable,
emPross_Finish,
emPross_enable,
emPross_Disable
};
#pragma execution_character_set("utf-8")
using namespace std;
//QTime m_ticktimer;
QTime m_ticktimer;
QModelMgrDlg::QModelMgrDlg(IWheelCtrl *ptr, QWidget *parent)
: QWidget(parent),m_pCtrl(ptr)
{
@ -34,6 +44,7 @@ QModelMgrDlg::QModelMgrDlg(IWheelCtrl *ptr, QWidget *parent)
connect(ui.m_pbAddPic, SIGNAL(clicked()), this, SLOT(onButtonClicked()));
connect(ui.m_pbDelAll, SIGNAL(clicked()), this, SLOT(onButtonClicked()));
m_pShowImgList = ui.listWidget;
m_pModelMgr = m_pCtrl->getModelMgr();
// m_pState = m_pCtrl->getDetectState();
@ -47,19 +58,20 @@ QModelMgrDlg::QModelMgrDlg(IWheelCtrl *ptr, QWidget *parent)
m_trainOneTsk->loadfunc(this, &QModelMgrDlg::TrainOneTskFunc);
m_pProgressView = new ProgressView();
Qt::WindowFlags flags = Qt::Dialog;
m_pProgressView = new ProgressView(this);
m_pProgressView->setUseCancel(true);
connect(m_pProgressView, SIGNAL(cancel()), this, SLOT(onProgassCancel()));
//m_pProgressView->finish();
connect(this, SIGNAL(sgPrograssShow(QString, QString, int, int)), this, SLOT(onPrograssShow(QString, QString, int, int)));
connect(this, SIGNAL(sgShowMsg(QString)), this, SLOT(onShowMessage(QString)));
{
m_pModelLists = new ModelsView(ui.ModelMgr_Models_tableView, m_pModelMgr->getAllModelMapPtr());
m_pModelLists->setHideItems(QStringList() << "NG");
connect(m_pModelLists, SIGNAL(sgSelectModel(QString)), this, SLOT(onShowModelInfo(QString)));
connect(m_pModelLists, SIGNAL(sgSelectModel(QString)), this, SLOT(onShowModelPic(QString)));
//connect(m_pModelLists, SIGNAL(sgSelectModel(QString)), this, SLOT(onShowModelPic(QString)));
connect(this, SIGNAL(sgTrainShowInfo(QString)), this, SLOT(onShowModelInfo(QString)));
connect(ui.ModelMgr_showPic_listWidget_tab1, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(onItemDoubleClicked(QListWidgetItem*)));
connect(m_pShowImgList, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(onItemDoubleClicked(QListWidgetItem*)));
QString strApp = QApplication::applicationDirPath();
QSettings setting(strApp + "\\user\\systemfile.ini", QSettings::IniFormat);
@ -77,6 +89,11 @@ QModelMgrDlg::QModelMgrDlg(IWheelCtrl *ptr, QWidget *parent)
QModelMgrDlg::~QModelMgrDlg()
{
for (int nIndex = (m_pShowImgList->count() - 1); nIndex >= 0; nIndex--) {
QListWidgetItem *pItem = m_pShowImgList->takeItem(nIndex);
delete pItem;
}
ui.ModelMgr_find_lineEdit->clear();
if (m_trainAllTsk) {
if (m_trainAllTsk->isRunning())
{
@ -112,7 +129,7 @@ void QModelMgrDlg::onSetCtrl(IWheelCtrl* ptr)
Q_SLOT void QModelMgrDlg::onAddPic2Model()
{
QString strModel = ui.ModelMgr_showPic_listWidget_tab1->property("model").toString();
QString strModel = m_pShowImgList->property("model").toString();
if (strModel.isEmpty()) {
onMessageBox(QMessageBox::Information, tr("提示"), tr("请选择一个您要追加图像的型号!"), 0);
return;
@ -162,7 +179,7 @@ Q_SLOT void QModelMgrDlg::onAddPic2Model()
Q_SLOT void QModelMgrDlg::onModifyModel()
{
QString strModel = ui.ModelMgr_showPic_listWidget_tab1->property("model").toString();
QString strModel = m_pShowImgList->property("model").toString();
if (strModel.isEmpty()) {
onMessageBox(QMessageBox::Information, tr("提示"), tr("请选择一个您要修改的型号!"), 0);
return;
@ -201,7 +218,7 @@ Q_SLOT void QModelMgrDlg::onModifyModel()
Q_SLOT void QModelMgrDlg::onDelModel()
{
QString strModel = ui.ModelMgr_showPic_listWidget_tab1->property("model").toString();
QString strModel = m_pShowImgList->property("model").toString();
if (strModel.isEmpty()) {
onMessageBox(QMessageBox::Information, tr("提示"), tr("请选择一个您要删除的型号"), 0);
return;
@ -274,13 +291,13 @@ Q_SLOT void QModelMgrDlg::onTrainModel()
{
if (m_trainOneTsk) {
if (!m_trainOneTsk->isRunning()) {
QString strModel = ui.ModelMgr_showPic_listWidget_tab1->property("model").toString();
QString strModel = m_pShowImgList->property("model").toString();
if (strModel.isEmpty()) {
onMessageBox(QMessageBox::Information, tr("提示"), tr("请选择一个您要训练的型号!"), 0);
return;
}
m_strTrainModel = strModel;
//m_ticktimer.start();
m_ticktimer.start();
m_trainOneTsk->InitStopFlag();
m_trainOneTsk->start();
}
@ -298,7 +315,7 @@ Q_SLOT void QModelMgrDlg::onTrainAllModels()
if (!m_trainAllTsk->isRunning()) {
if (onMessageBox(QMessageBox::Warning, tr("提示"), tr("将对所有型号模板进行重新训练,期间系统的检测功能将不能正常运行直到模板训练完成,全部重新训练模板将需要很长时间,期间将不能进行其他工作,是否继续执行?"), 1) == false)
return;
//m_ticktimer.start();
m_ticktimer.start();
m_trainAllTsk->InitStopFlag();
m_trainAllTsk->start();
}
@ -314,12 +331,12 @@ Q_SLOT void QModelMgrDlg::onItemDoubleClicked(QListWidgetItem * item)
{
QObject *obj = sender();
QString objName = obj->objectName();
if ("ModelMgr_showPic_listWidget_tab1" == objName)
//if ("ModelMgr_showPic_listWidget_tab1" == objName)
{
// if (m_pCtrl->getDetectState()->m_Debug != 100)
// if (m_pCtrl->getUserLevel() <= 0)
// return;
QString strModel = ui.ModelMgr_showPic_listWidget_tab1->property("model").toString();
QString strModel = m_pShowImgList->property("model").toString();
QString itemText = item->text();
QString strWarning = tr("确定删除该图像?");
if (onMessageBox(QMessageBox::Warning, tr("模板图片删除"), strWarning, 1) == false)
@ -329,19 +346,18 @@ Q_SLOT void QModelMgrDlg::onItemDoubleClicked(QListWidgetItem * item)
pImg->remove(itemText);
}
delete item;
QString m_str = QString("%1 %2 %3").arg(tr("")).arg(ui.ModelMgr_showPic_listWidget_tab1->count()).arg(tr("个图像"));
//if (m_pLbListWidgetNum)
ui.ModelMgr_label_Pic_Number->setText(m_str);
}
else if ("ModelMgr_listWidget_tab2" == objName)
{
int a = 0;
QString m_str = QString("%1 %2 %3").arg(tr("")).arg(m_pShowImgList->count()).arg(tr("个图像"));
ui.label_imgNum->setText(m_str);
}
// else if ("ModelMgr_listWidget_tab2" == objName)
// {
// int a = 0;
// }
}
Q_SLOT void QModelMgrDlg::onPrograssShow(QString title, QString strValue, int size, int model)
{
/* switch (model)
switch (model)
{
case emPross_Init:
{
@ -366,7 +382,7 @@ Q_SLOT void QModelMgrDlg::onPrograssShow(QString title, QString strValue, int si
break;
case emPross_Disable:
break;
}*/
}
}
Q_SLOT void QModelMgrDlg::setValue(int value)
@ -401,7 +417,7 @@ Q_SLOT void QModelMgrDlg::onDelAllModels()
Q_SLOT void QModelMgrDlg::onChangeModelName()
{
QString strModel = ui.ModelMgr_showPic_listWidget_tab1->property("model").toString();
QString strModel = m_pShowImgList->property("model").toString();
if (strModel.isEmpty())
{
onMessageBox(QMessageBox::Information, tr("提示"), tr("请选择一个您要修改的型号!"), 0);
@ -439,7 +455,7 @@ Q_SLOT void QModelMgrDlg::onProgassCancel()
m_trainOneTsk->stop();
m_trainOneTsk->quit();
}
//m_ticktimer.elapsed();
m_ticktimer.elapsed();
}
Q_SLOT void QModelMgrDlg::onTableWidget(int nIndex)
@ -476,10 +492,7 @@ Q_SLOT void QModelMgrDlg::onShowModelInfo(QString str)
double FalseMinDis = m_pModelMgr->getModel(str)->getImageComModel()->getFalseSampleMinDis();
double disMax = m_pModelMgr->getModel(str)->getImageComModel()->getDisMax();
//if (m_RepetBox)
{
ui.ModelMgr_model_Repet_spinBox->setValue(m_pModelMgr->getModel(str)->getRepeatNum());
}
if (disThred >= 1.7976931348623157e+308)
{
disThred = FalseMinDis;
@ -501,14 +514,13 @@ Q_SLOT void QModelMgrDlg::onShowModelInfo(QString str)
ui.ModelMgr_horizontalSlider->setValue(vvv);
ui.ModelMgr_Num->setText(QString::number(vvv) + "%");
updateWidget(str);
//if (m_pLbListWidgetNum)
{
int IImgNum = ui.ModelMgr_showPic_listWidget_tab1->count();
int IImgNum = m_pShowImgList->count();
QString strShow = QString("%1 %2 %3").arg(tr("")).arg(IImgNum).arg(tr("个图像"));
if (IImgNum > 0 && IImgNum < nGlobalMinImgs)
strShow += QString(",%1 %2 %3.").arg(tr("图像数量少于")).arg(nGlobalMinImgs).arg(tr("个,请及时补充训练样本"));
ui.ModelMgr_label_Pic_Number->setText(strShow);
}
ui.label_imgNum->setText(strShow);
/* if (m_WarningMsg)
{
int nTypeModel = m_pModelMgr->getModel(str)->getImageModel();
@ -570,25 +582,25 @@ void QModelMgrDlg::onClearShow()
QPixmap pix(MODEL_UI_ICON_NONE);
ui.ModelMgr_modelpic_lable->setPixmap(pix.scaled(WS_PICSIZE, WS_PICSIZE));
ui.ModelMgr_horizontalSlider->setValue(0);
ui.ModelMgr_showPic_listWidget_tab1->setProperty("model", "");
ui.ModelMgr_showPic_listWidget_tab1->clear();
m_pShowImgList->setProperty("model", "");
m_pShowImgList->clear();
}
void QModelMgrDlg::TrainAllTskFunc()
{
QStringList lstAll = m_pModelMgr->getAllModelName();
QMap<QString, vector<Mat>> mpAllImage = m_pModelMgr->getAllModelImage();
// emit sgPrograssShow(tr("模板更新进度"), tr("正在初始化所有模板 共需要训练%1个模板,请稍后.....").arg(lstAll.size()), lstAll.size(), emPross_Init);
emit sgPrograssShow(tr("模板更新进度"), tr("正在初始化所有模板 共需要训练%1个模板,请稍后.....").arg(lstAll.size()), lstAll.size(), emPross_Init);
int nIndex = 0;
for (; nIndex < lstAll.size() && (!m_trainAllTsk->getStopFlag()); nIndex++) {
// emit sgPrograssShow(tr("模板更新进度"), "", nIndex, emPross_SetValue);
emit sgPrograssShow(tr("模板更新进度"), "", nIndex, emPross_SetValue);
QString m_modelName = lstAll.at(nIndex);
TempImage *pImg = m_pModelMgr->getTmpImage(m_modelName);
if (!pImg) {
continue;
}
QString str = tr("正在训练%1的模板 已完成%2/%3,请稍后.....").arg(m_modelName).arg(nIndex + 1).arg(m_pModelMgr->getAllModelName().size());
// emit sgPrograssShow(tr("模板更新进度"), str, lstAll.size(), emPross_SetLable);
emit sgPrograssShow(tr("模板更新进度"), str, lstAll.size(), emPross_SetLable);
IWheelModel *pModel = m_pModelMgr->getModel(m_modelName);
std::vector<cv::Mat> mMat = pImg->getImgVector();
ImageCompareModel *m_compareModel = pModel->getImageComModel();
@ -644,7 +656,7 @@ void QModelMgrDlg::TrainAllTskFunc()
m_pModelMgr->modModel(m_modelName);
}
str = tr("%1的模板获取特征 已完成%2/%3,请稍后.....").arg(m_modelName).arg(nIndex + 1).arg(m_pModelMgr->getAllModelName().size());
// emit sgPrograssShow(tr("模板更新进度"), str, lstAll.size(), emPross_SetLable);
emit sgPrograssShow(tr("模板更新进度"), str, lstAll.size(), emPross_SetLable);
m_compareModel->setIsEnableCache(true);
if (m_trainAllTsk->getStopFlag())
@ -681,12 +693,12 @@ void QModelMgrDlg::TrainAllTskFunc()
emit sgTrainShowInfo(m_modelName);
str = tr("%1的模板训练完成 已完成%2/%3,请稍后.....").arg(m_modelName).arg(nIndex + 1).arg(m_pModelMgr->getAllModelName().size());
// emit sgPrograssShow(tr("模板更新进度"), "", nIndex, emPross_SetValue);
emit sgPrograssShow(tr("模板更新进度"), "", nIndex, emPross_SetValue);
}
if (!m_trainAllTsk->getStopFlag())
{
// emit sgPrograssShow(tr("模板更新进度"), "", nIndex, emPross_Finish);
// emit sgPrograssShow(tr("模板更新进度"), tr("全部模板更新完成!%1s").arg(m_ticktimer.elapsed() / 1000.0), nIndex, emPross_enable);
emit sgPrograssShow(tr("模板更新进度"), "", nIndex, emPross_Finish);
emit sgPrograssShow(tr("模板更新进度"), tr("全部模板更新完成!%1s").arg(m_ticktimer.elapsed() / 1000.0), nIndex, emPross_enable);
QString str = m_pCtrl->getUserName() + ":" + tr("对全部模板进行了重新训练,共%1个模板").arg(lstAll.size());
m_pCtrl->addLog(str, emTypeUseState);
}
@ -698,28 +710,28 @@ void QModelMgrDlg::TrainOneTskFunc()
return;
int m_step = 5;
QString str = tr("模板正在准备请稍后.....");
// emit sgPrograssShow(tr("模板训练进度"), str, m_step, emPross_Init);
emit sgPrograssShow(tr("模板训练进度"), str, m_step, emPross_Init);
IWheelModel*pModel = m_pModelMgr->getModel(m_strTrainModel);
if (!pModel) {
return;
}
// emit sgPrograssShow(tr("模板训练进度"), str, 0, emPross_SetValue);
emit sgPrograssShow(tr("模板训练进度"), str, 0, emPross_SetValue);
if (m_trainOneTsk->getStopFlag())
return;
TempImage *pTempImg = pModel->getTempImage();
std::vector<Mat> m_MatVec = pTempImg->getImgVector();
if (m_MatVec.size() <= 0)
{
// emit sgPrograssShow(tr("模板训练进度"), tr("%1型号没有图片不能训练").arg(m_strTrainModel), 6, emPross_enable);
// emit sgPrograssShow(tr("模板训练进度"), tr("%1型号没有图片不能训练").arg(m_strTrainModel), 6, emPross_Finish);
emit sgPrograssShow(tr("模板训练进度"), tr("%1型号没有图片不能训练").arg(m_strTrainModel), 6, emPross_enable);
emit sgPrograssShow(tr("模板训练进度"), tr("%1型号没有图片不能训练").arg(m_strTrainModel), 6, emPross_Finish);
return;
}
if (m_trainOneTsk->getStopFlag())
return;
/*这里需要加载提示 说明模板正在训练*/
// emit sgPrograssShow(tr("模板训练进度"), str, 1, emPross_SetValue);
emit sgPrograssShow(tr("模板训练进度"), str, 1, emPross_SetValue);
ImageCompareModel *m_compareModel = pModel->getImageComModel();
//std::vector<cv::Mat> firstFalseSample = m_pModelMgr->getFirstImgFromFalse(pModel->getModelID());
@ -766,7 +778,7 @@ void QModelMgrDlg::TrainOneTskFunc()
m_compareModel->calculateAllParams(m_MatVec);
if (m_trainOneTsk->getStopFlag())
return;
// emit sgPrograssShow(tr("模板训练进度"), str, 2, emPross_SetValue);
emit sgPrograssShow(tr("模板训练进度"), str, 2, emPross_SetValue);
hubBase::mkdir(m_pCtrl->appRoot() + "\\pattern");
QString templatepath = m_pCtrl->appRoot() + "\\pattern\\template\\";
hubBase::mkdir(templatepath);
@ -788,9 +800,9 @@ void QModelMgrDlg::TrainOneTskFunc()
}
if (m_trainOneTsk->getStopFlag())
return;
// emit sgPrograssShow(tr("模板训练进度"), str, 3, emPross_SetValue);
// emit sgPrograssShow(tr("模板训练进度"), str, 4, emPross_SetValue);
// emit sgPrograssShow(tr("模板训练进度"), tr("%1的模板 正在获取特征值,请稍后....").arg(m_strTrainModel), 4, emPross_SetLable);
emit sgPrograssShow(tr("模板训练进度"), str, 3, emPross_SetValue);
emit sgPrograssShow(tr("模板训练进度"), str, 4, emPross_SetValue);
emit sgPrograssShow(tr("模板训练进度"), tr("%1的模板 正在获取特征值,请稍后....").arg(m_strTrainModel), 4, emPross_SetLable);
m_compareModel->setIsEnableCache(false);
//if (pModel->getDiameter() && pModel->getThickness())
@ -809,9 +821,9 @@ void QModelMgrDlg::TrainOneTskFunc()
m_compareModel->save2file(strS/*string((const char *)templatepath.toLocal8Bit())*/);
if (m_trainOneTsk->getStopFlag())
return;
// emit sgPrograssShow(tr("模板训练进度"), str, 6, emPross_SetValue);
// emit sgPrograssShow(tr("模板训练进度"), str, 6, emPross_Finish);
// emit sgPrograssShow(tr("模板训练进度"), tr("训练完成!%1s").arg(m_ticktimer.elapsed() / 1000.0), 6, emPross_enable);
emit sgPrograssShow(tr("模板训练进度"), str, 6, emPross_SetValue);
emit sgPrograssShow(tr("模板训练进度"), str, 6, emPross_Finish);
emit sgPrograssShow(tr("模板训练进度"), tr("训练完成!%1s").arg(m_ticktimer.elapsed() / 1000.0), 6, emPross_enable);
emit sgTrainShowInfo(m_strTrainModel);
str = m_pCtrl->getUserName() + ":" + tr("训练了模板:%1").arg(m_strTrainModel);
m_pCtrl->addLog(str, emTypeUseState);
@ -821,18 +833,18 @@ void QModelMgrDlg::TrainOneTskFunc()
void QModelMgrDlg::updateWidget(QString str)
{
// update images
for (int nIndex = (ui.ModelMgr_showPic_listWidget_tab1->count() - 1); nIndex >= 0; nIndex--) {
QListWidgetItem *pItem = ui.ModelMgr_showPic_listWidget_tab1->takeItem(nIndex);
for (int nIndex = (m_pShowImgList->count() - 1); nIndex >= 0; nIndex--) {
QListWidgetItem *pItem = m_pShowImgList->takeItem(nIndex);
delete pItem;
}
ui.ModelMgr_showPic_listWidget_tab1->setViewMode(QListView::IconMode);
ui.ModelMgr_showPic_listWidget_tab1->clear();
ui.ModelMgr_showPic_listWidget_tab1->setProperty("model", str);
m_pShowImgList->setViewMode(QListView::IconMode);
m_pShowImgList->clear();
m_pShowImgList->setProperty("model", str);
/*
*/
ui.ModelMgr_showPic_listWidget_tab1->setIconSize(QSize(WS_PICSIZELIST_ITEM, WS_PICSIZELIST_ITEM));
ui.ModelMgr_showPic_listWidget_tab1->setAcceptDrops(false);
m_pShowImgList->setIconSize(QSize(WS_PICSIZELIST_ITEM, WS_PICSIZELIST_ITEM));
m_pShowImgList->setAcceptDrops(false);
std::vector<TempImageInfo*> imgTemplateLib = m_pModelMgr->getTmpImage(str)->getVectors();
for (int j = 0; j < imgTemplateLib.size(); j++)
{
@ -842,17 +854,15 @@ void QModelMgrDlg::updateWidget(QString str)
QImage img(dst.data, dst.cols, dst.rows, QImage::Format_Indexed8);
QPixmap pix = QPixmap::fromImage(img);
QIcon icon(pix.scaled(QSize(WS_PICSIZELIST_ITEM, WS_PICSIZELIST_ITEM)));
QListWidgetItem* pItem = new QListWidgetItem(icon, imgTemplateLib.at(j)->m_strFileName);
ui.ModelMgr_showPic_listWidget_tab1->addItem(pItem);
QListWidgetItem* pItem = new QListWidgetItem(icon, imgTemplateLib.at(j)->m_strFileName, m_pShowImgList);
m_pShowImgList->addItem(pItem);
}
}
bool QModelMgrDlg::appImage2Widget(QString strPath, QString strModel)
{
//抠图+
//cv::Mat dst = ModelTrain::findCircleObject(strPath);
cv::Mat dst = imread(string((const char *)strPath.toLocal8Bit()), 0);
//cv::Mat dst = imread(strPath.toLatin1().data(), 0);
if (dst.empty()) {
return false;
}
@ -868,13 +878,12 @@ bool QModelMgrDlg::appImage2Widget(QString strPath, QString strModel)
QFileInfo fi;
fi = QFileInfo(strPath);
QListWidgetItem *pItem = new QListWidgetItem(icon, strFileName);
// if (m_pListWgtImages != NULL)
{
ui.ModelMgr_showPic_listWidget_tab1->insertItem(ui.ModelMgr_showPic_listWidget_tab1->count(), pItem);
ui.ModelMgr_showPic_listWidget_tab1->setViewMode(QListView::IconMode);
ui.ModelMgr_showPic_listWidget_tab1->setIconSize(QSize(WS_PICSIZELIST_ITEM, WS_PICSIZELIST_ITEM));
ui.ModelMgr_showPic_listWidget_tab1->setAcceptDrops(false);
}
m_pShowImgList->insertItem(m_pShowImgList->count(), pItem);
m_pShowImgList->setViewMode(QListView::IconMode);
m_pShowImgList->setIconSize(QSize(WS_PICSIZELIST_ITEM, WS_PICSIZELIST_ITEM));
m_pShowImgList->setAcceptDrops(false);
//add 2 lib
IWheelModel *pModel = m_pModelMgr->getModel(strModel);
QString strPath2 = m_pCtrl->appRoot() + "\\pattern\\template\\";
@ -885,9 +894,8 @@ bool QModelMgrDlg::appImage2Widget(QString strPath, QString strModel)
cv::imwrite(string((const char *)strPath2.toLocal8Bit()), dst);
//cv::imwrite(strPath2.toLatin1().data(), dst);
pModel->getTempImage()->add(dst, strFileName, strPath2);
QString m_str = QString("%1 %2 %3").arg(tr("")).arg(ui.ModelMgr_showPic_listWidget_tab1->count()).arg(tr("个图像"));
//if (m_pLbListWidgetNum)
ui.ModelMgr_label_Pic_Number->setText(m_str);
QString m_str = QString("%1 %2 %3").arg(tr("")).arg(m_pShowImgList->count()).arg(tr("个图像"));
ui.label_imgNum->setText(m_str);
return true;
}

@ -64,6 +64,7 @@ private:
class QMyThread *m_trainOneTsk{ nullptr };
class ModelManager *m_pModelMgr{ nullptr };
class ModelsView *m_pModelLists{ nullptr };
QListWidget *m_pShowImgList{ nullptr };
int nGlobalMinImgs{5};
QString m_strTrainModel;

@ -444,25 +444,17 @@
<string>图片显示:</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QListWidget" name="ModelMgr_showPic_listWidget_tab1">
<property name="font">
<font>
<family>Arial</family>
</font>
</property>
<property name="acceptDrops">
<bool>true</bool>
</property>
<property name="dragEnabled">
<bool>false</bool>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::DragDrop</enum>
<item row="1" column="0">
<widget class="QLabel" name="label_imgNum">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="0" column="1">
<item row="0" column="0">
<widget class="QListWidget" name="listWidget"/>
</item>
<item row="0" column="1" rowspan="2">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QPushButton" name="m_pbAddPic">
@ -529,25 +521,6 @@
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="ModelMgr_label_Pic_Number">
<property name="font">
<font>
<family>Consolas</family>
<pointsize>11</pointsize>
<weight>50</weight>
<italic>false</italic>
<bold>false</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>

@ -116,9 +116,6 @@
<ClCompile Include="GeneratedFiles\Debug\moc_modelmgrdb.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="GeneratedFiles\Debug\moc_ModelMgrUi.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="GeneratedFiles\Debug\moc_ModelTableView.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
@ -281,9 +278,6 @@
<ClCompile Include="GeneratedFiles\Release\moc_modelmgrdb.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="GeneratedFiles\Release\moc_ModelMgrUi.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="GeneratedFiles\Release\moc_ModelTableView.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
</ClCompile>
@ -896,14 +890,18 @@
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DWIN64 -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DTPMAIN_LIB -DTPMAIN_EXPORTS -DQT_GUI_LIB -DQT_WIDGETS_LIB -DQT_SQL_LIB -DQT_PRINTSUPPORT_LIB -DQT_NETWORK_LIB -DQT_SERIALPORT_LIB -D%(PreprocessorDefinitions) "-I." "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\ActiveQt" "-I$(QTDIR)\include\QtSerialPort" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtPrintSupport" "-I$(QTDIR)\include\QtSql" "-I$(QTDIR)\include\QtNetwork" "-I.\..\..\..\spider\libZK" "-I.\..\..\..\tadpole\include" "-I.\..\..\..\tadpole\src\SubFilters" "-I.\..\..\..\tadpole\src\SubFilters\tpSubFilterDemo" "-I.\..\..\..\tadpole\src\tpGui" "-I.\..\..\..\tadpole\src\tpBase" "-I.\..\..\..\tadpole\src\lpbengine" "-I.\..\..\..\tadpole\src\tpNet" "-I.\..\..\..\tadpole\src\lpdesigner" "-I.\..\..\..\tadpole\src\tpMain" "-I.\..\..\..\tadpole\src\tpSubFilter" "-I.\..\..\..\tadpole\src\libzkq" "-I.\..\..\..\tadpole\src\tpAssister" "-I.\..\..\include\tpMain" "-I.\..\..\include\tpMain\SubFilters" "-I.\..\include" "-I.\..\..\..\lpOpenCV\opencv2.4.9\build\include" "-I.\..\..\..\lpOpenCV\opencv2.4.9\build\include\opencv2" "-I.\..\..\..\lpOpenCV\opencv2.4.9\build\include\opencv" "-I.\..\..\..\Cyclops\include" "-I.\..\..\src\algorithm" "-I.\..\..\include" "-I.\..\..\.\src\tpMain" "-I.\..\..\.\src\tpMain\thread" "-I.\..\..\.\src\tpMain\splashScreen" "-I.\..\..\.\src\tpMain\LightBoxwidget" "-I.\..\..\.\src\tpMain\QDiskCleanThread" "-I.\..\..\.\src\tpMain\QPixmapListBar" "-I.\..\..\.\src\userCtrl" "-I.\..\..\.\src\NetWheel" "-I.\..\..\.\src\RasterSDG20" "-I.\..\..\.\src\ReportModel"</Command>
</CustomBuild>
<CustomBuild Include="..\..\src\tpMain\ModelMgrUi.h">
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Moc%27ing ModelMgrUi.h...</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DWIN64 -DQT_CORE_LIB -DTPMAIN_LIB -DTPMAIN_EXPORTS -DQT_GUI_LIB -DQT_WIDGETS_LIB -DQT_SQL_LIB -DQT_PRINTSUPPORT_LIB -DQT_NETWORK_LIB -DQT_SERIALPORT_LIB -D_WINDOWS -D%(PreprocessorDefinitions) "-I." "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\ActiveQt" "-I$(QTDIR)\include\QtSerialPort" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtPrintSupport" "-I$(QTDIR)\include\QtSql" "-I$(QTDIR)\include\QtNetwork" "-I.\..\..\src\algorithm" "-I.\..\..\src\tpMain" "-I.\..\..\src\tpMain\thread" "-I.\..\..\src\tpMain\splashScreen" "-I.\..\..\src\tpMain\LightBoxwidget" "-I.\..\..\src\tpMain\QDiskCleanThread" "-I.\..\..\src\tpMain\QPixmapListBar" "-I.\..\..\src\userCtrl" "-I.\..\..\src\NetWheel" "-I.\..\..\src\RasterSDG20" "-I.\..\..\src\ReportModel" "-I.\..\..\3part\libzkq\include" "-I.\..\..\3part\tadpole\include\tpBase" "-I.\..\..\3part\opencv3.4.1\include" "-I.\..\..\3part\opencv3.4.1\include\opencv" "-I.\..\..\3part\opencv3.4.1\include\opencv2" "-I.\..\..\3part\Cyclops\include" "-I.\..\..\3part\lpCoreCtrl\include" "-I.\..\..\src\tpMain\algela"</Command>
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Moc%27ing ModelMgrUi.h...</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DWIN64 -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DTPMAIN_LIB -DTPMAIN_EXPORTS -DQT_GUI_LIB -DQT_WIDGETS_LIB -DQT_SQL_LIB -DQT_PRINTSUPPORT_LIB -DQT_NETWORK_LIB -DQT_SERIALPORT_LIB -D%(PreprocessorDefinitions) "-I." "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\ActiveQt" "-I$(QTDIR)\include\QtSerialPort" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtPrintSupport" "-I$(QTDIR)\include\QtSql" "-I$(QTDIR)\include\QtNetwork" "-I.\..\..\..\spider\libZK" "-I.\..\..\..\tadpole\include" "-I.\..\..\..\tadpole\src\SubFilters" "-I.\..\..\..\tadpole\src\SubFilters\tpSubFilterDemo" "-I.\..\..\..\tadpole\src\tpGui" "-I.\..\..\..\tadpole\src\tpBase" "-I.\..\..\..\tadpole\src\lpbengine" "-I.\..\..\..\tadpole\src\tpNet" "-I.\..\..\..\tadpole\src\lpdesigner" "-I.\..\..\..\tadpole\src\tpMain" "-I.\..\..\..\tadpole\src\tpSubFilter" "-I.\..\..\..\tadpole\src\libzkq" "-I.\..\..\..\tadpole\src\tpAssister" "-I.\..\..\include\tpMain" "-I.\..\..\include\tpMain\SubFilters" "-I.\..\include" "-I.\..\..\..\lpOpenCV\opencv2.4.9\build\include" "-I.\..\..\..\lpOpenCV\opencv2.4.9\build\include\opencv2" "-I.\..\..\..\lpOpenCV\opencv2.4.9\build\include\opencv" "-I.\..\..\..\Cyclops\include" "-I.\..\..\src\algorithm" "-I.\..\..\include" "-I.\..\..\.\src\tpMain" "-I.\..\..\.\src\tpMain\thread" "-I.\..\..\.\src\tpMain\splashScreen" "-I.\..\..\.\src\tpMain\LightBoxwidget" "-I.\..\..\.\src\tpMain\QDiskCleanThread" "-I.\..\..\.\src\tpMain\QPixmapListBar" "-I.\..\..\.\src\userCtrl" "-I.\..\..\.\src\NetWheel" "-I.\..\..\.\src\RasterSDG20" "-I.\..\..\.\src\ReportModel"</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
</Command>
</CustomBuild>
<ClInclude Include="..\..\src\tpMain\ModelResult.h" />
<ClInclude Include="..\..\src\tpMain\modelsdb.h" />

Loading…
Cancel
Save