3DiVi Face SDK  3.25.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Groups
TemplatesIndex.h
Go to the documentation of this file.
1 
9 #ifndef __PBIO_API__PBIO__TEMPLATES_INDEX_H_
10 #define __PBIO_API__PBIO__TEMPLATES_INDEX_H_
11 
12 
13 #include <ostream>
14 #include <sstream>
15 #include <vector>
16 #include <string>
17 
18 
19 #include "ComplexObject.h"
20 #include "Error.h"
21 #include "SmartPtr.h"
22 #include "stl_wraps_impls/WrapOStreamImpl.h"
23 
24 
25 
26 
27 namespace pbio
28 {
29 
30 class Recognizer;
31 
37 class TemplatesIndex : public ComplexObject
38 {
39 public:
40 
46  typedef LightSmartPtr<TemplatesIndex>::tPtr Ptr;
47 
65  std::string getMethodName() const;
66 
84  size_t size() const;
85 
109  pbio::Template::Ptr at(size_t i) const;
110 
111 
132  void reserveSearchMemory(const int queries_count) const;
133 
134 private:
136  const DHPtr &dll_handle,
137  void* impl);
138 
139  friend class Recognizer;
140  friend class object_with_ref_counter<TemplatesIndex>;
141 };
142 
143 } // pbio namespace
144 
145 
146 
147 
151 
152 namespace pbio
153 {
154 
155 inline
156 TemplatesIndex::TemplatesIndex(
157  const DHPtr &dll_handle,
158  void* impl):
159 ComplexObject(dll_handle, impl)
160 {
161  // nothing else
162 }
163 
164 
165 
166 inline
167 std::string TemplatesIndex::getMethodName() const
168 {
169  std::ostringstream name_stream;
170  pbio::stl_wraps::WrapOStreamImpl name_stream_wrap(name_stream);
171 
172  void* exception = NULL;
173 
174  _dll_handle->TemplatesIndex_getMethodName(
175  _impl,
176  &name_stream_wrap,
177  pbio::stl_wraps::WrapOStream::write_func,
178  &exception);
179 
180  checkException(exception, *_dll_handle);
181 
182  return name_stream.str();
183 }
184 
185 
186 inline
187 size_t TemplatesIndex::size() const
188 {
189  void* exception = NULL;
190 
191  const size_t size = _dll_handle->TemplatesIndex_size(
192  _impl,
193  &exception);
194 
195  checkException(exception, *_dll_handle);
196 
197  return size;
198 }
199 
200 
201 inline
203 {
204  void* exception = NULL;
205 
206  pbio::facerec::TemplateImpl* const result_impl = _dll_handle->TemplatesIndex_at(
207  _impl,
208  i,
209  &exception);
210 
211  checkException(exception, *_dll_handle);
212 
213  return Template::Ptr::make(_dll_handle, result_impl);
214 }
215 
216 
217 inline
218 void TemplatesIndex::reserveSearchMemory(const int queries_count) const
219 {
220  void* exception = NULL;
221 
222  _dll_handle->TemplatesIndex_reserveSearchMemory(
223  _impl,
224  queries_count,
225  &exception);
226 
227  checkException(exception, *_dll_handle);
228 }
229 } // pbio namespace
230 #endif // __PBIO_API__PBIO__TEMPLATES_INDEX_H_
size_t size() const
Get a number of templates in the index. Thread-safe.
Definition: TemplatesIndex.h:187
Interface object for working with the template index.
Definition: TemplatesIndex.h:37
std::string getMethodName() const
Get a method name. Thread-safe.
Definition: TemplatesIndex.h:167
Definition: Recognizer.h:64
Interface object for creating and matching templates.
Definition: Recognizer.h:37
LightSmartPtr< Template >::tPtr Ptr
Alias for the type of a smart pointer to Template.
Definition: Template.h:46
LightSmartPtr< TemplatesIndex >::tPtr Ptr
Alias for the type of a smart pointer to TemplatesIndex.
Definition: TemplatesIndex.h:46
Error - the class of exceptions thrown when errors occur.
void reserveSearchMemory(const int queries_count) const
Reserve memory for temporary buffers used while searching. These temporary buffers require 8 * size()...
Definition: TemplatesIndex.h:218
SmartPtr.
pbio::Template::Ptr at(size_t i) const
Get an i-th template. Thread-safe.
Definition: TemplatesIndex.h:202