| 231 | } |
| 232 | |
| 233 | int main(int argc, char** argv) { |
| 234 | if (argc != 3) { |
| 235 | std::cout << "Usage: " << argv[0] << " <model_path> <image_path>" << std::endl; |
| 236 | return -1; |
| 237 | } |
| 238 | |
| 239 | std::string modelPath = argv[1]; |
| 240 | std::string imagePath = argv[2]; |
| 241 | |
| 242 | // Initialize InspireFace using C API |
| 243 | HResult ret = HFLaunchInspireFace(modelPath.c_str()); |
| 244 | if (ret != HSUCCEED) { |
| 245 | std::cerr << "Failed to launch InspireFace: " << ret << std::endl; |
| 246 | return -1; |
| 247 | } |
| 248 | |
| 249 | // Create session using C API |
| 250 | HOption option = HF_ENABLE_FACE_RECOGNITION; |
| 251 | HFSession session; |
| 252 | ret = HFCreateInspireFaceSessionOptional(option, HF_DETECT_MODE_LIGHT_TRACK, 10, -1, -1, &session); |
| 253 | if (ret != HSUCCEED) { |
| 254 | std::cerr << "Failed to create session: " << ret << std::endl; |
| 255 | return -1; |
| 256 | } |
| 257 | |
| 258 | // Set session parameters using C API |
| 259 | HFSessionSetTrackPreviewSize(session, 640); |
| 260 | |
| 261 | // Create thread-safe token storage |
| 262 | ThreadSafeTokenStorage tokenStorage; |
| 263 | |
| 264 | // Start face tracking thread |
| 265 | std::thread trackingThread(faceTrackingThread, std::ref(tokenStorage), session, imagePath, 50); |
| 266 | |
| 267 | // Start feature extraction thread |
| 268 | std::thread extractionThread(featureExtractionThread, std::ref(tokenStorage), session, imagePath); |
| 269 | |
| 270 | // Main thread: monitor and print statistics |
| 271 | std::cout << "Main thread: Monitoring token storage..." << std::endl; |
| 272 | for (int i = 0; i < 30; i++) { |
| 273 | std::this_thread::sleep_for(std::chrono::milliseconds(500)); |
| 274 | |
| 275 | size_t tokenCount = tokenStorage.getTokenCount(); |
| 276 | std::cout << "Token storage status: " << tokenCount << " tokens available" << std::endl; |
| 277 | } |
| 278 | |
| 279 | // Stop threads |
| 280 | std::cout << "Stopping threads..." << std::endl; |
| 281 | tokenStorage.stop(); |
| 282 | |
| 283 | // Wait for threads to finish |
| 284 | trackingThread.join(); |
| 285 | extractionThread.join(); |
| 286 | |
| 287 | // Cleanup using C API |
| 288 | HFReleaseInspireFaceSession(session); |
| 289 | |
| 290 | std::cout << "All threads finished successfully" << std::endl; |
nothing calls this directly
no test coverage detected