#include "IDCardRecognitionSo.h" void* CreateIDCardRecognition() { try { return static_cast(new IDCardRecognitionLibs::IDCardRecognition()); } catch (...) { // 处理异常 return nullptr; } } void ReleaseIDCardRecognition(void* hIDCardRecognition) { if (hIDCardRecognition == nullptr) { return; } try { const auto iDCardRecognition = static_cast(hIDCardRecognition); iDCardRecognition->Dispose(); delete iDCardRecognition; } catch (...) { return; } } bool LoadNetWorks(void* hIDCardRecognition, ModelDataInfor modelDataInfor) { if (hIDCardRecognition == nullptr) { return false; } try{ const auto iDCardRecognition = static_cast(hIDCardRecognition); bool status = iDCardRecognition->LoadNetWorks(modelDataInfor); return status; } catch (...) { return false; } } IDCardRecogResult EvaluateOneImage(void* hIDCardRecognition, ImageInfo imgInfor) { if (hIDCardRecognition == nullptr) { return IDCardRecogResult(); } const auto iDCardRecognition = static_cast(hIDCardRecognition); IDCardRecogResult result; try { //// 记录开始时间点 //auto start = std::chrono::high_resolution_clock::now(); iDCardRecognition->EvaluateOneImage(imgInfor, result); //// 记录结束时间点 计算时间差 //auto end = std::chrono::high_resolution_clock::now(); //auto duration = std::chrono::duration_cast(end - start); //auto duration_ms = std::chrono::duration_cast(duration); // 将微秒转换为毫秒 //result.TimeSpan = duration_ms.count(); return result; } catch (std::exception& excep) { return IDCardRecogResult(); // 表示失败. } }