Main Page · Modules · All Classes · Class Hierarchy
MAWeakModel.hpp
1 /*
2  * This file is part of the AiBO+ project
3  *
4  * Copyright (C) 2005-2016 Csaba Kertész (csaba.kertesz@gmail.com)
5  *
6  * AiBO+ is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * AiBO+ is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
19  *
20  */
21 
22 #pragma once
23 
24 #include "core/MACoreTypes.hpp"
25 #include "MAModel.hpp"
26 
27 #include <string>
28 
29 #include <boost/scoped_ptr.hpp>
30 
31 class MAWeakModel;
32 
38 namespace MA
39 {
41 typedef std::vector<ModelSPtr> OpenCVModelPtrList;
42 
44 typedef boost::scoped_ptr<MAWeakModel> WeakModelSPtr;
45 }
46 
51 {
52 public:
53  /*
54  * @brief Class constructor
55  *
56  * @param classifier First classifier in the weak model
57  *
58  * Note: The ownership of the classifier is taken and destroyed along with this object.
59  *
60  */
61 
62  explicit MAWeakModel(MAModel& classifier);
64  ~MAWeakModel();
65 
66  /*
67  * @brief Get feature vector size
68  *
69  * @return Composite vector size of all classifiers
70  *
71  */
72 
73  unsigned int GetFeatureCount() const;
74 
75  /*
76  * @brief Get list of labels in the weak model
77  *
78  * @return Reference to the label list in the weak model
79  *
80  */
81 
82  MC::FloatList& GetModelLabels();
83 
84  /*
85  * @brief Add an other classifier to the weak model
86  *
87  * @param classifier New classifier
88  *
89  * Note: The ownership of the classifier is taken and destroyed along with this object.
90  *
91  */
92 
93  void AddClassifier(MAModel& classifier);
94 
95  /*
96  * @brief Predict some samples with labels
97  *
98  * @param input_vectors Input samples for prediction
99  * @param[out] confidences Confidence values for the predictions
100  *
101  * @return Predicted label for each vector
102  *
103  */
104 
105  MC::FloatList Predict(const MC::FloatTable& input_vectors, MC::FloatList& confidences);
106 
107  /*
108  * @brief Predict one sample with multiple weak labels
109  *
110  * @param input_vector One input sample for prediction
111  * @param[out] confidence Confidence value for the prediction
112  *
113  * @return Predicted label
114  *
115  */
116 
117  float Predict(const MC::FloatList& input_vector, MC::FloatList& confidence);
118 
119  /*
120  * @brief Predict some samples with labels
121  *
122  * @param input_vectors Input samples for prediction
123  *
124  * @return Predicted weak labels for each vector
125  *
126  */
127 
128  MC::FloatTable Predict(const MC::FloatTable& input_vectors);
129 
130  /*
131  * @brief Predict one sample with multiple weak labels
132  *
133  * @param input_vector One input sample for prediction
134  *
135  * @return Predicted weak labels
136  *
137  */
138 
139  MC::FloatList Predict(const MC::FloatList& input_vector);
140 
141  /*
142  * @brief Encode the weak model into binary data
143  *
144  * @return Binary data
145  *
146  */
147 
148  MCBinaryData* Encode() const;
149 
150  /*
151  * @brief Decode the weak model from binary data
152  *
153  * @param data Binary data
154  *
155  * @return Decoded weak model otherwise NULL.
156  *
157  */
158 
159  static MAWeakModel* Decode(const MCBinaryData& data);
160 
161 private:
163  MA::OpenCVModelPtrList Classifiers;
164 };
165 
Binary data class.
Classifier model based on OpenCV classifiers.
Definition: MAModel.hpp:50
MA::OpenCVModelPtrList Classifiers
OpenCV classifiers.
Weak model based on OpenCV classifiers.
Definition: MAWeakModel.hpp:50