CVB++ 15.0
search_result.hpp
1#pragma once
2
3#include "../_cexports/c_polimago.h"
4
5#include "../global.hpp"
6#include "../angle.hpp"
7#include "../matrix_2d.hpp"
8
9namespace Cvb
10{
11 CVB_BEGIN_INLINE_NS
12
14 namespace Polimago
15 {
16
18
20 class SearchResult
21 {
22 public:
23 SearchResult() noexcept
24 : quality_(0.0)
25 , x_(0.0)
26 , y_(0.0)
27 , scale_(0.0)
28 , rotation_()
29 , matrix_()
30 , resInternal_()
31 {
32 }
33
34 private:
35 SearchResult(CExports::TSearchResult res, CExports::TSCLF clfHandle)
36 : SearchResult()
37 {
38 quality_ = res.Quality; // NOLINT(cppcoreguidelines-prefer-member-initializer)
39 CVB_CALL_CAPI(PMGetXY(clfHandle, res, x_, y_));
41 CVB_CALL_CAPI(PMGetScaleAngle(clfHandle, res, scale_, arad));
42 rotation_ = Angle::FromRadians(arad);
43 /* Note: the binary compatibility between Matrix and TMatrix is guaranteed, therefore the cast below is legal.
44 */
45 CVB_CALL_CAPI(PMGetMatrix(clfHandle, res, reinterpret_cast<CExports::TMatrix &>(matrix_)));
46 resInternal_ = res; // NOLINT(cppcoreguidelines-prefer-member-initializer)
47 }
48 friend class SearchPredictor;
49
50 public:
52
56 double Quality() const noexcept
57 {
58 return quality_;
59 }
60
62
66 double Confidence() const noexcept
67 {
68 return quality_;
69 }
70
72
76 double X() const noexcept
77 {
78 return x_;
79 }
80
82
86 double Y() const noexcept
87 {
88 return y_;
89 }
90
92
96 double Scale() const noexcept
97 {
98 return scale_;
99 }
100
102
106 Angle Rotation() const noexcept
107 {
108 return rotation_;
109 }
110
112
116 class Matrix2D Matrix() const noexcept
117 {
118 return matrix_;
119 }
120
121 private:
122 double quality_;
123 double x_;
124 double y_;
125 double scale_;
126 Angle rotation_;
127 class Matrix2D matrix_;
128 // (Internal search result needed for SearchPredictor::Inspect).
129 CExports::TSearchResult resInternal_;
130 };
131
133
140 inline bool operator==(const SearchResult &lhs, const SearchResult &rhs) noexcept
141 {
142 return (lhs.Quality() == rhs.Quality()) && (lhs.X() == rhs.X()) && (lhs.Y() == rhs.Y())
143 && (lhs.Matrix() == rhs.Matrix()) && (lhs.Rotation() == rhs.Rotation()) && (lhs.Scale() == rhs.Scale());
144 }
145
147
154 inline bool operator!=(const SearchResult &lhs, const SearchResult &rhs) noexcept
155 {
156 return (!(lhs == rhs));
157 }
158
159 } /* namespace Polimago */
160 CVB_END_INLINE_NS
161} /* namespace Cvb */
Object for convenient and type - safe handling of angles.
Definition angle.hpp:16
static Angle FromRadians(double rad, bool trim=false) noexcept
Create an angle in radians.
Definition angle.hpp:39
Double precision 2x2 matrix class.
Definition matrix_2d.hpp:16
Search results as provided by a Search Classifier.
Definition search_result.hpp:21
double Confidence() const noexcept
Search result quality or confidence (just under a different name).
Definition search_result.hpp:66
double Quality() const noexcept
Search result quality or confidence.
Definition search_result.hpp:56
double Scale() const noexcept
Scale of the result (if applicable).
Definition search_result.hpp:96
Angle Rotation() const noexcept
Rotation of the result (if applicable).
Definition search_result.hpp:106
double Y() const noexcept
Y-position.
Definition search_result.hpp:86
double X() const noexcept
X-position.
Definition search_result.hpp:76
class Matrix2D Matrix() const noexcept
Transformation description in Matrix form.
Definition search_result.hpp:116
Namespace for the Polimago package.
Definition classification_predictor.hpp:38
bool operator==(const SearchResult &lhs, const SearchResult &rhs) noexcept
Comparison operator for SearchResult objects.
Definition search_result.hpp:140
bool operator!=(const SearchResult &lhs, const SearchResult &rhs) noexcept
Comparison operator for SearchResult objects.
Definition search_result.hpp:154
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17
T quiet_NaN(T... args)