libcrn  3.9.5
A document image processing library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CRNClassifResult.h
Go to the documentation of this file.
1 /* Copyright 2008-2015 INSA Lyon, CoReNum
2  *
3  * This file is part of libcrn.
4  *
5  * libcrn is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * libcrn is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with libcrn. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * file: CRNClassifResult.h
19  * \author Yann LEYDIER
20  */
21 
22 #ifndef CRNCLASSIFRESULT_HEADER
23 #define CRNCLASSIFRESULT_HEADER
24 
25 #include <CRNString.h>
26 #include <math.h>
27 
28 namespace crn
29 {
30  /****************************************************************************/
41  {
42  public:
44  ClassifResult():class_id(-1),class_label(U""),distance(HUGE_VAL),prototype(nullptr) {}
52  ClassifResult(int cid, double dist, const SCObject &proto):class_id(cid),class_label(cid),distance(dist),prototype(proto) {}
61  ClassifResult(int cid, const String &label, double dist, const SCObject &proto):class_id(cid),class_label(label),distance(dist),prototype(proto) {}
62 
63  ClassifResult(const ClassifResult&) = default;
64  ClassifResult(ClassifResult&&) = default;
65  ClassifResult& operator=(const ClassifResult&) = default;
67 
68  int class_id;
70  double distance;
71  const SCObject prototype;
79  inline bool operator<(const ClassifResult &cr) const noexcept { return distance < cr.distance; }
80 
85  class SelectId: public std::unary_function<const ClassifResult&, bool>
86  {
87  public:
88  SelectId() = default;
94  inline SelectId(int id) noexcept:class_id(id) {}
102  inline bool operator()(const ClassifResult &cr) const noexcept { return class_id == cr.class_id; }
103 
104  private:
105  int class_id = 0;
106  };
107  };
108 
109  CRN_ALIAS_SMART_PTR(ClassifResult)
110 }
111 #endif
ClassifResult(int cid, const String &label, double dist, const SCObject &proto)
Constructor from prototype and label.
SelectId(int id) noexcept
Initialization of the functor.
A UTF32 character string class.
Definition: CRNString.h:61
const SCObject prototype
A generic classification result.
Functor to select results in a container.
bool operator<(const ClassifResult &cr) const noexcept
Comparison operator.
ClassifResult()
Default constructor.
ClassifResult(int cid, double dist, const SCObject &proto)
Constructor from prototype.
CRN_ALIAS_SMART_PTR(ImageBW)
bool operator()(const ClassifResult &cr) const noexcept
Functor operator.
ClassifResult & operator=(const ClassifResult &)=default