IdentifyWorker.cpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #include "StdAfx.h"
  2. #include "IdentifyWorker.h"
  3. CIdentifyWorker::CIdentifyWorker(void):m_identify_state(IS_WAITING)
  4. {
  5. }
  6. CIdentifyWorker::~CIdentifyWorker(void)
  7. {
  8. }
  9. void CIdentifyWorker::SetUseQr(bool bUseQr, const std::string&strQr)
  10. {
  11. m_Identifier.SetUseQr(bUseQr, strQr);
  12. }
  13. ServiceState CIdentifyWorker::OnRunning( void )
  14. {
  15. if(m_identify_state == IS_WAITING){
  16. ServiceState nextState = IService::OnRunning();
  17. if(nextState != running) return nextState;
  18. Sleep(10);
  19. return running;
  20. }
  21. if (m_identify_task_type == ITT_NORMARL || m_identify_task_type == ITT_MANUALMATCH)
  22. m_Identifier.Identify2(m_img, m_out_result);
  23. //if(m_identify_task_type == ITT_MANUALMATCH)m_Identifier.Identify3(m_img,m_schema_index,m_muban,m_shijuan,m_out_result);
  24. *m_presult_buffer_state = identified;
  25. cvReleaseImage(&m_img);
  26. m_identify_state = IS_WAITING;
  27. return running;
  28. }
  29. BOOL CIdentifyWorker::Start(void)
  30. {
  31. return __super::Start();
  32. }
  33. ServiceState CIdentifyWorker::OnStarting( void )
  34. {
  35. m_identify_state = IS_WAITING;
  36. return IService::OnStarting();
  37. }
  38. BOOL CIdentifyWorker::Identify(const IplImage * img, OMR_RESULT * out_result, result_buffer_state * presult_buffer_state)
  39. {
  40. if(m_identify_state == IS_IDENTIFING)return FALSE;
  41. m_img =(IplImage * )img;
  42. m_out_result =out_result;
  43. m_presult_buffer_state = presult_buffer_state;
  44. m_identify_task_type = ITT_NORMARL;
  45. m_identify_state = IS_IDENTIFING;
  46. return TRUE;
  47. }
  48. BOOL CIdentifyWorker::Identify(const IplImage * img, OMR_RESULT * out_result, result_buffer_state * presult_buffer_state, int schema_index, const std::vector<Point2f>& muban, const std::vector<Point2f>& shijuan)
  49. {
  50. if (m_identify_state == IS_IDENTIFING)return FALSE;
  51. m_img = (IplImage *)img;
  52. m_out_result = out_result;
  53. m_presult_buffer_state = presult_buffer_state;
  54. m_schema_index = schema_index;
  55. m_muban = muban;
  56. m_shijuan = shijuan;
  57. m_identify_task_type = ITT_MANUALMATCH;
  58. m_identify_state = IS_IDENTIFING;
  59. return TRUE;
  60. }
  61. void CIdentifyWorker::LoadSchema(const boost::shared_ptr<const ISCH_Schema>& schema)
  62. {
  63. m_Identifier.LoadMuban2(schema);
  64. }