Face Engine SDK  5.16.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 <fsdk/IAsyncContext.h>
4 #include <fsdk/IDescriptor.h>
5 
6 namespace fsdk {
7 
8  #ifndef DOXYGEN_SHOULD_SKIP_THIS
9  DECLARE_SMARTPTR(IStaticDescriptorStorage);
10  DECLARE_SMARTPTR(IDynamicDescriptorStorage);
11  DECLARE_SMARTPTR(IIndex);
12  DECLARE_SMARTPTR(IDenseIndex);
13  DECLARE_SMARTPTR(IDynamicIndex);
14  DECLARE_SMARTPTR(IIndexBuilder);
15  #endif
16 
18  using DescriptorId = size_t;
19 
26 
28  SearchResult() noexcept
29  : MatchingResult()
30  , index(std::numeric_limits<DescriptorId>::max())
31  {}
32 
40  float distance,
41  float similarity,
42  DescriptorId index) noexcept
44  , index(index)
45  {}
46  };
47 
64  const DescriptorId index,
65  IDescriptor* descriptor) const noexcept = 0;
66 
71  virtual uint32_t getDescriptorVersion() const noexcept = 0;
72 
77  virtual uint64_t size() const noexcept = 0;
78  };
79 
98  const IDescriptor* descriptor) noexcept = 0;
99 
113  const IDescriptorBatch* batch) noexcept = 0;
114 
132  virtual Result<FSDKError> removeDescriptor(const DescriptorId index) noexcept = 0;
133  };
134 
139  struct IIndex
140  : IRefCounted {
152  const IDescriptor* reference,
153  int maxResultsCount,
154  SearchResult* results) const noexcept = 0;
155  };
156 
160  struct IDenseIndex
162  , IIndex {
163 
164  };
165 
171  , IIndex {
181  virtual Result<FSDKError> saveToDenseIndex(const char* path) const noexcept = 0;
182 
192  virtual Result<FSDKError> saveToDynamicIndex(const char* path) const noexcept = 0;
193 
207  virtual uint64_t countOfIndexedDescriptors() const noexcept = 0;
208  };
209 
219  virtual void progress(const float completion) const noexcept = 0;
220  };
221 
227  , IRefCounted {
237  const IProgressTracker* const progressTracker = nullptr) noexcept = 0;
238 
250  IAsyncContext* const asyncContext,
251  const IProgressTracker* const progressTracker = nullptr) noexcept = 0;
252  };
253 
254 
255 }
256 
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 internal storage. 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:139
Progress tracker interface.
Definition: IIndex.h:214
Result of index search.
Definition: IIndex.h:23
Descriptor batch interface.
Definition: IDescriptor.h:146
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 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:28
virtual Result< FSDKError > descriptorByIndex(const DescriptorId index, IDescriptor *descriptor) const noexcept=0
Requests descriptor data out of internal storage.
Descriptor extractor and matcher interfaces.
float similarity
similarity (normalized in [0..1] range).
Definition: IDescriptor.h:37
Dynamic index interface.
Definition: IIndex.h:169
size_t DescriptorId
Intergral type used as identification of descriptor in internal storage.
Definition: IIndex.h:18
virtual Result< FSDKError > saveToDynamicIndex(const char *path) const noexcept=0
Saves index as dynamic.
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:39
Dense (read only) index interface.
Definition: IIndex.h:160
Result of descriptor matching.
Definition: IDescriptor.h:35
DescriptorId index
Identificator of descriptor in some storage.
Definition: IIndex.h:25
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:98
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:84
Index builder interface.
Definition: IIndex.h:225
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:52
virtual void progress(const float completion) const noexcept=0
Function is called on some operation progress change.