|
|
|
|
@ -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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|