| 7 | #include <inspireface/inspireface.hpp> |
| 8 | |
| 9 | int main(int argc, char** argv) { |
| 10 | if (argc != 3) { |
| 11 | std::cout << "Usage: " << argv[0] << " <model_path> <image_path>" << std::endl; |
| 12 | return -1; |
| 13 | } |
| 14 | |
| 15 | std::string model_path = argv[1]; |
| 16 | std::string image_path = argv[2]; |
| 17 | |
| 18 | // Global init(only once) |
| 19 | INSPIREFACE_CONTEXT->Reload(model_path); |
| 20 | |
| 21 | // Create image and frame process |
| 22 | inspirecv::Image image = inspirecv::Image::Create(image_path); |
| 23 | inspirecv::FrameProcess process = |
| 24 | inspirecv::FrameProcess::Create(image.Data(), image.Height(), image.Width(), inspirecv::BGR, inspirecv::ROTATION_0); |
| 25 | |
| 26 | // Create session |
| 27 | inspire::CustomPipelineParameter param; |
| 28 | param.enable_recognition = true; |
| 29 | param.enable_liveness = true; |
| 30 | param.enable_mask_detect = true; |
| 31 | param.enable_face_attribute = true; |
| 32 | param.enable_face_quality = true; |
| 33 | std::shared_ptr<inspire::Session> session(inspire::Session::CreatePtr(inspire::DETECT_MODE_LIGHT_TRACK, 100, param, 640)); |
| 34 | session->SetTrackPreviewSize(640); |
| 35 | session->SetTrackModeDetectInterval(10); |
| 36 | |
| 37 | INSPIREFACE_CHECK_MSG(session != nullptr, "Session is not valid"); |
| 38 | |
| 39 | |
| 40 | for (int i = 0; i < 100; i++) { |
| 41 | |
| 42 | // Detect and track |
| 43 | std::vector<inspire::FaceTrackWrap> results; |
| 44 | int32_t ret; |
| 45 | // Start time |
| 46 | auto start = std::chrono::high_resolution_clock::now(); |
| 47 | ret = session->FaceDetectAndTrack(process, results); |
| 48 | INSPIREFACE_CHECK_MSG(ret == 0, "FaceDetectAndTrack failed"); |
| 49 | auto end = std::chrono::high_resolution_clock::now(); |
| 50 | // End time |
| 51 | auto duration = std::chrono::duration_cast<std::chrono::microseconds>(end - start); |
| 52 | std::cout << i << " MultipleFacePipelineProcess: " << duration.count() / 1000.0 << " ms" << std::endl; |
| 53 | |
| 54 | } |
| 55 | |
| 56 | |
| 57 | return 0; |
| 58 | } |
nothing calls this directly
no test coverage detected