OnlineCardIdentifier.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #include "stdafx.h"
  2. #include "OnlineCardIdentifier.h"
  3. #include <tuple>
  4. #include <fstream>
  5. #include <atomic>
  6. extern std::atomic<int> g_examid_by_qr_code;
  7. namespace OnLineCard{
  8. void COnlineCardIdentifier::resetflag()
  9. {
  10. g_examid_by_qr_code.store(0);
  11. }
  12. COnlineCardIdentifier::COnlineCardIdentifier()
  13. {
  14. pageIdentifier = new COnLineCardPageIdentifier;
  15. }
  16. COnlineCardIdentifier::~COnlineCardIdentifier()
  17. {
  18. delete pageIdentifier; pageIdentifier = nullptr;
  19. }
  20. void COnlineCardIdentifier::SetTemplate(PaperTemplate*pT)
  21. {
  22. pageIdentifier->SetTemplate(pT);
  23. }
  24. void COnlineCardIdentifier::SetQr(bool bUseQr, const std::string&strQr)
  25. {
  26. if (pageIdentifier){
  27. pageIdentifier->SetUseQr(strQr, bUseQr);
  28. }
  29. }
  30. void COnlineCardIdentifier::SetOnlineScanType(int nOnlineScanType)
  31. {
  32. if (pageIdentifier)
  33. pageIdentifier->SetOnlineScanType(nOnlineScanType);
  34. }
  35. int COnlineCardIdentifier::Identify(const IplImage* img, void* out_result, int out_size)
  36. {
  37. int ret = 0;
  38. if (pageIdentifier){
  39. HMODULE module = GetModuleHandle(0);
  40. char pFileName[MAX_PATH + 2] = { 0 };
  41. GetModuleFileNameA(module, pFileName, MAX_PATH);
  42. std::string strPath = pFileName;
  43. int pos = strPath.find_last_of('\\', strPath.length());
  44. strPath = strPath.substr(0, pos) + "\\..\\config.ini";
  45. int nType = GetPrivateProfileIntA("USER", "algorithmflag", 0, strPath.c_str());
  46. pageIdentifier->m_nXianXiaDaFenType = nType;
  47. ret = pageIdentifier->Identify(img, out_result, out_size);
  48. }
  49. return ret;
  50. }
  51. }