Compare commits
No commits in common. "main" and "v0.1.6" have entirely different histories.
2
.gitignore
vendored
2
.gitignore
vendored
@ -11,8 +11,6 @@ UserSettings/
|
||||
*.asmdef
|
||||
*.pdb
|
||||
*.mdb
|
||||
!Samples/**/*.cs
|
||||
!Samples/**/*.asmdef
|
||||
!Samples~/**/*.cs
|
||||
!Samples~/**/*.asmdef
|
||||
|
||||
|
||||
20
CHANGELOG.md
20
CHANGELOG.md
@ -1,19 +1,5 @@
|
||||
# Changelog
|
||||
|
||||
## 0.1.8
|
||||
|
||||
- Added detailed API documentation for result codes, face state codes, module statuses, directions, image DPI, feature types, bio types, configuration enums, model fields, license statuses, and license features.
|
||||
- Added configuration documentation for auto-verify exclusive command policies and runtime status code entry points.
|
||||
- Updated `FaceModuleManager.Instance` to lazily create and open the manager during Play Mode.
|
||||
- Added read-only `FaceModuleManager` Inspector config display and an Editor menu for creating or selecting the scene manager.
|
||||
|
||||
## 0.1.7
|
||||
|
||||
- Fixed Unity runtime license binding so cached application parameters are used safely outside the Unity main thread.
|
||||
- Fixed auto verify stop flow and shutdown handling so hardware receives explicit auto verify off, face reset, and reset commands before the serial port is closed.
|
||||
- Added `Shutdown()` and `ShutdownAsync()` lifecycle APIs and callback adapter support for closing all hardware states.
|
||||
- Fixed SDK error logging so the debug log switch also suppresses SDK error logs and dispatcher callback errors.
|
||||
|
||||
## 0.1.6
|
||||
|
||||
- Added `FaceModuleManager` singleton lifecycle validation.
|
||||
@ -22,12 +8,6 @@
|
||||
- Added auto verify configuration fields to `FaceSdkSettings`.
|
||||
- Limited Editor menu entries to Settings and License.
|
||||
- Updated samples to use explicit auto verify start/stop and exclusive operation preparation.
|
||||
- Fixed safe shutdown so `Close()`, `CloseAsync()`, `OnDestroy()`, and `OnApplicationQuit()` stop auto verify and active face operations before closing the serial port.
|
||||
- Added auto verify result dispatch interval configuration.
|
||||
- Added `FaceAutoVerifyControlResult` and aligned high-level result models around `Success` and `ResultCode`.
|
||||
- Updated high-level face verification, enrollment, image, and feature result APIs to return business failure codes instead of throwing for normal module failures.
|
||||
- Removed `FaceReply.IsSuccess` and `FaceReply.Result`; `FaceReply` now only exposes `Success` and `ResultCode`.
|
||||
- Removed Editor Demo generation/copy code and kept Samples as a normal visible `Samples` folder.
|
||||
|
||||
## 0.1.5
|
||||
|
||||
|
||||
@ -2,43 +2,12 @@
|
||||
|
||||
中文说明见 [README_UI.zh-CN.md](README_UI.zh-CN.md).
|
||||
|
||||
## Scenes
|
||||
The public DLL-only UPM package does not include Demo UI source files or importable sample scenes.
|
||||
|
||||
Open `AISU/SI-M1 Face SDK/Settings` and click `Import Demos` before opening demo scenes.
|
||||
Use the SDK from your own Unity scene by creating a `FaceModuleManager` through:
|
||||
|
||||
```text
|
||||
Assets/Samples/AISU SI-M1 Face SDK/SIM1FaceDemo/Scenes/FaceModuleDemo.unity
|
||||
Assets/Samples/AISU SI-M1 Face SDK/FaceDetectionDemo/Scenes/FaceDetectionDemo.unity
|
||||
AISU/SI-M1 Face SDK/Create Manager GameObject
|
||||
```
|
||||
|
||||
## SI-M1 Face Demo
|
||||
|
||||
This scene covers the main SDK commands:
|
||||
|
||||
- Connection and basic status
|
||||
- Protocol debug
|
||||
- Face verification
|
||||
- Face enrollment
|
||||
- User management
|
||||
- QR code
|
||||
- Image capture
|
||||
- Photo and feature enrollment
|
||||
- Feature management
|
||||
- UVC settings
|
||||
- Advanced settings
|
||||
|
||||
## Face Detection Demo
|
||||
|
||||
This scene provides a compact workflow for:
|
||||
|
||||
- Camera enumeration and preview
|
||||
- Serial port selection
|
||||
- Module connection and disconnection
|
||||
- Face enrollment
|
||||
- Face verification
|
||||
- User list refresh and deletion
|
||||
- Operation log display
|
||||
|
||||
## Mock Mode
|
||||
|
||||
Enable `Use Mock In Editor` in `FaceSdkSettings` to test UI flow without real SI-M1 hardware.
|
||||
For Demo UI source, sample scenes, or internal validation tests, use the private development SDK repository.
|
||||
|
||||
@ -2,43 +2,12 @@
|
||||
|
||||
English documentation: [README_UI.md](README_UI.md).
|
||||
|
||||
## 场景
|
||||
公开 DLL-only UPM 包不包含 Demo UI 源码,也不包含可导入的示例场景。
|
||||
|
||||
打开 Demo 场景前,先打开 `AISU/SI-M1 Face SDK/Settings` 并点击 `Import Demos`。
|
||||
请在自己的 Unity 场景中通过以下菜单创建 `FaceModuleManager`:
|
||||
|
||||
```text
|
||||
Assets/Samples/AISU SI-M1 Face SDK/SIM1FaceDemo/Scenes/FaceModuleDemo.unity
|
||||
Assets/Samples/AISU SI-M1 Face SDK/FaceDetectionDemo/Scenes/FaceDetectionDemo.unity
|
||||
AISU/SI-M1 Face SDK/Create Manager GameObject
|
||||
```
|
||||
|
||||
## SI-M1 Face Demo
|
||||
|
||||
该场景覆盖主要 SDK 命令:
|
||||
|
||||
- 连接和基础状态
|
||||
- 协议调试
|
||||
- 人脸验证
|
||||
- 人脸录入
|
||||
- 用户管理
|
||||
- 二维码
|
||||
- 图片抓拍
|
||||
- 照片和特征录入
|
||||
- 特征管理
|
||||
- UVC 设置
|
||||
- 高级设置
|
||||
|
||||
## Face Detection Demo
|
||||
|
||||
该场景提供最小测试流程:
|
||||
|
||||
- 摄像头枚举和预览
|
||||
- 串口选择
|
||||
- 模组连接和断开
|
||||
- 人脸录入
|
||||
- 人脸验证
|
||||
- 用户列表刷新和删除
|
||||
- 操作日志显示
|
||||
|
||||
## Mock 模式
|
||||
|
||||
在 `FaceSdkSettings` 中启用 `Use Mock In Editor`,可以在没有真实 SI-M1 硬件时测试 UI 流程。
|
||||
如需 Demo UI 源码、示例场景或内部验证测试,请使用私有开发 SDK 仓库。
|
||||
|
||||
@ -1,241 +1,181 @@
|
||||
# SI-M1 Face SDK 接口文档
|
||||
# SDK API Reference
|
||||
|
||||
本文列出 SDK 对业务层推荐使用的公开 API。命名空间统一为 `Aisu.SIM1.Face.*`。
|
||||
中文说明见 [SDK_API_Reference.zh-CN.md](SDK_API_Reference.zh-CN.md).
|
||||
|
||||
## 1. 命名空间
|
||||
This document lists the public business-level API exposed by `xin.aisu.si-m1.face`. The package is DLL-only; source files are not included in the public release.
|
||||
|
||||
| 命名空间 | 说明 |
|
||||
## Namespaces
|
||||
|
||||
| Namespace | Description |
|
||||
|---|---|
|
||||
| `Aisu.SIM1.Face.Core` | Manager、配置、回调适配、日志、主线程调度 |
|
||||
| `Aisu.SIM1.Face.Commands` | 业务服务、命令服务、加密接口 |
|
||||
| `Aisu.SIM1.Face.Protocol` | 协议枚举、封包、拆包、编码工具 |
|
||||
| `Aisu.SIM1.Face.Transport` | 通信接口、串口、Mock |
|
||||
| `Aisu.SIM1.Face.Models` | Reply、Note、用户、验证、录入、图片、UVC 等模型 |
|
||||
| `Aisu.SIM1.Face.Core` | Manager, settings, callback adapter, logging, main-thread dispatch |
|
||||
| `Aisu.SIM1.Face.Commands` | Business services, command service, encryption adapter |
|
||||
| `Aisu.SIM1.Face.Protocol` | Protocol enums, packet build/parse helpers, encoding helpers |
|
||||
| `Aisu.SIM1.Face.Transport` | Transport interface, serial transport, mock transport |
|
||||
| `Aisu.SIM1.Face.Models` | Reply, note, user, verification, enrollment, image, and UVC models |
|
||||
|
||||
## 2. FaceModuleManager
|
||||
## FaceModuleManager
|
||||
|
||||
`FaceModuleManager` 是 SDK 推荐的统一入口。
|
||||
Use `FaceModuleManager` as the recommended single entry point:
|
||||
|
||||
```csharp
|
||||
using Aisu.SIM1.Face.Core;
|
||||
```
|
||||
|
||||
### 属性
|
||||
### Properties
|
||||
|
||||
| 属性 | 类型 | 说明 |
|
||||
| Property | Type | Description |
|
||||
|---|---|---|
|
||||
| `Basic` | `FaceBasicService` | 基础命令服务 |
|
||||
| `Verify` | `FaceVerifyService` | 人脸验证服务 |
|
||||
| `Enrollment` | `FaceEnrollmentService` | 人脸录入服务 |
|
||||
| `Users` | `FaceUserService` | 用户管理服务 |
|
||||
| `QrCode` | `FaceQrCodeService` | 二维码服务 |
|
||||
| `Images` | `FaceImageService` | 图片抓拍与照片注册服务 |
|
||||
| `Features` | `FaceFeatureService` | 特征读写服务 |
|
||||
| `Uvc` | `FaceUvcService` | UVC 和高级参数服务 |
|
||||
| `Encryption` | `FaceEncryptionService` | 加密相关服务 |
|
||||
| `Callback` | `FaceModuleCallbackAdapter` | 回调式 API 适配 |
|
||||
| `IsOpen` | `bool` | 通信是否打开 |
|
||||
| `IsReady` | `bool` | 是否收到 READY |
|
||||
| `CurrentStatus` | `FaceModuleStatus` | 当前模组状态 |
|
||||
| `LastError` | `string` | 最近错误文本 |
|
||||
| `CurrentCommand` | `string` | 当前命令名 |
|
||||
| `Config` | `FaceModuleConfig` | 当前运行配置 |
|
||||
| `Settings` | `FaceSdkSettings` | 当前绑定配置资产 |
|
||||
| `Basic` | `FaceBasicService` | Basic module commands |
|
||||
| `Verify` | `FaceVerifyService` | Face verification service |
|
||||
| `Enrollment` | `FaceEnrollmentService` | Face enrollment service |
|
||||
| `Users` | `FaceUserService` | User management service |
|
||||
| `QrCode` | `FaceQrCodeService` | QR code service |
|
||||
| `Images` | `FaceImageService` | Image capture and photo enrollment service |
|
||||
| `Features` | `FaceFeatureService` | Feature read/write service |
|
||||
| `Uvc` | `FaceUvcService` | UVC and advanced parameter service |
|
||||
| `Encryption` | `FaceEncryptionService` | Encryption service |
|
||||
| `Callback` | `FaceModuleCallbackAdapter` | Callback-style API adapter |
|
||||
| `IsOpen` | `bool` | Whether the transport is open |
|
||||
| `IsReady` | `bool` | Whether READY has been received |
|
||||
| `CurrentStatus` | `FaceModuleStatus` | Current module status |
|
||||
| `LastError` | `string` | Latest error message |
|
||||
| `CurrentCommand` | `string` | Current command name |
|
||||
| `Config` | `FaceModuleConfig` | Current runtime config |
|
||||
| `Settings` | `FaceSdkSettings` | Bound settings asset |
|
||||
|
||||
### 方法
|
||||
### Methods
|
||||
|
||||
| 方法 | 说明 |
|
||||
| Method | Description |
|
||||
|---|---|
|
||||
| `ConfigureTransport(IFaceModuleTransport transport)` | 注入自定义通信层 |
|
||||
| `Configure(bool useMockInEditor, string portName, int baudRate)` | 兼容旧代码的快速配置入口 |
|
||||
| `ApplySettings(FaceSdkSettings sdkSettings)` | 应用 ScriptableObject 配置并重建 transport |
|
||||
| `Open()` | 打开通信 |
|
||||
| `Close()` | 同步安全关闭硬件流程并关闭串口 |
|
||||
| `CloseAsync()` | 异步安全关闭硬件流程并关闭串口 |
|
||||
| `StopFaceOperationAsync()` | 停止当前人脸流程,优先关闭自动验证 |
|
||||
| `StartAutoVerifyAsync(byte timeout)` | 开启自动验证,返回开关命令结果 |
|
||||
| `StopAutoVerifyAsync(byte timeout = 1)` | 关闭自动验证,返回开关命令结果 |
|
||||
| `WaitReadyAsync(int timeoutMs = 5000)` | 等待 READY NOTE |
|
||||
| `ProbeReadyByStatusAsync()` | 主动查询状态并标记 READY |
|
||||
| `SendRawBytes(byte[] bytes)` | 发送原始协议 bytes |
|
||||
| `RefreshStatus()` | 异步刷新 `CurrentStatus` |
|
||||
| `ConfigureTransport(IFaceModuleTransport transport)` | Inject a custom transport |
|
||||
| `Configure(bool useMockInEditor, string portName, int baudRate)` | Quick configuration for legacy code |
|
||||
| `ApplySettings(FaceSdkSettings sdkSettings)` | Apply ScriptableObject settings and rebuild transport |
|
||||
| `Open()` | Open transport |
|
||||
| `Close()` | Close transport |
|
||||
| `WaitReadyAsync(int timeoutMs = 5000)` | Wait for READY note |
|
||||
| `ProbeReadyByStatusAsync()` | Query status and mark manager ready |
|
||||
| `SendRawBytes(byte[] bytes)` | Send raw protocol bytes |
|
||||
| `RefreshStatus()` | Asynchronously refresh `CurrentStatus` |
|
||||
|
||||
真实串口运行前会自动校验 SDK 授权。授权文件默认路径:
|
||||
### Events
|
||||
|
||||
```text
|
||||
Assets/StreamingAssets/si-m1_face.dat
|
||||
```
|
||||
|
||||
### 事件
|
||||
|
||||
| 事件 | 说明 |
|
||||
| Event | Description |
|
||||
|---|---|
|
||||
| `OnReady` | 首次 READY |
|
||||
| `OnStatusChanged(FaceModuleStatus)` | 当前状态变化 |
|
||||
| `OnReplyReceived(FaceReply)` | 收到 REPLY 包 |
|
||||
| `OnNoteReceived(FaceNote)` | 收到 NOTE 包 |
|
||||
| `OnFaceStateUpdated(FaceFaceStateNote)` | 收到人脸状态 NOTE |
|
||||
| `OnAutoVerifyResult(FaceAutoVerifyResult)` | 收到自动验证识别结果 NOTE |
|
||||
| `OnQrCodeReceived(string)` | 收到二维码 NOTE |
|
||||
| `OnFeatureReceived(byte[])` | 收到读取特征数据包 |
|
||||
| `OnDataPacketReceived(FacePacket)` | 收到 ImageOrTemplate 数据包 |
|
||||
| `OnError(FaceResultCode, string)` | 错误上报 |
|
||||
| `OnRawLog(string)` | 原始 TX / RX 日志 |
|
||||
| `OnReady` | First READY event |
|
||||
| `OnStatusChanged(FaceModuleStatus)` | Module status changed |
|
||||
| `OnReplyReceived(FaceReply)` | REPLY packet received |
|
||||
| `OnNoteReceived(FaceNote)` | NOTE packet received |
|
||||
| `OnFaceStateUpdated(FaceFaceStateNote)` | Face state NOTE received |
|
||||
| `OnQrCodeReceived(string)` | QR code NOTE received |
|
||||
| `OnFeatureReceived(byte[])` | Feature data packet received |
|
||||
| `OnDataPacketReceived(FacePacket)` | Image/template data packet received |
|
||||
| `OnError(FaceResultCode, string)` | Error reported |
|
||||
| `OnRawLog(string)` | Raw TX/RX log |
|
||||
|
||||
## 3. 基础服务 FaceBasicService
|
||||
## Async Services
|
||||
|
||||
访问路径:
|
||||
### FaceBasicService
|
||||
|
||||
```csharp
|
||||
manager.Basic
|
||||
```
|
||||
Access path: `manager.Basic`
|
||||
|
||||
| 方法 | 返回 | 说明 |
|
||||
| Method | Return | Description |
|
||||
|---|---|---|
|
||||
| `ResetAsync()` | `Task<FaceReply>` | 复位模组 |
|
||||
| `FaceResetAsync()` | `Task<FaceReply>` | 取消当前人脸流程 |
|
||||
| `GetStatusAsync()` | `Task<FaceModuleStatus>` | 获取模组状态 |
|
||||
| `GetVersionAsync()` | `Task<string>` | 获取固件版本 |
|
||||
| `GetSnAsync()` | `Task<string>` | 获取设备序列号 |
|
||||
| `SetDemoModeAsync(bool enable)` | `Task<FaceReply>` | 设置 Demo Mode |
|
||||
| `UpgradeFirmwareAsync()` | `Task<FaceReply>` | 启动固件升级命令 |
|
||||
| `ResetAsync()` | `Task<FaceReply>` | Reset module |
|
||||
| `FaceResetAsync()` | `Task<FaceReply>` | Cancel current face flow |
|
||||
| `GetStatusAsync()` | `Task<FaceModuleStatus>` | Get module status |
|
||||
| `GetVersionAsync()` | `Task<string>` | Get firmware version |
|
||||
| `GetSnAsync()` | `Task<string>` | Get device serial number |
|
||||
| `SetDemoModeAsync(bool enable)` | `Task<FaceReply>` | Set Demo Mode |
|
||||
| `UpgradeFirmwareAsync()` | `Task<FaceReply>` | Start firmware upgrade command |
|
||||
|
||||
## 4. 验证服务 FaceVerifyService
|
||||
### FaceVerifyService
|
||||
|
||||
访问路径:
|
||||
Access path: `manager.Verify`
|
||||
|
||||
```csharp
|
||||
manager.Verify
|
||||
```
|
||||
|
||||
| 方法 | 返回 | 说明 |
|
||||
| Method | Return | Description |
|
||||
|---|---|---|
|
||||
| `VerifyAsync(byte timeout, byte maxRecognitionTimes = 30)` | `Task<FaceVerifyResult>` | 单次人脸验证 |
|
||||
| `AutoVerifyAsync(bool enable, byte timeout)` | `Task<FaceReply>` | 底层自动验证开关命令,只表示开关命令 ACK |
|
||||
| `VerifyAsync(byte timeout, byte maxRecognitionTimes = 30)` | `Task<FaceVerifyResult>` | Run one face verification |
|
||||
| `AutoVerifyAsync(bool enable, byte timeout)` | `Task<FaceVerifyResult>` | Enable or disable automatic verification |
|
||||
|
||||
推荐业务层使用 `FaceModuleManager.StartAutoVerifyAsync()` 和 `FaceModuleManager.StopAutoVerifyAsync()` 控制自动验证,识别结果通过 `OnAutoVerifyResult` 获取。
|
||||
### FaceEnrollmentService
|
||||
|
||||
```csharp
|
||||
var control = await manager.StartAutoVerifyAsync(10);
|
||||
if (control.Success)
|
||||
{
|
||||
manager.OnAutoVerifyResult += result =>
|
||||
{
|
||||
Debug.Log("自动验证结果: " + result.ResultCode);
|
||||
};
|
||||
}
|
||||
```
|
||||
Access path: `manager.Enrollment`
|
||||
|
||||
`StartAutoVerifyAsync()` / `StopAutoVerifyAsync()` 的返回值是 `FaceAutoVerifyControlResult`,表示开启或关闭命令是否成功,不表示识别结果。
|
||||
|
||||
## 5. 录入服务 FaceEnrollmentService
|
||||
|
||||
访问路径:
|
||||
|
||||
```csharp
|
||||
manager.Enrollment
|
||||
```
|
||||
|
||||
| 方法 | 返回 | 说明 |
|
||||
| Method | Return | Description |
|
||||
|---|---|---|
|
||||
| `EnrollAsync(bool admin, string userName, FaceDirection direction, byte timeout)` | `Task<FaceEnrollResult>` | 交互式多方向录入 |
|
||||
| `EnrollSingleAsync(bool admin, string userName, byte timeout)` | `Task<FaceEnrollResult>` | 单帧录入 |
|
||||
| `EnrollIntegratedAsync(bool admin, string userName, FaceDirection direction, byte timeout, bool singleFrame = false, bool duplicateCheck = true)` | `Task<FaceEnrollResult>` | 集成式录入 |
|
||||
| `EnrollSnapFaceImageAsync(bool admin, string userName)` | `Task<FaceEnrollResult>` | 抓拍人脸后注册 |
|
||||
| `EnrollAsync(bool admin, string userName, FaceDirection direction, byte timeout)` | `Task<FaceEnrollResult>` | Interactive multi-direction enrollment |
|
||||
| `EnrollSingleAsync(bool admin, string userName, byte timeout)` | `Task<FaceEnrollResult>` | Single-frame enrollment |
|
||||
| `EnrollIntegratedAsync(bool admin, string userName, FaceDirection direction, byte timeout, bool singleFrame = false, bool duplicateCheck = true)` | `Task<FaceEnrollResult>` | Integrated enrollment |
|
||||
| `EnrollSnapFaceImageAsync(bool admin, string userName)` | `Task<FaceEnrollResult>` | Capture face image and enroll |
|
||||
|
||||
## 6. 用户服务 FaceUserService
|
||||
### FaceUserService
|
||||
|
||||
访问路径:
|
||||
Access path: `manager.Users`
|
||||
|
||||
```csharp
|
||||
manager.Users
|
||||
```
|
||||
|
||||
| 方法 | 返回 | 说明 |
|
||||
| Method | Return | Description |
|
||||
|---|---|---|
|
||||
| `DeleteUserAsync(int userId)` | `Task<FaceReply>` | 删除指定用户 |
|
||||
| `DeleteAllAsync()` | `Task<FaceReply>` | 删除全部用户 |
|
||||
| `GetUserInfoAsync(int userId)` | `Task<FaceUserInfo>` | 查询用户信息 |
|
||||
| `GetAllUserIdsAsync()` | `Task<List<int>>` | 查询用户 ID 列表 |
|
||||
| `GetAllUserIds2Async()` | `Task<List<int>>` | 使用扩展命令查询用户 ID 列表 |
|
||||
| `GetAllUserInfosAsync()` | `Task<List<FaceUserInfo>>` | 查询全部用户详情 |
|
||||
| `GetAllUserInfos2Async()` | `Task<List<FaceUserInfo>>` | 使用扩展命令查询全部用户详情 |
|
||||
| `DeleteUserAsync(int userId)` | `Task<FaceReply>` | Delete a user |
|
||||
| `DeleteAllAsync()` | `Task<FaceReply>` | Delete all users |
|
||||
| `GetUserInfoAsync(int userId)` | `Task<FaceUserInfo>` | Query one user |
|
||||
| `GetAllUserIdsAsync()` | `Task<List<int>>` | Query all user IDs |
|
||||
| `GetAllUserIds2Async()` | `Task<List<int>>` | Query all user IDs with extended command |
|
||||
| `GetAllUserInfosAsync()` | `Task<List<FaceUserInfo>>` | Query all user details |
|
||||
| `GetAllUserInfos2Async()` | `Task<List<FaceUserInfo>>` | Query all user details with extended command |
|
||||
|
||||
## 7. 二维码服务 FaceQrCodeService
|
||||
### FaceQrCodeService
|
||||
|
||||
访问路径:
|
||||
Access path: `manager.QrCode`
|
||||
|
||||
```csharp
|
||||
manager.QrCode
|
||||
```
|
||||
|
||||
| 方法 | 返回 | 说明 |
|
||||
| Method | Return | Description |
|
||||
|---|---|---|
|
||||
| `ScanQrCodeAsync(byte timeout)` | `Task<string>` | 扫描二维码并返回内容 |
|
||||
| `ScanQrCodeAsync(byte timeout)` | `Task<string>` | Scan QR code and return content |
|
||||
|
||||
## 8. 图片服务 FaceImageService
|
||||
### FaceImageService
|
||||
|
||||
访问路径:
|
||||
Access path: `manager.Images`
|
||||
|
||||
```csharp
|
||||
manager.Images
|
||||
```
|
||||
|
||||
| 方法 | 返回 | 说明 |
|
||||
| Method | Return | Description |
|
||||
|---|---|---|
|
||||
| `SnapUploadImageAsync()` | `Task<FaceImageResult>` | 抓拍普通图片 |
|
||||
| `SnapUploadFaceImageAsync()` | `Task<FaceImageResult>` | 抓拍人脸图片 |
|
||||
| `SnapUploadLargeImageAsync(ImageDpi dpi)` | `Task<FaceImageResult>` | 抓拍大图 |
|
||||
| `EnrollWithPhotoAsync(byte[] photoBytes, BioType type, string userName = null, bool duplicateCheck = true, Action<int, int> onProgress = null)` | `Task<FaceEnrollResult>` | 照片注册 |
|
||||
| `EnrollWithPhotoAndIdAsync(int userId, byte[] photoBytes, BioType type, string userName = null, bool duplicateCheck = true, Action<int, int> onProgress = null)` | `Task<FaceEnrollResult>` | 指定用户 ID 照片注册 |
|
||||
| `SnapUploadImageAsync()` | `Task<FaceImageResult>` | Capture normal image |
|
||||
| `SnapUploadFaceImageAsync()` | `Task<FaceImageResult>` | Capture face image |
|
||||
| `SnapUploadLargeImageAsync(ImageDpi dpi)` | `Task<FaceImageResult>` | Capture large image |
|
||||
| `EnrollWithPhotoAsync(byte[] photoBytes, BioType type, string userName = null, bool duplicateCheck = true, Action<int, int> onProgress = null)` | `Task<FaceEnrollResult>` | Enroll with photo |
|
||||
| `EnrollWithPhotoAndIdAsync(int userId, byte[] photoBytes, BioType type, string userName = null, bool duplicateCheck = true, Action<int, int> onProgress = null)` | `Task<FaceEnrollResult>` | Enroll photo with specified user ID |
|
||||
|
||||
## 9. 特征服务 FaceFeatureService
|
||||
### FaceFeatureService
|
||||
|
||||
访问路径:
|
||||
Access path: `manager.Features`
|
||||
|
||||
```csharp
|
||||
manager.Features
|
||||
```
|
||||
|
||||
| 方法 | 返回 | 说明 |
|
||||
| Method | Return | Description |
|
||||
|---|---|---|
|
||||
| `ReadFeatureAsync(int userId, FeatureType type)` | `Task<byte[]>` | 读取指定用户特征 |
|
||||
| `WriteFeatureAsync(byte[] featureBytes, FeatureType type, string userName = null, Action<int, int> onProgress = null)` | `Task<FaceEnrollResult>` | 写入特征并注册 |
|
||||
| `ReadFeatureAsync(int userId, FeatureType type)` | `Task<byte[]>` | Read user feature |
|
||||
| `WriteFeatureAsync(byte[] featureBytes, FeatureType type, string userName = null, Action<int, int> onProgress = null)` | `Task<FaceEnrollResult>` | Write feature and enroll |
|
||||
|
||||
## 10. UVC 和高级参数 FaceUvcService
|
||||
### FaceUvcService
|
||||
|
||||
访问路径:
|
||||
Access path: `manager.Uvc`
|
||||
|
||||
```csharp
|
||||
manager.Uvc
|
||||
```
|
||||
|
||||
| 方法 | 返回 | 说明 |
|
||||
| Method | Return | Description |
|
||||
|---|---|---|
|
||||
| `ReadUsbUvcParametersAsync()` | `Task<UsbUvcParameters>` | 读取 USB / UVC 参数 |
|
||||
| `SetUsbUvcParametersAsync(UsbUvcParameters parameters)` | `Task<FaceReply>` | 设置 USB / UVC 参数 |
|
||||
| `SetFaceLocationDisplayAsync(bool visible)` | `Task<FaceReply>` | 设置人脸框显示 |
|
||||
| `SetRgbLevelAsync(byte level)` | `Task<FaceReply>` | 设置 RGB 阈值 |
|
||||
| `SetDuplicateCheckAsync(bool enableCheck)` | `Task<FaceReply>` | 设置查重 |
|
||||
| `ReadDuplicateCheckAsync()` | `Task<bool>` | 读取查重状态 |
|
||||
| `ReadUsbUvcParametersAsync()` | `Task<UsbUvcParameters>` | Read USB/UVC parameters |
|
||||
| `SetUsbUvcParametersAsync(UsbUvcParameters parameters)` | `Task<FaceReply>` | Set USB/UVC parameters |
|
||||
| `SetFaceLocationDisplayAsync(bool visible)` | `Task<FaceReply>` | Set face rectangle display |
|
||||
| `SetRgbLevelAsync(byte level)` | `Task<FaceReply>` | Set RGB level |
|
||||
| `SetDuplicateCheckAsync(bool enableCheck)` | `Task<FaceReply>` | Set duplicate check |
|
||||
| `ReadDuplicateCheckAsync()` | `Task<bool>` | Read duplicate check state |
|
||||
|
||||
## 11. 加密服务 FaceEncryptionService
|
||||
### FaceEncryptionService
|
||||
|
||||
访问路径:
|
||||
Access path: `manager.Encryption`
|
||||
|
||||
```csharp
|
||||
manager.Encryption
|
||||
```
|
||||
|
||||
| 方法 | 返回 | 说明 |
|
||||
| Method | Return | Description |
|
||||
|---|---|---|
|
||||
| `SetReleaseEncryptionKeyAsync(byte[] key16)` | `Task<FaceReply>` | 设置 Release 加密密钥 |
|
||||
| `SetDebugEncryptionKeyAsync(byte[] key16)` | `Task<FaceReply>` | 设置 Debug 加密密钥 |
|
||||
| `InitEncryptionAsync(byte[] seed4, byte mode)` | `Task<FaceReply>` | 初始化加密流程 |
|
||||
| `EnableEncryption(IFaceModuleCrypto crypto)` | `void` | 设置本地加密算法适配器 |
|
||||
| `DisableEncryption()` | `void` | 关闭本地加密算法适配器 |
|
||||
|
||||
`IFaceModuleCrypto`:
|
||||
| `SetReleaseEncryptionKeyAsync(byte[] key16)` | `Task<FaceReply>` | Set release encryption key |
|
||||
| `SetDebugEncryptionKeyAsync(byte[] key16)` | `Task<FaceReply>` | Set debug encryption key |
|
||||
| `InitEncryptionAsync(byte[] seed4, byte mode)` | `Task<FaceReply>` | Initialize encryption |
|
||||
| `EnableEncryption(IFaceModuleCrypto crypto)` | `void` | Enable local crypto adapter |
|
||||
| `DisableEncryption()` | `void` | Disable local crypto adapter |
|
||||
|
||||
```csharp
|
||||
public interface IFaceModuleCrypto
|
||||
@ -246,239 +186,103 @@ public interface IFaceModuleCrypto
|
||||
}
|
||||
```
|
||||
|
||||
## 12. 回调式 API
|
||||
## Callback API
|
||||
|
||||
`FaceModuleManager.Callback` 适合 Unity Button、旧项目回调风格或不方便使用 `await` 的业务。
|
||||
`FaceModuleManager.Callback` is useful for Unity UI, button events, legacy callback-style code, or workflows where `await` is inconvenient.
|
||||
|
||||
```csharp
|
||||
manager.Callback.Verify(
|
||||
timeout: 10,
|
||||
success: result => Debug.Log(result.UserId),
|
||||
error: message => Debug.LogError(message));
|
||||
```
|
||||
Callbacks use a consistent pattern:
|
||||
|
||||
回调特点:
|
||||
- `success` is invoked on success.
|
||||
- `error` receives an error message on failure.
|
||||
- Photo enrollment and feature writing support `progress(current, total)`.
|
||||
- Callbacks are dispatched back to the Unity main thread through `FaceModuleMainThreadDispatcher`.
|
||||
|
||||
- 所有 API 统一使用 `success` 和 `error`。
|
||||
- 照片注册、特征写入支持 `progress(current, total)`。
|
||||
- 回调会通过 `FaceModuleMainThreadDispatcher` 回到 Unity 主线程。
|
||||
### Lifecycle and Transport
|
||||
|
||||
## 13. 主要模型
|
||||
|
||||
| 类型 | 说明 |
|
||||
|---|---|
|
||||
| `FaceReply` | REPLY 包解析结果 |
|
||||
| `FaceNote` | NOTE 包解析结果 |
|
||||
| `FaceFaceStateNote` | 人脸状态 NOTE |
|
||||
| `FaceUserInfo` | 用户 ID、姓名、管理员标记 |
|
||||
| `FaceVerifyResult` | 验证结果、用户信息、开锁状态 |
|
||||
| `FaceAutoVerifyResult` | 自动验证识别结果 |
|
||||
| `FaceAutoVerifyControlResult` | 自动验证开启/关闭命令结果 |
|
||||
| `FaceEnrollResult` | 录入结果、用户 ID、方向 |
|
||||
| `FaceImageResult` | 图片 bytes、Texture2D、用户 ID |
|
||||
| `UsbUvcParameters` | USB / UVC 参数 |
|
||||
| `FaceCommandException` | 底层命令 REPLY 非成功时抛出的异常 |
|
||||
|
||||
高层业务 Result 类型统一使用 `Success` 和 `ResultCode`。`FaceReply` 是底层 REPLY 模型,也统一只暴露 `Success` 和 `ResultCode`。
|
||||
|
||||
### 13.1 常用模型字段
|
||||
|
||||
| 类型 | 字段 | 说明 |
|
||||
| Method | Success Callback | Description |
|
||||
|---|---|---|
|
||||
| `FaceReply` | `Mid` | 对应的命令 ID |
|
||||
| `FaceReply` | `Success` | `ResultCode == FaceResultCode.Success` |
|
||||
| `FaceReply` | `ResultCode` | 模组返回结果码 |
|
||||
| `FaceReply` | `Data` | REPLY 业务数据,不包含命令 ID 和结果码 |
|
||||
| `FaceNote` | `Nid` | NOTE 类型 |
|
||||
| `FaceNote` | `Data` | NOTE 业务数据,不包含 NOTE ID |
|
||||
| `FaceFaceStateNote` | `State` | 人脸状态码 |
|
||||
| `FaceFaceStateNote` | `Left` / `Top` / `Right` / `Bottom` | 人脸框坐标 |
|
||||
| `FaceFaceStateNote` | `Yaw` / `Pitch` / `Roll` | 人脸姿态角 |
|
||||
| `FaceUserInfo` | `UserId` | 用户 ID |
|
||||
| `FaceUserInfo` | `UserName` | 用户名 |
|
||||
| `FaceUserInfo` | `IsAdmin` | 是否管理员 |
|
||||
| `FaceVerifyResult` | `Success` / `ResultCode` | 验证是否成功及结果码 |
|
||||
| `FaceVerifyResult` | `UserId` / `UserName` / `IsAdmin` | 验证成功时的用户信息 |
|
||||
| `FaceVerifyResult` | `UnlockStatus` | 模组返回的开锁状态 |
|
||||
| `FaceAutoVerifyResult` | `Success` / `ResultCode` | 自动验证 NOTE 的识别结果 |
|
||||
| `FaceAutoVerifyResult` | `VerifyResult` | 成功时解析出的验证结果详情 |
|
||||
| `FaceAutoVerifyControlResult` | `Success` / `ResultCode` | 自动验证开关命令结果 |
|
||||
| `FaceAutoVerifyControlResult` | `Enabled` | 本次命令目标状态 |
|
||||
| `FaceAutoVerifyControlResult` | `Reply` | 底层开关命令 REPLY |
|
||||
| `FaceEnrollResult` | `Success` / `ResultCode` | 录入是否成功及结果码 |
|
||||
| `FaceEnrollResult` | `UserId` | 录入成功后分配或写入的用户 ID |
|
||||
| `FaceEnrollResult` | `Direction` | 录入方向 |
|
||||
| `FaceImageResult` | `Success` / `ResultCode` | 图片命令是否成功及结果码 |
|
||||
| `FaceImageResult` | `UserId` | 照片注册相关用户 ID |
|
||||
| `FaceImageResult` | `Bytes` | 图片原始 bytes |
|
||||
| `FaceImageResult` | `Texture` | Unity `Texture2D` |
|
||||
| `UsbUvcParameters` | `UsbType` | USB 输出类型 |
|
||||
| `UsbUvcParameters` | `BitrateMbps` | 码率,单位 Mbps |
|
||||
| `UsbUvcParameters` | `MjpgQuality` | MJPG 质量 |
|
||||
| `UsbUvcParameters` | `Mirror` | 是否镜像 |
|
||||
| `UsbUvcParameters` | `Rotate180` | 是否旋转 180 度 |
|
||||
| `ConfigureTransport(IFaceModuleTransport transport, Action success, Action<string> error)` | `Action` | Inject custom transport |
|
||||
| `Configure(bool useMockInEditor, string portName, int baudRate, Action success, Action<string> error)` | `Action` | Configure default transport parameters |
|
||||
| `Open(Action success, Action<string> error)` | `Action` | Open transport |
|
||||
| `Close(Action success, Action<string> error)` | `Action` | Close transport |
|
||||
| `SendRawBytes(byte[] bytes, Action success, Action<string> error)` | `Action` | Send raw bytes |
|
||||
| `WaitReady(int timeoutMs, Action success, Action<string> error)` | `Action` | Wait for READY |
|
||||
| `ProbeReadyByStatus(Action<FaceModuleStatus> success, Action<string> error)` | `Action<FaceModuleStatus>` | Probe status and mark ready |
|
||||
|
||||
### 13.2 FaceResultCode 结果码
|
||||
### Basic Commands
|
||||
|
||||
`FaceResultCode` 会出现在 `FaceReply.ResultCode`、高层业务 Result、`OnError`、`FaceCommandException.ResultCode` 中。可使用 `FaceProtocolEncoding.ResultMessage(code)` 获取中文提示。
|
||||
|
||||
| 值 | 名称 | 说明 |
|
||||
|---:|---|---|
|
||||
| 0 | `Success` | 成功 |
|
||||
| 1 | `Rejected` | 模组拒绝命令 |
|
||||
| 2 | `Aborted` | 操作已终止 |
|
||||
| 4 | `CameraOpenFailed` | 相机打开失败 |
|
||||
| 5 | `UnknownReason` | 未知错误 |
|
||||
| 6 | `InvalidParam` | 参数无效 |
|
||||
| 7 | `NoMemory` | 内存不足 |
|
||||
| 8 | `UnknownUser` | 未找到用户或没有已录入用户 |
|
||||
| 9 | `MaxUser` | 超过最大用户数量 |
|
||||
| 10 | `FaceEnrolled` | 人脸已录入 |
|
||||
| 12 | `LivenessCheckFailed` | 活体检测失败 |
|
||||
| 13 | `Timeout` | 操作超时 |
|
||||
| 14 | `AuthorizationFailed` | 模组侧授权失败 |
|
||||
| 19 | `ReadFileFailed` | 读文件失败 |
|
||||
| 20 | `WriteFileFailed` | 写文件失败 |
|
||||
| 21 | `NoEncrypt` | 通信未加密 |
|
||||
| 23 | `NoRgbImage` | RGB 图像未就绪 |
|
||||
| 24 | `JpgPhotoTooLarge` | JPG 照片过大 |
|
||||
| 25 | `JpgPhotoTooSmall` | JPG 照片过小 |
|
||||
| 26 | `DetectQr` | 识别过程中检测到二维码 |
|
||||
|
||||
### 13.3 FaceStateCode 人脸状态码
|
||||
|
||||
`FaceStateCode` 来自 `OnFaceStateUpdated(FaceFaceStateNote)`,主要用于录入、检测和 UI 引导。可使用 `FaceProtocolEncoding.FaceStateMessage(code)` 获取中文提示。
|
||||
|
||||
| 值 | 名称 | 说明 |
|
||||
|---:|---|---|
|
||||
| 0 | `Normal` | 人脸正常 |
|
||||
| 1 | `NoFace` | 未检测到人脸 |
|
||||
| 2 | `TooUp` | 人脸太靠上 |
|
||||
| 3 | `TooDown` | 人脸太靠下 |
|
||||
| 4 | `TooLeft` | 人脸太靠左 |
|
||||
| 5 | `TooRight` | 人脸太靠右 |
|
||||
| 6 | `Far` | 距离太远 |
|
||||
| 7 | `Close` | 距离太近 |
|
||||
| 8 | `EyebrowOcclusion` | 眉毛遮挡 |
|
||||
| 9 | `EyeOcclusion` | 眼睛遮挡 |
|
||||
| 10 | `FaceOcclusion` | 脸部遮挡 |
|
||||
| 11 | `DirectionError` | 录入方向错误 |
|
||||
| 12 | `EyeCloseStatusOpenEye` | 闭眼检测中发现睁眼 |
|
||||
| 13 | `EyeCloseStatus` | 当前为闭眼状态 |
|
||||
| 14 | `EyeCloseUnknownStatus` | 无法判定睁闭眼状态 |
|
||||
| 128 | `PalmDetected` | 检测到手掌信息 |
|
||||
|
||||
### 13.4 业务常用枚举
|
||||
|
||||
| 枚举 | 值 | 说明 |
|
||||
| Method | Success Callback | Description |
|
||||
|---|---|---|
|
||||
| `FaceModuleStatus` | `Standby = 0` | 模组待机 |
|
||||
| `FaceModuleStatus` | `Busy = 1` | 模组忙碌 |
|
||||
| `FaceModuleStatus` | `Error = 2` | 模组错误 |
|
||||
| `FaceModuleStatus` | `Invalid = 3` | SDK 未知或无效状态 |
|
||||
| `FaceDirection` | `Undefined = 0x00` | 未定义方向 |
|
||||
| `FaceDirection` | `Middle = 0x01` | 正脸 |
|
||||
| `FaceDirection` | `Right = 0x02` | 向右 |
|
||||
| `FaceDirection` | `Left = 0x04` | 向左 |
|
||||
| `FaceDirection` | `Down = 0x08` | 向下 |
|
||||
| `FaceDirection` | `Up = 0x10` | 向上 |
|
||||
| `BioType` | `NormalPhoto = 0` | 普通照片 |
|
||||
| `BioType` | `EncryptedPhoto = 1` | 加密照片 |
|
||||
| `BioType` | `NormalFeature = 2` | 普通特征 |
|
||||
| `BioType` | `CompressedFeature = 3` | 压缩特征 |
|
||||
| `FeatureType` | `ColorFace = 1` | 彩色人脸特征 |
|
||||
| `FeatureType` | `ColorAndIrFace = 2` | 彩色加红外人脸特征 |
|
||||
| `FeatureType` | `Palm = 3` | 手掌特征 |
|
||||
| `ImageDpi` | `Dpi480x640 = 0` | 480x640 大图 |
|
||||
| `ImageDpi` | `Dpi600x800 = 1` | 600x800 大图 |
|
||||
| `ImageDpi` | `Dpi1200x1600 = 2` | 1200x1600 大图 |
|
||||
| `Reset(Action<FaceReply> success, Action<string> error)` | `Action<FaceReply>` | Reset module |
|
||||
| `FaceReset(Action<FaceReply> success, Action<string> error)` | `Action<FaceReply>` | Cancel current face flow |
|
||||
| `GetStatus(Action<FaceModuleStatus> success, Action<string> error)` | `Action<FaceModuleStatus>` | Get module status |
|
||||
| `GetVersion(Action<string> success, Action<string> error)` | `Action<string>` | Get firmware version |
|
||||
| `GetSn(Action<string> success, Action<string> error)` | `Action<string>` | Get device serial number |
|
||||
| `SetDemoMode(bool enable, Action<FaceReply> success, Action<string> error)` | `Action<FaceReply>` | Set Demo Mode |
|
||||
| `UpgradeFirmware(Action<FaceReply> success, Action<string> error)` | `Action<FaceReply>` | Start firmware upgrade |
|
||||
|
||||
### 13.5 配置枚举
|
||||
### Verification and Enrollment
|
||||
|
||||
| 枚举 | 值 | 说明 |
|
||||
| Method | Success Callback | Description |
|
||||
|---|---|---|
|
||||
| `FaceTransportMode` | `Auto = 0` | 默认通信模式,当前串口实现下等价于串口,Editor 可按 Mock 配置切换 |
|
||||
| `FaceTransportMode` | `SerialPort = 1` | 强制使用串口通信 |
|
||||
| `FaceTransportMode` | `Mock = 3` | 使用 Mock 模组 |
|
||||
| `FaceExclusiveCommandPolicy` | `RejectWhenAutoVerifyEnabled = 0` | 自动验证开启时拒绝独占命令 |
|
||||
| `FaceExclusiveCommandPolicy` | `StopAutoVerify = 1` | 独占命令前自动关闭自动验证 |
|
||||
| `FaceExclusiveCommandPolicy` | `Ignore = 2` | 不处理自动验证状态,由业务自行保证不冲突 |
|
||||
| `Verify(byte timeout, Action<FaceVerifyResult> success, Action<string> error, byte maxRecognitionTimes = 30)` | `Action<FaceVerifyResult>` | Run face verification |
|
||||
| `AutoVerify(bool enable, byte timeout, Action<FaceVerifyResult> success, Action<string> error)` | `Action<FaceVerifyResult>` | Enable or disable auto verification |
|
||||
| `Enroll(bool admin, string userName, FaceDirection direction, byte timeout, Action<FaceEnrollResult> success, Action<string> error)` | `Action<FaceEnrollResult>` | Interactive enrollment |
|
||||
| `EnrollSingle(bool admin, string userName, byte timeout, Action<FaceEnrollResult> success, Action<string> error)` | `Action<FaceEnrollResult>` | Single-frame enrollment |
|
||||
| `EnrollIntegrated(bool admin, string userName, FaceDirection direction, byte timeout, bool singleFrame, bool duplicateCheck, Action<FaceEnrollResult> success, Action<string> error)` | `Action<FaceEnrollResult>` | Integrated enrollment |
|
||||
| `EnrollSnapFaceImage(bool admin, string userName, Action<FaceEnrollResult> success, Action<string> error)` | `Action<FaceEnrollResult>` | Capture face image and enroll |
|
||||
|
||||
## 14. 协议和通信底层
|
||||
### Users
|
||||
|
||||
业务层通常不需要直接使用底层 API。需要协议调试或自定义通信时可使用:
|
||||
| Method | Success Callback | Description |
|
||||
|---|---|---|
|
||||
| `DeleteUser(int userId, Action<FaceReply> success, Action<string> error)` | `Action<FaceReply>` | Delete user |
|
||||
| `DeleteAll(Action<FaceReply> success, Action<string> error)` | `Action<FaceReply>` | Delete all users |
|
||||
| `GetUserInfo(int userId, Action<FaceUserInfo> success, Action<string> error)` | `Action<FaceUserInfo>` | Query one user |
|
||||
| `GetAllUserIds(Action<List<int>> success, Action<string> error)` | `Action<List<int>>` | Query all user IDs |
|
||||
| `GetAllUserIds2(Action<List<int>> success, Action<string> error)` | `Action<List<int>>` | Query all user IDs with extended command |
|
||||
| `GetAllUserInfos(Action<List<FaceUserInfo>> success, Action<string> error)` | `Action<List<FaceUserInfo>>` | Query all user details |
|
||||
| `GetAllUserInfos2(Action<List<FaceUserInfo>> success, Action<string> error)` | `Action<List<FaceUserInfo>>` | Query all user details with extended command |
|
||||
|
||||
| 类型 | 说明 |
|
||||
### QR Code, Images, and Features
|
||||
|
||||
| Method | Success Callback | Description |
|
||||
|---|---|---|
|
||||
| `ScanQrCode(byte timeout, Action<string> success, Action<string> error)` | `Action<string>` | Scan QR code |
|
||||
| `SnapUploadImage(Action<FaceImageResult> success, Action<string> error)` | `Action<FaceImageResult>` | Capture normal image |
|
||||
| `SnapUploadFaceImage(Action<FaceImageResult> success, Action<string> error)` | `Action<FaceImageResult>` | Capture face image |
|
||||
| `SnapUploadLargeImage(ImageDpi dpi, Action<FaceImageResult> success, Action<string> error)` | `Action<FaceImageResult>` | Capture large image |
|
||||
| `EnrollWithPhoto(byte[] photoBytes, BioType type, string userName, bool duplicateCheck, Action<FaceEnrollResult> success, Action<string> error, Action<int, int> progress = null)` | `Action<FaceEnrollResult>` | Enroll with photo |
|
||||
| `EnrollWithPhotoAndId(int userId, byte[] photoBytes, BioType type, string userName, bool duplicateCheck, Action<FaceEnrollResult> success, Action<string> error, Action<int, int> progress = null)` | `Action<FaceEnrollResult>` | Enroll photo with specified user ID |
|
||||
| `ReadFeature(int userId, FeatureType type, Action<byte[]> success, Action<string> error)` | `Action<byte[]>` | Read user feature |
|
||||
| `WriteFeature(byte[] featureBytes, FeatureType type, string userName, Action<FaceEnrollResult> success, Action<string> error, Action<int, int> progress = null)` | `Action<FaceEnrollResult>` | Write feature and enroll |
|
||||
|
||||
### UVC and Encryption
|
||||
|
||||
| Method | Success Callback | Description |
|
||||
|---|---|---|
|
||||
| `ReadUsbUvcParameters(Action<UsbUvcParameters> success, Action<string> error)` | `Action<UsbUvcParameters>` | Read USB/UVC parameters |
|
||||
| `SetUsbUvcParameters(UsbUvcParameters parameters, Action<FaceReply> success, Action<string> error)` | `Action<FaceReply>` | Set USB/UVC parameters |
|
||||
| `SetFaceLocationDisplay(bool visible, Action<FaceReply> success, Action<string> error)` | `Action<FaceReply>` | Set face rectangle display |
|
||||
| `SetRgbLevel(byte level, Action<FaceReply> success, Action<string> error)` | `Action<FaceReply>` | Set RGB level |
|
||||
| `SetDuplicateCheck(bool enableCheck, Action<FaceReply> success, Action<string> error)` | `Action<FaceReply>` | Set duplicate check |
|
||||
| `ReadDuplicateCheck(Action<bool> success, Action<string> error)` | `Action<bool>` | Read duplicate check state |
|
||||
| `SetReleaseEncryptionKey(byte[] key16, Action<FaceReply> success, Action<string> error)` | `Action<FaceReply>` | Set release encryption key |
|
||||
| `SetDebugEncryptionKey(byte[] key16, Action<FaceReply> success, Action<string> error)` | `Action<FaceReply>` | Set debug encryption key |
|
||||
| `InitEncryption(byte[] seed4, byte mode, Action<FaceReply> success, Action<string> error)` | `Action<FaceReply>` | Initialize encryption |
|
||||
| `EnableEncryption(IFaceModuleCrypto crypto, Action success, Action<string> error)` | `Action` | Enable local crypto adapter |
|
||||
| `DisableEncryption(Action success, Action<string> error)` | `Action` | Disable local crypto adapter |
|
||||
|
||||
## Main Models
|
||||
|
||||
| Type | Description |
|
||||
|---|---|
|
||||
| `FacePacketBuilder` | 封包 |
|
||||
| `FacePacketParser` | 拆包 |
|
||||
| `FaceProtocolEncoding` | 用户名、ID、结果文本等编码工具 |
|
||||
| `IFaceModuleTransport` | 通信接口 |
|
||||
| `SerialPortTransport` | 串口实现 |
|
||||
| `MockFaceModuleTransport` | Mock 实现 |
|
||||
|
||||
## 15. 授权 API
|
||||
|
||||
命名空间:
|
||||
|
||||
```csharp
|
||||
using Aisu.SIM1.Face.Core;
|
||||
```
|
||||
|
||||
| 类型 | 说明 |
|
||||
|---|---|
|
||||
| `FaceLicenseManager` | 加载、验证授权 token,查询授权状态 |
|
||||
| `FaceLicensePayload` | 授权 payload 数据 |
|
||||
| `FaceLicenseStatus` | 授权状态枚举 |
|
||||
| `FaceLicenseException` | 授权异常 |
|
||||
| `FaceLicenseFeatures` | 功能授权常量 |
|
||||
| `FaceUnityRuntimeBinding` | 读取 `identifier`、`companyName`、`productName`、`version`、`unityVersion` |
|
||||
|
||||
常用方法:
|
||||
|
||||
| 方法 | 说明 |
|
||||
|---|---|
|
||||
| `FaceLicenseManager.LoadAndVerify()` | 读取默认授权文件并验签 |
|
||||
| `FaceLicenseManager.VerifyOrThrow()` | 授权无效时抛出异常 |
|
||||
| `FaceLicenseManager.VerifyFeatureOrThrow(string feature)` | 功能未授权时抛出异常 |
|
||||
| `FaceLicenseManager.IsFeatureEnabled(string feature)` | 查询功能是否授权 |
|
||||
| `FaceLicenseVerifier.VerifyToken(string token)` | 验签并校验授权 payload |
|
||||
| `FaceLicenseVerifier.ValidatePayload(FaceLicensePayload payload)` | 校验 payload 字段、有效期、功能和 Unity 绑定 |
|
||||
| `FaceLicenseVerifier.GetBeijingNow()` | 获取 SDK 授权使用的当前北京时间 |
|
||||
| `FaceLicenseVerifier.FormatBeijingTime(DateTimeOffset value)` | 格式化授权北京时间字符串 |
|
||||
| `FaceLicenseVerifier.GetRemainingDays(FaceLicensePayload payload)` | 计算授权剩余天数 |
|
||||
|
||||
### 15.1 FaceLicenseStatus
|
||||
|
||||
| 值 | 名称 | 说明 |
|
||||
|---:|---|---|
|
||||
| 0 | `Unknown` | 尚未验证或状态未知 |
|
||||
| 1 | `Valid` | 授权有效 |
|
||||
| 2 | `MissingFile` | 授权文件不存在 |
|
||||
| 3 | `InvalidFormat` | 授权格式无效 |
|
||||
| 4 | `InvalidSignature` | 授权签名无效 |
|
||||
| 5 | `ProductMismatch` | 产品 ID 不匹配 |
|
||||
| 6 | `BindingMismatch` | Unity 绑定参数不匹配 |
|
||||
| 7 | `Expired` | 授权已过期 |
|
||||
| 8 | `FeatureDenied` | 功能未授权 |
|
||||
| 9 | `PublicKeyInvalid` | SDK 公钥无效 |
|
||||
| 10 | `ReadFailed` | 授权读取失败 |
|
||||
| 11 | `NotYetValid` | 授权尚未生效 |
|
||||
|
||||
### 15.2 FaceLicenseFeatures
|
||||
|
||||
| 名称 | 说明 |
|
||||
|---|---|
|
||||
| `SerialRuntime` | 串口运行时 |
|
||||
| `Basic` | 基础命令 |
|
||||
| `Verify` | 人脸验证和自动验证 |
|
||||
| `Enroll` | 人脸录入 |
|
||||
| `UserManage` | 用户管理 |
|
||||
| `QrCode` | 二维码 |
|
||||
| `Image` | 图片抓拍、照片注册 |
|
||||
| `Feature` | 特征读写 |
|
||||
| `Uvc` | UVC 和高级参数 |
|
||||
| `Encryption` | 加密通信 |
|
||||
| `Firmware` | 固件升级 |
|
||||
|
||||
Runtime 不提供 token 签发 API,也不提供公钥覆盖 API。授权签发只应存在于内部 Editor DLL 或独立授权工具中。
|
||||
| `FaceReply` | REPLY packet parse result |
|
||||
| `FaceNote` | NOTE packet parse result |
|
||||
| `FaceFaceStateNote` | Face state NOTE |
|
||||
| `FaceUserInfo` | User ID, name, and admin flag |
|
||||
| `FaceVerifyResult` | Verification result, user info, unlock status |
|
||||
| `FaceEnrollResult` | Enrollment result, user ID, direction |
|
||||
| `FaceImageResult` | Image bytes, `Texture2D`, user ID |
|
||||
| `UsbUvcParameters` | USB/UVC parameters |
|
||||
| `FaceCommandException` | Exception thrown for unsuccessful command replies |
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
English documentation: [SDK_API_Reference.md](SDK_API_Reference.md).
|
||||
|
||||
本文列出 `xin.aisu.si-m1.face` 的业务层 API。
|
||||
本文列出 `xin.aisu.si-m1.face` 对外公开的业务层 API。公开包为 DLL-only 形式,不包含 SDK 源码。
|
||||
|
||||
## 命名空间
|
||||
|
||||
@ -52,11 +52,7 @@ using Aisu.SIM1.Face.Core;
|
||||
| `Configure(bool useMockInEditor, string portName, int baudRate)` | 兼容旧代码的快速配置入口 |
|
||||
| `ApplySettings(FaceSdkSettings sdkSettings)` | 应用 ScriptableObject 配置并重建 transport |
|
||||
| `Open()` | 打开通信 |
|
||||
| `Close()` | 停止当前人脸流程并关闭通信 |
|
||||
| `CloseAsync()` | 异步停止当前人脸流程并关闭通信 |
|
||||
| `StopFaceOperationAsync()` | 停止自动验证或重置当前人脸流程 |
|
||||
| `StartAutoVerifyAsync(byte timeout)` | 开启自动验证并返回控制命令结果 |
|
||||
| `StopAutoVerifyAsync(byte timeout = 1)` | 关闭自动验证并返回控制命令结果 |
|
||||
| `Close()` | 关闭通信 |
|
||||
| `WaitReadyAsync(int timeoutMs = 5000)` | 等待 READY NOTE |
|
||||
| `ProbeReadyByStatusAsync()` | 主动查询状态并标记 READY |
|
||||
| `SendRawBytes(byte[] bytes)` | 发送原始协议 bytes |
|
||||
@ -71,7 +67,6 @@ using Aisu.SIM1.Face.Core;
|
||||
| `OnReplyReceived(FaceReply)` | 收到 REPLY 包 |
|
||||
| `OnNoteReceived(FaceNote)` | 收到 NOTE 包 |
|
||||
| `OnFaceStateUpdated(FaceFaceStateNote)` | 收到人脸状态 NOTE |
|
||||
| `OnAutoVerifyResult(FaceAutoVerifyResult)` | 收到自动验证结果 NOTE |
|
||||
| `OnQrCodeReceived(string)` | 收到二维码 NOTE |
|
||||
| `OnFeatureReceived(byte[])` | 收到特征数据包 |
|
||||
| `OnDataPacketReceived(FacePacket)` | 收到图片或模板数据包 |
|
||||
@ -101,9 +96,7 @@ using Aisu.SIM1.Face.Core;
|
||||
| 方法 | 返回 | 说明 |
|
||||
|---|---|---|
|
||||
| `VerifyAsync(byte timeout, byte maxRecognitionTimes = 30)` | `Task<FaceVerifyResult>` | 单次人脸验证 |
|
||||
| `AutoVerifyAsync(bool enable, byte timeout)` | `Task<FaceReply>` | 底层自动验证控制命令 |
|
||||
|
||||
业务代码推荐使用 `FaceModuleManager.StartAutoVerifyAsync()` 和 `FaceModuleManager.StopAutoVerifyAsync()`。识别结果通过 `OnAutoVerifyResult` 获取。
|
||||
| `AutoVerifyAsync(bool enable, byte timeout)` | `Task<FaceVerifyResult>` | 启用或关闭自动验证 |
|
||||
|
||||
### FaceEnrollmentService
|
||||
|
||||
@ -212,7 +205,6 @@ public interface IFaceModuleCrypto
|
||||
| `Configure(bool useMockInEditor, string portName, int baudRate, Action success, Action<string> error)` | `Action` | 配置默认通信参数 |
|
||||
| `Open(Action success, Action<string> error)` | `Action` | 打开通信 |
|
||||
| `Close(Action success, Action<string> error)` | `Action` | 关闭通信 |
|
||||
| `StopFaceOperation(Action success, Action<string> error)` | `Action` | 停止自动验证或重置当前人脸流程 |
|
||||
| `SendRawBytes(byte[] bytes, Action success, Action<string> error)` | `Action` | 发送原始 bytes |
|
||||
| `WaitReady(int timeoutMs, Action success, Action<string> error)` | `Action` | 等待 READY |
|
||||
| `ProbeReadyByStatus(Action<FaceModuleStatus> success, Action<string> error)` | `Action<FaceModuleStatus>` | 主动探测状态并标记 READY |
|
||||
@ -234,9 +226,7 @@ public interface IFaceModuleCrypto
|
||||
| 方法 | 成功回调 | 说明 |
|
||||
|---|---|---|
|
||||
| `Verify(byte timeout, Action<FaceVerifyResult> success, Action<string> error, byte maxRecognitionTimes = 30)` | `Action<FaceVerifyResult>` | 人脸验证 |
|
||||
| `AutoVerify(bool enable, byte timeout, Action<FaceReply> success, Action<string> error)` | `Action<FaceReply>` | 底层自动验证控制命令 |
|
||||
| `StartAutoVerify(byte timeout, Action<FaceAutoVerifyControlResult> success, Action<string> error)` | `Action<FaceAutoVerifyControlResult>` | 开启自动验证 |
|
||||
| `StopAutoVerify(byte timeout, Action<FaceAutoVerifyControlResult> success, Action<string> error)` | `Action<FaceAutoVerifyControlResult>` | 关闭自动验证 |
|
||||
| `AutoVerify(bool enable, byte timeout, Action<FaceVerifyResult> success, Action<string> error)` | `Action<FaceVerifyResult>` | 启用或关闭自动验证 |
|
||||
| `Enroll(bool admin, string userName, FaceDirection direction, byte timeout, Action<FaceEnrollResult> success, Action<string> error)` | `Action<FaceEnrollResult>` | 交互式录入 |
|
||||
| `EnrollSingle(bool admin, string userName, byte timeout, Action<FaceEnrollResult> success, Action<string> error)` | `Action<FaceEnrollResult>` | 单帧录入 |
|
||||
| `EnrollIntegrated(bool admin, string userName, FaceDirection direction, byte timeout, bool singleFrame, bool duplicateCheck, Action<FaceEnrollResult> success, Action<string> error)` | `Action<FaceEnrollResult>` | 集成式录入 |
|
||||
@ -290,8 +280,6 @@ public interface IFaceModuleCrypto
|
||||
| `FaceReply` | REPLY 包解析结果 |
|
||||
| `FaceNote` | NOTE 包解析结果 |
|
||||
| `FaceFaceStateNote` | 人脸状态 NOTE |
|
||||
| `FaceAutoVerifyResult` | 自动验证识别结果 |
|
||||
| `FaceAutoVerifyControlResult` | 自动验证开启/关闭命令结果 |
|
||||
| `FaceUserInfo` | 用户 ID、姓名、管理员标记 |
|
||||
| `FaceVerifyResult` | 验证结果、用户信息、开锁状态 |
|
||||
| `FaceEnrollResult` | 录入结果、用户 ID、方向 |
|
||||
|
||||
@ -1,162 +1,76 @@
|
||||
# SI-M1 Face SDK 配置与 Editor 工具
|
||||
# SDK Configuration
|
||||
|
||||
SDK 使用 `FaceSdkSettings` 作为推荐配置方式。该配置是 `ScriptableObject`,可在项目中复用,并可同步到场景中的 `FaceModuleManager`。
|
||||
中文说明见 [SDK_Configuration.zh-CN.md](SDK_Configuration.zh-CN.md).
|
||||
|
||||
## 1. 默认配置资产
|
||||
The SDK uses `FaceSdkSettings` as the recommended configuration asset. It is a `ScriptableObject` created inside the importing Unity project and can be synchronized to scene `FaceModuleManager` instances.
|
||||
|
||||
默认路径:
|
||||
## Default Settings Asset
|
||||
|
||||
Default path in the importing Unity project:
|
||||
|
||||
```text
|
||||
Assets/Resources/AISU/SI-M1 Face SDK/FaceSdkSettings.asset
|
||||
Assets/AISU/SI-M1 Face SDK/FaceSdkSettings.asset
|
||||
```
|
||||
|
||||
打开菜单 `AISU/SI-M1 Face SDK/Settings` 后,Editor 会加载该路径。若文件不存在,点击 `Load Default` 会创建默认资产。
|
||||
Open `AISU/SI-M1 Face SDK/Settings` to load or create this asset.
|
||||
|
||||
## 2. FaceSdkSettings 字段
|
||||
## FaceSdkSettings Fields
|
||||
|
||||
| 字段 | 类型 | 说明 |
|
||||
| Field | Type | Description |
|
||||
|---|---|---|
|
||||
| `TransportMode` | `FaceTransportMode` | 通信模式:`Auto`、`SerialPort`、`Mock` |
|
||||
| `UseMockInEditor` | `bool` | Editor 下是否强制使用 Mock |
|
||||
| `PortName` | `string` | Player / 运行时串口号 |
|
||||
| `BaudRate` | `int` | Player / 运行时波特率 |
|
||||
| `ReadBufferSize` | `int` | Player / 运行时读取缓冲区 |
|
||||
| `UseEditorSerialDebugParameters` | `bool` | Editor 下连接真实串口时是否使用单独参数 |
|
||||
| `EditorPortName` | `string` | Editor 调试串口号 |
|
||||
| `EditorBaudRate` | `int` | Editor 调试波特率 |
|
||||
| `EditorReadBufferSize` | `int` | Editor 调试读取缓冲区 |
|
||||
| `MockResponseDelayFrames` | `int` | Mock 响应延迟帧数 |
|
||||
| `AutoVerifyOnOpen` | `bool` | READY 后是否自动开启验证 |
|
||||
| `AutoVerifyTimeout` | `byte` | 自动验证协议超时时间,单位秒 |
|
||||
| `AutoVerifyResultIntervalMs` | `int` | 自动验证结果最小派发间隔,0 表示不节流 |
|
||||
| `StopAutoVerifyBeforeExclusiveCommand` | `bool` | 独占业务命令前是否自动关闭自动验证 |
|
||||
| `ExclusiveCommandPolicy` | `FaceExclusiveCommandPolicy` | 自动验证开启时的独占命令处理策略 |
|
||||
| `DebugLogEnabled` | `bool` | 是否启用 SDK Debug 日志 |
|
||||
| `RawLogEnabled` | `bool` | 是否派发原始 TX / RX 日志 |
|
||||
| `LogPrefix` | `string` | 日志前缀 |
|
||||
| `TransportMode` | `FaceTransportMode` | `Auto`, `SerialPort`, or `Mock` |
|
||||
| `UseMockInEditor` | `bool` | Force mock transport in Unity Editor |
|
||||
| `PortName` | `string` | Runtime/player serial port |
|
||||
| `BaudRate` | `int` | Runtime/player baud rate |
|
||||
| `ReadBufferSize` | `int` | Runtime/player read buffer size |
|
||||
| `UseEditorSerialDebugParameters` | `bool` | Use separate serial parameters in Editor |
|
||||
| `EditorPortName` | `string` | Editor debug serial port |
|
||||
| `EditorBaudRate` | `int` | Editor debug baud rate |
|
||||
| `EditorReadBufferSize` | `int` | Editor debug read buffer size |
|
||||
| `MockResponseDelayFrames` | `int` | Mock response delay in frames |
|
||||
| `DebugLogEnabled` | `bool` | Enable SDK debug logs |
|
||||
| `RawLogEnabled` | `bool` | Dispatch raw TX/RX logs |
|
||||
| `LogPrefix` | `string` | Log prefix |
|
||||
|
||||
## 3. TransportMode 选择
|
||||
## TransportMode
|
||||
|
||||
| 模式 | 行为 |
|
||||
| Mode | Behavior |
|
||||
|---|---|
|
||||
| `Auto` | Editor 根据 `UseMockInEditor` 选择 Mock 或串口;Player 使用串口 |
|
||||
| `SerialPort` | 使用 `SerialPortTransport` |
|
||||
| `Mock` | 使用 `MockFaceModuleTransport` |
|
||||
| `Auto` | Editor chooses mock or serial based on `UseMockInEditor`; Player uses serial |
|
||||
| `SerialPort` | Use `SerialPortTransport` |
|
||||
| `Mock` | Use `MockFaceModuleTransport` |
|
||||
|
||||
Editor 下有一个额外优先级:
|
||||
When `UseMockInEditor = true`, the Editor always uses mock transport and does not open a real serial port.
|
||||
|
||||
```text
|
||||
UseMockInEditor = true 时,强制使用 Mock,不打开真实串口。
|
||||
```
|
||||
## Editor Tools
|
||||
|
||||
因此 Editor 中如果需要连接真实串口,必须将 `UseMockInEditor` 设为 `false`。
|
||||
|
||||
## 4. Editor Serial Debug 参数
|
||||
|
||||
Editor 连接真实硬件时,建议开启:
|
||||
|
||||
```text
|
||||
UseEditorSerialDebugParameters = true
|
||||
```
|
||||
|
||||
开启后,Editor 中串口使用:
|
||||
|
||||
- `EditorPortName`
|
||||
- `EditorBaudRate`
|
||||
- `EditorReadBufferSize`
|
||||
|
||||
Player 中仍使用:
|
||||
|
||||
- `PortName`
|
||||
- `BaudRate`
|
||||
- `ReadBufferSize`
|
||||
|
||||
这样可以避免 Editor 调试口和发布运行口互相覆盖。
|
||||
|
||||
## 5. Editor 工具按钮
|
||||
|
||||
配置窗口按钮:
|
||||
|
||||
| 按钮 | 行为 |
|
||||
| Menu | Purpose |
|
||||
|---|---|
|
||||
| `Load Default` | 固定加载或创建默认路径的 `FaceSdkSettings.asset` |
|
||||
| `Save` | 保存当前配置并同步场景中的 Manager |
|
||||
| `Save and Create/Update Manager` | 保存配置后创建或更新场景 Manager |
|
||||
| `AISU/SI-M1 Face SDK/Settings` | Open SDK settings window |
|
||||
| `AISU/SI-M1 Face SDK/Create Manager GameObject` | Create or update one scene `FaceModuleManager` |
|
||||
| `AISU/SI-M1 Face SDK/Open Diagnostics` | Open diagnostics window |
|
||||
|
||||
同步 Manager 时会写入:
|
||||
The public DLL-only package does not include importable demo samples. Any demo-related menu item should be treated as unavailable in the public release if it appears in the current Editor DLL.
|
||||
|
||||
- `m_settings`
|
||||
- `m_config.TransportMode`
|
||||
- `m_config.UseMockInEditor`
|
||||
- 串口参数
|
||||
- Editor 串口参数
|
||||
- Mock 延迟
|
||||
- 自动验证配置
|
||||
- Raw Log 开关
|
||||
|
||||
PlayMode 中同步配置时,会调用 `FaceModuleManager.ApplySettings(settings)`,立即重建当前 transport。
|
||||
|
||||
## 6. Manager 配置方式
|
||||
|
||||
推荐方式:
|
||||
## Recommended Usage
|
||||
|
||||
```csharp
|
||||
manager.ApplySettings(settings);
|
||||
manager.Open();
|
||||
```
|
||||
|
||||
兼容方式:
|
||||
Legacy quick configuration:
|
||||
|
||||
```csharp
|
||||
manager.Configure(useMockInEditor: true, portName: "COM3", baudRate: 115200);
|
||||
manager.Open();
|
||||
```
|
||||
|
||||
外部通信层注入:
|
||||
Custom transport injection:
|
||||
|
||||
```csharp
|
||||
manager.ConfigureTransport(customTransport);
|
||||
manager.Open();
|
||||
```
|
||||
|
||||
## 7. 场景约束
|
||||
|
||||
每个场景建议只保留一个 `FaceModuleManager`。
|
||||
|
||||
多个 Manager 可能导致:
|
||||
|
||||
- 多次打开同一串口。
|
||||
- 重复接收和派发事件。
|
||||
- UI 状态不一致。
|
||||
|
||||
`Create Manager GameObject` 菜单会校验 Manager 数量,并在存在多个 Manager 时停止创建。
|
||||
|
||||
## 8. 自动验证配置
|
||||
|
||||
`AutoVerifyTimeout` 是发送给模组的协议超时时间,不是结果间隔。
|
||||
|
||||
`AutoVerifyResultIntervalMs` 是 Unity SDK 侧的事件节流间隔。自动验证开启后,硬件可能持续通过 NOTE 上报识别结果,SDK 会按该间隔派发 `OnAutoVerifyResult`,避免 UI 或业务层被连续结果刷爆。
|
||||
|
||||
关闭连接时,`FaceModuleManager.Close()` 和 `CloseAsync()` 会先尝试关闭自动验证,再执行 `FaceResetAsync()`,最后关闭串口。`OnApplicationQuit()` 也会走同一套安全关闭流程,避免应用退出后硬件继续检测。
|
||||
|
||||
## 9. 独占命令策略
|
||||
|
||||
自动验证开启后,模组会持续进行检测。录入、删除、查询、照片注册等业务命令可能与自动验证互相冲突。`FaceExclusiveCommandPolicy` 用于控制 SDK 在执行这些命令前如何处理自动验证状态。
|
||||
|
||||
| 值 | 行为 | 适用场景 |
|
||||
|---|---|---|
|
||||
| `RejectWhenAutoVerifyEnabled` | 自动验证开启时直接拒绝独占命令 | 希望业务层显式控制状态切换 |
|
||||
| `StopAutoVerify` | SDK 在独占命令前自动关闭自动验证 | 默认推荐,减少业务层重复处理 |
|
||||
| `Ignore` | SDK 不处理自动验证状态 | 调试或自定义流程,业务层自行保证不冲突 |
|
||||
|
||||
## 10. 运行时状态码入口
|
||||
|
||||
配置项会影响以下运行时状态和返回值,详细枚举表见 `SDK_API_Reference.md`。
|
||||
|
||||
| 类型 | 使用位置 | 说明 |
|
||||
|---|---|---|
|
||||
| `FaceResultCode` | `ResultCode`、`OnError`、`FaceCommandException` | 命令和业务结果码 |
|
||||
| `FaceStateCode` | `OnFaceStateUpdated` | 人脸位置、遮挡、闭眼等状态 |
|
||||
| `FaceModuleStatus` | `CurrentStatus`、`GetStatusAsync()` | 模组待机、忙碌、错误状态 |
|
||||
| `FaceTransportMode` | `FaceSdkSettings.TransportMode` | 通信模式 |
|
||||
| `FaceExclusiveCommandPolicy` | `FaceSdkSettings.ExclusiveCommandPolicy` | 自动验证与独占命令冲突策略 |
|
||||
Keep only one `FaceModuleManager` in each scene to avoid duplicate serial connections and duplicated events.
|
||||
|
||||
@ -1,36 +1,33 @@
|
||||
# SDK 配置说明
|
||||
# SDK 配置
|
||||
|
||||
English documentation: [SDK_Configuration.md](SDK_Configuration.md).
|
||||
|
||||
SDK 推荐使用 `FaceSdkSettings` 作为配置资产。`FaceModuleManager` 可以读取该资产,并同步到运行时配置。
|
||||
SDK 推荐使用 `FaceSdkSettings` 作为配置资产。该配置是 `ScriptableObject`,会创建在导入该包的 Unity 项目中,并可同步到场景里的 `FaceModuleManager`。
|
||||
|
||||
## 默认配置资产
|
||||
|
||||
默认路径位于导入该包的 Unity 项目内:
|
||||
|
||||
```text
|
||||
Assets/Resources/AISU/SI-M1 Face SDK/FaceSdkSettings.asset
|
||||
Assets/AISU/SI-M1 Face SDK/FaceSdkSettings.asset
|
||||
```
|
||||
|
||||
打开 `AISU/SI-M1 Face SDK/Settings` 可以加载、编辑和保存配置。
|
||||
打开 `AISU/SI-M1 Face SDK/Settings` 可加载或创建该配置资产。
|
||||
|
||||
## FaceSdkSettings 字段
|
||||
|
||||
| 字段 | 类型 | 说明 |
|
||||
|---|---|---|
|
||||
| `TransportMode` | `FaceTransportMode` | `Auto`、`SerialPort` 或 `Mock` |
|
||||
| `UseMockInEditor` | `bool` | Editor 下强制使用 Mock 通信 |
|
||||
| `PortName` | `string` | 运行时串口号 |
|
||||
| `BaudRate` | `int` | 运行时波特率 |
|
||||
| `ReadBufferSize` | `int` | 运行时读取缓冲区 |
|
||||
| `UseEditorSerialDebugParameters` | `bool` | Editor 下是否使用单独串口参数 |
|
||||
| `UseMockInEditor` | `bool` | Unity Editor 中强制使用 Mock 通信 |
|
||||
| `PortName` | `string` | Runtime/Player 串口号 |
|
||||
| `BaudRate` | `int` | Runtime/Player 波特率 |
|
||||
| `ReadBufferSize` | `int` | Runtime/Player 读取缓冲区大小 |
|
||||
| `UseEditorSerialDebugParameters` | `bool` | Editor 中是否使用单独串口参数 |
|
||||
| `EditorPortName` | `string` | Editor 调试串口号 |
|
||||
| `EditorBaudRate` | `int` | Editor 调试波特率 |
|
||||
| `EditorReadBufferSize` | `int` | Editor 调试读取缓冲区 |
|
||||
| `EditorReadBufferSize` | `int` | Editor 调试读取缓冲区大小 |
|
||||
| `MockResponseDelayFrames` | `int` | Mock 响应延迟帧数 |
|
||||
| `AutoVerifyOnOpen` | `bool` | READY 后是否自动开启验证 |
|
||||
| `AutoVerifyTimeout` | `byte` | 自动验证协议超时时间,单位秒 |
|
||||
| `AutoVerifyResultIntervalMs` | `int` | 自动验证结果事件最小间隔 |
|
||||
| `StopAutoVerifyBeforeExclusiveCommand` | `bool` | 独占命令前是否停止自动验证 |
|
||||
| `ExclusiveCommandPolicy` | `FaceExclusiveCommandPolicy` | 自动验证期间执行独占命令的处理策略 |
|
||||
| `DebugLogEnabled` | `bool` | 是否启用 SDK Debug 日志 |
|
||||
| `RawLogEnabled` | `bool` | 是否派发原始 TX/RX 日志 |
|
||||
| `LogPrefix` | `string` | 日志前缀 |
|
||||
@ -43,33 +40,37 @@ Assets/Resources/AISU/SI-M1 Face SDK/FaceSdkSettings.asset
|
||||
| `SerialPort` | 使用 `SerialPortTransport` |
|
||||
| `Mock` | 使用 `MockFaceModuleTransport` |
|
||||
|
||||
当 `UseMockInEditor = true` 时,Editor 使用 Mock 通信,不会打开真实串口。
|
||||
当 `UseMockInEditor = true` 时,Editor 会始终使用 Mock 通信,不会打开真实串口。
|
||||
|
||||
## 自动验证
|
||||
## Editor 工具
|
||||
|
||||
`AutoVerifyTimeout` 会发送给 SI-M1 模组,表示识别超时时间。
|
||||
| 菜单 | 用途 |
|
||||
|---|---|
|
||||
| `AISU/SI-M1 Face SDK/Settings` | 打开 SDK 配置窗口 |
|
||||
| `AISU/SI-M1 Face SDK/Create Manager GameObject` | 创建或更新场景中的唯一 `FaceModuleManager` |
|
||||
| `AISU/SI-M1 Face SDK/Open Diagnostics` | 打开诊断窗口 |
|
||||
|
||||
`AutoVerifyResultIntervalMs` 由 Unity SDK 处理,用于限制 `OnAutoVerifyResult` 的派发频率。设置为 `0` 时不做节流。
|
||||
公开 DLL-only 包不包含可导入 Demo 示例。如果当前 Editor DLL 中仍出现 Demo 相关菜单,应视为公开版本不可用功能。
|
||||
|
||||
`StopAutoVerifyBeforeExclusiveCommand` 和 `ExclusiveCommandPolicy` 用于控制自动验证开启时,录入、用户管理、二维码、抓拍、特征等独占操作的行为。
|
||||
|
||||
## 运行时使用
|
||||
## 推荐用法
|
||||
|
||||
```csharp
|
||||
manager.ApplySettings(settings);
|
||||
manager.Open();
|
||||
```
|
||||
|
||||
快速配置:
|
||||
兼容式快速配置:
|
||||
|
||||
```csharp
|
||||
manager.Configure(useMockInEditor: true, portName: "COM3", baudRate: 115200);
|
||||
manager.Open();
|
||||
```
|
||||
|
||||
自定义通信层:
|
||||
自定义通信层注入:
|
||||
|
||||
```csharp
|
||||
manager.ConfigureTransport(customTransport);
|
||||
manager.Open();
|
||||
```
|
||||
|
||||
每个场景建议只保留一个 `FaceModuleManager`,避免重复打开串口和重复派发事件。
|
||||
|
||||
73
Documentation~/SDK_License_Request.md
Normal file
73
Documentation~/SDK_License_Request.md
Normal file
@ -0,0 +1,73 @@
|
||||
# SI-M1 Face SDK License Request
|
||||
|
||||
This public DLL-only package requires a project-specific license file for real serial-port runtime usage. Mock mode does not require a license.
|
||||
|
||||
## License File Path
|
||||
|
||||
Place the license file at:
|
||||
|
||||
```text
|
||||
Assets/StreamingAssets/si-m1_face.dat
|
||||
```
|
||||
|
||||
The SDK reads this file through `Application.streamingAssetsPath`.
|
||||
|
||||
## Required Unity Binding Parameters
|
||||
|
||||
Provide these values from the Unity project that will run the SDK:
|
||||
|
||||
| Field | Unity Source |
|
||||
|---|---|
|
||||
| `identifier` | `Application.identifier` |
|
||||
| `companyName` | `Application.companyName` |
|
||||
| `productName` | `Application.productName` |
|
||||
| `version` | `Application.version` |
|
||||
| `unityVersion` | `Application.unityVersion` |
|
||||
|
||||
If any of these values changes, the existing license becomes invalid and a new license is required.
|
||||
|
||||
## Parameter Probe
|
||||
|
||||
Add this temporary script to the customer project and copy the Console output when requesting a license:
|
||||
|
||||
```csharp
|
||||
using UnityEngine;
|
||||
|
||||
public sealed class FaceLicenseParameterPrinter : MonoBehaviour
|
||||
{
|
||||
private void Awake()
|
||||
{
|
||||
Debug.Log("identifier=" + Application.identifier);
|
||||
Debug.Log("companyName=" + Application.companyName);
|
||||
Debug.Log("productName=" + Application.productName);
|
||||
Debug.Log("version=" + Application.version);
|
||||
Debug.Log("unityVersion=" + Application.unityVersion);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Request Information
|
||||
|
||||
Provide:
|
||||
|
||||
| Item | Example |
|
||||
|---|---|
|
||||
| Customer name | `customer-a` |
|
||||
| Project name | `Face App` |
|
||||
| Unity binding parameters | See above |
|
||||
| License start time | `2026-08-10T00:00:00+08:00` |
|
||||
| License expiry time | `2027-08-10T00:00:00+08:00` |
|
||||
| Licensed features | `SerialRuntime,Basic,Verify,Enroll` |
|
||||
|
||||
License times use Beijing time and must use `yyyy-MM-ddTHH:mm:ss+08:00`.
|
||||
|
||||
## Common Failures
|
||||
|
||||
| Symptom | Cause |
|
||||
|---|---|
|
||||
| License file missing | `si-m1_face.dat` is not under `Assets/StreamingAssets` |
|
||||
| Binding mismatch | One of the Unity binding parameters changed |
|
||||
| Expired | Current Beijing time is after `expireAt` |
|
||||
| Not yet valid | Current Beijing time is before `issuedAt` |
|
||||
| Feature denied | The license does not include the requested SDK feature |
|
||||
| Invalid signature | The file was modified or does not match this SDK build |
|
||||
7
Documentation~/SDK_License_Request.md.meta
Normal file
7
Documentation~/SDK_License_Request.md.meta
Normal file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7f0d681e6f6b4d6a86f6a989cdf55091
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
73
Documentation~/SDK_License_Request.zh-CN.md
Normal file
73
Documentation~/SDK_License_Request.zh-CN.md
Normal file
@ -0,0 +1,73 @@
|
||||
# SI-M1 Face SDK 授权申请
|
||||
|
||||
DLL-only 公开包在真实串口运行时需要项目专用授权文件。Mock 模式不需要授权。
|
||||
|
||||
## 授权文件路径
|
||||
|
||||
授权文件必须放在客户 Unity 项目中:
|
||||
|
||||
```text
|
||||
Assets/StreamingAssets/si-m1_face.dat
|
||||
```
|
||||
|
||||
SDK 会通过 `Application.streamingAssetsPath` 读取该文件。
|
||||
|
||||
## 需要提供的 Unity 绑定参数
|
||||
|
||||
申请授权时需要提供运行 SDK 的 Unity 项目参数:
|
||||
|
||||
| 字段 | Unity 读取来源 |
|
||||
|---|---|
|
||||
| `identifier` | `Application.identifier` |
|
||||
| `companyName` | `Application.companyName` |
|
||||
| `productName` | `Application.productName` |
|
||||
| `version` | `Application.version` |
|
||||
| `unityVersion` | `Application.unityVersion` |
|
||||
|
||||
这些值任意变化后,已有授权会失效,需要重新申请授权。
|
||||
|
||||
## 参数打印脚本
|
||||
|
||||
客户可以在项目中临时添加以下脚本,并把 Console 输出发给授权人员:
|
||||
|
||||
```csharp
|
||||
using UnityEngine;
|
||||
|
||||
public sealed class FaceLicenseParameterPrinter : MonoBehaviour
|
||||
{
|
||||
private void Awake()
|
||||
{
|
||||
Debug.Log("identifier=" + Application.identifier);
|
||||
Debug.Log("companyName=" + Application.companyName);
|
||||
Debug.Log("productName=" + Application.productName);
|
||||
Debug.Log("version=" + Application.version);
|
||||
Debug.Log("unityVersion=" + Application.unityVersion);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 授权申请信息
|
||||
|
||||
建议提供:
|
||||
|
||||
| 项 | 示例 |
|
||||
|---|---|
|
||||
| 客户名称 | `customer-a` |
|
||||
| 项目名称 | `Face App` |
|
||||
| Unity 绑定参数 | 见上文 |
|
||||
| 授权开始时间 | `2026-08-10T00:00:00+08:00` |
|
||||
| 授权过期时间 | `2027-08-10T00:00:00+08:00` |
|
||||
| 授权功能 | `SerialRuntime,Basic,Verify,Enroll` |
|
||||
|
||||
授权时间使用北京时间,格式必须为 `yyyy-MM-ddTHH:mm:ss+08:00`。
|
||||
|
||||
## 常见失败原因
|
||||
|
||||
| 现象 | 原因 |
|
||||
|---|---|
|
||||
| 授权文件不存在 | `si-m1_face.dat` 没有放在 `Assets/StreamingAssets` 下 |
|
||||
| 授权绑定不匹配 | Unity 绑定参数发生变化 |
|
||||
| 授权已过期 | 当前北京时间晚于 `expireAt` |
|
||||
| 授权尚未生效 | 当前北京时间早于 `issuedAt` |
|
||||
| 功能未授权 | 授权中不包含当前调用的 SDK 功能 |
|
||||
| 签名无效 | 授权文件被修改,或与当前 SDK 构建不匹配 |
|
||||
7
Documentation~/SDK_License_Request.zh-CN.md.meta
Normal file
7
Documentation~/SDK_License_Request.zh-CN.md.meta
Normal file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9204393b20cb4dd9a9edb6f230fe6d3b
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -2,6 +2,8 @@
|
||||
|
||||
中文说明见 [SDK_Mock_And_Testing.zh-CN.md](SDK_Mock_And_Testing.zh-CN.md).
|
||||
|
||||
The public DLL-only package includes runtime mock support inside `Aisu.SIM1.Face.Runtime.dll`, but it does not include EditMode test source files.
|
||||
|
||||
## Editor Mock
|
||||
|
||||
For Editor integration without real hardware, enable mock mode in `FaceSdkSettings`:
|
||||
@ -10,14 +12,7 @@ For Editor integration without real hardware, enable mock mode in `FaceSdkSettin
|
||||
Use Mock In Editor = true
|
||||
```
|
||||
|
||||
When this option is enabled, the SDK uses `MockFaceModuleTransport` in the Unity Editor instead of opening a real serial port.
|
||||
|
||||
Mock mode is useful for:
|
||||
|
||||
- UI flow testing
|
||||
- Command callback testing
|
||||
- User-list display testing
|
||||
- Basic enrollment and verification workflow testing
|
||||
When this option is enabled, the SDK uses the built-in mock transport in the Unity Editor instead of opening a real serial port.
|
||||
|
||||
## Hardware Validation
|
||||
|
||||
@ -25,12 +20,9 @@ For real SI-M1 hardware validation:
|
||||
|
||||
1. Set `Use Mock In Editor = false`.
|
||||
2. Configure `Editor Port Name`, `Editor Baud Rate`, and `Editor Read Buffer Size`.
|
||||
3. Open the scene that contains one `FaceModuleManager`.
|
||||
4. Call `Open()`.
|
||||
5. Wait for `WaitReadyAsync()` or handle `OnReady`.
|
||||
3. Create a `FaceModuleManager` in the scene.
|
||||
4. Call `Open()`, then wait for `WaitReadyAsync()` or handle `OnReady`.
|
||||
|
||||
## Logs
|
||||
## Automated Tests
|
||||
|
||||
Enable `RawLogEnabled` to receive raw TX/RX logs through `OnRawLog`.
|
||||
|
||||
Enable `DebugLogEnabled` to print SDK-level debug logs.
|
||||
Internal EditMode tests are maintained in the private development SDK repository and are not distributed in this DLL-only public package.
|
||||
|
||||
@ -2,6 +2,8 @@
|
||||
|
||||
English documentation: [SDK_Mock_And_Testing.md](SDK_Mock_And_Testing.md).
|
||||
|
||||
公开 DLL-only 包在 `Aisu.SIM1.Face.Runtime.dll` 中包含运行时 Mock 支持,但不包含 EditMode 测试源码。
|
||||
|
||||
## Editor Mock
|
||||
|
||||
无真实硬件进行 Editor 联调时,在 `FaceSdkSettings` 中启用:
|
||||
@ -10,14 +12,7 @@ English documentation: [SDK_Mock_And_Testing.md](SDK_Mock_And_Testing.md).
|
||||
Use Mock In Editor = true
|
||||
```
|
||||
|
||||
启用后,SDK 在 Unity Editor 中使用 `MockFaceModuleTransport`,不会打开真实串口。
|
||||
|
||||
Mock 模式适用于:
|
||||
|
||||
- UI 流程测试
|
||||
- 命令回调测试
|
||||
- 用户列表显示测试
|
||||
- 基础录入和验证流程测试
|
||||
启用后,SDK 在 Unity Editor 中使用内置 Mock 通信层,不会打开真实串口。
|
||||
|
||||
## 真实硬件验证
|
||||
|
||||
@ -25,12 +20,9 @@ Mock 模式适用于:
|
||||
|
||||
1. 设置 `Use Mock In Editor = false`。
|
||||
2. 配置 `Editor Port Name`、`Editor Baud Rate` 和 `Editor Read Buffer Size`。
|
||||
3. 打开包含一个 `FaceModuleManager` 的场景。
|
||||
4. 调用 `Open()`。
|
||||
5. 等待 `WaitReadyAsync()` 或处理 `OnReady`。
|
||||
3. 在场景中创建 `FaceModuleManager`。
|
||||
4. 调用 `Open()`,然后等待 `WaitReadyAsync()` 或处理 `OnReady`。
|
||||
|
||||
## 日志
|
||||
## 自动化测试
|
||||
|
||||
启用 `RawLogEnabled` 后,可以通过 `OnRawLog` 接收原始 TX/RX 日志。
|
||||
|
||||
启用 `DebugLogEnabled` 后,可以输出 SDK 层 Debug 日志。
|
||||
内部 EditMode 测试保留在私有开发 SDK 仓库中,不随 DLL-only 公开包发布。
|
||||
|
||||
@ -2,7 +2,23 @@
|
||||
|
||||
中文说明见 [SDK_QuickStart.zh-CN.md](SDK_QuickStart.zh-CN.md).
|
||||
|
||||
## 1. Settings
|
||||
This public UPM package is distributed as compiled DLLs and does not include SDK source code, demo source code, test source code, or debug symbols.
|
||||
|
||||
## 1. Install
|
||||
|
||||
Add the package through Unity Package Manager:
|
||||
|
||||
```text
|
||||
https://git.aisu.xin/aisu-sdk/si-m1-face-package.git#v0.1.2
|
||||
```
|
||||
|
||||
Or add it to `Packages/manifest.json`:
|
||||
|
||||
```json
|
||||
"xin.aisu.si-m1.face": "https://git.aisu.xin/aisu-sdk/si-m1-face-package.git#v0.1.2"
|
||||
```
|
||||
|
||||
## 2. Create Settings
|
||||
|
||||
Open Unity menu:
|
||||
|
||||
@ -10,26 +26,25 @@ Open Unity menu:
|
||||
AISU/SI-M1 Face SDK/Settings
|
||||
```
|
||||
|
||||
The default settings asset path is:
|
||||
The tool creates or loads this settings asset inside the importing Unity project:
|
||||
|
||||
```text
|
||||
Assets/Resources/AISU/SI-M1 Face SDK/FaceSdkSettings.asset
|
||||
Assets/AISU/SI-M1 Face SDK/FaceSdkSettings.asset
|
||||
```
|
||||
|
||||
Configure:
|
||||
Configure serial port, baud rate, mock mode, and logging options.
|
||||
|
||||
- Transport mode
|
||||
- Runtime serial port and baud rate
|
||||
- Editor serial debug parameters
|
||||
- Mock mode
|
||||
- Auto verify options
|
||||
- Debug and raw protocol logs
|
||||
## 3. Create Manager
|
||||
|
||||
## 2. Scene Manager
|
||||
Open Unity menu:
|
||||
|
||||
Add one `FaceModuleManager` to the scene and bind the settings asset. Keep only one manager in a scene to avoid duplicate serial connections and duplicated callbacks.
|
||||
```text
|
||||
AISU/SI-M1 Face SDK/Create Manager GameObject
|
||||
```
|
||||
|
||||
## 3. Minimal Code
|
||||
Keep one `FaceModuleManager` in the scene to avoid duplicate serial connections and duplicate event dispatch.
|
||||
|
||||
## 4. Minimal Code
|
||||
|
||||
```csharp
|
||||
using Aisu.SIM1.Face.Core;
|
||||
@ -42,73 +57,24 @@ public sealed class FaceExample : MonoBehaviour
|
||||
private async void Start()
|
||||
{
|
||||
manager.Open();
|
||||
await manager.WaitReadyAsync(5000);
|
||||
await manager.WaitReadyAsync();
|
||||
|
||||
var status = await manager.Basic.GetStatusAsync();
|
||||
var version = await manager.Basic.GetVersionAsync();
|
||||
Debug.Log("Status: " + status);
|
||||
Debug.Log("Version: " + version);
|
||||
}
|
||||
|
||||
private void OnApplicationQuit()
|
||||
{
|
||||
manager?.Close();
|
||||
Debug.Log("SI-M1 version: " + version);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 4. Common Operations
|
||||
## 5. Runtime Modes
|
||||
|
||||
Face verification:
|
||||
| Scenario | Recommended Setting |
|
||||
|---|---|
|
||||
| Editor integration without hardware | `Use Mock In Editor = true` |
|
||||
| Editor with real serial hardware | `Use Mock In Editor = false`, configure editor serial parameters |
|
||||
| Windows Player | `Transport Mode = SerialPort` or `Auto`, configure runtime serial parameters |
|
||||
|
||||
```csharp
|
||||
var result = await manager.Verify.VerifyAsync(timeout: 10);
|
||||
if (result.Success)
|
||||
{
|
||||
Debug.Log("UserId: " + result.UserId);
|
||||
Debug.Log("UserName: " + result.UserName);
|
||||
}
|
||||
```
|
||||
## Notes
|
||||
|
||||
Face enrollment:
|
||||
|
||||
```csharp
|
||||
var enroll = await manager.Enrollment.EnrollSingleAsync(
|
||||
admin: false,
|
||||
userName: "Tester",
|
||||
timeout: 20);
|
||||
```
|
||||
|
||||
User list:
|
||||
|
||||
```csharp
|
||||
var ids = await manager.Users.GetAllUserIdsAsync();
|
||||
```
|
||||
|
||||
Auto verify:
|
||||
|
||||
```csharp
|
||||
manager.OnAutoVerifyResult += result =>
|
||||
{
|
||||
Debug.Log("AutoVerify: " + result.ResultCode);
|
||||
};
|
||||
|
||||
var control = await manager.StartAutoVerifyAsync(timeout: 10);
|
||||
if (!control.Success)
|
||||
{
|
||||
Debug.LogError("AutoVerify start failed: " + control.ResultCode);
|
||||
}
|
||||
|
||||
await manager.StopFaceOperationAsync();
|
||||
```
|
||||
|
||||
## 5. Samples
|
||||
|
||||
Open `AISU/SI-M1 Face SDK/Settings`, click `Import Demos`, then open:
|
||||
|
||||
```text
|
||||
Assets/Samples/AISU SI-M1 Face SDK/SIM1FaceDemo/Scenes/FaceModuleDemo.unity
|
||||
Assets/Samples/AISU SI-M1 Face SDK/FaceDetectionDemo/Scenes/FaceDetectionDemo.unity
|
||||
```
|
||||
|
||||
Package scenes under `Packages/xin.aisu.si-m1.face/Samples` are read-only and should not be opened directly.
|
||||
- Git URL packages may appear as `xin.aisu.si-m1.face@<commit-hash>` in Unity's package cache. This is normal.
|
||||
- This DLL-only release does not include importable demo samples.
|
||||
- Demo source and EditMode test source remain in the private development SDK repository.
|
||||
|
||||
@ -2,7 +2,23 @@
|
||||
|
||||
English documentation: [SDK_QuickStart.md](SDK_QuickStart.md).
|
||||
|
||||
## 1. 配置
|
||||
公开 UPM 包以编译后的 DLL 形式发布,不包含 SDK 源码、Demo 源码、测试源码或调试符号。
|
||||
|
||||
## 1. 安装
|
||||
|
||||
通过 Unity Package Manager 添加 Git URL:
|
||||
|
||||
```text
|
||||
https://git.aisu.xin/aisu-sdk/si-m1-face-package.git#v0.1.2
|
||||
```
|
||||
|
||||
或写入 `Packages/manifest.json`:
|
||||
|
||||
```json
|
||||
"xin.aisu.si-m1.face": "https://git.aisu.xin/aisu-sdk/si-m1-face-package.git#v0.1.2"
|
||||
```
|
||||
|
||||
## 2. 创建配置
|
||||
|
||||
打开 Unity 菜单:
|
||||
|
||||
@ -10,26 +26,25 @@ English documentation: [SDK_QuickStart.md](SDK_QuickStart.md).
|
||||
AISU/SI-M1 Face SDK/Settings
|
||||
```
|
||||
|
||||
默认配置资产路径:
|
||||
工具会在导入该包的 Unity 项目中创建或加载配置资产:
|
||||
|
||||
```text
|
||||
Assets/Resources/AISU/SI-M1 Face SDK/FaceSdkSettings.asset
|
||||
Assets/AISU/SI-M1 Face SDK/FaceSdkSettings.asset
|
||||
```
|
||||
|
||||
常用配置:
|
||||
配置串口号、波特率、Mock 模式和日志选项。
|
||||
|
||||
- 通信模式
|
||||
- 运行时串口号和波特率
|
||||
- Editor 串口调试参数
|
||||
- Mock 模式
|
||||
- 自动验证选项
|
||||
- Debug 日志和原始协议日志
|
||||
## 3. 创建 Manager
|
||||
|
||||
## 2. 场景 Manager
|
||||
打开 Unity 菜单:
|
||||
|
||||
在场景中添加一个 `FaceModuleManager` 并绑定配置资产。每个场景只保留一个 Manager,避免重复打开串口和重复派发回调。
|
||||
```text
|
||||
AISU/SI-M1 Face SDK/Create Manager GameObject
|
||||
```
|
||||
|
||||
## 3. 最小代码
|
||||
每个场景建议只保留一个 `FaceModuleManager`,避免重复打开串口和重复派发事件。
|
||||
|
||||
## 4. 最小代码
|
||||
|
||||
```csharp
|
||||
using Aisu.SIM1.Face.Core;
|
||||
@ -42,73 +57,24 @@ public sealed class FaceExample : MonoBehaviour
|
||||
private async void Start()
|
||||
{
|
||||
manager.Open();
|
||||
await manager.WaitReadyAsync(5000);
|
||||
await manager.WaitReadyAsync();
|
||||
|
||||
var status = await manager.Basic.GetStatusAsync();
|
||||
var version = await manager.Basic.GetVersionAsync();
|
||||
Debug.Log("Status: " + status);
|
||||
Debug.Log("Version: " + version);
|
||||
}
|
||||
|
||||
private void OnApplicationQuit()
|
||||
{
|
||||
manager?.Close();
|
||||
Debug.Log("SI-M1 version: " + version);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 4. 常用操作
|
||||
## 5. 运行模式
|
||||
|
||||
人脸验证:
|
||||
| 场景 | 推荐配置 |
|
||||
|---|---|
|
||||
| Editor 中无硬件联调 | `Use Mock In Editor = true` |
|
||||
| Editor 中连接真实串口硬件 | `Use Mock In Editor = false`,并配置 Editor 串口参数 |
|
||||
| Windows Player | `Transport Mode = SerialPort` 或 `Auto`,并配置运行时串口参数 |
|
||||
|
||||
```csharp
|
||||
var result = await manager.Verify.VerifyAsync(timeout: 10);
|
||||
if (result.Success)
|
||||
{
|
||||
Debug.Log("UserId: " + result.UserId);
|
||||
Debug.Log("UserName: " + result.UserName);
|
||||
}
|
||||
```
|
||||
## 注意事项
|
||||
|
||||
人脸录入:
|
||||
|
||||
```csharp
|
||||
var enroll = await manager.Enrollment.EnrollSingleAsync(
|
||||
admin: false,
|
||||
userName: "Tester",
|
||||
timeout: 20);
|
||||
```
|
||||
|
||||
用户列表:
|
||||
|
||||
```csharp
|
||||
var ids = await manager.Users.GetAllUserIdsAsync();
|
||||
```
|
||||
|
||||
自动验证:
|
||||
|
||||
```csharp
|
||||
manager.OnAutoVerifyResult += result =>
|
||||
{
|
||||
Debug.Log("AutoVerify: " + result.ResultCode);
|
||||
};
|
||||
|
||||
var control = await manager.StartAutoVerifyAsync(timeout: 10);
|
||||
if (!control.Success)
|
||||
{
|
||||
Debug.LogError("AutoVerify start failed: " + control.ResultCode);
|
||||
}
|
||||
|
||||
await manager.StopFaceOperationAsync();
|
||||
```
|
||||
|
||||
## 5. Samples
|
||||
|
||||
打开 `AISU/SI-M1 Face SDK/Settings`,点击 `Import Demos`,然后打开:
|
||||
|
||||
```text
|
||||
Assets/Samples/AISU SI-M1 Face SDK/SIM1FaceDemo/Scenes/FaceModuleDemo.unity
|
||||
Assets/Samples/AISU SI-M1 Face SDK/FaceDetectionDemo/Scenes/FaceDetectionDemo.unity
|
||||
```
|
||||
|
||||
`Packages/xin.aisu.si-m1.face/Samples` 下的场景是只读包内容,不要直接打开。
|
||||
- Unity 对 Git URL 包可能显示为 `xin.aisu.si-m1.face@<commit-hash>`,这是正常行为。
|
||||
- DLL-only 公开版本不包含可导入 Demo 示例。
|
||||
- Demo 源码和 EditMode 测试源码保留在私有开发 SDK 仓库中。
|
||||
|
||||
Binary file not shown.
62
README.md
62
README.md
@ -1,8 +1,8 @@
|
||||
# AISU SI-M1 Face SDK
|
||||
|
||||
`xin.aisu.si-m1.face` is a Unity SDK for AISU SI-M1 face recognition modules. It provides serial communication, packet parsing, module lifecycle management, face verification, face enrollment, user management, image capture, QR code, UVC parameters, mock transport, and sample scenes.
|
||||
`xin.aisu.si-m1.face` is a Unity UPM package for the AISU SI-M1 face recognition module. This public package is distributed as compiled DLLs and does not include SDK source code, demo source code, test source code, or debug symbols.
|
||||
|
||||
中文说明见 [README.zh-CN.md](README.zh-CN.md)。
|
||||
中文说明见 [README.zh-CN.md](README.zh-CN.md).
|
||||
|
||||
## Package Info
|
||||
|
||||
@ -10,17 +10,34 @@
|
||||
|---|---|
|
||||
| Package Name | `xin.aisu.si-m1.face` |
|
||||
| Display Name | `AISU SI-M1 Face SDK` |
|
||||
| Version | `0.1.5` |
|
||||
| Runtime Assembly | `Aisu.SIM1.Face.Runtime.dll` |
|
||||
| Editor Assembly | `Aisu.SIM1.Face.Editor.dll` |
|
||||
| Unity Version | `2021.3` or newer |
|
||||
| Settings Asset | `Assets/Resources/AISU/SI-M1 Face SDK/FaceSdkSettings.asset` |
|
||||
| User Settings Asset | `Assets/AISU/SI-M1 Face SDK/FaceSdkSettings.asset` in the importing Unity project |
|
||||
|
||||
## Install
|
||||
|
||||
Add the package through Unity Package Manager using this Git URL:
|
||||
|
||||
```text
|
||||
https://git.aisu.xin/aisu-sdk/si-m1-face-package.git#v0.1.5
|
||||
```
|
||||
|
||||
Or add it to `Packages/manifest.json`:
|
||||
|
||||
```json
|
||||
"xin.aisu.si-m1.face": "https://git.aisu.xin/aisu-sdk/si-m1-face-package.git#v0.1.5"
|
||||
```
|
||||
|
||||
Unity may display Git packages as `xin.aisu.si-m1.face@<commit-hash>` in `Library/PackageCache`. This is expected for Git URL packages; the package version remains defined by `package.json`.
|
||||
|
||||
## Quick Start
|
||||
|
||||
1. Open `AISU/SI-M1 Face SDK/Settings`.
|
||||
2. Configure serial port, baud rate, mock mode, auto verify, and logging options.
|
||||
3. Add one `FaceModuleManager` to the scene and bind the settings asset.
|
||||
4. Call SDK services through `FaceModuleManager`.
|
||||
1. Open `AISU/SI-M1 Face SDK/Settings` and create or load `FaceSdkSettings`.
|
||||
2. Set serial port, baud rate, mock mode, and logging options.
|
||||
3. Open `AISU/SI-M1 Face SDK/Create Manager GameObject` to create a `FaceModuleManager` in the current scene.
|
||||
4. Reference the manager from your own scripts and call the SDK services.
|
||||
|
||||
```csharp
|
||||
using Aisu.SIM1.Face.Core;
|
||||
@ -38,27 +55,9 @@ public sealed class FaceExample : MonoBehaviour
|
||||
var version = await manager.Basic.GetVersionAsync();
|
||||
Debug.Log("SI-M1 version: " + version);
|
||||
}
|
||||
|
||||
private void OnApplicationQuit()
|
||||
{
|
||||
manager?.Close();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Samples
|
||||
|
||||
Open `AISU/SI-M1 Face SDK/Settings` and click `Import Demos`, then open the imported scenes under `Assets/Samples`.
|
||||
|
||||
```text
|
||||
Assets/Samples/AISU SI-M1 Face SDK/SIM1FaceDemo/Scenes/FaceModuleDemo.unity
|
||||
Assets/Samples/AISU SI-M1 Face SDK/FaceDetectionDemo/Scenes/FaceDetectionDemo.unity
|
||||
```
|
||||
|
||||
Do not open sample scenes directly from `Packages/xin.aisu.si-m1.face/Samples`, because Git UPM package contents are read-only in Unity.
|
||||
|
||||
Use `SI-M1 Face Demo` for full SDK command testing. Use `Face Detection Demo` for a compact camera, serial, enrollment, verification, and user-list workflow.
|
||||
|
||||
## Documentation
|
||||
|
||||
| English | Chinese |
|
||||
@ -66,11 +65,14 @@ Use `SI-M1 Face Demo` for full SDK command testing. Use `Face Detection Demo` fo
|
||||
| [Quick Start](Documentation~/SDK_QuickStart.md) | [快速开始](Documentation~/SDK_QuickStart.zh-CN.md) |
|
||||
| [Configuration](Documentation~/SDK_Configuration.md) | [配置说明](Documentation~/SDK_Configuration.zh-CN.md) |
|
||||
| [API Reference](Documentation~/SDK_API_Reference.md) | [API 参考](Documentation~/SDK_API_Reference.zh-CN.md) |
|
||||
| [License Request](Documentation~/SDK_License_Request.md) | [授权申请](Documentation~/SDK_License_Request.zh-CN.md) |
|
||||
| [Mock and Testing](Documentation~/SDK_Mock_And_Testing.md) | [Mock 与测试](Documentation~/SDK_Mock_And_Testing.zh-CN.md) |
|
||||
| [Demo UI](Documentation~/README_UI.md) | [Demo UI](Documentation~/README_UI.zh-CN.md) |
|
||||
| [Demo UI Notice](Documentation~/README_UI.md) | [Demo UI 说明](Documentation~/README_UI.zh-CN.md) |
|
||||
|
||||
## Runtime Notes
|
||||
## Public Package Scope
|
||||
|
||||
- Keep one `FaceModuleManager` in each scene.
|
||||
- Use `Close()` or `CloseAsync()` when leaving a scene or quitting the app.
|
||||
- When auto verify is enabled, use `StopFaceOperationAsync()` before enrollment, user management, QR scan, image capture, or other exclusive operations.
|
||||
- SDK source files are not included.
|
||||
- `.pdb` debug symbols are not included.
|
||||
- Demo and test source files are not included.
|
||||
- Importable `Samples~` are not included in this DLL-only release.
|
||||
- Sample source and internal validation tests are maintained in the private development SDK repository.
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
# AISU SI-M1 Face SDK
|
||||
|
||||
`xin.aisu.si-m1.face` 是面向 AISU SI-M1 人脸识别模组的 Unity SDK,提供串口通信、协议封包/拆包、模组生命周期管理、人脸验证、人脸录入、用户管理、图片抓拍、二维码、UVC 参数、Mock 通信和示例场景。
|
||||
`xin.aisu.si-m1.face` 是面向 AISU SI-M1 人脸识别模组的 Unity UPM 包。公开发布包以编译后的 DLL 形式提供,不包含 SDK 源码、Demo 源码、测试源码或调试符号。
|
||||
|
||||
English documentation: [README.md](README.md).
|
||||
|
||||
@ -10,17 +10,34 @@ English documentation: [README.md](README.md).
|
||||
|---|---|
|
||||
| Package Name | `xin.aisu.si-m1.face` |
|
||||
| Display Name | `AISU SI-M1 Face SDK` |
|
||||
| Version | `0.1.5` |
|
||||
| Runtime Assembly | `Aisu.SIM1.Face.Runtime.dll` |
|
||||
| Editor Assembly | `Aisu.SIM1.Face.Editor.dll` |
|
||||
| Unity Version | `2021.3` 或更高 |
|
||||
| 配置资产路径 | `Assets/Resources/AISU/SI-M1 Face SDK/FaceSdkSettings.asset` |
|
||||
| 用户项目配置资产 | 导入项目中的 `Assets/AISU/SI-M1 Face SDK/FaceSdkSettings.asset` |
|
||||
|
||||
## 安装
|
||||
|
||||
在 Unity Package Manager 中使用以下 Git URL 导入:
|
||||
|
||||
```text
|
||||
https://git.aisu.xin/aisu-sdk/si-m1-face-package.git#v0.1.5
|
||||
```
|
||||
|
||||
或写入 `Packages/manifest.json`:
|
||||
|
||||
```json
|
||||
"xin.aisu.si-m1.face": "https://git.aisu.xin/aisu-sdk/si-m1-face-package.git#v0.1.5"
|
||||
```
|
||||
|
||||
Unity 对 Git URL 包可能会在 `Library/PackageCache` 中显示为 `xin.aisu.si-m1.face@<commit-hash>`。这是 Git 包的正常行为;包版本仍由 `package.json` 中的 `version` 字段定义。
|
||||
|
||||
## 快速开始
|
||||
|
||||
1. 打开 `AISU/SI-M1 Face SDK/Settings`。
|
||||
2. 配置串口号、波特率、Mock 模式、自动验证和日志选项。
|
||||
3. 在场景中保留一个 `FaceModuleManager`,并绑定配置资产。
|
||||
4. 通过 `FaceModuleManager` 调用 SDK 服务。
|
||||
1. 打开 `AISU/SI-M1 Face SDK/Settings`,创建或加载 `FaceSdkSettings`。
|
||||
2. 配置串口号、波特率、Mock 模式和日志选项。
|
||||
3. 打开 `AISU/SI-M1 Face SDK/Create Manager GameObject`,在当前场景中创建 `FaceModuleManager`。
|
||||
4. 在业务脚本中引用该 Manager 并调用 SDK 服务。
|
||||
|
||||
```csharp
|
||||
using Aisu.SIM1.Face.Core;
|
||||
@ -38,27 +55,9 @@ public sealed class FaceExample : MonoBehaviour
|
||||
var version = await manager.Basic.GetVersionAsync();
|
||||
Debug.Log("SI-M1 version: " + version);
|
||||
}
|
||||
|
||||
private void OnApplicationQuit()
|
||||
{
|
||||
manager?.Close();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Samples
|
||||
|
||||
打开 `AISU/SI-M1 Face SDK/Settings` 并点击 `Import Demos`,然后打开 `Assets/Samples` 下的场景。
|
||||
|
||||
```text
|
||||
Assets/Samples/AISU SI-M1 Face SDK/SIM1FaceDemo/Scenes/FaceModuleDemo.unity
|
||||
Assets/Samples/AISU SI-M1 Face SDK/FaceDetectionDemo/Scenes/FaceDetectionDemo.unity
|
||||
```
|
||||
|
||||
不要直接打开 `Packages/xin.aisu.si-m1.face/Samples` 下的示例场景,Git UPM 包内容在 Unity 中是只读的。
|
||||
|
||||
`SI-M1 Face Demo` 用于完整 SDK 命令测试。`Face Detection Demo` 用于摄像头、串口、录入、识别和用户列表的最小流程测试。
|
||||
|
||||
## 文档
|
||||
|
||||
| English | 中文 |
|
||||
@ -66,11 +65,14 @@ Assets/Samples/AISU SI-M1 Face SDK/FaceDetectionDemo/Scenes/FaceDetectionDemo.un
|
||||
| [Quick Start](Documentation~/SDK_QuickStart.md) | [快速开始](Documentation~/SDK_QuickStart.zh-CN.md) |
|
||||
| [Configuration](Documentation~/SDK_Configuration.md) | [配置说明](Documentation~/SDK_Configuration.zh-CN.md) |
|
||||
| [API Reference](Documentation~/SDK_API_Reference.md) | [API 参考](Documentation~/SDK_API_Reference.zh-CN.md) |
|
||||
| [License Request](Documentation~/SDK_License_Request.md) | [授权申请](Documentation~/SDK_License_Request.zh-CN.md) |
|
||||
| [Mock and Testing](Documentation~/SDK_Mock_And_Testing.md) | [Mock 与测试](Documentation~/SDK_Mock_And_Testing.zh-CN.md) |
|
||||
| [Demo UI](Documentation~/README_UI.md) | [Demo UI](Documentation~/README_UI.zh-CN.md) |
|
||||
| [Demo UI Notice](Documentation~/README_UI.md) | [Demo UI 说明](Documentation~/README_UI.zh-CN.md) |
|
||||
|
||||
## 运行注意
|
||||
## 公开包范围
|
||||
|
||||
- 每个场景只保留一个 `FaceModuleManager`。
|
||||
- 离开场景或退出应用时调用 `Close()` 或 `CloseAsync()`。
|
||||
- 开启自动验证后,录入、用户管理、二维码、抓拍等独占操作前调用 `StopFaceOperationAsync()`。
|
||||
- 不包含 SDK 源码。
|
||||
- 不包含 `.pdb` 调试符号。
|
||||
- 不包含 Demo 和测试源码。
|
||||
- DLL-only 公开版本不包含可导入的 `Samples~`。
|
||||
- 示例源码和内部验证测试保留在私有开发 SDK 仓库中。
|
||||
|
||||
@ -18,15 +18,14 @@ MonoBehaviour:
|
||||
m_baudRate: 115200
|
||||
m_readBufferSize: 4096
|
||||
m_useEditorSerialDebugParameters: 1
|
||||
m_editorPortName: COM4
|
||||
m_editorPortName: COM3
|
||||
m_editorBaudRate: 115200
|
||||
m_editorReadBufferSize: 4096
|
||||
m_mockResponseDelayFrames: 1
|
||||
m_autoVerifyOnOpen: 0
|
||||
m_autoVerifyTimeout: 10
|
||||
m_autoVerifyResultIntervalMs: 1000
|
||||
m_stopAutoVerifyBeforeExclusiveCommand: 1
|
||||
m_exclusiveCommandPolicy: 1
|
||||
m_debugLogEnabled: 0
|
||||
m_rawLogEnabled: 0
|
||||
m_debugLogEnabled: 1
|
||||
m_rawLogEnabled: 1
|
||||
m_logPrefix: '[FaceModule]'
|
||||
|
||||
Binary file not shown.
@ -4,10 +4,10 @@
|
||||
|
||||
## 场景
|
||||
|
||||
场景位于包内普通 `Samples` 目录:
|
||||
通过 Package Manager 导入 `SI-M1 Face Demo`,或使用 `AISU/SI-M1 Face SDK/Generate Demo Scene` 后,场景会位于:
|
||||
|
||||
```text
|
||||
Packages/xin.aisu.si-m1.face/Samples/Face Detection Demo/Scenes/FaceDetectionDemo.unity
|
||||
Assets/Samples/Face Detection Demo/Scenes/FaceDetectionDemo.unity
|
||||
```
|
||||
|
||||
打开该场景后运行,`FaceDetectionDemoBootstrap` 会自动生成单页 UGUI。
|
||||
|
||||
@ -216,16 +216,9 @@ namespace Aisu.SIM1.Face.Samples.FaceDetectionDemo
|
||||
/// </summary>
|
||||
public void DisconnectModule()
|
||||
{
|
||||
RunAsync(async () =>
|
||||
{
|
||||
if (m_manager != null)
|
||||
{
|
||||
await m_manager.CloseAsync();
|
||||
}
|
||||
|
||||
LogInfo("模组连接已关闭");
|
||||
RefreshStatus();
|
||||
});
|
||||
m_manager?.Close();
|
||||
LogInfo("模组连接已关闭");
|
||||
RefreshStatus();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -433,7 +426,7 @@ namespace Aisu.SIM1.Face.Samples.FaceDetectionDemo
|
||||
{
|
||||
try
|
||||
{
|
||||
await m_manager.StopFaceOperationAsync();
|
||||
await m_manager.Basic.FaceResetAsync();
|
||||
LogInfo(operationName + " 前已取消残留人脸流程");
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
8
Samples~/SI-M1 Face Demo/Editor.meta
Normal file
8
Samples~/SI-M1 Face Demo/Editor.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4ac476647a08a364289fa596d310bf3a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "Aisu.SIM1.Face.Samples.Editor",
|
||||
"rootNamespace": "Aisu.SIM1.Face.Editor",
|
||||
"references": [
|
||||
"Aisu.SIM1.Face.Runtime",
|
||||
"Aisu.SIM1.Face.Samples"
|
||||
],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 73502db286784cc3ac4a9e71f06f1002
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,39 @@
|
||||
#if UNITY_EDITOR
|
||||
using System.IO;
|
||||
using Aisu.SIM1.Face.Core;
|
||||
using Aisu.SIM1.Face.UI.Common;
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Aisu.SIM1.Face.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// 生成 SI-M1 全功能 Demo 场景。
|
||||
/// </summary>
|
||||
public static class FaceModuleDemoSceneGenerator
|
||||
{
|
||||
private const string ScenePath = "Assets/SI-M1 Face Demo/Scenes/FaceModuleDemo.unity"; // Demo 场景保存路径。
|
||||
|
||||
/// <summary>
|
||||
/// 创建并保存 Demo 场景。
|
||||
/// </summary>
|
||||
[MenuItem("AISU/SI-M1 Face SDK/Regenerate Imported Demo Scene")]
|
||||
public static void Generate()
|
||||
{
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(ScenePath));
|
||||
var scene = EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single);
|
||||
var managerGo = new GameObject("FaceModuleManager");
|
||||
managerGo.AddComponent<FaceModuleManager>();
|
||||
|
||||
var bootstrapGo = new GameObject("FaceModuleDemoBootstrap");
|
||||
bootstrapGo.AddComponent<FaceModuleDemoBootstrap>();
|
||||
|
||||
EditorSceneManager.SaveScene(scene, ScenePath);
|
||||
AssetDatabase.Refresh();
|
||||
Selection.activeObject = bootstrapGo;
|
||||
Debug.Log("FaceModule demo scene generated: " + ScenePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 230f42ee40b783c4784659a677f2fc59
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -303,14 +303,10 @@ namespace Aisu.SIM1.Face.Core
|
||||
/// <summary>
|
||||
/// 关闭串口。
|
||||
/// </summary>
|
||||
public async void CloseSerial()
|
||||
public void CloseSerial()
|
||||
{
|
||||
try
|
||||
{
|
||||
await Manager.CloseAsync();
|
||||
Log("串口已关闭。");
|
||||
}
|
||||
catch (Exception ex) { LogError("关闭串口失败:" + ex.Message); }
|
||||
Manager.Close();
|
||||
Log("串口已关闭。");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -383,7 +379,7 @@ namespace Aisu.SIM1.Face.Core
|
||||
/// </summary>
|
||||
public async void ResetModule()
|
||||
{
|
||||
try { await Manager.StopFaceOperationAsync(); Log("已停止当前人脸流程。"); }
|
||||
try { await Manager.Basic.ResetAsync(); Log("RESET 成功。"); }
|
||||
catch (Exception ex) { LogError("RESET 失败:" + ex.Message); }
|
||||
}
|
||||
|
||||
|
||||
@ -118,12 +118,9 @@ namespace Aisu.SIM1.Face.UI.Pages
|
||||
/// </summary>
|
||||
public void CloseConnection()
|
||||
{
|
||||
RunAsync(async () =>
|
||||
{
|
||||
await m_manager.CloseAsync();
|
||||
RefreshState();
|
||||
SetResult("连接已关闭");
|
||||
});
|
||||
m_manager.Close();
|
||||
RefreshState();
|
||||
SetResult("连接已关闭");
|
||||
}
|
||||
|
||||
/// <summary>等待 READY NOTE。</summary>
|
||||
@ -442,7 +439,14 @@ namespace Aisu.SIM1.Face.UI.Pages
|
||||
RunAsync(async () =>
|
||||
{
|
||||
if (!RequireConnected()) return;
|
||||
await m_manager.StopFaceOperationAsync();
|
||||
if (m_manager.IsAutoVerifyEnabled)
|
||||
{
|
||||
await m_manager.StopAutoVerifyAsync();
|
||||
SetResult("自动验证已关闭");
|
||||
return;
|
||||
}
|
||||
|
||||
await m_manager.Basic.ResetAsync();
|
||||
SetResult("已停止验证");
|
||||
});
|
||||
}
|
||||
@ -840,7 +844,14 @@ namespace Aisu.SIM1.Face.UI.Pages
|
||||
RunAsync(async () =>
|
||||
{
|
||||
if (!RequireConnected()) return;
|
||||
await m_manager.StopFaceOperationAsync();
|
||||
if (m_manager.IsAutoVerifyEnabled)
|
||||
{
|
||||
await m_manager.StopAutoVerifyAsync();
|
||||
SetResult("自动探测已停止");
|
||||
return;
|
||||
}
|
||||
|
||||
await m_manager.Basic.ResetAsync();
|
||||
SetResult("已停止");
|
||||
});
|
||||
}
|
||||
|
||||
18
package.json
18
package.json
@ -1,9 +1,9 @@
|
||||
{
|
||||
"name": "xin.aisu.si-m1.face",
|
||||
"displayName": "AISU SI-M1 Face SDK",
|
||||
"version": "0.1.8",
|
||||
"version": "0.1.6",
|
||||
"unity": "2021.3",
|
||||
"description": "Unity UPM package for the AISU SI-M1 face recognition module protocol, transport, command services, lifecycle manager, and demo samples.",
|
||||
"description": "Unity UPM package for the AISU SI-M1 face recognition module protocol, transport, command services, lifecycle manager, tests, and demo sample.",
|
||||
"author": {
|
||||
"name": "AISU"
|
||||
},
|
||||
@ -14,5 +14,17 @@
|
||||
"recognition",
|
||||
"serial",
|
||||
"unity"
|
||||
]
|
||||
],
|
||||
"samples": [
|
||||
{
|
||||
"displayName": "SI-M1 Face Demo",
|
||||
"description": "Full demo scene and UI for connecting, registering, recognizing, querying, deleting, and releasing the SI-M1 face module.",
|
||||
"path": "Samples~/SI-M1 Face Demo"
|
||||
},
|
||||
{
|
||||
"displayName": "Face Detection Demo",
|
||||
"description": "Minimal camera preview, serial connection, enrollment, recognition, and user data test scene.",
|
||||
"path": "Samples~/Face Detection Demo"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user