LocateTester.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #pragma once
  2. #include "scan_common.h"
  3. #include "..\Schema\schema_struct.h"
  4. #include <opencv2\opencv.hpp>
  5. #include "..\Identifier\schema_struct.h"
  6. #include "TestWorker.h"
  7. #include "..\Identifier\PageMatcher.h"
  8. #include <boost\smart_ptr.hpp>
  9. class CTestMatchTask:public CBaseTask{
  10. public:
  11. CTestMatchTask(){
  12. }
  13. CTestMatchTask(const cv::Mat& img, identify::CPageMatcher * matcher,int schama_index,int rotation){
  14. img_t =img;
  15. this->img =&img_t;
  16. this->matcher =matcher;
  17. this->schama_index =schama_index;
  18. this->rotation =rotation;
  19. }
  20. ~CTestMatchTask(){}
  21. virtual void run(){
  22. matcher->Identifi(img,schama_index,rotation,result);
  23. }
  24. public:
  25. identify::CPageMatcher * matcher ;
  26. const IplImage * img;
  27. IplImage img_t;
  28. int schama_index ;
  29. int rotation ;
  30. MATCH_REUSLT result;
  31. };
  32. class CLocateTester:private IService
  33. {
  34. private:
  35. enum{
  36. WORKER_COUNT=1,
  37. };
  38. public:
  39. CLocateTester(void);
  40. ~CLocateTester(void);
  41. public:
  42. bool isReady();
  43. bool isSameLocateSchema(const schema::SCHEMA& schema);
  44. bool test(const schema::SCHEMA& schema,const std::vector<std::string>& img_paths);
  45. bool isResultOk(){return m_isResultOk;}
  46. bool getTestResult(std::string& error_msg){error_msg = m_error_msg;return m_isOk;}
  47. protected:
  48. virtual ServiceState OnRunning( void );
  49. virtual ServiceState OnStarting( void );
  50. private:
  51. void loadSchema(const schema::SCHEMA& schema,const std::vector<std::string>& img_paths,std::vector<ISCH_SCHEMA_PAGE>& _schema);
  52. void SetPageDefault(ISCH_SCHEMA_PAGE& page);
  53. virtual ServiceState OnStoping( void );
  54. //std::vector<SchemaPage> _schema;
  55. boost::shared_ptr<ISCH_Schema> _schema;
  56. CTestWorker m_worker[WORKER_COUNT];
  57. identify::CPageMatcher matcher[WORKER_COUNT];
  58. std::vector<CTestMatchTask> m_matchtask;
  59. //std::vector<IplImage * > imgs;
  60. std::vector<cv::Mat> imgs;
  61. //测试器是否准备就绪
  62. bool m_isReady;
  63. //上一层测试模板
  64. schema::SCHEMA last_test_schema;
  65. //测试结果
  66. bool m_isOk;
  67. //测试结果字符串
  68. std::string m_error_msg;
  69. //标记结果是否已经检测出来了,是否有效
  70. bool m_isResultOk;
  71. };