CVB++ 15.0
search_result.hpp
1#pragma once
2
3#include "../_cexports/c_sf2.h"
4
5#include "shapefinder2.hpp"
6
7#include "../point_2d.hpp"
8#include "../string.hpp"
9//
10#include <iomanip>
11
12namespace Cvb
13{
14CVB_BEGIN_INLINE_NS
15
16
17namespace ShapeFinder2
18{
19
21
24{
25
26public:
27
28 SearchResult () noexcept
29 : precisionMode_ (Cvb::ShapeFinder2::PrecisionMode::NoCorrelation), position_(), quality_ (0.0), rotation_ (0.0), scale_ (0.0)
30 {}
31
33
38 {
39 return precisionMode_;
40 }
41
43
47 Point2D<double> Position () const noexcept
48 {
49 return position_;
50 }
51
53
57 double X () const noexcept
58 {
59 return position_.X();
60 }
61
63
67 double Y () const noexcept
68 {
69 return position_.Y();
70 }
71
73
77 double Quality () const noexcept
78 {
79 return quality_;
80 }
81
83
87 double Scale () const noexcept
88 {
89 return scale_;
90 }
91
93
97 Angle Rotation () const noexcept
98 {
99 return Angle::FromRadians(rotation_);
100 }
101
103
109 bool operator!= (const SearchResult & rhs) const noexcept
110 {
111 return ((*this).PrecisionMode() != rhs.PrecisionMode()) || ((*this).Position() != rhs.Position()) || ((*this).Quality() != rhs.Quality()) || ((*this).Rotation() != rhs.Rotation()) || ((*this).Scale() != rhs.Scale());
112 }
113
115
121 bool operator== (const SearchResult & rhs) const noexcept
122 {
123 return (!(*this != rhs));
124 }
125
126private:
128 : precisionMode_ (mode)
129 {
130 if (data.size() == 5)
131 {
132 position_.SetX(data[0]);
133 position_.SetY(data[1]);
134 quality_ = data[2];
135 rotation_ = data[3] * CVB_M_PI / 180.0;
136 scale_ = data[4];
137 }
138 }
139
140private:
142 Point2D<double> position_;
143 double quality_;
144 double rotation_;
145 double scale_;
146
147 friend class Classifier;
148}; // Search Result
149
150
151} // %ShapeFinder2
152
153using ShapeFinder2::SearchResult;
154
155CVB_END_INLINE_NS
156} // CVB
Object for convenient and type - safe handling of angles.
Definition: angle.hpp:19
static Angle FromRadians(double rad, bool trim=false) noexcept
Create an angle in radians.
Definition: angle.hpp:44
T X() const noexcept
Gets the x-component of the point.
Definition: point_2d.hpp:86
T Y() const noexcept
Gets the y-component of the point.
Definition: point_2d.hpp:106
void SetX(T x) noexcept
Sets the x-component of the point.
Definition: point_2d.hpp:96
void SetY(T y)
Sets the y-component of the point.
Definition: point_2d.hpp:116
Search result as returned by the classifier.
Definition: search_result.hpp:24
bool operator!=(const SearchResult &rhs) const noexcept
Comparison operator for SearchResult objects.
Definition: search_result.hpp:109
double Quality() const noexcept
Quality measure of the result.
Definition: search_result.hpp:77
double Scale() const noexcept
Scale of the result relative the originally trained object.
Definition: search_result.hpp:87
Point2D< double > Position() const noexcept
Result location in the image.
Definition: search_result.hpp:47
Angle Rotation() const noexcept
Rotation angle of the result.
Definition: search_result.hpp:97
double Y() const noexcept
Y position at which the object has been found.
Definition: search_result.hpp:67
double X() const noexcept
X position at which the object has been found.
Definition: search_result.hpp:57
bool operator==(const SearchResult &rhs) const noexcept
Comparison operator for SearchResult objects.
Definition: search_result.hpp:121
Cvb::ShapeFinder2::PrecisionMode PrecisionMode() const noexcept
PrecisionMode that was used for generating this result.
Definition: search_result.hpp:37
PrecisionMode
Controls precision over accuracy for ShapeFinder 1 type searches.
Definition: shapefinder2.hpp:47
@ NoCorrelation
In the NoCorrelation mode, only the ShapeFinder edge model will be searched.
Root namespace for the Image Manager interface.
Definition: c_barcode.h:24