1.添加特征值model。
This commit is contained in:
@ -9,6 +9,7 @@ add_executable(Analyser Analyser.rc
|
||||
CategoryLogSinkBackend.h CategoryLogSinkBackend.cpp
|
||||
Widget.h Widget.cpp
|
||||
ModuleCommunication.h ModuleCommunication.cpp
|
||||
PalmFeatureTableModel.h PalmFeatureTableModel.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(Analyser
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef MODULECOMMUNICATION_H
|
||||
#define MODULECOMMUNICATION_H
|
||||
|
||||
#include "Database.h"
|
||||
#include "DataStructure.h"
|
||||
#include <QObject>
|
||||
#include <memory>
|
||||
|
||||
|
17
Analyser/PalmFeatureTableModel.cpp
Normal file
17
Analyser/PalmFeatureTableModel.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
#include "PalmFeatureTableModel.h"
|
||||
|
||||
PalmFeatureTableModel::PalmFeatureTableModel(QObject *parent) {
|
||||
}
|
||||
|
||||
int PalmFeatureTableModel::rowCount(const QModelIndex &parent) const {
|
||||
return static_cast<int>(m_features.size());
|
||||
}
|
||||
|
||||
int PalmFeatureTableModel::columnCount(const QModelIndex &parent) const {
|
||||
return 2;
|
||||
}
|
||||
|
||||
QVariant PalmFeatureTableModel::data(const QModelIndex &index, int role) const {
|
||||
QVariant ret;
|
||||
return ret;
|
||||
}
|
19
Analyser/PalmFeatureTableModel.h
Normal file
19
Analyser/PalmFeatureTableModel.h
Normal file
@ -0,0 +1,19 @@
|
||||
#ifndef __PALMFEATURETABLEMODEL_H__
|
||||
#define __PALMFEATURETABLEMODEL_H__
|
||||
|
||||
#include "DataStructure.h"
|
||||
#include <QAbstractTableModel>
|
||||
|
||||
class PalmFeatureTableModel : public QAbstractTableModel {
|
||||
Q_OBJECT
|
||||
public:
|
||||
PalmFeatureTableModel(QObject *parent = nullptr);
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const final;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const final;
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const final;
|
||||
|
||||
private:
|
||||
PalmFeatures m_features;
|
||||
};
|
||||
|
||||
#endif // __PALMFEATURETABLEMODEL_H__
|
@ -1,7 +1,9 @@
|
||||
#include "Widget.h"
|
||||
#include "BoostLog.h"
|
||||
#include "CategoryLogSinkBackend.h"
|
||||
#include "Database.h"
|
||||
#include "ModuleCommunication.h"
|
||||
#include "PalmFeatureTableModel.h"
|
||||
#include <QComboBox>
|
||||
#include <QFormLayout>
|
||||
#include <QGridLayout>
|
||||
@ -11,6 +13,7 @@
|
||||
#include <QPushButton>
|
||||
#include <QSerialPortInfo>
|
||||
#include <QTabWidget>
|
||||
#include <QTableView>
|
||||
#include <QTextBrowser>
|
||||
#include <QTimer>
|
||||
#include <QVBoxLayout>
|
||||
@ -51,10 +54,12 @@ Widget::Widget(QWidget *parent) : QWidget{parent} {
|
||||
connect(btn, &QPushButton::clicked, this, &Widget::onClearLogButtonClicked);
|
||||
logLayout->addWidget(btn, 0, Qt::AlignBottom | Qt::AlignRight);
|
||||
|
||||
m_featureTableView = new QTableView();
|
||||
|
||||
auto tabWidget = new QTabWidget();
|
||||
tabWidget->addTab(m_logBrowser, "日志");
|
||||
tabWidget->addTab(new QWidget(), "视频流");
|
||||
tabWidget->addTab(new QWidget(), "已注册列表");
|
||||
tabWidget->addTab(m_featureTableView, "本地特征值列表");
|
||||
|
||||
m_commandGroupBox = initializeCommandGroupBox();
|
||||
|
||||
@ -68,6 +73,8 @@ Widget::Widget(QWidget *parent) : QWidget{parent} {
|
||||
layout->addWidget(tabWidget, 3);
|
||||
|
||||
m_database = std::make_shared<Database>();
|
||||
m_featureModel = new PalmFeatureTableModel(this);
|
||||
m_featureTableView->setModel(m_featureModel);
|
||||
|
||||
QTimer::singleShot(0, this, [this]() {
|
||||
onSerialRefreshButtonClicked();
|
||||
@ -194,14 +201,14 @@ QGroupBox *Widget::initializeUvcGroupBox() {
|
||||
}
|
||||
|
||||
void Widget::onNewPalmFeature(const PalmFeature &feature) {
|
||||
auto palms = m_database->palmFeatures();
|
||||
if (std::find(palms.cbegin(), palms.cend(), feature) != palms.cend()) {
|
||||
LOG(warning) << "本地数据库已有相同特征数据。";
|
||||
return;
|
||||
}
|
||||
if (!m_database->addPalmFeature(feature)) {
|
||||
LOG(error) << "add palm feature failed.";
|
||||
}
|
||||
|
||||
auto palms = m_database->palmFeatures();
|
||||
for (auto &p : palms) {
|
||||
LOG(info) << p.id << " " << p.username << " " << p.feature.size();
|
||||
}
|
||||
}
|
||||
|
||||
void Widget::onSerialConnectButtonClicked() {
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef WIDGET_H
|
||||
#define WIDGET_H
|
||||
|
||||
#include "Database.h"
|
||||
#include "DataStructure.h"
|
||||
#include <QWidget>
|
||||
|
||||
class QPushButton;
|
||||
@ -9,7 +9,10 @@ class QTextBrowser;
|
||||
class QComboBox;
|
||||
class QLineEdit;
|
||||
class QGroupBox;
|
||||
class QTableView;
|
||||
class ModuleCommunication;
|
||||
class PalmFeatureTableModel;
|
||||
class Database;
|
||||
|
||||
class Widget : public QWidget {
|
||||
Q_OBJECT
|
||||
@ -63,6 +66,9 @@ private:
|
||||
|
||||
std::shared_ptr<ModuleCommunication> m_communication;
|
||||
std::shared_ptr<Database> m_database;
|
||||
|
||||
PalmFeatureTableModel *m_featureModel = nullptr;
|
||||
QTableView *m_featureTableView = nullptr;
|
||||
};
|
||||
|
||||
#endif // WIDGET_H
|
||||
|
Reference in New Issue
Block a user