12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- #include "IDCardRecognitionSo.h"
- void* CreateIDCardRecognition()
- {
- try
- {
- return static_cast<void*>(new IDCardRecognitionLibs::IDCardRecognition());
- }
- catch (...)
- {
- // 处理异常
- return nullptr;
- }
- }
- void ReleaseIDCardRecognition(void* hIDCardRecognition)
- {
- if (hIDCardRecognition == nullptr) { return; }
- try
- {
- const auto iDCardRecognition = static_cast<IDCardRecognitionLibs::IDCardRecognition*>(hIDCardRecognition);
- iDCardRecognition->Dispose();
- delete iDCardRecognition;
- }
- catch (...)
- {
- return;
- }
- }
- bool LoadNetWorks(void* hIDCardRecognition, ModelDataInfor modelDataInfor)
- {
- if (hIDCardRecognition == nullptr) { return false; }
- try{
- const auto iDCardRecognition = static_cast<IDCardRecognitionLibs::IDCardRecognition*>(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<IDCardRecognitionLibs::IDCardRecognition*>(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<std::chrono::microseconds>(end - start);
- //auto duration_ms = std::chrono::duration_cast<std::chrono::milliseconds>(duration); // 将微秒转换为毫秒
- //result.TimeSpan = duration_ms.count();
- return result;
- }
- catch (std::exception& excep)
- {
- return IDCardRecogResult(); // 表示失败.
- }
- }
|