diff --git a/3part/tadpole/include/tpBase/lpbengine.h b/3part/tadpole/include/tpBase/lpbengine.h
index fff372c..eb4ea8e 100644
Binary files a/3part/tadpole/include/tpBase/lpbengine.h and b/3part/tadpole/include/tpBase/lpbengine.h differ
diff --git a/src/lpbdesigner/AlgoDlg.ui b/src/lpbdesigner/AlgoDlg.ui
index 1886976..63ab1fb 100644
--- a/src/lpbdesigner/AlgoDlg.ui
+++ b/src/lpbdesigner/AlgoDlg.ui
@@ -9,13 +9,13 @@
0
0
- 274
- 194
+ 372
+ 160
- 10
+ 12
@@ -29,7 +29,7 @@
- -
+
-
-
@@ -39,10 +39,10 @@
- -
+
-
- -
+
-
请选择
@@ -56,10 +56,10 @@
- -
+
-
- -
+
-
请选择
@@ -73,22 +73,64 @@
- -
+
-
- -
-
-
- 确定
-
-
-
- -
-
-
- 取消
-
-
+
-
+
+
-
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ 确定
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ 取消
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
diff --git a/src/lpbdesigner/AlgorithmParamMgrDlg.ui b/src/lpbdesigner/AlgorithmParamMgrDlg.ui
index 1eb8f83..277eb53 100644
--- a/src/lpbdesigner/AlgorithmParamMgrDlg.ui
+++ b/src/lpbdesigner/AlgorithmParamMgrDlg.ui
@@ -13,6 +13,11 @@
388
+
+
+ 12
+
+
算法设置
@@ -33,7 +38,7 @@
- 10
+ 12
@@ -71,11 +76,24 @@
1
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
-
- 10
+ 12
@@ -87,7 +105,7 @@
- 10
+ 12
@@ -99,7 +117,7 @@
- 10
+ 12
@@ -111,7 +129,7 @@
- 10
+ 12
@@ -123,7 +141,7 @@
- 10
+ 12
@@ -135,7 +153,7 @@
- 10
+ 12
diff --git a/src/lpbdesigner/DsgAlgorithmParamMgr.cpp b/src/lpbdesigner/DsgAlgorithmParamMgr.cpp
index b0440a7..570af10 100644
--- a/src/lpbdesigner/DsgAlgorithmParamMgr.cpp
+++ b/src/lpbdesigner/DsgAlgorithmParamMgr.cpp
@@ -24,11 +24,6 @@ CDsgAlgorithmParamMgrDlg::CDsgAlgorithmParamMgrDlg(QWidget *parent) : QDialog(pa
ui->tableWidget->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->tableWidget, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(OnPopMenu(const QPoint&)));
connect(ui->tableWidget, SIGNAL(cellDoubleClicked(int, int)), this, SLOT(OnEditParam()));
-// Qt::WindowFlags flags = Qt::Dialog;
-// flags |= Qt::WindowMinMaxButtonsHint;
-// flags |= Qt::WindowCloseButtonHint;
-// setWindowFlags(flags);
- //m_tParamDlg.setParent(this);
}
CDsgAlgorithmParamMgrDlg::~CDsgAlgorithmParamMgrDlg()
@@ -221,13 +216,15 @@ bool CDsgAlgorithmParamMgrDlg::OnAddParam()
{
if (!m_tParamDlg.InitGraphView())
return false;
-
+ m_tParamDlg.setParent(this);
+ m_tParamDlg.setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
+ m_tParamDlg.setWindowIcon(QIcon(":/image/leaper"));
+ m_tParamDlg.setWindowModality(Qt::ApplicationModal);
+ m_tParamDlg.setAttribute(Qt::WA_ShowModal, true);
PLP_ALGORITHM_PARAM pParam = m_tParamDlg.ShowParamDlg(NULL);
-
if (pParam)
{
int nRowCount = ui->tableWidget->rowCount();
-
ui->tableWidget->setRowCount(nRowCount + 1);
ui->tableWidget->setItem(nRowCount, 0, new QTableWidgetItem(QString::number(pParam->nID)));
ui->tableWidget->setItem(nRowCount, 1, new QTableWidgetItem(pParam->strName));
@@ -235,7 +232,6 @@ bool CDsgAlgorithmParamMgrDlg::OnAddParam()
ui->tableWidget->setItem(nRowCount, 3, new QTableWidgetItem(showVariant(pParam->type, pParam->value)));
QString str = QString("%1").arg(pParam->strDescription);
ui->tableWidget->setItem(nRowCount, 4, new QTableWidgetItem(str));
-
return true;
}
@@ -251,7 +247,6 @@ bool CDsgAlgorithmParamMgrDlg::OnDeleteParam()
QTableWidgetItem*item = items.at(0);
if (item)
{
-
QMessageBox msgBox(QMessageBox::Warning, QObject::tr("提示"), QObject::tr("确认删除?"), 0, this);
msgBox.addButton(QObject::tr("是"), QMessageBox::AcceptRole);
msgBox.addButton(QObject::tr("否"), QMessageBox::RejectRole);
@@ -266,15 +261,8 @@ bool CDsgAlgorithmParamMgrDlg::OnDeleteParam()
ui->tableWidget->removeRow(nRowIndex);
return true;
}
- else
- {
- }
-
-
}
-
}
-
return false;
}
@@ -287,27 +275,25 @@ bool CDsgAlgorithmParamMgrDlg::OnEditParam()
if (items.size() <= 0)
return false;
QTableWidgetItem*item = items.at(1);
- if (item)
- {
+ if (item) {
QString strParaName = item->text();
- //int nCurrentID = item->text().toInt();
AlgoParamType type;
PLP_ALGORITHM_PARAM pParam = NULL;
- if (m_type == PARAM_IN)
- {
+ if (m_type == PARAM_IN) {
pParam = m_pAlgo->GetParamByName(strParaName);
- //pParam = m_pAlgo->GetParam(nCurrentID);
}
- else if (m_type == PARAM_OUT)
- {
+ else if (m_type == PARAM_OUT) {
pParam = m_pAlgo->GetOutParamByName(strParaName);
- //pParam = m_pAlgo->GetOutParam(nCurrentID);
}
- if (pParam)
- {
+ if (pParam) {
if (!m_tParamDlg.InitGraphView())
return false;
+ m_tParamDlg.setParent(this);
+ m_tParamDlg.setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
+ m_tParamDlg.setWindowIcon(QIcon(":/image/leaper"));
+ m_tParamDlg.setWindowModality(Qt::ApplicationModal);
+ m_tParamDlg.setAttribute(Qt::WA_ShowModal, true);
m_tParamDlg.ShowParamDlg(pParam);
items.at(1)->setText(pParam->strName);
items.at(2)->setText(GetParamTypeStr(pParam->type));
@@ -318,40 +304,19 @@ bool CDsgAlgorithmParamMgrDlg::OnEditParam()
return true;
}
}
-
}
return false;
}
-
bool CDsgAlgorithmParamMgrDlg::OnPopMenu(const QPoint&)
{
QMenu menu;
QAction *insertParamAction = menu.addAction(QObject::tr("编辑参数"));
-
-
QAction *selectedAction = menu.exec(QCursor::pos());
if (selectedAction == insertParamAction)
{
OnEditParam();
- /*if (!m_tParamDlg.InitGraphView())
- return false;
-
- PLP_ALGORITHM_PARAM pParam = m_tParamDlg.ShowParamDlg(NULL);
- if (pParam)
- {
- int nRowIndex = ui->tableWidget->currentRow();
- if (m_pAlgo->InsertParamOrder(pParam->nID, ui->tableWidget->currentRow()))
- {
-
- }
-
- InitGraphView();
- ui->tableWidget->setCurrentItem(ui->tableWidget->item(nRowIndex, 0));
- }*/
-
}
-
menu.clear();
return true;
}
@@ -391,9 +356,7 @@ bool CDsgAlgorithmParamMgrDlg::OnUpMove()
m_pAlgo->SwapParamOrder(nCurrentID, nSwapID);
SystemStateInfo::bParamStateFlag = true;
return true;
-
}
-
}
}
return false;
@@ -435,12 +398,9 @@ bool CDsgAlgorithmParamMgrDlg::OnDownMove()
m_pAlgo->SwapParamOrder(nCurrentID, nSwapID);
SystemStateInfo::bParamStateFlag = true;
return true;
-
}
-
}
}
-
return false;
}
@@ -467,67 +427,4 @@ QString CDsgAlgorithmParamMgrDlg::GetParamTypeStr(AlgoParamType type)
{
QString strType;
return AlgoParamName[type];
-
- switch (type)
- {
- case LP_INT:
- {
- strType = "INT";
- break;
- }
- case LP_BOOLEAN:
- {
- strType = "BOOLEAN";
- break;
- }
- case LP_STRING:
- {
- strType = "STRING";
- break;
- }
- case LP_DOUBLE:
- {
- strType = "DOUBLE";
- break;
- }
- case LP_IMAGE:
- {
- strType = "IMAGE";
- break;
- }
- case LP_POINT:
- {
- strType = "POINT";
- break;
- }
- case LP_POINTF:
- {
- strType = "POINTF";
- break;
- }
- case LP_RECT:
- {
- strType = "RECT";
- break;
- }
- case LP_RECTF:
- {
- strType = "RECTF";
- break;
- }
- case LP_ROI:
- {
- strType = "ROI";
- break;
- }
- case LP_MAT:
- {
- strType = "MAT";
- break;
- }
- default:
- break;
- }
-
- return strType;
-}
\ No newline at end of file
+}
diff --git a/src/lpbdesigner/GeneratedFiles/ui_ParamDlg.h b/src/lpbdesigner/GeneratedFiles/ui_ParamDlg.h
deleted file mode 100644
index 02d4f85..0000000
--- a/src/lpbdesigner/GeneratedFiles/ui_ParamDlg.h
+++ /dev/null
@@ -1,246 +0,0 @@
-/********************************************************************************
-** Form generated from reading UI file 'ParamDlg.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_PARAMDLG_H
-#define UI_PARAMDLG_H
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-QT_BEGIN_NAMESPACE
-
-class Ui_ParamDlg
-{
-public:
- QGridLayout *gridLayout_2;
- QGridLayout *gridLayout;
- QLabel *label_6;
- QLineEdit *lineEdit_2;
- QComboBox *comboBox_2;
- QLabel *label_5;
- QComboBox *comboBox_3;
- QLabel *label_4;
- QLineEdit *lineEdit_3;
- QLabel *label_2;
- QComboBox *comboBox;
- QLabel *label_3;
- QLineEdit *lineEdit;
- QLabel *label;
- QCheckBox *checkBox;
- QCheckBox *checkBox_2;
- QPushButton *m_pbROISet;
- QHBoxLayout *horizontalLayout;
- QSpacerItem *horizontalSpacer;
- QPushButton *pushButton;
- QPushButton *pushButton_2;
- QSpacerItem *verticalSpacer;
-
- void setupUi(QDialog *ParamDlg)
- {
- if (ParamDlg->objectName().isEmpty())
- ParamDlg->setObjectName(QStringLiteral("ParamDlg"));
- ParamDlg->setWindowModality(Qt::ApplicationModal);
- ParamDlg->resize(279, 304);
- QFont font;
- font.setFamily(QStringLiteral("Arial"));
- font.setPointSize(10);
- font.setBold(false);
- font.setWeight(50);
- ParamDlg->setFont(font);
- gridLayout_2 = new QGridLayout(ParamDlg);
- gridLayout_2->setObjectName(QStringLiteral("gridLayout_2"));
- gridLayout_2->setContentsMargins(9, 9, 9, 9);
- gridLayout = new QGridLayout();
- gridLayout->setObjectName(QStringLiteral("gridLayout"));
- label_6 = new QLabel(ParamDlg);
- label_6->setObjectName(QStringLiteral("label_6"));
- QFont font1;
- font1.setFamily(QStringLiteral("Arial"));
- label_6->setFont(font1);
- label_6->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
-
- gridLayout->addWidget(label_6, 5, 0, 1, 1);
-
- lineEdit_2 = new QLineEdit(ParamDlg);
- lineEdit_2->setObjectName(QStringLiteral("lineEdit_2"));
- lineEdit_2->setFont(font1);
-
- gridLayout->addWidget(lineEdit_2, 2, 1, 1, 1);
-
- comboBox_2 = new QComboBox(ParamDlg);
- comboBox_2->setObjectName(QStringLiteral("comboBox_2"));
- comboBox_2->setMinimumSize(QSize(0, 30));
- comboBox_2->setFont(font1);
-
- gridLayout->addWidget(comboBox_2, 4, 1, 1, 1);
-
- label_5 = new QLabel(ParamDlg);
- label_5->setObjectName(QStringLiteral("label_5"));
- label_5->setFont(font1);
- label_5->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
-
- gridLayout->addWidget(label_5, 4, 0, 1, 1);
-
- comboBox_3 = new QComboBox(ParamDlg);
- comboBox_3->setObjectName(QStringLiteral("comboBox_3"));
- comboBox_3->setMinimumSize(QSize(0, 30));
- comboBox_3->setFont(font1);
-
- gridLayout->addWidget(comboBox_3, 5, 1, 1, 1);
-
- label_4 = new QLabel(ParamDlg);
- label_4->setObjectName(QStringLiteral("label_4"));
- label_4->setFont(font1);
- label_4->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
-
- gridLayout->addWidget(label_4, 6, 0, 1, 1);
-
- lineEdit_3 = new QLineEdit(ParamDlg);
- lineEdit_3->setObjectName(QStringLiteral("lineEdit_3"));
- lineEdit_3->setFont(font1);
-
- gridLayout->addWidget(lineEdit_3, 6, 1, 1, 1);
-
- label_2 = new QLabel(ParamDlg);
- label_2->setObjectName(QStringLiteral("label_2"));
- label_2->setFont(font1);
- label_2->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
-
- gridLayout->addWidget(label_2, 2, 0, 1, 1);
-
- comboBox = new QComboBox(ParamDlg);
- comboBox->setObjectName(QStringLiteral("comboBox"));
- comboBox->setMinimumSize(QSize(0, 30));
- comboBox->setFont(font1);
-
- gridLayout->addWidget(comboBox, 1, 1, 1, 1);
-
- label_3 = new QLabel(ParamDlg);
- label_3->setObjectName(QStringLiteral("label_3"));
- label_3->setFont(font1);
- label_3->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
-
- gridLayout->addWidget(label_3, 1, 0, 1, 1);
-
- lineEdit = new QLineEdit(ParamDlg);
- lineEdit->setObjectName(QStringLiteral("lineEdit"));
- lineEdit->setFont(font1);
-
- gridLayout->addWidget(lineEdit, 0, 1, 1, 1);
-
- label = new QLabel(ParamDlg);
- label->setObjectName(QStringLiteral("label"));
- label->setFont(font1);
- label->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
-
- gridLayout->addWidget(label, 0, 0, 1, 1);
-
- checkBox = new QCheckBox(ParamDlg);
- checkBox->setObjectName(QStringLiteral("checkBox"));
- checkBox->setFont(font1);
-
- gridLayout->addWidget(checkBox, 7, 0, 1, 1);
-
- checkBox_2 = new QCheckBox(ParamDlg);
- checkBox_2->setObjectName(QStringLiteral("checkBox_2"));
- checkBox_2->setFont(font1);
-
- gridLayout->addWidget(checkBox_2, 7, 1, 1, 1);
-
- m_pbROISet = new QPushButton(ParamDlg);
- m_pbROISet->setObjectName(QStringLiteral("m_pbROISet"));
- QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
- sizePolicy.setHorizontalStretch(0);
- sizePolicy.setVerticalStretch(0);
- sizePolicy.setHeightForWidth(m_pbROISet->sizePolicy().hasHeightForWidth());
- m_pbROISet->setSizePolicy(sizePolicy);
- m_pbROISet->setMinimumSize(QSize(0, 30));
- m_pbROISet->setMaximumSize(QSize(1000, 50));
- m_pbROISet->setFont(font1);
-
- gridLayout->addWidget(m_pbROISet, 3, 0, 1, 2);
-
-
- gridLayout_2->addLayout(gridLayout, 0, 1, 1, 1);
-
- horizontalLayout = new QHBoxLayout();
- horizontalLayout->setObjectName(QStringLiteral("horizontalLayout"));
- horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
-
- horizontalLayout->addItem(horizontalSpacer);
-
- pushButton = new QPushButton(ParamDlg);
- pushButton->setObjectName(QStringLiteral("pushButton"));
- pushButton->setMinimumSize(QSize(0, 30));
- pushButton->setFont(font1);
-
- horizontalLayout->addWidget(pushButton);
-
- pushButton_2 = new QPushButton(ParamDlg);
- pushButton_2->setObjectName(QStringLiteral("pushButton_2"));
- pushButton_2->setMinimumSize(QSize(0, 30));
- pushButton_2->setFont(font1);
-
- horizontalLayout->addWidget(pushButton_2);
-
-
- gridLayout_2->addLayout(horizontalLayout, 2, 1, 1, 1);
-
- verticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
-
- gridLayout_2->addItem(verticalSpacer, 1, 1, 1, 1);
-
- gridLayout_2->setRowStretch(0, 100);
- gridLayout_2->setRowStretch(1, 1);
-
- retranslateUi(ParamDlg);
-
- QMetaObject::connectSlotsByName(ParamDlg);
- } // setupUi
-
- void retranslateUi(QDialog *ParamDlg)
- {
- ParamDlg->setWindowTitle(QApplication::translate("ParamDlg", "\345\217\202\346\225\260\344\277\241\346\201\257", Q_NULLPTR));
- label_6->setText(QApplication::translate("ParamDlg", "\350\276\223\345\207\272\345\217\202\346\225\260\357\274\232", Q_NULLPTR));
- comboBox_2->clear();
- comboBox_2->insertItems(0, QStringList()
- << QApplication::translate("ParamDlg", "None", Q_NULLPTR)
- );
- label_5->setText(QApplication::translate("ParamDlg", "\347\256\227\346\263\225\357\274\232", Q_NULLPTR));
- label_4->setText(QApplication::translate("ParamDlg", "\346\217\217\350\277\260\357\274\232", Q_NULLPTR));
- label_2->setText(QApplication::translate("ParamDlg", "\345\200\274\357\274\232", Q_NULLPTR));
- label_3->setText(QApplication::translate("ParamDlg", "\347\261\273\345\236\213\357\274\232", Q_NULLPTR));
- label->setText(QApplication::translate("ParamDlg", "\345\220\215\347\247\260\357\274\232", Q_NULLPTR));
- checkBox->setText(QApplication::translate("ParamDlg", "\346\230\257\345\220\246\344\277\235\345\255\230", Q_NULLPTR));
- checkBox_2->setText(QApplication::translate("ParamDlg", "\346\230\257\345\220\246\351\224\201\345\256\232", Q_NULLPTR));
- m_pbROISet->setText(QApplication::translate("ParamDlg", "\350\256\276\347\275\256ROI", Q_NULLPTR));
- pushButton->setText(QApplication::translate("ParamDlg", "\347\241\256\345\256\232", Q_NULLPTR));
- pushButton_2->setText(QApplication::translate("ParamDlg", "\345\217\226\346\266\210", Q_NULLPTR));
- } // retranslateUi
-
-};
-
-namespace Ui {
- class ParamDlg: public Ui_ParamDlg {};
-} // namespace Ui
-
-QT_END_NAMESPACE
-
-#endif // UI_PARAMDLG_H
diff --git a/src/lpbdesigner/GeneratedFiles/ui_RoiDlg.h b/src/lpbdesigner/GeneratedFiles/ui_RoiDlg.h
deleted file mode 100644
index f78f418..0000000
--- a/src/lpbdesigner/GeneratedFiles/ui_RoiDlg.h
+++ /dev/null
@@ -1,188 +0,0 @@
-/********************************************************************************
-** Form generated from reading UI file 'RoiDlg.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_ROIDLG_H
-#define UI_ROIDLG_H
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-QT_BEGIN_NAMESPACE
-
-class Ui_RoiDlg
-{
-public:
- QGridLayout *gridLayout_3;
- QSpacerItem *horizontalSpacer_5;
- QPushButton *pushButton;
- QPushButton *pushButton_2;
- QSplitter *splitter;
- QGroupBox *groupBox_2;
- QVBoxLayout *verticalLayout_2;
- QHBoxLayout *horizontalLayout_2;
- QPushButton *pushButton_8;
- QLineEdit *lineEdit_3;
- QPushButton *pushButton_7;
- QSpacerItem *verticalSpacer;
- QPushButton *pushButton_5;
- QGroupBox *groupBox;
- QVBoxLayout *verticalLayout;
- QLabel *label_pixel_info;
- QGraphicsView *graphicsView;
-
- void setupUi(QDialog *RoiDlg)
- {
- if (RoiDlg->objectName().isEmpty())
- RoiDlg->setObjectName(QStringLiteral("RoiDlg"));
- RoiDlg->setWindowModality(Qt::ApplicationModal);
- RoiDlg->resize(816, 590);
- QFont font;
- font.setPointSize(11);
- RoiDlg->setFont(font);
- gridLayout_3 = new QGridLayout(RoiDlg);
- gridLayout_3->setObjectName(QStringLiteral("gridLayout_3"));
- gridLayout_3->setContentsMargins(5, 5, 5, 5);
- horizontalSpacer_5 = new QSpacerItem(649, 27, QSizePolicy::Expanding, QSizePolicy::Minimum);
-
- gridLayout_3->addItem(horizontalSpacer_5, 1, 0, 1, 1);
-
- pushButton = new QPushButton(RoiDlg);
- pushButton->setObjectName(QStringLiteral("pushButton"));
- pushButton->setMinimumSize(QSize(0, 30));
-
- gridLayout_3->addWidget(pushButton, 1, 1, 1, 1);
-
- pushButton_2 = new QPushButton(RoiDlg);
- pushButton_2->setObjectName(QStringLiteral("pushButton_2"));
- pushButton_2->setMinimumSize(QSize(0, 30));
-
- gridLayout_3->addWidget(pushButton_2, 1, 2, 1, 1);
-
- splitter = new QSplitter(RoiDlg);
- splitter->setObjectName(QStringLiteral("splitter"));
- splitter->setOrientation(Qt::Horizontal);
- groupBox_2 = new QGroupBox(splitter);
- groupBox_2->setObjectName(QStringLiteral("groupBox_2"));
- groupBox_2->setMaximumSize(QSize(140, 16777215));
- QFont font1;
- font1.setPointSize(10);
- groupBox_2->setFont(font1);
- verticalLayout_2 = new QVBoxLayout(groupBox_2);
- verticalLayout_2->setObjectName(QStringLiteral("verticalLayout_2"));
- verticalLayout_2->setContentsMargins(2, 2, 2, 2);
- horizontalLayout_2 = new QHBoxLayout();
- horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
- pushButton_8 = new QPushButton(groupBox_2);
- pushButton_8->setObjectName(QStringLiteral("pushButton_8"));
- pushButton_8->setMaximumSize(QSize(80, 16777215));
-
- horizontalLayout_2->addWidget(pushButton_8);
-
- lineEdit_3 = new QLineEdit(groupBox_2);
- lineEdit_3->setObjectName(QStringLiteral("lineEdit_3"));
- QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
- sizePolicy.setHorizontalStretch(0);
- sizePolicy.setVerticalStretch(0);
- sizePolicy.setHeightForWidth(lineEdit_3->sizePolicy().hasHeightForWidth());
- lineEdit_3->setSizePolicy(sizePolicy);
- lineEdit_3->setMaximumSize(QSize(50, 16777215));
-
- horizontalLayout_2->addWidget(lineEdit_3);
-
-
- verticalLayout_2->addLayout(horizontalLayout_2);
-
- pushButton_7 = new QPushButton(groupBox_2);
- pushButton_7->setObjectName(QStringLiteral("pushButton_7"));
- pushButton_7->setMinimumSize(QSize(0, 30));
- pushButton_7->setMaximumSize(QSize(130, 16777215));
-
- verticalLayout_2->addWidget(pushButton_7);
-
- verticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
-
- verticalLayout_2->addItem(verticalSpacer);
-
- pushButton_5 = new QPushButton(groupBox_2);
- pushButton_5->setObjectName(QStringLiteral("pushButton_5"));
- pushButton_5->setMinimumSize(QSize(0, 30));
-
- verticalLayout_2->addWidget(pushButton_5);
-
- splitter->addWidget(groupBox_2);
- groupBox = new QGroupBox(splitter);
- groupBox->setObjectName(QStringLiteral("groupBox"));
- groupBox->setFont(font1);
- verticalLayout = new QVBoxLayout(groupBox);
- verticalLayout->setSpacing(2);
- verticalLayout->setObjectName(QStringLiteral("verticalLayout"));
- verticalLayout->setContentsMargins(2, 2, 2, 2);
- label_pixel_info = new QLabel(groupBox);
- label_pixel_info->setObjectName(QStringLiteral("label_pixel_info"));
- QFont font2;
- font2.setFamily(QStringLiteral("Arial"));
- font2.setPointSize(8);
- font2.setBold(false);
- font2.setWeight(50);
- label_pixel_info->setFont(font2);
-
- verticalLayout->addWidget(label_pixel_info);
-
- graphicsView = new QGraphicsView(groupBox);
- graphicsView->setObjectName(QStringLiteral("graphicsView"));
- graphicsView->setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
- graphicsView->setResizeAnchor(QGraphicsView::AnchorUnderMouse);
-
- verticalLayout->addWidget(graphicsView);
-
- splitter->addWidget(groupBox);
-
- gridLayout_3->addWidget(splitter, 0, 0, 1, 3);
-
-
- retranslateUi(RoiDlg);
-
- QMetaObject::connectSlotsByName(RoiDlg);
- } // setupUi
-
- void retranslateUi(QDialog *RoiDlg)
- {
- RoiDlg->setWindowTitle(QApplication::translate("RoiDlg", "ROI\346\243\200\346\265\213\345\214\272\345\237\237\351\205\215\347\275\256", Q_NULLPTR));
- pushButton->setText(QApplication::translate("RoiDlg", "\347\241\256\345\256\232", Q_NULLPTR));
- pushButton_2->setText(QApplication::translate("RoiDlg", "\345\217\226\346\266\210", Q_NULLPTR));
- groupBox_2->setTitle(QApplication::translate("RoiDlg", "\345\267\245\345\205\267", Q_NULLPTR));
- pushButton_8->setText(QApplication::translate("RoiDlg", "\351\242\234\350\211\262", Q_NULLPTR));
- pushButton_7->setText(QApplication::translate("RoiDlg", "\345\234\206", Q_NULLPTR));
- pushButton_5->setText(QApplication::translate("RoiDlg", "\345\215\201\345\255\227\346\240\207\345\256\232\347\272\277", Q_NULLPTR));
- groupBox->setTitle(QApplication::translate("RoiDlg", "\347\273\230\345\233\276\345\214\272\345\237\237\357\274\232", Q_NULLPTR));
- label_pixel_info->setText(QApplication::translate("RoiDlg", "Pixel info: ", Q_NULLPTR));
- } // retranslateUi
-
-};
-
-namespace Ui {
- class RoiDlg: public Ui_RoiDlg {};
-} // namespace Ui
-
-QT_END_NAMESPACE
-
-#endif // UI_ROIDLG_H
diff --git a/src/lpbdesigner/MainFrame.ui b/src/lpbdesigner/MainFrame.ui
index 8202e1a..37cf09c 100644
--- a/src/lpbdesigner/MainFrame.ui
+++ b/src/lpbdesigner/MainFrame.ui
@@ -19,19 +19,19 @@
- 5
+ 9
- 5
+ 9
- 5
+ 9
- 5
+ 9
- 5
+ 6
-
@@ -93,6 +93,9 @@
Qt::Horizontal
+
+ 9
+
@@ -122,7 +125,15 @@
Qt::Vertical
+
+ 9
+
+
+
+ 12
+
+
QFrame::StyledPanel
@@ -131,26 +142,50 @@
- 2
+ 6
- 2
+ 6
- 2
+ 6
- 2
+ 6
-
+
+ QFrame::NoFrame
+
Qt::Vertical
+
+ true
+
+
+ 9
+
+
+ true
+
- 1
+ 5
+
+
+ 5
+
+
+ 5
+
+
+ 5
+
+
+ 5
-
@@ -160,6 +195,9 @@
200
+
+ QFrame::StyledPanel
+
Qt::ScrollBarAlwaysOff
@@ -179,6 +217,9 @@
200
+
+ QFrame::StyledPanel
+
Qt::ScrollBarAlwaysOff
@@ -204,16 +245,16 @@
- 2
+ 5
- 2
+ 5
- 2
+ 5
- 2
+ 5
-
@@ -290,21 +331,26 @@
-
+
+
+ 12
+
+
算法列表
- 2
+ 5
- 2
+ 5
- 2
+ 5
- 2
+ 5
-
@@ -336,21 +382,26 @@
-
+
+
+ 12
+
+
参数列表
- 2
+ 5
- 2
+ 5
- 2
+ 5
- 2
+ 5
-
diff --git a/src/lpbdesigner/ParamDlg.ui b/src/lpbdesigner/ParamDlg.ui
index fc817e2..3a59be0 100644
--- a/src/lpbdesigner/ParamDlg.ui
+++ b/src/lpbdesigner/ParamDlg.ui
@@ -9,14 +9,14 @@
0
0
- 279
- 304
+ 343
+ 334
Arial
- 10
+ 12
50
false
diff --git a/src/lpbdesigner/RoiDlg.ui b/src/lpbdesigner/RoiDlg.ui
index fa6eea8..f605aa6 100644
--- a/src/lpbdesigner/RoiDlg.ui
+++ b/src/lpbdesigner/RoiDlg.ui
@@ -15,7 +15,7 @@
- 11
+ 12
@@ -189,7 +189,7 @@
- 10
+ 12
@@ -200,16 +200,16 @@
2
- 2
+ 6
- 2
+ 6
- 2
+ 6
- 2
+ 6
-
diff --git a/tpvs17/caliValve/algEg.cpp b/tpvs17/caliValve/algEg.cpp
index 7ff0729..8f60886 100644
--- a/tpvs17/caliValve/algEg.cpp
+++ b/tpvs17/caliValve/algEg.cpp
@@ -58,7 +58,7 @@ bool algEg::Exec(IDetectorTask *lpTask, IDetectorAlgorithm* lpAlgorithm)
qWarning() << "img size not compare";
return false;
}
- //if (paramInput.ifClasify == 1)
+
if (paramInput.ibackground == 1)
{
QString str = qApp->applicationDirPath() + QString("\\backGround\\%1.BMP").arg(nID);//imread("E:\\1.BMP");
@@ -70,12 +70,11 @@ bool algEg::Exec(IDetectorTask *lpTask, IDetectorAlgorithm* lpAlgorithm)
else
{
std::string starName = str.toLocal8Bit().toStdString();
- paramOutput.background = imread(starName,0);
+ paramOutput.background = imread(starName, 0);
}
if (paramOutput.background.empty())
{
qDebug() << "cali valve : background image is empty";
- //return false;
}
}
@@ -92,6 +91,7 @@ bool algEg::Exec(IDetectorTask *lpTask, IDetectorAlgorithm* lpAlgorithm)
lpAlgorithm->SetOutParamValue("image", lp::QtCVUtils::cvMatToQImage(mask));
lpAlgorithm->SetOutParamValue("center", pt);
lpAlgorithm->SetOutParamValue("valveDis", paramOutput.fValveDis);
+ lpAlgorithm->SetOutParamValue("startDis", paramOutput.fStartDis);
lpAlgorithm->SetOutParamValue("valveWidth", paramOutput.fValveWidth);
lpAlgorithm->SetOutParamValue("valveOffset", paramOutput.nValveOffset);
lpAlgorithm->SetOutParamValue("startOffset", paramOutput.nStartOffset);
@@ -149,11 +149,10 @@ bool algEg::Init(IDetectorTask *lpTask, IDetectorAlgorithm* lpAlgorithm)
LP_ALGORITHM_PARAM param12("valveOffset", LP_INT);
lpAlgorithm->AddOutParam(¶m12, 1);
- LP_ALGORITHM_PARAM param13("valveTemplate", LP_MAT);
+ LP_ALGORITHM_PARAM param13("valveTemplate", LP_MAT);//气门芯模板
lpAlgorithm->AddOutParam(¶m13, 1);
-
- LP_ALGORITHM_PARAM param14("barTemplate", LP_MAT);
+ LP_ALGORITHM_PARAM param14("barTemplate", LP_MAT);//辐条模板
lpAlgorithm->AddOutParam(¶m14, 1);
LP_ALGORITHM_PARAM param15("withinOffset", LP_INT);
@@ -165,25 +164,22 @@ bool algEg::Init(IDetectorTask *lpTask, IDetectorAlgorithm* lpAlgorithm)
LP_ALGORITHM_PARAM param17("flagCircle", LP_INT);
lpAlgorithm->AddOutParam(¶m17, 1);
-
LP_ALGORITHM_PARAM param18("baseImage", LP_MAT);
lpAlgorithm->AddOutParam(¶m18, 1);
-
LP_ALGORITHM_PARAM param19("weightMat", LP_MAT);
lpAlgorithm->AddOutParam(¶m19, 1);
-
LP_ALGORITHM_PARAM param20("backgroundThresh", LP_INT);
lpAlgorithm->AddOutParam(¶m20, 1);
-
LP_ALGORITHM_PARAM param21("background", LP_MAT);
lpAlgorithm->AddOutParam(¶m21, 1);
- LP_ALGORITHM_PARAM param_startOffset("startOffset", LP_INT, 0, QObject::tr(" "));
- lpAlgorithm->AddParam(¶m_startOffset, 1);
-
+ LP_ALGORITHM_PARAM param_startOffset("startOffset", LP_INT, 0, QObject::tr(" "));//标定点距离0轴坐标系的角度
+ lpAlgorithm->AddOutParam(¶m_startOffset, 1);
+ LP_ALGORITHM_PARAM param_startDis("startDis", LP_DOUBLE);//标定点距离圆心的距离
+ lpAlgorithm->AddOutParam(¶m_startDis, 1);
return true;
}
diff --git a/tpvs17/caliValve/caliValve.cpp b/tpvs17/caliValve/caliValve.cpp
index 6ff2d2f..e2bcbef 100644
--- a/tpvs17/caliValve/caliValve.cpp
+++ b/tpvs17/caliValve/caliValve.cpp
@@ -321,8 +321,9 @@ bool CaliValve::cutValve(Mat & img2Rect, Mat &imgTemplate, Rect rtCut, int nAngl
bool CaliValve::detect(Mat & imgSrc, InputParam ¶mIn, OutputParam ¶mOut, Mat &imgDst /*= Mat()*/)
{
Record_List valueRecords = paramIn.valueROI.records;//оλ
- Record_List barRecords = paramIn.barROI.records;//
- Record_List startRecords = paramIn.startROI.records;
+ Record_List barRecords = paramIn.barROI.records;//λ
+ Record_List startRecords = paramIn.startROI.records;//궨λ
+
int valueCircleCount = valueRecords.size();
int barCircleCount = barRecords.size();
if (valueCircleCount == 0 && barCircleCount ==0) {
@@ -367,7 +368,6 @@ bool CaliValve::detect(Mat & imgSrc, InputParam ¶mIn, OutputParam ¶mOut,
barCircle.fRadius = abs(circleFeature.second.at(2));
break;
}
-
}
luffy_base::luffyCircle startCircle;
@@ -386,7 +386,6 @@ bool CaliValve::detect(Mat & imgSrc, InputParam ¶mIn, OutputParam ¶mOut,
startCircle.fRadius = abs(circleFeature.second.at(2));
break;
}
-
}
//о궨Բ
cv::circle(imgDst, valueCircle.ptCenter, valueCircle.fRadius, LP_COLOR_RED, 2);
@@ -409,7 +408,7 @@ bool CaliValve::detect(Mat & imgSrc, InputParam ¶mIn, OutputParam ¶mOut,
int nImgHeight = valueCircle.fRadius * 2 + 2 * offset;
Mat img2Rect;
luffy_math::polar2rect(imgSrc, img2Rect, paramIn.ptCenter, fRadius - nImgHeight / 2, fRadius + nImgHeight / 2, paramIn.nAngleMax);
-
+ paramOut.fStartDis = luffy_math::disofPoints(startCircle.ptCenter, paramIn.ptCenter);
if (paramIn.flagCircle > 0)
{
qWarning() << "outPut param flagCircle :" << paramIn.flagCircle;
diff --git a/tpvs17/caliValve/caliValve.h b/tpvs17/caliValve/caliValve.h
index 2c65bf9..be9341b 100644
--- a/tpvs17/caliValve/caliValve.h
+++ b/tpvs17/caliValve/caliValve.h
@@ -22,8 +22,9 @@ struct InputParam
struct OutputParam
{
- float fValveDis;
+ float fValveDis;//оԲľ λʱõ ͨòȡָѧͼ
float fValveWidth;
+ float fStartDis;//
Mat imgTemplate;
int nValveOffset;//оԲϵĽǶƫֵ
int nStartOffset;//οԲϵĽǶƫֵ
diff --git a/tpvs17/valveDetector/algEg.cpp b/tpvs17/valveDetector/algEg.cpp
index ca33e36..18ff434 100644
--- a/tpvs17/valveDetector/algEg.cpp
+++ b/tpvs17/valveDetector/algEg.cpp
@@ -18,33 +18,41 @@ algEg::~algEg()
{
}
-const int nAngleMax = 3600;
+const int nAngleMax = 3600;//将角度精确到0.1度 把整个圆分成3600份
bool algEg::Exec(IDetectorTask *lpTask, IDetectorAlgorithm* lpAlgorithm)
{
- //GetParamValue("scoreTh", LP_DOUBLE).toDouble();
- paramInput.nBarScore = lpAlgorithm->GetParamValue("barScore", LP_INT).toDouble();
+ paramInput.nMaxAngle = nAngleMax;
+ paramInput.dScoreThres = lpAlgorithm->GetParamValue("scoreTh", LP_DOUBLE).toDouble();//匹配分数阈值 低于该阈值 表示气门芯寻找失败
+ paramInput.nBarScore = lpAlgorithm->GetParamValue("barScore", LP_INT).toDouble();//辐条分数
paramInput.nBarScore = paramInput.nBarScore > 50 ? paramInput.nBarScore : 50;
paramInput.withinOffset = lpAlgorithm->GetParamValue("withinOffset", LP_INT).toInt();
paramInput.barNum = lpAlgorithm->GetParamValue("barNum", LP_INT).toInt();
- paramOutput.bIsFind = false;
- paramOutput.dScore = 0;
- paramOutput.showMatchScore = -1;
- paramInput.nMaxAngle = nAngleMax;
- paramOutput.dAngle = 361;
- paramOutput.nErrorType = 0;
paramInput.flagCircle = lpAlgorithm->GetParamValue("flagCircle", LP_INT).toInt();
paramInput.roi = lpAlgorithm->GetParamValue("cirlceArea", LP_ROI).value();
paramInput.cMatchScore = lpAlgorithm->GetParamValue("cMatchScore", LP_DOUBLE).toDouble();
paramInput.wheelType = lpAlgorithm->GetParamValue("wheelType", LP_INT).toInt();
paramInput.backgroundThresh = lpAlgorithm->GetParamValue("backgroundThresh", LP_INT).toInt();
+ paramInput.nValveOffset = lpAlgorithm->GetParamValue("valveOffset", LP_INT).toInt();//获取气门芯标定位置在圆心坐标系中的角度偏移值
+ paramInput.nStartOffset = lpAlgorithm->GetParamValue("startOffset", LP_INT).toInt();
+ paramInput.fValveWidth = lpAlgorithm->GetParamValue("valveWidth", LP_DOUBLE).toDouble();
+ paramInput.fValveDis = lpAlgorithm->GetParamValue("valveDis", LP_DOUBLE).toDouble();
+ paramInput.fStartDis = lpAlgorithm->GetParamValue("startDis", LP_DOUBLE).toDouble();//标定时标定点的圆心坐标与轮毂中心的坐标距离
+
+ paramOutput.bIsFind = false;
+ paramOutput.dScore = 0;
+ paramOutput.showMatchScore = -1;
+
+ paramOutput.dAngle = 361;
+ paramOutput.nErrorType = 0;
Mat mask;
Mat gray;
+ Mat centerRoi = lpAlgorithm->GetParamValue("centerRoi", LP_MAT).value();
+
if (!lpTask->GetTaskInfo()->detectImg.empty()) {
luffy_imageProc::createImage(lpTask->GetTaskInfo()->detectImg, gray, luffy_imageProc::emCreateGray);
qDebug() << "luffy_imageProc::createImage";
@@ -63,8 +71,6 @@ bool algEg::Exec(IDetectorTask *lpTask, IDetectorAlgorithm* lpAlgorithm)
paramOutput.nErrorType += 2;
}
- Mat centerRoi = lpAlgorithm->GetParamValue("centerRoi", LP_MAT).value();
-
if (!centerRoi.empty()) {
qDebug() << "valve detection: creating CenterRoi";
luffy_imageProc::createImage(centerRoi, paramInput.centerRoi, luffy_imageProc::emCreateGray);
@@ -111,13 +117,10 @@ bool algEg::Exec(IDetectorTask *lpTask, IDetectorAlgorithm* lpAlgorithm)
}
}
- paramInput.nValveOffset = lpAlgorithm->GetParamValue("valveOffset", LP_INT).toInt();
- paramInput.nStartOffset = lpAlgorithm->GetParamValue("startOffset", LP_INT).toInt();
- paramInput.fValveWidth = lpAlgorithm->GetParamValue("valveWidth", LP_DOUBLE).toDouble();
- paramInput.fValveDis = lpAlgorithm->GetParamValue("valveDis", LP_DOUBLE).toDouble();
- Mat tmp = lpAlgorithm->GetParamValue("valveTemplate", LP_MAT).value();
- Mat barTemp = lpAlgorithm->GetParamValue("barTemplate", LP_MAT).value();
- Mat weightMat = lpAlgorithm->GetParamValue("weightMat", LP_MAT).value();
+
+ Mat tmp = lpAlgorithm->GetParamValue("valveTemplate", LP_MAT).value();//获取气门芯模板图
+ Mat barTemp = lpAlgorithm->GetParamValue("barTemplate", LP_MAT).value();//获取辐条模板图
+ Mat weightMat = lpAlgorithm->GetParamValue("weightMat", LP_MAT).value();//
Mat baseImage = lpAlgorithm->GetParamValue("baseImage", LP_MAT).value();
int num = lpTask->GetSystemInfoValue("station").toInt();
if (num == 2)
@@ -141,7 +144,6 @@ bool algEg::Exec(IDetectorTask *lpTask, IDetectorAlgorithm* lpAlgorithm)
bExist = false;
}
}
-
}
}
@@ -159,11 +161,11 @@ bool algEg::Exec(IDetectorTask *lpTask, IDetectorAlgorithm* lpAlgorithm)
qWarning() << "valve detection: can not get template for detecting";
bExist = false;
}
-
}
if (bExist) {
qDebug() << "valve detection: try finding";
+ //定位检测
m_objDetect.detect(gray, paramInput, paramOutput, mask);
}
else {
@@ -173,7 +175,6 @@ bool algEg::Exec(IDetectorTask *lpTask, IDetectorAlgorithm* lpAlgorithm)
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;
@@ -181,7 +182,6 @@ bool algEg::Exec(IDetectorTask *lpTask, IDetectorAlgorithm* lpAlgorithm)
int tmpX = paramInput.ptCenter.x + paramInput.fValveDis * luffy_base::luffy_triangle::getCos(paramInput.nMaxAngle, nAngle);
int tmpY = paramInput.ptCenter.y - paramInput.fValveDis * luffy_base::luffy_triangle::getSin(paramInput.nMaxAngle, nAngle);
-
Point ptValve(tmpX, tmpY);
QString strBase = lpTask->GetSystemInfoValue("folderBase").toString();
QString strFile = lpTask->GetSystemInfoValue("fileName").toString();
@@ -192,15 +192,14 @@ bool algEg::Exec(IDetectorTask *lpTask, IDetectorAlgorithm* lpAlgorithm)
vMap.insert("model_cali", true);
lpTask->GetTaskInfo()->property = vMap;
- paramOutput.dAngleRes = (paramOutput.dAngle - paramInput.nValveOffset) / paramInput.nMaxAngle * 360.0;
- paramOutput.dAngleRes = m_objDetect.ruleData(paramOutput.dAngleRes, paramOutput.nErrorType);
+ //paramOutput.dAngleRes = (paramOutput.dAngle - paramInput.nValveOffset) / paramInput.nMaxAngle * 360.0;
+ paramOutput.dAngleRes = (paramOutput.dAngle - paramInput.nStartOffset) / paramInput.nMaxAngle * 360.0;
+ paramOutput.dAngleRes = m_objDetect.ruleData(paramOutput.dAngleRes, paramOutput.nErrorType);//随机数
paramOutput.strResultTip = m_objDetect.genResultTip(paramOutput.strResultTip, paramOutput.nErrorType);
-
paramOutput.dTime = (double)(cv::getTickCount() - nStart) / cv::getTickFrequency() * 1000.0;
-
m_objDetect.drawResult(mask, paramInput, paramOutput);
- m_objDetect.saveResult(gray, paramInput, paramOutput, strObj);
+ //m_objDetect.saveResult(gray, paramInput, paramOutput, strObj);
lpAlgorithm->SetOutParamValue("image", EngineBase::convMat2QImage(mask));
lpAlgorithm->SetOutParamValue("score", paramOutput.dScore);
lpAlgorithm->SetOutParamValue("angle", paramOutput.dAngleRes);
@@ -209,7 +208,6 @@ bool algEg::Exec(IDetectorTask *lpTask, IDetectorAlgorithm* lpAlgorithm)
QString cLetter = paramOutput.strResultTip + "/" + QString::number(paramInput.dScoreThres);
lpAlgorithm->SetOutParamValue("resultTip", cLetter);
- //lpAlgorithm->SetOutParamValue("resultTip", paramOutput.strResultTip);
QString strImgName = lpTask->GetTaskInfo()->strImageName;
lpAlgorithm->SetOutParamValue("imageName", lpTask->GetTaskInfo()->strImageName);
qDebug() << "finish alg valve detect";
@@ -264,9 +262,12 @@ bool algEg::Init(IDetectorTask *lpTask, IDetectorAlgorithm* lpAlgorithm)
LP_ALGORITHM_PARAM param23("valveWidth", LP_DOUBLE, 0, QObject::tr(" "));
lpAlgorithm->AddParam(¶m23, 1);
- LP_ALGORITHM_PARAM param33("valveDis", LP_DOUBLE, 0, QObject::tr(" "));
+ LP_ALGORITHM_PARAM param33("valveDis", LP_DOUBLE, 0, QObject::tr(" "));//标定时气门芯的圆心坐标与轮毂中心的坐标距离
lpAlgorithm->AddParam(¶m33, 1);
+ LP_ALGORITHM_PARAM param_startDis("startDis", LP_DOUBLE, 0, QObject::tr(" "));//标定时标定点的圆心坐标与轮毂中心的坐标距离
+ lpAlgorithm->AddParam(¶m_startDis, 1);
+
LP_ALGORITHM_PARAM param43("valveTemplate", LP_MAT, QVariant(), QObject::tr(" "));
lpAlgorithm->AddParam(¶m43, 1);
diff --git a/tpvs17/valveDetector/valveDetector.cpp b/tpvs17/valveDetector/valveDetector.cpp
index 89ecf40..37f76f9 100644
--- a/tpvs17/valveDetector/valveDetector.cpp
+++ b/tpvs17/valveDetector/valveDetector.cpp
@@ -304,39 +304,6 @@ void histMeanStddev(const Mat& hist, double* pMean, double* pStddev)
*pStddev = sqrt(sum / (double)(count - 1));
}
-//void rotateMatchData(const Mat& _img, Mat &templ, RotateData* pData, float angleStep, float startAngle, float endAngle)
-//{
-// Mat img = _img.clone();
-// Point2f center(img.cols / 2.0, img.rows / 2.0);
-// int nNum = (endAngle - startAngle) / angleStep;
-// RotateData& data = *pData;
-// data.init(_img, center, angleStep, nNum);
-// data.mStartAngle = startAngle;
-// data.mEndAngle = endAngle;
-//
-// parallel_for_(Range(0, nNum), ImageCompareModelInvoker(templ, pData));
-//}
-//
-//void parallelDetect(int index, void *p, Mat templ)
-//{
-// RotateData *pData = (RotateData *)p;
-// Mat t = getRotationMatrix2D(pData->mCenter, pData->angle(index), 1.0);
-// Mat rImg;
-// warpAffine(pData->mImgSrc, rImg, t, pData->mImgSrc.size());
-//
-// Mat imgRes = templ - rImg;
-// double val = norm(imgRes);
-// pData->mDisValVec[index] = val;
-// pData->mRImgVec[index] = rImg;
-//}
-//void ImageCompareModelInvoker::operator()(const cv::Range& range) const
-//{
-// int i0 = range.start;
-// int i1 = range.end;
-// assert(abs(i1 - i0) == 1);
-// parallelDetect(i0, m_pData, temp);
-//}
-
double tempScoreShoot(Mat &_img, Mat &template_img, detectMode mode)
{
qDebug() << "tempScoreShoot";
@@ -465,205 +432,7 @@ double tempScoreShoot(Mat &_img, Mat &template_img, detectMode mode)
qDebug() << "end tempScoreShoot";
return 0;
}
-//template
-//double pointDis(const _Point& i, const _Point& j)
-//{
-// return norm(i - j);
-//}
-
-//float interpolate(float* pY, int n, float stepX, float x)
-//{
-// int lIdx = (int)(x / stepX);
-// int rIdx = lIdx + 1;
-// if (rIdx > n - 1)
-// {
-// return pY[n - 1];
-// }
-// assert(lIdx >= 0 && lIdx < n && rIdx >= 0 && rIdx < n);
-// float s = (x - lIdx*stepX) / stepX;
-// float ly = pY[lIdx];
-// float ry = pY[rIdx];
-// return ly + (ry - ly)*s;
-//}
-//cv::Mat cocentricNorm( Mat& img, Point2f center, const Mat& weightMat, float dstMeanVal)
-//{
-// assert(weightMat.empty() || weightMat.type() == CV_32FC1);
-//
-// int w = img.cols;
-// int h = img.rows;
-// vector corners;
-// corners.push_back(Point2f(0, 0));
-// corners.push_back(Point2f(0, h));
-// corners.push_back(Point2f(w, h));
-// corners.push_back(Point2f(w, 0));
-// vector cornerDisVec;
-// for_each(corners.begin(), corners.end(), [&](const Point2f& pt)
-// {
-// double dis = pointDis(center, pt);
-// cornerDisVec.push_back(dis);
-// });
-//
-// auto farthestCornerDis = max_element(cornerDisVec.begin(), cornerDisVec.end());
-// float maxRadius = *farthestCornerDis;
-//
-// int radiusNum = floorf(maxRadius);
-// //radiusNum = 20;
-// float radiusStep = (maxRadius / radiusNum);
-// Mat cocentricSumMat = Mat::zeros(1, radiusNum, CV_32FC1);
-// float* pSumData = (float*)cocentricSumMat.data;
-// Mat cocentricWeightSumMat = Mat::zeros(1, radiusNum, CV_32FC1);
-// float* pWeightSumData = (float*)cocentricWeightSumMat.data;
-// Mat radiusMat(img.rows, img.cols, CV_32FC1);
-//
-// for (int y = 0; y < h; y++)
-// {
-// const Mat& imgRow = img.row(y);
-// float* pImgRowData = (float*)imgRow.data;
-// float* pRadiusRowData = (float*)radiusMat.row(y).data;
-//
-// float* pWeightRowData = NULL;
-// if (!weightMat.empty())
-// {
-// pWeightRowData = (float*)weightMat.row(y).data;
-// }
-//
-// for (int x = 0; x < w; x++)
-// {
-// //std::cout << x << " " << y << std::endl;
-// float weight;
-// if (pWeightRowData)
-// {
-// weight = pWeightRowData[x];
-// }
-// else
-// {
-// weight = 1.0;
-// }
-// float val = pImgRowData[x] * weight;
-// float radius = pointDis(Point2f(x, y), center);
-// pRadiusRowData[x] = radius;
-// int radiusIdx0 = (int)(radius / radiusStep);
-// assert(radiusIdx0 >= 0);
-// int radiusIdx1 = radiusIdx0 + 1;
-// if (radiusIdx0 >= radiusNum - 1)
-// {
-// pSumData[radiusNum - 1] += val;
-// pWeightSumData[radiusNum - 1] += weight;
-// }
-// else
-// {
-// float s = (radius - radiusStep*radiusIdx0) / radiusStep;
-// pSumData[radiusIdx0] += val*s;
-// pSumData[radiusIdx1] += val*(1 - s);
-// pWeightSumData[radiusIdx0] += s*weight;
-// pWeightSumData[radiusIdx1] += (1 - s)*weight;
-// }
-// }
-// // CvPlot::plot("sum", pSumData, radiusNum);
-// // CvPlot::plot("count", pCountData, radiusNum);
-// // waitKey();
-// }
-//
-// for (int i = 0; i < radiusNum; ++i)
-// {
-// //float radius = (i*radiusStep + radiusStep) / 2;
-// if (pWeightSumData[i] == 0)
-// {
-//
-// }
-// else
-// {
-// pSumData[i] /= pWeightSumData[i];
-// }
-// }
-//
-// Mat retMat = Mat::zeros(img.rows, img.cols, CV_32FC1);
-// for (int y = 0; y < h; y++)
-// {
-// float* pImgRowData = (float*)img.row(y).data;
-// float* pRetRowData = (float*)retMat.row(y).data;
-// float* pRadiusData = (float*)radiusMat.row(y).data;
-// for (int x = 0; x < w; x++)
-// {
-// float val = pImgRowData[x];
-// float radius = pRadiusData[x];
-// float mean = interpolate(pSumData, radiusNum, radiusStep, radius);
-// if (mean == 0)
-// {
-// continue;
-// }
-// float newVal = (float)val * dstMeanVal / mean;
-// pRetRowData[x] = newVal;
-// }
-// }
-//
-// Mat viewRetMat = retMat / 255.0;
-//
-//
-// return retMat;
-//}
-
-
-//bool ValveDetector::isValid(Mat target, Mat templ, Point2f pt, int validThresh)
-//{
-// qDebug() << "detect if image is valid";
-// if (target.type() != CV_32FC1)
-// {
-// target.convertTo(target, CV_32FC1);
-// }
-// templ.convertTo(templ, CV_32FC1);
-// int templW = templ.cols;
-// int templH = templ.rows;
-// Mat imgRoi;
-// target(Rect(pt.x - templW / 2, pt.y - templH / 2, templW, templH)).copyTo(imgRoi);
-// Mat circleMask(imgRoi.size(), CV_32FC1, Scalar::all(0));
-// cv::circle(circleMask, Point(imgRoi.cols / 2, imgRoi.rows / 2), imgRoi.cols / 2, Scalar(1), -1);
-// imgRoi = imgRoi.mul(circleMask);
-// templ = templ.mul(circleMask);
-//
-// resize(imgRoi, imgRoi, Size(imgRoi.cols / 2, imgRoi.cols / 2), INTER_LINEAR);
-// resize(templ, templ, Size(templ.cols / 2, templ.cols / 2), INTER_LINEAR);
-//
-// Mat bullredTempl, blurredRoi;
-// cv::GaussianBlur(imgRoi, bullredTempl, Size(3, 3), 5.0);
-// cv::GaussianBlur(templ, blurredRoi, Size(3, 3), 5.0);
-// Mat innerMask(bullredTempl.size(), CV_8UC1, Scalar::all(0));
-// cv::circle(innerMask, Point(bullredTempl .cols / 2, bullredTempl.rows / 2), bullredTempl.cols / 2, Scalar(255), -1);
-// Mat normTempl, normRoi;
-// luffy_imageProc::meanvarnorm(bullredTempl, normTempl, 60, 30, innerMask); // 50
-// luffy_imageProc::meanvarnorm(blurredRoi, normRoi, 60, 30, innerMask);
-// innerMask.convertTo(innerMask, CV_32FC1);
-//
-// RotateData* pData = new RotateData();
-// rotateMatchData(normRoi, normTempl, pData, 1, 0, 90);
-//
-// double result = 0;
-// Mat rstImg;
-// if (pData->mDisValVec.empty())
-// {
-// delete pData;
-// qDebug() << "the distance of centers is empty";
-// result = FLT_MAX;
-// }
-// else
-// {
-// size_t bestIndex = min_element(pData->mDisValVec.begin(), pData->mDisValVec.end()) - pData->mDisValVec.begin();
-//
-// result = pData->mDisValVec[bestIndex];
-// qDebug() << "found the minimal value of distance:" << result;
-// delete pData;
-// }
-// if (result < validThresh)
-// {
-// qDebug() << "image is valid";
-// return true;
-// }
-// else
-// {
-// qDebug() << "image is not valid";
-// return false;
-// }
-//}
+
cv::Mat LoopRoi(Mat &src, int x, int nWidth) {
Mat dst;
@@ -967,114 +736,6 @@ void getTargetPosAndVal(const Mat &img, InputParam &in, double &val, int &nPos)
//nPos = barX;
}
-//int matchValveScoreShoot(const vector& rois, const Mat &templ, int candidateIndex)
-//{
-// cv::SurfFeatureDetector Detector(400);
-// vector roiKeyPoint, templkeyPoint;
-// Detector.detect(templ, templkeyPoint);
-//
-// SurfDescriptorExtractor Descriptor;
-// Mat roiDesc, templDesc;
-// Descriptor.compute(templ, templkeyPoint, templDesc);
-// int Tnum = templkeyPoint.size();
-// if (Tnum <3)
-// {
-// qDebug() << "num of template keyPoints is less than 3, need to be returned";
-// return -1;
-// }
-// qDebug() << "the template keyPoints num ;" << Tnum;
-// int tarIndex = -1;
-// for (int i = 0; i < rois.size(); ++i)
-// {
-// const Mat &roi = rois[i];
-// Detector.detect(roi, roiKeyPoint);
-// Descriptor.compute(roi, roiKeyPoint, roiDesc);
-// int keyNum = roiKeyPoint.size();
-// if (keyNum < 3)
-// {
-// qDebug() << "the Point num is less than 2, need to be returned;" << keyNum;
-// continue;
-// }
-// else
-// {
-// qDebug() << "the Point num success";
-// }
-// /*BFMatcher matcher(NORM_L2, true);
-// vector matches;
-// matcher.match(templateDesc, imageDesc2, matches);
-// Mat img_match;
-// drawMatches(templateMat, keyPointTemplate, rightImage, keyPoint2, matches, img_match);*/
-// /*BFMatcher matcher;
-// vector matchePoints;
-// matcher.match(templDesc, roiDesc, matchePoints);*/
-// /*vector GoodMatchePoints;
-//
-// double maxDis = 0, minDis = 100;
-// for (int j = 0; j < matchePoints.size(); ++j)
-// {
-// double dis = matchePoints[j].distance;
-// if (dis < minDis)
-// {
-// minDis = dis;
-// }
-//
-// if (dis > maxDis)
-// {
-// maxDis = dis;
-// }
-// }
-//
-// for (int k = 0; k < matchePoints.size(); ++k)
-// {
-// if (matchePoints[k].distance < 1.2*minDis)
-// {
-// GoodMatchePoints.push_back(matchePoints[k]);
-// }
-// }*/
-// FlannBasedMatcher matcher;
-// vector > matchePoints;
-// vector GoodMatchePoints;
-//
-// vector train_desc(1, templDesc);
-// matcher.add(train_desc);
-// qDebug() << "start training";
-// matcher.train();
-// qDebug() << "finish training";
-//
-// matcher.knnMatch(roiDesc, matchePoints, 2);
-// qDebug()<<"finish match";
-//
-// //vector GoodMatchePoints;
-// for (int j = 0; j < matchePoints.size(); j++)
-// {
-// if (matchePoints[j][0].distance < 0.6 * matchePoints[j][1].distance)
-// {
-// GoodMatchePoints.push_back(matchePoints[j][0]);
-// }
-// }
-// int maxVal = -1;
-// int num = 0;
-//
-// Mat ShowResult;
-// int x = GoodMatchePoints.size();
-// if (GoodMatchePoints.size() <= 0)
-// {
-// continue;
-// }
-// else
-// {
-// if (x > maxVal)
-// {
-// maxVal = GoodMatchePoints.size();
-// tarIndex = i;
-// }
-// }
-// //Mat ShowResult;
-// //drawMatches(roi, roiKeyPoint, templ, templkeyPoint, GoodMatchePoints, ShowResult);
-// }
-//
-// return tarIndex;
-//}
int roiCandidateMatch(const vector &vec, Mat templ)
{
@@ -1094,7 +755,6 @@ int roiCandidateMatch(const vector &vec, Mat templ)
return index;
}
-
bool imageRotateMatch(Mat & imgSrc, InputParam ¶mIn, OutputParam ¶mOut, vector candidatePoints)
{
float templateAngle = paramIn.nValveOffset / paramIn.nMaxAngle * 360;
@@ -1241,7 +901,6 @@ bool imageRotateMatch(Mat & imgSrc, InputParam ¶mIn, OutputParam ¶mOut,
return true;
}
-
bool ValveDetector::detect(Mat & imgSrc, InputParam ¶mIn, OutputParam ¶mOut, Mat &imgDst /*= Mat()*/)
{
int rtWidth = 100;
@@ -1268,18 +927,15 @@ bool ValveDetector::detect(Mat & imgSrc, InputParam ¶mIn, OutputParam ¶m
int nImgHeight = fValveWidth * 2 + 2 * offset;
Mat img2Rect;
paramIn.ptCenter = Point(paramIn.ptCenter.x , paramIn.ptCenter.y);
- luffy_math::polar2rect(imgSrc, img2Rect, paramIn.ptCenter,
- fValveDis - nImgHeight / 2, fValveDis + nImgHeight / 2, paramIn.nMaxAngle);
+ luffy_math::polar2rect(imgSrc, img2Rect, paramIn.ptCenter, fValveDis - nImgHeight / 2, fValveDis + nImgHeight / 2, paramIn.nMaxAngle);
Mat imgMatch, barCompare;
-
-
if (paramIn.flagCircle == 1 )
{
luffy_match::LoopMatMatch(img2Rect, paramIn.barTemplate, luffy_match::emLoopMatX, barCompare);
double score = 0;
int tarPos;
- getTargetPosAndVal(barCompare, paramIn, score, tarPos);
+ getTargetPosAndVal(barCompare, paramIn, score, tarPos);//ǶȺͷ
paramOut.dAngle = tarPos;
paramOut.dScore = score;
}
@@ -1333,10 +989,8 @@ bool ValveDetector::detect(Mat & imgSrc, InputParam ¶mIn, OutputParam ¶m
{
vecImg.push_back(roi);
}
-
}
-
// FOR MOTORCIRCLE PROGRAM START
Mat ret(vecImg.size(), vecImg.size(), CV_32FC1, Scalar(0));
for (int i = 0; i < vecImg.size(); i++) {
@@ -1448,27 +1102,6 @@ bool ValveDetector::detect(Mat & imgSrc, InputParam ¶mIn, OutputParam ¶m
}
}
- /*identicalImg = vecImg[targetIndex](Rect(10, 0, imgTemplate.cols, imgTemplate.rows));
- vector localMatVec;
- imgCrop(vecImg[targetIndex], localMatVec);
-
- for each (Mat mat in localMatVec)
- {
- double s = tempScoreShoot(mat, imgTemplate, detectMode::shootTargetMatch);
- if (s > disVal)
- {
- disVal = s;
- }
- }
- */
-
- /*disVal = tempScoreShoot(identicalImg, imgTemplate, detectMode::shootTargetMatch);
-
- if (disVal > maxVal)
- {
- maxVal = disVal;
- targetIndex = k;
- }*/
}
nIndex = targetIndex;
Mat imgMatchRet;
@@ -1503,18 +1136,10 @@ bool ValveDetector::detect(Mat & imgSrc, InputParam ¶mIn, OutputParam ¶m
m_index = k;
}
}
-
- //Mat imgMatchRet;
- //int m_index = roiCandidateMatch(vecImg, imgTemplate);
- //matchTemplate(vecImg[nIndex], imgTemplate, imgMatchRet, CV_TM_CCORR_NORMED);
- //Point pt3;
- // double v3 = luffy_math::getMinMaxData(imgMatchRet, luffy_math::emDataMax, &pt3);
float nPos = m_posIndex + detectedOffset.at(m_index) - nOffset - imgTemplate.cols / 2.0;
paramOut.dAngle = fmod(nPos, (double)paramIn.nMaxAngle);
- //paramOut.dScore = disVal;
paramOut.dScore = maxVal / 100.0;
}
- //}
}
else {
qDebug() << "bar check is failed";
@@ -1522,7 +1147,6 @@ bool ValveDetector::detect(Mat & imgSrc, InputParam ¶mIn, OutputParam ¶m
paramOut.dScore = 0;
}
}
-
}
if (paramOut.dScore < paramIn.dScoreThres / 100.0 )
@@ -1589,16 +1213,15 @@ void ValveDetector::drawResult(Mat &img, InputParam ¶mIn, OutputParam ¶m
if (paramOut.bIsFind) {
//= paramIn.nMaxAngle ? 0 : paramOut.dAngle;
int tmpX = paramIn.ptCenter.x + paramIn.fValveDis * luffy_base::luffy_triangle::getCos(paramIn.nMaxAngle, angle);
int tmpY = paramIn.ptCenter.y - paramIn.fValveDis * luffy_base::luffy_triangle::getSin(paramIn.nMaxAngle, angle);
@@ -1607,6 +1230,16 @@ void ValveDetector::drawResult(Mat &img, InputParam ¶mIn, OutputParam ¶m
cv::circle(img, ptValve, paramIn.fValveWidth, LP_COLOR_RED, 2);
cv::circle(img, ptValve, 3, LP_COLOR_BLUE, 3);
+ double startAlg = paramIn.nStartOffset*1.0 / 10;
+ double endAlg = angle * 1.0 / 10;
+ if (startAlg < endAlg)
+ {
+ cv::ellipse(img, paramIn.ptCenter, Size(150, 150), 0, 360-startAlg, 360-endAlg,Scalar(255,0,255),2);
+ }
+ else {
+ cv::ellipse(img, paramIn.ptCenter, Size(150, 150), 0, 0, -endAlg, Scalar(255, 0, 255), 2);
+ cv::ellipse(img, paramIn.ptCenter, Size(150, 150), 0, 0, 360-startAlg, Scalar(255, 0, 255), 2);
+ }
}
cv::circle(img, paramIn.ptCenter, 3, LP_COLOR_BLUE, 2);
if (paramIn.nCenterAlg == 1)
@@ -1709,32 +1342,6 @@ cv::Point2f ValveDetector::getCenter(Mat & imgSrc, Point2f pt, InputParam ¶m
return pt;
}
-bool ValveDetector::saveResult(Mat &img, InputParam ¶mIn, OutputParam ¶mOut, QString modelStr)
-{
- return true;
-/* if (0 == paramOut.nErrorType) {
- return true;
- }
- QString strName = "";
- strName += "time" + QDateTime::currentDateTime().toString("yyyy-MM-dd-hh-mm-ss-zzz") + "error=" + QString::number(paramOut.nErrorType);
- strName += ".bmp";
- QString strPath = qApp->applicationDirPath() + "//errorImage//";
- QString str = strPath + modelStr + "\\";
- QDir fileInfo(strPath);
- if (fileInfo.exists())
- {
- QDir errorFile(str);
- if (!errorFile.exists())
- {
- fileInfo.mkdir(str);
- }
- }
- strName = str + strName;
- bool bSave = cv::imwrite(strName.toLocal8Bit().data(), img);
- qDebug() << "save error image:" << bSave;
- return true;*/
-}
-
void ValveDetector::drawToImage(Mat &img, InputParam ¶mIn, OutputParam ¶mOut)
{
if (img.empty())
@@ -1788,7 +1395,6 @@ void ValveDetector::drawToImage(Mat &img, InputParam ¶mIn, OutputParam ¶
cv::circle(img, paramOut.rstPoint, 3, LP_COLOR_BLUE, 3);
}
cv::circle(img, paramIn.ptCenter, 3, LP_COLOR_BLUE, 2);
-
-
-
}
+
+//void ValveDetector::drawAngle()
diff --git a/tpvs17/valveDetector/valveDetector.h b/tpvs17/valveDetector/valveDetector.h
index 100391e..dcb2eb5 100644
--- a/tpvs17/valveDetector/valveDetector.h
+++ b/tpvs17/valveDetector/valveDetector.h
@@ -16,6 +16,7 @@ struct InputParam
int nStartOffset;
float fValveWidth;
float fValveDis;
+ float fStartDis;
Point2f ptCenter;
double dScoreThres;
int nMaxAngle;
@@ -65,7 +66,7 @@ public:
double ruleData(double, int);
QString genResultTip(QString str, int nType);
Point2f getCenterPoints(Mat &_img, const Mat ¢erTempl, InputParam paramIn, Point2f pt, Mat& rstMat);
- bool saveResult(Mat &img, InputParam ¶mIn, OutputParam ¶mOut, QString modelStr);
+ //bool saveResult(Mat &img, InputParam ¶mIn, OutputParam ¶mOut, QString modelStr);
bool isValid(Mat target, Mat templ, Point2f pt, int validThresh);
void drawToImage(Mat &img, InputParam ¶mIn, OutputParam ¶mOut);
cv::Mat findCircleObject(const Mat &src, const Mat& backgroundImg, int nThres = 20, luffy_base::luffyCircle *pCircle = NULL);