实现互斥。
This commit is contained in:
parent
f74081a06a
commit
9ed27e2c37
@ -208,11 +208,12 @@ void Application::verify(bool captureImage, uint8_t timeout) {
|
|||||||
m_verifyExtendedMode = captureImage;
|
m_verifyExtendedMode = captureImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::enroll(const QString &username, bool strictMode, bool persistence, uint8_t timeout) {
|
void Application::enroll(const QString &username, bool strictMode, uint8_t excludeMode, bool persistence,
|
||||||
|
uint8_t timeout) {
|
||||||
if (m_communication->currentMessageId() != ModuleCommunication::Idle) {
|
if (m_communication->currentMessageId() != ModuleCommunication::Idle) {
|
||||||
m_communication->reset();
|
m_communication->reset();
|
||||||
}
|
}
|
||||||
m_communication->enroll(username.toStdString(), strictMode, persistence, timeout);
|
m_communication->enroll(username.toStdString(), strictMode, excludeMode, persistence, timeout);
|
||||||
m_palmUsername = username;
|
m_palmUsername = username;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,11 +231,12 @@ void Application::deleteAll() {
|
|||||||
m_communication->deleteAll();
|
m_communication->deleteAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::enrollExtended(const QString &username, bool strictMode, bool persistence, uint8_t timeout) {
|
void Application::enrollExtended(const QString &username, bool strictMode, uint8_t excludeMode, bool persistence,
|
||||||
|
uint8_t timeout) {
|
||||||
if (m_communication->currentMessageId() != ModuleCommunication::Idle) {
|
if (m_communication->currentMessageId() != ModuleCommunication::Idle) {
|
||||||
m_communication->reset();
|
m_communication->reset();
|
||||||
}
|
}
|
||||||
m_communication->enrollExtended(username.toStdString(), strictMode, persistence, timeout);
|
m_communication->enrollExtended(username.toStdString(), strictMode, excludeMode, persistence, timeout);
|
||||||
m_palmUsername = username;
|
m_palmUsername = username;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,8 +52,10 @@ public:
|
|||||||
Q_INVOKABLE void closeUVC();
|
Q_INVOKABLE void closeUVC();
|
||||||
Q_INVOKABLE bool startOta(const QString &path);
|
Q_INVOKABLE bool startOta(const QString &path);
|
||||||
Q_INVOKABLE void verify(bool captureImage, uint8_t timeout);
|
Q_INVOKABLE void verify(bool captureImage, uint8_t timeout);
|
||||||
Q_INVOKABLE void enroll(const QString &username, bool strictMode, bool persistence, uint8_t timeout);
|
Q_INVOKABLE void enroll(const QString &username, bool strictMode, uint8_t excludeMode, bool persistence,
|
||||||
Q_INVOKABLE void enrollExtended(const QString &username, bool strictMode, bool persistence, uint8_t timeout);
|
uint8_t timeout);
|
||||||
|
Q_INVOKABLE void enrollExtended(const QString &username, bool strictMode, uint8_t excludeMode, bool persistence,
|
||||||
|
uint8_t timeout);
|
||||||
Q_INVOKABLE void deleteUser(uint16_t userid);
|
Q_INVOKABLE void deleteUser(uint16_t userid);
|
||||||
Q_INVOKABLE void deleteAll();
|
Q_INVOKABLE void deleteAll();
|
||||||
Q_INVOKABLE void uploadImage(const QString &path, const QString &username, int operation);
|
Q_INVOKABLE void uploadImage(const QString &path, const QString &username, int operation);
|
||||||
|
@ -70,9 +70,11 @@ void ModuleCommunication::reset() {
|
|||||||
LOG_CAT(info, GUI) << Separator;
|
LOG_CAT(info, GUI) << Separator;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModuleCommunication::enroll(const std::string &username, bool strictMode, bool persistence, uint8_t timeout) {
|
void ModuleCommunication::enroll(const std::string &username, bool strictMode, uint8_t excludeMode, bool persistence,
|
||||||
EnrollData data = {0};
|
uint8_t timeout) {
|
||||||
|
EnrollRequest data = {0};
|
||||||
data.strictMode = strictMode ? 1 : 0;
|
data.strictMode = strictMode ? 1 : 0;
|
||||||
|
data.excludeMode = excludeMode;
|
||||||
data.timeout = timeout;
|
data.timeout = timeout;
|
||||||
data.skipSave = persistence ? 0 : 1;
|
data.skipSave = persistence ? 0 : 1;
|
||||||
strncpy(reinterpret_cast<char *>(data.username), username.c_str(), sizeof(data.username));
|
strncpy(reinterpret_cast<char *>(data.username), username.c_str(), sizeof(data.username));
|
||||||
@ -85,10 +87,11 @@ void ModuleCommunication::enroll(const std::string &username, bool strictMode, b
|
|||||||
LOG_CAT(info, GUI) << Separator;
|
LOG_CAT(info, GUI) << Separator;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModuleCommunication::enrollExtended(const std::string &username, bool strictMode, bool persistence,
|
void ModuleCommunication::enrollExtended(const std::string &username, bool strictMode, uint8_t excludeMode,
|
||||||
uint8_t timeout) {
|
bool persistence, uint8_t timeout) {
|
||||||
EnrollData data = {};
|
EnrollRequest data = {};
|
||||||
data.strictMode = strictMode ? 1 : 0;
|
data.strictMode = strictMode ? 1 : 0;
|
||||||
|
data.excludeMode = excludeMode;
|
||||||
data.timeout = timeout;
|
data.timeout = timeout;
|
||||||
data.skipSave = persistence ? 0 : 1;
|
data.skipSave = persistence ? 0 : 1;
|
||||||
strncpy(reinterpret_cast<char *>(data.username), username.c_str(), sizeof(data.username));
|
strncpy(reinterpret_cast<char *>(data.username), username.c_str(), sizeof(data.username));
|
||||||
@ -251,10 +254,13 @@ void ModuleCommunication::processPackage(const uint8_t *data, uint16_t size) {
|
|||||||
uint16_t userId = InvalidUserId;
|
uint16_t userId = InvalidUserId;
|
||||||
if (replyId == EnrollExtended) {
|
if (replyId == EnrollExtended) {
|
||||||
auto info = reinterpret_cast<const EnrollExtendedReply *>(data + 7);
|
auto info = reinterpret_cast<const EnrollExtendedReply *>(data + 7);
|
||||||
uint16_t width = ntohs(info->image_width);
|
uint16_t width = ntohs(info->imageWidth);
|
||||||
uint16_t height = ntohs(info->image_height);
|
uint16_t height = ntohs(info->imageHeight);
|
||||||
userId = ntohs(info->userid);
|
userId = ntohs(info->userid);
|
||||||
LOG_CAT(info, GUI) << "注册成功,用户ID: " << userId << ", 图片大小: " << width << "x" << height;
|
LOG_CAT(info, GUI) << "注册成功,用户ID: " << userId << ", 图片大小: " << width << "x" << height
|
||||||
|
<< ", 已有ID: " << ntohs(info->enrolledId)
|
||||||
|
<< ", 姓名: " << (const char *)info->enrolledUsername;
|
||||||
|
|
||||||
emit newImageInfo(static_cast<MessageId>(replyId), width * height, info->md5);
|
emit newImageInfo(static_cast<MessageId>(replyId), width * height, info->md5);
|
||||||
} else {
|
} else {
|
||||||
auto info = reinterpret_cast<const EnrollReply *>(data + 7);
|
auto info = reinterpret_cast<const EnrollReply *>(data + 7);
|
||||||
@ -263,7 +269,11 @@ void ModuleCommunication::processPackage(const uint8_t *data, uint16_t size) {
|
|||||||
}
|
}
|
||||||
emit newEnrollResult(userId);
|
emit newEnrollResult(userId);
|
||||||
} else if (result == Failed4Timeout) {
|
} else if (result == Failed4Timeout) {
|
||||||
LOG_CAT(info, GUI) << "识别超时。";
|
LOG_CAT(info, GUI) << "录入超时。";
|
||||||
|
emit errorOccurred(NoteId::InteractWarning, "录入", "录入超时");
|
||||||
|
} else if (result == Failed4PalmEnrolled) {
|
||||||
|
emit errorOccurred(NoteId::InteractWarning, "手掌已被录入");
|
||||||
|
LOG_CAT(info, GUI) << "手掌已被录入。";
|
||||||
} else {
|
} else {
|
||||||
LOG_CAT(info, GUI) << "未知错误(" << static_cast<int>(result) << ")。";
|
LOG_CAT(info, GUI) << "未知错误(" << static_cast<int>(result) << ")。";
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ public:
|
|||||||
Failed4NoMemory = 7,
|
Failed4NoMemory = 7,
|
||||||
Failed4UnknownUser = 8,
|
Failed4UnknownUser = 8,
|
||||||
Failed4MaxUser = 9,
|
Failed4MaxUser = 9,
|
||||||
Failed4FaceEnrolled = 10,
|
Failed4PalmEnrolled = 10,
|
||||||
Failed4LivenessCheck = 12,
|
Failed4LivenessCheck = 12,
|
||||||
Failed4Timeout = 13,
|
Failed4Timeout = 13,
|
||||||
Failed4Authorization = 14,
|
Failed4Authorization = 14,
|
||||||
@ -97,11 +97,13 @@ public:
|
|||||||
uint16_t bottom;
|
uint16_t bottom;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct EnrollData {
|
struct EnrollRequest {
|
||||||
uint8_t username[32];
|
uint8_t username[32];
|
||||||
uint8_t strictMode = 0;
|
uint8_t strictMode = 0;
|
||||||
|
uint8_t excludeMode = 0; // 掌静脉库里面是否已经存在 0:不进行验证 1:只进行比对 2:如果存在,则现在不予录入
|
||||||
uint8_t skipSave = 0;
|
uint8_t skipSave = 0;
|
||||||
uint8_t timeout;
|
uint8_t timeout;
|
||||||
|
uint8_t reserved[4];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct EnrollReply {
|
struct EnrollReply {
|
||||||
@ -111,10 +113,13 @@ public:
|
|||||||
|
|
||||||
struct EnrollExtendedReply {
|
struct EnrollExtendedReply {
|
||||||
uint16_t userid;
|
uint16_t userid;
|
||||||
uint16_t image_width;
|
uint16_t imageWidth;
|
||||||
uint16_t image_height;
|
uint16_t imageHeight;
|
||||||
uint8_t image_format; // 0: 只有Y分量,灰度图
|
uint8_t imageFormat; // 0: 只有Y分量,灰度图
|
||||||
uint8_t md5[16];
|
uint8_t md5[16];
|
||||||
|
uint8_t enrolledUsername[32];
|
||||||
|
uint16_t enrolledId; // 掌静脉库里已经存在的id
|
||||||
|
uint8_t reserved[4];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ImageSliceRequest {
|
struct ImageSliceRequest {
|
||||||
@ -178,8 +183,9 @@ public:
|
|||||||
void verifyExtended(bool captureImage, uint8_t timeout);
|
void verifyExtended(bool captureImage, uint8_t timeout);
|
||||||
Q_INVOKABLE void reset();
|
Q_INVOKABLE void reset();
|
||||||
|
|
||||||
void enroll(const std::string &username, bool strictMode, bool persistence, uint8_t timeout);
|
void enroll(const std::string &username, bool strictMode, uint8_t excludeMode, bool persistence, uint8_t timeout);
|
||||||
void enrollExtended(const std::string &username, bool strictMode, bool persistence, uint8_t timeout);
|
void enrollExtended(const std::string &username, bool strictMode, uint8_t excludeMode, bool persistence,
|
||||||
|
uint8_t timeout);
|
||||||
Q_INVOKABLE void deleteUser(uint16_t userid);
|
Q_INVOKABLE void deleteUser(uint16_t userid);
|
||||||
Q_INVOKABLE void deleteAll();
|
Q_INVOKABLE void deleteAll();
|
||||||
Q_INVOKABLE void requestUniqueId();
|
Q_INVOKABLE void requestUniqueId();
|
||||||
|
@ -13,7 +13,7 @@ Window {
|
|||||||
|
|
||||||
OperationItem {
|
OperationItem {
|
||||||
id: operationItem
|
id: operationItem
|
||||||
width: 510
|
width: 530
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,6 +45,13 @@ Item {
|
|||||||
Switch {
|
Switch {
|
||||||
id: strictMode
|
id: strictMode
|
||||||
}
|
}
|
||||||
|
Label {
|
||||||
|
text: qsTr("互斥模式")
|
||||||
|
}
|
||||||
|
ComboBox {
|
||||||
|
id: excludeMode
|
||||||
|
model: ["无","仅比对","互斥"]
|
||||||
|
}
|
||||||
Label {
|
Label {
|
||||||
text: qsTr("超时时间")
|
text: qsTr("超时时间")
|
||||||
}
|
}
|
||||||
@ -76,9 +83,9 @@ Item {
|
|||||||
if (enrolling) {
|
if (enrolling) {
|
||||||
App.module.reset()
|
App.module.reset()
|
||||||
} else if (extendedMode.checked) {
|
} else if (extendedMode.checked) {
|
||||||
App.enrollExtended(enrollName.text, strictMode.checked, persistence.checked, parseInt(enrollTimeout.text))
|
App.enrollExtended(enrollName.text, strictMode.checked, excludeMode.currentIndex, persistence.checked, parseInt(enrollTimeout.text))
|
||||||
} else {
|
} else {
|
||||||
App.enroll(enrollName.text, strictMode.checked, persistence.checked, parseInt(enrollTimeout.text))
|
App.enroll(enrollName.text, strictMode.checked, excludeMode.currentIndex, persistence.checked, parseInt(enrollTimeout.text))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
cmake_minimum_required(VERSION 3.29)
|
cmake_minimum_required(VERSION 3.29)
|
||||||
|
|
||||||
project(SmartLockerTools VERSION 0.1 LANGUAGES C CXX)
|
project(SmartLockerTools VERSION 0.2 LANGUAGES C CXX)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
@ -61,7 +61,7 @@ HOST_TOOLS := /opt/Xuantie-900-gcc-elf-newlib-x86_64-V2.6.1/bin
|
|||||||
|
|
||||||
# 编译OTA固件,11为OTA版本号,这个版本号只做固件文件名显示。
|
# 编译OTA固件,11为OTA版本号,这个版本号只做固件文件名显示。
|
||||||
# 实际的版本设置在 cv181x_alios/solutions/smart_doorbell/package.yaml.L015_V200R002
|
# 实际的版本设置在 cv181x_alios/solutions/smart_doorbell/package.yaml.L015_V200R002
|
||||||
./rebuild-app-ota.sh y L015 V200 R002 03
|
./rebuild-app-ota.sh y L015 V200 R002 04
|
||||||
600X800
|
600X800
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user