You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
InspireFace SDK adopts a layered modular architecture design that provides high-performance face recognition capabilities across diverse hardware platforms. The system is structured into five main layers: Client Interface, Session Management, Core Services, Engine Layer, and Platform Support.
At the top level, the **Client Interface Layer** provides a unified C API that abstracts complex implementations, allowing developers to easily integrate face detection, recognition, and liveness detection functionalities. The **Session Management Layer** serves as the core processing unit, supporting multiple concurrent Session instances with independent configurations and resource isolation, alongside comprehensive image codec and processing capabilities for various formats (RGB, BGR, YUV).
8
+
9
+
The **Core Services Layer** encompasses two global services: App Context for SDK lifecycle and resource management, and Feature Hub for centralized face feature vector storage, search, and comparison with support for both memory and persistent storage modes.
10
+
11
+
The **Engine Layer** represents the performance cornerstone, featuring a **multi-backend heterogeneous neural network inference architecture** that intelligently selects optimal backends including ONNX Runtime, TensorRT, CoreML, and MNN based on available hardware resources.
12
+
13
+
The **Hardware Support Layer** provides comprehensive acceleration across multiple platforms. **GPU acceleration** includes full CUDA support for NVIDIA hardware with Tensor Core optimization, OpenCL compatibility for AMD devices, and native Metal framework support for Apple platforms. **Embedded NPU support** encompasses ARM Mali NPU, Rockchip NPU, and Apple NPU Engine(**ANE**) architectures. **CPU optimization** leverages ARM NEON SIMD instructions, Intel AVX/SSE extensions, and OpenMP-based multi-threading. Additionally, **2D image processing acceleration** utilizes hardware engines like ARM Mali GPU, Rockchip RGA for efficient format conversion, scaling, and geometric transformations with DMA-optimized zero-copy memory management.
14
+
15
+
This architecture ensures optimal performance through intelligent hardware detection and resource scheduling while maintaining cross-platform compatibility and easy integration across Linux, Windows, Android, and iOS environments.
Copy file name to clipboardExpand all lines: docs/using-with/c-cpp.md
+145-2Lines changed: 145 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -202,10 +202,153 @@ if (ret != HSUCCEED) {
202
202
// Not in use need to release
203
203
HFReleaseFaceFeature(&feature);
204
204
```
205
+
## Face Embedding Database
205
206
206
-
## Face Feature Management
207
+
We provide a lightweight face embedding vector database (**FeatureHub**) storage solution that includes basic functions such as adding, deleting, modifying, and searching, while supporting both **memory** and **persistent** storage modes.
207
208
208
-
TODO
209
+
Before starting FeatureHub, you need to be familiar with the following parameters:
210
+
211
+
-**primaryKeyMode**: Primary key mode, with two modes available. It's recommended to use HF_PK_AUTO_INCREMENT by default
212
+
- HF_PK_AUTO_INCREMENT: Auto-increment mode for primary keys
213
+
- HF_PK_MANUAL_INPUT: Manual input mode for primary keys, requiring users to avoid duplicate primary keys themselves
214
+
-**enablePersistence**: Whether to enable persistent database storage mode
215
+
- If true: The database will write to local files for persistent storage during usage
216
+
- If false: High-speed memory management mode, dependent on program lifecycle
217
+
-**persistenceDbPath**: Storage path required only for persistent mode, defined by the user. If the input is a folder rather than a file, the system default file naming will be used
218
+
-**searchThreshold**: Face search threshold, using floating-point numbers. During search, only embeddings above the threshold are searched. Different models and scenarios require manual threshold settings
219
+
-**searchMode**: Search mode, **effective only when searching for top-1 face**, with EAGER and EXHAUSTIVE modes (**this feature is temporarily disabled in the current version**)
220
+
- HF_SEARCH_MODE_EAGER: Complete search immediately upon encountering the first face above the threshold
221
+
- HF_SEARCH_MODE_EXHAUSTIVE: Search all similar faces and return the one with the highest similarity
222
+
223
+
### Enable/Disable FeatureHub
224
+
225
+
Using thread-safe singleton pattern design, it has global scope and only needs to be opened once:
226
+
227
+
```c
228
+
// When you need to enable global storage
229
+
HFFeatureHubConfiguration configuration;
230
+
configuration.primaryKeyMode = HF_PK_AUTO_INCREMENT; // Recommended to use auto increment
231
+
configuration.enablePersistence = 1; // If the memory mode is set to 0
// You can manually close it when you don't need to use it, or ignore it until the program ends
244
+
HFFeatureHubDataDisable();
245
+
```
246
+
247
+
### Insert Face Embedding
248
+
249
+
Insert a face embedding feature vector into FeatureHub. If in HF_PK_AUTO_INCREMENT mode, the input feature.id will be ignored. If in HF_PK_MANUAL_INPUT mode, the input feature.id is the ID the user expects to insert, and the actual inserted face ID is returned through result_id.
250
+
251
+
```c
252
+
// Insert face feature into the hub
253
+
HFFaceFeatureIdentity featureIdentity;
254
+
featureIdentity.feature = &feature;
255
+
featureIdentity.id = -1;
256
+
HFaceId result_id;
257
+
ret = HFFeatureHubInsertFeature(featureIdentity, &result_id);
Search for the top K faces with the highest similarity. Note that the data obtained by the `HFFeatureHubFaceSearchTopK` interface is cached data, and you need to retrieve all the result data you need before the next call, otherwise the next call will overwrite the historical data.
285
+
286
+
```c
287
+
// Create HFSearchTopKResults to store search results
288
+
HFSearchTopKResults results;
289
+
ret = HFFeatureHubFaceSearchTopK(feature, topK, &results);
290
+
if (ret != HSUCCEED) {
291
+
HFLogPrint(HF_LOG_ERROR, "The search for the top k vectors failed: %d", ret);
292
+
return ret;
293
+
}
294
+
295
+
// Get all the results
296
+
for (int i = 0; i < results.size; i++) {
297
+
HFloat score = results.confidence[i];
298
+
HPFaceId id = results.ids[i];
299
+
}
300
+
```
301
+
302
+
### Delete Face Embedding
303
+
304
+
Specify a face ID to delete that face from FeatureHub.
0 commit comments