115 lines
2.3 KiB
Markdown
115 lines
2.3 KiB
Markdown
# SDK Quick Start
|
|
|
|
中文说明见 [SDK_QuickStart.zh-CN.md](SDK_QuickStart.zh-CN.md).
|
|
|
|
## 1. Settings
|
|
|
|
Open Unity menu:
|
|
|
|
```text
|
|
AISU/SI-M1 Face SDK/Settings
|
|
```
|
|
|
|
The default settings asset path is:
|
|
|
|
```text
|
|
Assets/Resources/AISU/SI-M1 Face SDK/FaceSdkSettings.asset
|
|
```
|
|
|
|
Configure:
|
|
|
|
- Transport mode
|
|
- Runtime serial port and baud rate
|
|
- Editor serial debug parameters
|
|
- Mock mode
|
|
- Auto verify options
|
|
- Debug and raw protocol logs
|
|
|
|
## 2. Scene Manager
|
|
|
|
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.
|
|
|
|
## 3. Minimal Code
|
|
|
|
```csharp
|
|
using Aisu.SIM1.Face.Core;
|
|
using UnityEngine;
|
|
|
|
public sealed class FaceExample : MonoBehaviour
|
|
{
|
|
[SerializeField] private FaceModuleManager manager;
|
|
|
|
private async void Start()
|
|
{
|
|
manager.Open();
|
|
await manager.WaitReadyAsync(5000);
|
|
|
|
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();
|
|
}
|
|
}
|
|
```
|
|
|
|
## 4. Common Operations
|
|
|
|
Face verification:
|
|
|
|
```csharp
|
|
var result = await manager.Verify.VerifyAsync(timeout: 10);
|
|
if (result.Success)
|
|
{
|
|
Debug.Log("UserId: " + result.UserId);
|
|
Debug.Log("UserName: " + result.UserName);
|
|
}
|
|
```
|
|
|
|
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.
|