| Face Engine SDK 5.2.0 A face detection, recognition and tracking engine.

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
IIndex.h
1 #pragma once
2
3 #include "IAsyncContext.h"
4 #include "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
23 struct SearchResult : MatchingResult {
25 DescriptorId index;
26
28 SearchResult() noexcept
29 : MatchingResult()
30 , index(std::numeric_limits<DescriptorId>::max())
31 {}
32
39 SearchResult(
40 float distance,
41 float similarity,
42 DescriptorId index) noexcept
43 : MatchingResult(distance, similarity)
44 , index(index)
45 {}
46 };
47
52 struct IStaticDescriptorStorage {
62 virtual Result<FSDKError> descriptorByIndex(
63 const DescriptorId index,
64 IDescriptor* descriptor) const noexcept = 0;
65
70 virtual uint32_t getDescriptorVersion() const noexcept = 0;
71
76 virtual uint64_t size() const noexcept = 0;
77 };
78
83 struct IDynamicDescriptorStorage
84 : IStaticDescriptorStorage {
95 virtual ResultValue<FSDKError, DescriptorId> appendDescriptor(
96 const IDescriptor* desciptor) noexcept = 0;
97
109 virtual ResultValue<FSDKError, DescriptorId> appendBatch(
110 const IDescriptorBatch* batch) noexcept = 0;
111
126 virtual Result<FSDKError> removeDescriptor(const DescriptorId index) noexcept = 0;
127 };
128
133 struct IIndex
134 : IRefCounted {
145 virtual ResultValue<FSDKError, int> search(
146 const IDescriptor* reference,
147 int maxResultsCount,
148 SearchResult* results) const noexcept = 0;
149 };
150
154 struct IDenseIndex
155 : IStaticDescriptorStorage
156 , IIndex {
157
158 };
159
163 struct IDynamicIndex
164 : IDynamicDescriptorStorage
165 , IIndex {
174 virtual Result<FSDKError> saveToDenseIndex(const char* path) const noexcept = 0;
175
184 virtual Result<FSDKError> saveToDynamicIndex(const char* path) const noexcept = 0;
185
199 virtual uint64_t countOfIndexedDescriptors() const noexcept = 0;
200 };
201
206 struct IProgressTracker {
211 virtual void progress(const float completion) const noexcept = 0;
212 };
213
217 struct IIndexBuilder
218 : IDynamicDescriptorStorage
219 , IRefCounted {
228 virtual ResultValue<FSDKError, IDynamicIndex*> buildIndex(
229 const IProgressTracker* const progressTracker = nullptr) noexcept = 0;
230
240 virtual ResultValue<FSDKError, Future<ResultValue<FSDKError, IDynamicIndex*>>>
241 buildIndexAsync(
242 IAsyncContext* const asyncContext,
243 const IProgressTracker* const progressTracker = nullptr) noexcept = 0;
244 };
245
246
247 }
248
DECLARE_SMARTPTR
#define DECLARE_SMARTPTR(X)
Smart ptr declaration helper macro.
Definition: Def.h:59
fsdk::IStaticDescriptorStorage::getDescriptorVersion
virtual uint32_t getDescriptorVersion() const noexcept=0
Return version of stored descriptors.
fsdk::IDynamicDescriptorStorage::removeDescriptor
virtual Result< FSDKError > removeDescriptor(const DescriptorId index) noexcept=0
Removes descriptor out of internal storage. If used on.
fsdk::IDynamicIndex::saveToDenseIndex
virtual Result< FSDKError > saveToDenseIndex(const char *path) const noexcept=0
Saves index as dense.
fsdk::Result
A structure that encapsulates an action result enumeration.
Definition: Result.h:29
fsdk::IIndex
Base index interface.
Definition: IIndex.h:133
fsdk::IProgressTracker
Progress tracker interface.
Definition: IIndex.h:206
fsdk::SearchResult
Result of index search.
Definition: IIndex.h:23
fsdk::IDescriptorBatch
Descriptor batch interface.
Definition: IDescriptor.h:140
fsdk::IIndexBuilder::buildIndexAsync
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.
fsdk::IStaticDescriptorStorage::size
virtual uint64_t size() const noexcept=0
Return size of internal storage.
fsdk::IDynamicIndex::countOfIndexedDescriptors
virtual uint64_t countOfIndexedDescriptors() const noexcept=0
Returns count of indexed descriptors.
fsdk::IRefCounted
Base strong reference counted object interface.
Definition: IRefCounted.h:36
fsdk::IAsyncContext
Interface for running tasks asynchronously.
Definition: IAsyncContext.h:24
fsdk::SearchResult::SearchResult
SearchResult() noexcept
Default constructor.
Definition: IIndex.h:28
fsdk::IStaticDescriptorStorage::descriptorByIndex
virtual Result< FSDKError > descriptorByIndex(const DescriptorId index, IDescriptor *descriptor) const noexcept=0
Requests descriptor data out of internal storage.
IDescriptor.h
Descriptor extractor and matcher interfaces.
fsdk::MatchingResult::similarity
float similarity
similarity (normalized in [0..1] range).
Definition: IDescriptor.h:37
fsdk::IDynamicIndex
Dynamic index interface.
Definition: IIndex.h:163
fsdk::DescriptorId
size_t DescriptorId
Intergral type used as identification of descriptor in internal storage.
Definition: IIndex.h:18
fsdk::IDynamicIndex::saveToDynamicIndex
virtual Result< FSDKError > saveToDynamicIndex(const char *path) const noexcept=0
Saves index as dynamic.
fsdk::ResultValue
Addon for Result to output some value aside the result. Specialization for copiable types...
Definition: ResultValue.h:21
fsdk::MatchingResult::MatchingResult
MatchingResult(void) noexcept
Initializes result to default values.
Definition: IDescriptor.h:42
IAsyncContext.h
Async context interface.
fsdk::IDynamicDescriptorStorage::appendDescriptor
virtual ResultValue< FSDKError, DescriptorId > appendDescriptor(const IDescriptor *desciptor) noexcept=0
Appends descriptor to internal storage. If used on.
fsdk::SearchResult::SearchResult
SearchResult(float distance, float similarity, DescriptorId index) noexcept
Construct structure with parameters.
Definition: IIndex.h:39
fsdk::IDenseIndex
Dense (read only) index interface.
Definition: IIndex.h:154
fsdk::MatchingResult
Result of descriptor matching.
Definition: IDescriptor.h:34
fsdk::SearchResult::index
DescriptorId index
Identificator of descriptor in some storage.
Definition: IIndex.h:25
fsdk::IIndex::search
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.
fsdk::IDescriptor
Descriptor interface.
Definition: IDescriptor.h:92
fsdk::MatchingResult::distance
float distance
distance between descriptor vectors.
Definition: IDescriptor.h:36
fsdk::IIndexBuilder::buildIndex
virtual ResultValue< FSDKError, IDynamicIndex * > buildIndex(const IProgressTracker *const progressTracker=nullptr) noexcept=0
Builds index with every descriptor appended. Blocks until completed.
fsdk::IDynamicDescriptorStorage
Dynamic descriptor storage interface.
Definition: IIndex.h:83
fsdk::IIndexBuilder
Index builder interface.
Definition: IIndex.h:217
fsdk::IDynamicDescriptorStorage::appendBatch
virtual ResultValue< FSDKError, DescriptorId > appendBatch(const IDescriptorBatch *batch) noexcept=0
Appends batch of descriptors to internal storage. If used on.
fsdk::IStaticDescriptorStorage
Static descriptor storage interface.
Definition: IIndex.h:52
fsdk::IProgressTracker::progress
virtual void progress(const float completion) const noexcept=0
Function is called on some operation progress change.