同步代码/

This commit is contained in:
luocai 2024-09-25 17:09:00 +08:00
parent 699a9150c0
commit 1731ea445f
4 changed files with 44 additions and 2 deletions

View File

@ -30,6 +30,7 @@ qt_add_qml_module(Analyser
RESOURCES RESOURCES
resources/successfull.svg resources/successfull.svg
resources/warning.svg resources/warning.svg
resources/palm-middle.png
) )
target_compile_definitions(Analyser target_compile_definitions(Analyser

View File

@ -1,6 +1,8 @@
#include "ModuleCommunication.h" #include "ModuleCommunication.h"
#include "BoostLog.h" #include "BoostLog.h"
#include "StringUtility.h" #include "StringUtility.h"
#include <boost/describe.hpp>
#include <boost/mp11.hpp>
#include <mbedtls/md5.h> #include <mbedtls/md5.h>
#include <sstream> #include <sstream>
#ifdef WIN32 #ifdef WIN32
@ -257,9 +259,16 @@ void ModuleCommunication::processPackage(const uint8_t *data, uint16_t size) {
uint16_t width = ntohs(info->imageWidth); uint16_t width = ntohs(info->imageWidth);
uint16_t height = ntohs(info->imageHeight); uint16_t height = ntohs(info->imageHeight);
userId = ntohs(info->userid); userId = ntohs(info->userid);
uint16_t plamX = ntohs(info->palmVeinInformation.x1);
uint16_t plamY = ntohs(info->palmVeinInformation.y1);
LOG_CAT(info, GUI) << "注册成功,用户ID: " << userId << ", 图片大小: " << width << "x" << height LOG_CAT(info, GUI) << "注册成功,用户ID: " << userId << ", 图片大小: " << width << "x" << height
<< ", 已有ID: " << ntohs(info->enrolledId) << ", 已有ID: " << ntohs(info->enrolledId)
<< ", 姓名: " << (const char *)info->enrolledUsername; << ", 姓名: " << (const char *)info->enrolledUsername << ". palm vein: ("
<< plamX << "," << plamY << " " << (ntohs(info->palmVeinInformation.x2) - plamX)
<< "x" << (ntohs(info->palmVeinInformation.y2) - plamY)
<< "), detection probability: "
<< ntohs(info->palmVeinInformation.detectionProbability) / 1000.f
<< ", quality: " << ntohs(info->palmVeinInformation.quality) / 1000.f;
emit newImageInfo(static_cast<MessageId>(replyId), width * height, info->md5); emit newImageInfo(static_cast<MessageId>(replyId), width * height, info->md5);
} else { } else {
@ -388,11 +397,15 @@ void ModuleCommunication::processPackage(const uint8_t *data, uint16_t size) {
} }
case NoteId::PalmState: { // 模组返回的数据为当前帧的手掌状态 case NoteId::PalmState: { // 模组返回的数据为当前帧的手掌状态
auto state = reinterpret_cast<const PalmStateNote *>(data + 6); auto state = reinterpret_cast<const PalmStateNote *>(data + 6);
uint16_t palmState = ntohs(state->state); PalmState palmState = static_cast<PalmState>(ntohs(state->state));
if (palmState == NeedMoveToCenter) { if (palmState == NeedMoveToCenter) {
emit errorOccurred(NoteId::InteractWarning, "录入提示", "请将手掌置于画面中心"); emit errorOccurred(NoteId::InteractWarning, "录入提示", "请将手掌置于画面中心");
} else if (palmState == TooFar) { } else if (palmState == TooFar) {
emit errorOccurred(NoteId::InteractWarning, "录入提示", "请将手掌靠近一点"); emit errorOccurred(NoteId::InteractWarning, "录入提示", "请将手掌靠近一点");
} else if (palmState == ManyPalm) {
emit errorOccurred(NoteId::InteractWarning, "录入提示", "检测到多个手掌");
} else if (palmState == NoAlive) {
emit errorOccurred(NoteId::InteractWarning, "录入提示", "活体检测未通过");
} }
LOG(info) << "palm state: " << palmState; LOG(info) << "palm state: " << palmState;
break; break;
@ -504,3 +517,15 @@ std::string ModuleCommunication::protocolDataFormatString(const uint8_t *data, i
} }
return oss.str(); return oss.str();
} }
BOOST_DESCRIBE_ENUM(ModuleCommunication::PalmState, NoPalm, TooFar, NeedMoveToCenter, ManyPalm, NoAlive)
namespace std {
std::ostream &operator<<(std::ostream &stream, const ModuleCommunication::PalmState &element) {
char const *r = "(unnamed)";
boost::mp11::mp_for_each<boost::describe::describe_enumerators<ModuleCommunication::PalmState>>([&](auto D) {
if (element == D.value) r = D.name;
});
stream << r << "(" << static_cast<int>(element) << ")";
return stream;
}
} // namespace std

View File

@ -59,6 +59,7 @@ public:
NoPalm = 1, NoPalm = 1,
TooFar = 6, TooFar = 6,
NeedMoveToCenter = 15, NeedMoveToCenter = 15,
ManyPalm = 101, // 太多掌静脉
NoAlive = 122, NoAlive = 122,
}; };
@ -112,6 +113,15 @@ public:
uint8_t operation; uint8_t operation;
}; };
struct PalmVeinInformation {
uint16_t x1;
uint16_t y1;
uint16_t x2;
uint16_t y2;
uint16_t detectionProbability;
uint16_t quality;
};
struct EnrollExtendedReply { struct EnrollExtendedReply {
uint16_t userid; uint16_t userid;
uint16_t imageWidth; uint16_t imageWidth;
@ -120,6 +130,7 @@ public:
uint8_t md5[16]; uint8_t md5[16];
uint8_t enrolledUsername[32]; uint8_t enrolledUsername[32];
uint16_t enrolledId; // 掌静脉库里已经存在的id uint16_t enrolledId; // 掌静脉库里已经存在的id
PalmVeinInformation palmVeinInformation;
uint8_t reserved[4]; uint8_t reserved[4];
}; };
@ -144,6 +155,7 @@ public:
uint16_t image_height; uint16_t image_height;
uint8_t image_format; // 0: 只有Y分量,灰度图 uint8_t image_format; // 0: 只有Y分量,灰度图
uint8_t md5[16]; uint8_t md5[16];
PalmVeinInformation palmVeinInformation;
}; };
struct UploadImageInformation { struct UploadImageInformation {
@ -234,4 +246,8 @@ private:
int m_otaVerison; int m_otaVerison;
}; };
namespace std {
std::ostream &operator<<(std::ostream &stream, const ModuleCommunication::PalmState &element);
} // namespace std
#endif // MODULECOMMUNICATION_H #endif // MODULECOMMUNICATION_H

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB