Advertisement
Guest User

Untitled

a guest
Jul 27th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. class PhotoRecognizer
  2. {
  3. public:
  4. int perform_recogniton()
  5. {
  6. pPreProcessing->do_preprocessing();
  7. pFeatureExtractor->do_feature_extraction();
  8. pClassifier->do_classification()
  9. }
  10.  
  11. boost::shared_ptr<PreProcessing> pPreProcessing;
  12. boost::shared_ptr<FeatureExtractor> pFeatureExtractor;
  13. boost::shared_ptr<Classifier> pClassifier;
  14.  
  15. }
  16.  
  17. class SVMClassifier: public Classifier
  18. {
  19. public:
  20. void do_classification();
  21.  
  22. };
  23.  
  24. class MethodFactory
  25. {
  26. public:
  27. MethodFactory(){};
  28. boost::shared_ptr<PreProcessing> pPreProcessing;
  29. boost::shared_ptr<FeatureExtractor> pFeatureExtractor;
  30. boost::shared_ptr<Classifier> pClassifier;
  31.  
  32. };
  33. class Method1:public MethodFactory
  34. {
  35. public:
  36. Method1():MethodFactory()
  37. {
  38. pPreProcessing.reset(new GaussianFiltering);
  39. pFeatureExtractor.reset(new FFTStatictis);
  40. pClassifier.reset(new SVMClassifier);
  41.  
  42. }
  43.  
  44. };
  45.  
  46. class Method2:public MethodFactory
  47. {
  48. public:
  49. Method1():MethodFactory()
  50. {
  51. pPreProcessing.reset(new MedianFiltering);
  52. pFeatureExtractor.reset(new WaveletStatictis);
  53. pClassifier.reset(new NearestNeighborClassifier);
  54.  
  55. }
  56.  
  57. };
  58.  
  59.  
  60.  
  61. class PhotoRecognizer
  62. {
  63. public:
  64. PhotoRecognizer(MethodFactory *p):pFactory(p)
  65. {
  66. }
  67. int perform_recogniton()
  68. {
  69. pFactory->pPreProcessing->do_preprocessing();
  70. pFactory->pFeatureExtractor->do_feature_extraction();
  71. pFactory->pClassifier->do_classification()
  72. }
  73.  
  74. MethodFactory *pFactory;
  75.  
  76.  
  77. }
  78.  
  79. Method1 med;
  80. PhotoRecognizer recogMethod1(&med);
  81. med.perform_recognition()
  82.  
  83. enum RecMethod
  84. {
  85. Method1, Method2
  86.  
  87. };
  88.  
  89. class PhotoRecognizer
  90. {
  91. public:
  92. PhotoRecognizer(RecMethod)
  93. {
  94. switch(RecMethod)
  95. {
  96. case Method1:
  97. pFactory.reset(new Method1());
  98. break;
  99. ...
  100. }
  101. }
  102.  
  103. boost::shared_ptr<MethodFactory> pFactory;
  104.  
  105. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement