CVB++ 15.0
search_result.hpp
1#pragma once
2
3#include "../_cexports/c_minos.h"
4
5#include "../global.hpp"
6#include "../point_2d.hpp"
7#include "../string.hpp"
8#include "../utilities/system_info.hpp"
9
10#include <sstream>
11#include <iomanip>
12
13namespace Cvb
14{
15 CVB_BEGIN_INLINE_NS
16
18 namespace Minos
19 {
20
22
24 class SearchResult
25 {
26 public:
27 SearchResult(const String &className, double quality, Point2D<double> position, Point2D<double> advanceVector)
28 : name_(className)
29 , quality_(quality)
30 , position_(position)
31 , advanceVector_(advanceVector)
32 {
33 }
34
35 SearchResult() noexcept = default;
36
37 public:
39
43 String Name() const
44 {
45 return name_;
46 }
47
49
53 double Quality() const noexcept
54 {
55 return quality_;
56 }
57
59
63 Point2D<double> Position() const noexcept
64 {
65 return position_;
66 }
67
69
73 double X() const noexcept
74 {
75 return position_.X();
76 }
77
79
83 double Y() const noexcept
84 {
85 return position_.Y();
86 }
87
89
94 {
95 return advanceVector_;
96 }
97
99
103 bool IsNothing() const noexcept
104 {
105 if (std::isnan(quality_))
106 return true;
107 return false;
108 }
109
111
115 explicit operator bool() const noexcept
116 {
117 return !IsNothing();
118 }
119
120 private:
121 String name_;
122 double quality_ = std::numeric_limits<double>::quiet_NaN();
123 Point2D<double> position_;
124 Point2D<double> advanceVector_;
125 };
126
128
135 inline bool operator!=(const SearchResult &lhs, const SearchResult &rhs) noexcept
136 {
137 return (lhs.Name() != rhs.Name()) || (lhs.Position() != rhs.Position()) || (lhs.Quality() != rhs.Quality())
138 || (lhs.AdvanceVector() != rhs.AdvanceVector());
139 }
140
142
149 inline bool operator==(const SearchResult &lhs, const SearchResult &rhs) noexcept
150 {
151 return (!(lhs != rhs));
152 }
153
154 namespace Private
155 {
156 /* Convert a Minos Result list into a list of SearchResult struts. */
157 inline std::vector<SearchResult> SearchResultsToArray(CExports::RESULTS hResults)
158 {
160
161 auto resultCount = CVB_CALL_CAPI(SearchResultsCount(hResults));
162 for (CExports::cvbdim_t i = 0; i < resultCount; ++i)
163 {
167 Cvb::Char *strName = nullptr;
168 CExports::cvbval_t searchID = 0;
169 CVB_CALL_CAPI_CHECKED(SearchResultTyped(hResults, i, quality, xpos, ypos, dx, dy, strName, searchID));
170 results.push_back(SearchResult((strName != nullptr) ? Cvb::String(strName) : Cvb::String(), quality,
171 Point2D<double>(xpos, ypos), Point2D<double>(dx, dy)));
172 }
173
174 return results;
175 }
176 } /* namespace Private */
177
178 } /* namespace Minos */
179 CVB_END_INLINE_NS
180} /* namespace Cvb */
Search result returned by Minos.
Definition search_result.hpp:25
bool IsNothing() const noexcept
Returns whether the search result is empty or not.
Definition search_result.hpp:103
String Name() const
Name of the class that has been found.
Definition search_result.hpp:43
double Quality() const noexcept
Quality at which the object has been found.
Definition search_result.hpp:53
Point2D< double > Position() const noexcept
Position at which the object has been found.
Definition search_result.hpp:63
double Y() const noexcept
Y position at which the object has been found.
Definition search_result.hpp:83
double X() const noexcept
X position at which the object has been found.
Definition search_result.hpp:73
Point2D< double > AdvanceVector() const noexcept
Advance vector of the model that has been found.
Definition search_result.hpp:93
Multi-purpose 2D vector class.
Definition point_2d.hpp:20
Search result as returned by the classifier.
Definition search_result.hpp:23
T isnan(T... args)
Namespace for the Minos package.
Definition classifier.hpp:29
bool operator==(const ClassifierModelInfo &lhs, const ClassifierModelInfo &rhs) noexcept
Comparison operator for ClassifierModelInfo objects.
Definition classifier.hpp:173
bool operator!=(const ClassifierModelInfo &lhs, const ClassifierModelInfo &rhs) noexcept
Comparison operator for ClassifierModelInfo objects.
Definition classifier.hpp:160
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17
char Char
Character type for wide characters or unicode characters.
Definition string.hpp:63
std::string String
String for wide characters or unicode characters.
Definition string.hpp:49
T quiet_NaN(T... args)