Face Engine SDK  5.17.0
A face detection, recognition and tracking engine.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
IIndex.h
1 #pragma once
2 
3 #include "IIDMap.h"
4 #include <fsdk/IAsyncContext.h>
5 #include <fsdk/IDescriptor.h>
6 
7 namespace fsdk {
8 
9  #ifndef DOXYGEN_SHOULD_SKIP_THIS
10  DECLARE_SMARTPTR(IStaticDescriptorStorage);
11  DECLARE_SMARTPTR(IDynamicDescriptorStorage);
12  DECLARE_SMARTPTR(IIndex);
13  DECLARE_SMARTPTR(IDenseIndex);
14  DECLARE_SMARTPTR(IDynamicIndex);
15  DECLARE_SMARTPTR(IIndexBuilder);
16  DECLARE_SMARTPTR(IIDMap);
17  #endif
18 
22  enum DynamicIndexState : uint8_t {
26  DIS_COUNT
27  };
29  using DescriptorId = size_t;
30 
37 
39  SearchResult() noexcept
40  : MatchingResult()
41  , index(std::numeric_limits<DescriptorId>::max())
42  {}
43 
51  float distance,
52  float similarity,
53  DescriptorId index) noexcept
55  , index(index)
56  {}
57  };
58 
75  const DescriptorId index,
76  IDescriptor* descriptor) const noexcept = 0;
77 
82  virtual uint32_t getDescriptorVersion() const noexcept = 0;
83 
88  virtual uint64_t size() const noexcept = 0;
89  };
90 
109  const IDescriptor* descriptor) noexcept = 0;
110 
124  const IDescriptorBatch* batch) noexcept = 0;
125 
143  virtual Result<FSDKError> removeDescriptor(const DescriptorId index) noexcept = 0;
144  };
145 
150  struct IIndex
151  : IRefCounted {
163  const IDescriptor* reference,
164  int maxResultsCount,
165  SearchResult* results) const noexcept = 0;
166  };
167 
171  struct IDenseIndex
173  , IIndex {
174 
175  };
176 
182  , IIndex {
192  virtual Result<FSDKError> saveToDenseIndex(const char* path) const noexcept = 0;
193 
204  virtual ResultValue<FSDKError, DynamicIndexState> saveToDynamicIndex(const char* path) const noexcept = 0;
205 
219  virtual uint64_t countOfIndexedDescriptors() const noexcept = 0;
220 
229  };
230 
240  virtual void progress(const float completion) const noexcept = 0;
241  };
242 
248  , IRefCounted {
258  const IProgressTracker* const progressTracker = nullptr) noexcept = 0;
259 
271  IAsyncContext* const asyncContext,
272  const IProgressTracker* const progressTracker = nullptr) noexcept = 0;
273  };
274 
275 
276 }
277 
DIS_VALID - index is valid for search.
Definition: IIndex.h:24
virtual ResultValue< FSDKError, DescriptorId > appendDescriptor(const IDescriptor *descriptor) noexcept=0
Appends descriptor to internal storage. If used on.
#define DECLARE_SMARTPTR(X)
Smart ptr declaration helper macro.
Definition: Def.h:56
virtual uint32_t getDescriptorVersion() const noexcept=0
Return version of stored descriptors.
virtual Result< FSDKError > removeDescriptor(const DescriptorId index) noexcept=0
Removes descriptor out of graph. If used on.
virtual Result< FSDKError > saveToDenseIndex(const char *path) const noexcept=0
Saves index as dense.
A structure that encapsulates an action result enumeration.
Definition: Result.h:27
Base index interface.
Definition: IIndex.h:150
Progress tracker interface.
Definition: IIndex.h:235
DIS_UNKNOWN - index state is unknown.
Definition: IIndex.h:25
Result of index search.
Definition: IIndex.h:34
Descriptor batch interface.
Definition: IDescriptor.h:148
virtual ResultValue< FSDKError, Future< ResultValue< FSDKError, IDynamicIndex * > > > buildIndexAsync(IAsyncContext *const asyncContext, const IProgressTracker *const progressTracker=nullptr) noexcept=0
Builds index with every descriptor appended. Non blocking operation.
virtual ResultValue< FSDKError, DynamicIndexState > saveToDynamicIndex(const char *path) const noexcept=0
Saves index as dynamic.
virtual uint64_t size() const noexcept=0
Return size of internal storage.
virtual uint64_t countOfIndexedDescriptors() const noexcept=0
Returns count of indexed descriptors.
Base strong reference counted object interface.
Definition: IRefCounted.h:37
Interface for running tasks asynchronously.
Definition: IAsyncContext.h:24
SearchResult() noexcept
Default constructor.
Definition: IIndex.h:39
DynamicIndexState
Index state.
Definition: IIndex.h:22
virtual Result< FSDKError > descriptorByIndex(const DescriptorId index, IDescriptor *descriptor) const noexcept=0
Requests descriptor data out of internal storage.
virtual ResultValue< FSDKError, IIDMapPtr > eraseRemovedDescriptors() noexcept=0
Erases removed descriptors out of index fully.
Descriptor extractor and matcher interfaces.
float similarity
similarity (normalized in [0..1] range).
Definition: IDescriptor.h:37
size_t DescriptorId
Intergral type used as identification of descriptor in internal storage.
Definition: IIDMap.h:17
Dynamic index interface.
Definition: IIndex.h:180
Addon for Result to output some value aside the result. Specialization for copiable types...
Definition: ResultValue.h:21
MatchingResult(void) noexcept
Initializes result to default values.
Definition: IDescriptor.h:42
Async context interface.
SearchResult(float distance, float similarity, DescriptorId index) noexcept
Construct structure with parameters.
Definition: IIndex.h:50
Dense (read only) index interface.
Definition: IIndex.h:171
Result of descriptor matching.
Definition: IDescriptor.h:35
DescriptorId index
Identificator of descriptor in some storage.
Definition: IIndex.h:36
virtual ResultValue< FSDKError, int > search(const IDescriptor *reference, int maxResultsCount, SearchResult *results) const noexcept=0
Search for descriptors with the shorter distance to passed descriptor.
Descriptor interface.
Definition: IDescriptor.h:100
float distance
distance between descriptor vectors.
Definition: IDescriptor.h:36
virtual ResultValue< FSDKError, IDynamicIndex * > buildIndex(const IProgressTracker *const progressTracker=nullptr) noexcept=0
Builds index with every descriptor appended. Blocks until completed.
Dynamic descriptor storage interface.
Definition: IIndex.h:95
DIS_INVALID - index is invalid for search.
Definition: IIndex.h:23
Index builder interface.
Definition: IIndex.h:246
virtual ResultValue< FSDKError, DescriptorId > appendBatch(const IDescriptorBatch *batch) noexcept=0
Appends batch of descriptors to internal storage. If used on.
Static descriptor storage interface.
Definition: IIndex.h:63
virtual void progress(const float completion) const noexcept=0
Function is called on some operation progress change.