From 9ed27e2c37961179938e88fb642e10a6b81cd382 Mon Sep 17 00:00:00 2001 From: luocai Date: Wed, 11 Sep 2024 15:45:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E4=BA=92=E6=96=A5=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Analyser/Application.cpp | 10 ++++++---- Analyser/Application.h | 6 ++++-- Analyser/ModuleCommunication.cpp | 28 +++++++++++++++++++--------- Analyser/ModuleCommunication.h | 20 +++++++++++++------- Analyser/qml/Main.qml | 2 +- Analyser/qml/OperationItem.qml | 11 +++++++++-- CMakeLists.txt | 2 +- Readme.md | 2 +- 8 files changed, 54 insertions(+), 27 deletions(-) diff --git a/Analyser/Application.cpp b/Analyser/Application.cpp index 585dede..5c3a02a 100644 --- a/Analyser/Application.cpp +++ b/Analyser/Application.cpp @@ -208,11 +208,12 @@ void Application::verify(bool captureImage, uint8_t timeout) { 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) { m_communication->reset(); } - m_communication->enroll(username.toStdString(), strictMode, persistence, timeout); + m_communication->enroll(username.toStdString(), strictMode, excludeMode, persistence, timeout); m_palmUsername = username; } @@ -230,11 +231,12 @@ void Application::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) { m_communication->reset(); } - m_communication->enrollExtended(username.toStdString(), strictMode, persistence, timeout); + m_communication->enrollExtended(username.toStdString(), strictMode, excludeMode, persistence, timeout); m_palmUsername = username; } diff --git a/Analyser/Application.h b/Analyser/Application.h index 31242d2..bc502b9 100644 --- a/Analyser/Application.h +++ b/Analyser/Application.h @@ -52,8 +52,10 @@ public: Q_INVOKABLE void closeUVC(); Q_INVOKABLE bool startOta(const QString &path); 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 enrollExtended(const QString &username, bool strictMode, bool persistence, uint8_t timeout); + Q_INVOKABLE void enroll(const QString &username, bool strictMode, uint8_t excludeMode, bool persistence, + 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 deleteAll(); Q_INVOKABLE void uploadImage(const QString &path, const QString &username, int operation); diff --git a/Analyser/ModuleCommunication.cpp b/Analyser/ModuleCommunication.cpp index 82f1311..a64e3ed 100644 --- a/Analyser/ModuleCommunication.cpp +++ b/Analyser/ModuleCommunication.cpp @@ -70,9 +70,11 @@ void ModuleCommunication::reset() { LOG_CAT(info, GUI) << Separator; } -void ModuleCommunication::enroll(const std::string &username, bool strictMode, bool persistence, uint8_t timeout) { - EnrollData data = {0}; +void ModuleCommunication::enroll(const std::string &username, bool strictMode, uint8_t excludeMode, bool persistence, + uint8_t timeout) { + EnrollRequest data = {0}; data.strictMode = strictMode ? 1 : 0; + data.excludeMode = excludeMode; data.timeout = timeout; data.skipSave = persistence ? 0 : 1; strncpy(reinterpret_cast(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; } -void ModuleCommunication::enrollExtended(const std::string &username, bool strictMode, bool persistence, - uint8_t timeout) { - EnrollData data = {}; +void ModuleCommunication::enrollExtended(const std::string &username, bool strictMode, uint8_t excludeMode, + bool persistence, uint8_t timeout) { + EnrollRequest data = {}; data.strictMode = strictMode ? 1 : 0; + data.excludeMode = excludeMode; data.timeout = timeout; data.skipSave = persistence ? 0 : 1; strncpy(reinterpret_cast(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; if (replyId == EnrollExtended) { auto info = reinterpret_cast(data + 7); - uint16_t width = ntohs(info->image_width); - uint16_t height = ntohs(info->image_height); + uint16_t width = ntohs(info->imageWidth); + uint16_t height = ntohs(info->imageHeight); 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(replyId), width * height, info->md5); } else { auto info = reinterpret_cast(data + 7); @@ -263,7 +269,11 @@ void ModuleCommunication::processPackage(const uint8_t *data, uint16_t size) { } emit newEnrollResult(userId); } 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 { LOG_CAT(info, GUI) << "未知错误(" << static_cast(result) << ")。"; } diff --git a/Analyser/ModuleCommunication.h b/Analyser/ModuleCommunication.h index 0d7c06e..8fc88e8 100644 --- a/Analyser/ModuleCommunication.h +++ b/Analyser/ModuleCommunication.h @@ -71,7 +71,7 @@ public: Failed4NoMemory = 7, Failed4UnknownUser = 8, Failed4MaxUser = 9, - Failed4FaceEnrolled = 10, + Failed4PalmEnrolled = 10, Failed4LivenessCheck = 12, Failed4Timeout = 13, Failed4Authorization = 14, @@ -97,11 +97,13 @@ public: uint16_t bottom; }; - struct EnrollData { + struct EnrollRequest { uint8_t username[32]; uint8_t strictMode = 0; + uint8_t excludeMode = 0; // 掌静脉库里面是否已经存在 0:不进行验证 1:只进行比对 2:如果存在,则现在不予录入 uint8_t skipSave = 0; uint8_t timeout; + uint8_t reserved[4]; }; struct EnrollReply { @@ -111,10 +113,13 @@ public: struct EnrollExtendedReply { uint16_t userid; - uint16_t image_width; - uint16_t image_height; - uint8_t image_format; // 0: 只有Y分量,灰度图 + uint16_t imageWidth; + uint16_t imageHeight; + uint8_t imageFormat; // 0: 只有Y分量,灰度图 uint8_t md5[16]; + uint8_t enrolledUsername[32]; + uint16_t enrolledId; // 掌静脉库里已经存在的id + uint8_t reserved[4]; }; struct ImageSliceRequest { @@ -178,8 +183,9 @@ public: void verifyExtended(bool captureImage, uint8_t timeout); Q_INVOKABLE void reset(); - void enroll(const std::string &username, bool strictMode, bool persistence, uint8_t timeout); - void enrollExtended(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, uint8_t excludeMode, bool persistence, + uint8_t timeout); Q_INVOKABLE void deleteUser(uint16_t userid); Q_INVOKABLE void deleteAll(); Q_INVOKABLE void requestUniqueId(); diff --git a/Analyser/qml/Main.qml b/Analyser/qml/Main.qml index 8df45bb..294358e 100644 --- a/Analyser/qml/Main.qml +++ b/Analyser/qml/Main.qml @@ -13,7 +13,7 @@ Window { OperationItem { id: operationItem - width: 510 + width: 530 anchors.top: parent.top } diff --git a/Analyser/qml/OperationItem.qml b/Analyser/qml/OperationItem.qml index 5db15d4..a060ed6 100644 --- a/Analyser/qml/OperationItem.qml +++ b/Analyser/qml/OperationItem.qml @@ -45,6 +45,13 @@ Item { Switch { id: strictMode } + Label { + text: qsTr("互斥模式") + } + ComboBox { + id: excludeMode + model: ["无","仅比对","互斥"] + } Label { text: qsTr("超时时间") } @@ -76,9 +83,9 @@ Item { if (enrolling) { App.module.reset() } 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 { - App.enroll(enrollName.text, strictMode.checked, persistence.checked, parseInt(enrollTimeout.text)) + App.enroll(enrollName.text, strictMode.checked, excludeMode.currentIndex, persistence.checked, parseInt(enrollTimeout.text)) } } } diff --git a/CMakeLists.txt b/CMakeLists.txt index bfc8497..b99e7bc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ 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_REQUIRED ON) diff --git a/Readme.md b/Readme.md index f3c3777..a90a399 100644 --- a/Readme.md +++ b/Readme.md @@ -61,7 +61,7 @@ HOST_TOOLS := /opt/Xuantie-900-gcc-elf-newlib-x86_64-V2.6.1/bin # 编译OTA固件,11为OTA版本号,这个版本号只做固件文件名显示。 # 实际的版本设置在 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 ```