1.添加特征值model。
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
add_library(Database
|
||||
Database.h Database.cpp
|
||||
DataStructure.h DataStructure.cpp
|
||||
# shell.c
|
||||
sqlite3.h sqlite3.c
|
||||
sqlite3ext.h
|
||||
|
5
Database/DataStructure.cpp
Normal file
5
Database/DataStructure.cpp
Normal file
@ -0,0 +1,5 @@
|
||||
#include "DataStructure.h"
|
||||
|
||||
bool operator==(const PalmFeature &lhs, const PalmFeature &rhs) {
|
||||
return lhs.feature == rhs.feature;
|
||||
}
|
23
Database/DataStructure.h
Normal file
23
Database/DataStructure.h
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef __DATASTRUCTURE_H__
|
||||
#define __DATASTRUCTURE_H__
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class PalmFeature {
|
||||
public:
|
||||
int64_t id; // 对应本地数据库的id
|
||||
std::string username;
|
||||
std::vector<uint8_t> feature;
|
||||
};
|
||||
|
||||
using PalmFeatures = std::vector<PalmFeature>;
|
||||
|
||||
bool operator==(const PalmFeature &lhs, const PalmFeature &rhs);
|
||||
|
||||
namespace std {
|
||||
template <>
|
||||
struct hash<PalmFeature> {};
|
||||
} // namespace std
|
||||
|
||||
#endif // __DATASTRUCTURE_H__
|
@ -23,8 +23,8 @@ bool Database::addPalmFeature(const PalmFeature &palm) {
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<PalmFeature> Database::palmFeatures() const {
|
||||
std::vector<PalmFeature> ret;
|
||||
PalmFeatures Database::palmFeatures() const {
|
||||
PalmFeatures ret;
|
||||
sqlite3_stmt *statement = nullptr;
|
||||
constexpr const char *sql = "SELECT * FROM palm_feature";
|
||||
if (sqlite3_prepare_v2(m_sqlite, sql, -1, &statement, NULL) != SQLITE_OK) {
|
||||
|
@ -1,23 +1,16 @@
|
||||
#ifndef __DATABASE_H__
|
||||
#define __DATABASE_H__
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "DataStructure.h"
|
||||
|
||||
struct sqlite3;
|
||||
|
||||
class PalmFeature {
|
||||
public:
|
||||
int64_t id; // 对应本地数据库的id
|
||||
std::string username;
|
||||
std::vector<uint8_t> feature;
|
||||
};
|
||||
|
||||
class Database{
|
||||
public:
|
||||
bool open(const std::string &path);
|
||||
bool addPalmFeature(const PalmFeature &palm);
|
||||
std::vector<PalmFeature> palmFeatures() const;
|
||||
PalmFeatures palmFeatures() const;
|
||||
|
||||
private:
|
||||
void initializeTables();
|
||||
|
Reference in New Issue
Block a user