OnlineCardIdentifyWorker.cpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #include "stdafx.h"
  2. #include "OnlineCardIdentifyWorker.h"
  3. namespace OnLineCard{
  4. COnlineCardIdentifyWorker::COnlineCardIdentifyWorker()
  5. {
  6. }
  7. COnlineCardIdentifyWorker::~COnlineCardIdentifyWorker()
  8. {
  9. }
  10. bool COnlineCardIdentifyWorker::OnLineCardIdentify(IplImage * img, void * out_result, int out_size, result_buffer_state * presult_buffer_state)
  11. {
  12. if (m_identify_state == identify_state::identifing)return false;
  13. m_identify_state = identify_state::identifing;
  14. m_img = img;
  15. m_out_result = out_result;
  16. m_out_size = out_size;
  17. m_presult_buffer_state = presult_buffer_state;
  18. return true;
  19. }
  20. ServiceState COnlineCardIdentifyWorker::OnStarting(void)
  21. {
  22. m_identify_state = identify_state::waiting;
  23. m_Identifier.resetflag();
  24. return IService::OnStarting();
  25. }
  26. void COnlineCardIdentifyWorker::SetTemplate(PaperTemplate*pT)
  27. {
  28. m_Identifier.SetTemplate(pT);
  29. }
  30. void COnlineCardIdentifyWorker::SetQr(bool bUseQr, const std::string&strQr)
  31. {
  32. m_Identifier.SetQr(bUseQr, strQr);
  33. }
  34. void COnlineCardIdentifyWorker::SetOnlineScanType(int nOnlineScanType)
  35. {
  36. m_Identifier.SetOnlineScanType(nOnlineScanType);
  37. }
  38. ServiceState COnlineCardIdentifyWorker::OnRunning(void)
  39. {
  40. if (m_identify_state == identify_state::waiting){
  41. ServiceState nextState = IService::OnRunning();
  42. if (nextState != ServiceState::running) return nextState;
  43. Sleep(10);
  44. return ServiceState::running;
  45. }
  46. // printf("Ïß³Ì%s: m_Identifier.Identify \n",std::to_string(GetCurrentThreadId()).c_str());
  47. m_Identifier.Identify(m_img, m_out_result, m_out_size);
  48. // printf("Ïß³Ì%s: m_Identifier.Identify--end \n", std::to_string(GetCurrentThreadId()).c_str());
  49. *m_presult_buffer_state = identified;
  50. m_identify_state = identify_state::waiting;
  51. cvReleaseImage(&m_img);
  52. return ServiceState::running;
  53. }
  54. }