12 #ifndef WITHOUT_PROCESSING_BLOCK
18 #include <unordered_map>
20 #include <pbio/DllHandle.h>
21 #include <pbio/RawImage.h>
22 #include <pbio/DynamicTemplateIndex.h>
27 typedef LightSmartPtr<import::DllHandle>::tPtr DHPtr;
29 inline void tdvCheckException(
const DHPtr& dll_handle, ContextEH*& out_exception) {
32 auto err = Error(dll_handle->TDVException_getErrorCode(out_exception), dll_handle->TDVException_getMessage(out_exception));
33 dll_handle->TDVException_deleteException(out_exception);
34 out_exception =
nullptr;
54 template<
bool isConst=false>
55 class ContextArrayIterator
61 charsList(
size_t length,
char** ptr) : length_(length), ptr_(ptr) {}
63 return (index<length_) ? *(ptr_+index) :
nullptr;
72 std::shared_ptr<charsList> keys_;
74 void charsList_deleter(charsList* ptr) {
75 for(
size_t indx=0; indx < ptr->length_; ++indx)
76 base_.dll_handle->TDVContext_freePtr(ptr->ptr_[indx]);
77 base_.dll_handle->TDVContext_freePtr(ptr->ptr_);
81 typedef std::ptrdiff_t difference_type;
82 typedef std::forward_iterator_tag iterator_category;
84 typedef typename std::conditional<isConst, const value_type*, value_type*>::type pointer;
85 typedef typename std::conditional<isConst, const value_type&, value_type&>::type reference;
86 typedef const value_type& const_reference;
88 ContextArrayIterator(
const Context& ctx,
long long index);
89 ContextArrayIterator(
const Context& ctx,
const std::string& key);
91 ContextArrayIterator(
const ContextArrayIterator& iter);
92 ContextArrayIterator& operator=(
const ContextArrayIterator& iter) =
delete;
93 ContextArrayIterator(ContextArrayIterator&& iter);
94 ContextArrayIterator& operator=(ContextArrayIterator&& iter) =
delete;
96 ~ContextArrayIterator() {
101 bool operator==(
const ContextArrayIterator& other)
const {
102 return ((this->base_ == other.base_) && (this->curr_ == other.curr_));
105 bool operator!=(
const ContextArrayIterator& other)
const {
106 return (!(this->base_ == other.base_) || !(this->curr_ == other.curr_));
109 ContextArrayIterator& operator++();
110 ContextArrayIterator operator++(
int);
112 reference operator*() {
116 pointer operator->() {
120 std::string key()
const {
121 if (keys_ && index_ < length_)
122 return std::string(keys_->operator[](index_));
123 return std::string();
140 Context(
const DHPtr& dll_handle) : dll_handle(dll_handle), weak_(
false), eh_(
nullptr) {
141 handle_ = dll_handle->TDVContext_create(&eh_);
142 tdvCheckException(dll_handle, eh_);
145 Context(
const DHPtr& dll_handle, HContext* handle,
bool weak =
true) : dll_handle(dll_handle), weak_(weak), eh_(
nullptr) {
150 handle_ = dll_handle->TDVContext_clone(handle, &eh_);
151 tdvCheckException(dll_handle, eh_);
155 Context(
const DHPtr& dll_handle,
const uint8_t* data, uint64_t dataSize) :
156 dll_handle(dll_handle),
160 handle_ = dll_handle->TDVContext_createFromEncodedImage(data, dataSize, &eh_);
161 tdvCheckException(dll_handle, eh_);
164 Context(
const DHPtr& dll_handle, uint8_t* data, int32_t width, int32_t height, Format format, int32_t baseAngle) :
165 dll_handle(dll_handle),
169 handle_ = dll_handle->TDVContext_createFromFrame(data, width, height, static_cast<int32_t>(format), baseAngle, &eh_);
170 tdvCheckException(dll_handle, eh_);
173 Context(
const DHPtr& dll_handle,
const char* path) :
174 dll_handle(dll_handle),
178 handle_ = dll_handle->TDVContext_createFromJsonFile(path, &eh_);
179 tdvCheckException(dll_handle, eh_);
185 mutable ContextEH* eh_;
194 dll_handle->TDVContext_destroy(handle_, &eh_);
196 #if __cplusplus >= 201703L
197 if (eh_ && std::uncaught_exceptions() > 0)
199 if (eh_ && std::uncaught_exception())
201 std::cerr <<
Error(dll_handle->TDVException_getErrorCode(eh_), dll_handle->TDVException_getMessage(eh_)).what();
203 tdvCheckException(dll_handle, eh_);
207 Context(
const Context& other) : dll_handle(other.dll_handle), weak_(
false), eh_(
nullptr) {
208 handle_ = dll_handle->TDVContext_clone(other.handle_, &eh_);
209 tdvCheckException(dll_handle, eh_);
216 dll_handle->TDVContext_copy(other.handle_, handle_, &eh_);
218 HContext* copy = dll_handle->TDVContext_clone(other.handle_, &eh_);
219 tdvCheckException(dll_handle, eh_);
220 std::swap(handle_, copy);
221 dll_handle->TDVContext_destroy(copy, &eh_);
223 tdvCheckException(dll_handle, eh_);
228 Context(
Context&& other) : dll_handle(other.dll_handle), weak_(
false), eh_(
nullptr) {
231 handle_ = dll_handle->TDVContext_clone(other.handle_, &eh_);
232 tdvCheckException(dll_handle, eh_);
236 handle_ = other.handle_;
237 other.handle_ =
nullptr;
246 dll_handle->TDVContext_copy(other.handle_, handle_, &eh_);
247 tdvCheckException(dll_handle, eh_);
253 HContext* copy = dll_handle->TDVContext_clone(other.handle_, &eh_);
254 tdvCheckException(dll_handle, eh_);
255 std::swap(handle_, copy);
256 dll_handle->TDVContext_destroy(copy, &eh_);
257 tdvCheckException(dll_handle, eh_);
261 handle_ = other.handle_;
262 other.handle_ =
nullptr;
280 template <typename T, typename = typename std::enable_if<!std::is_base_of<Context, typename std::decay<T>::type>::value>::type>
282 setValue(std::forward<T>(value));
286 bool operator==(
const Context& other)
const
287 {
return this->handle_ == other.handle_;}
298 size_t lenght = dll_handle->TDVContext_getLength(handle_, &eh_);
299 tdvCheckException(dll_handle, eh_);
303 ContextArrayIterator<> begin(){
304 return ContextArrayIterator<>(*
this, 0);
307 ContextArrayIterator<> end(){
308 return ContextArrayIterator<>(*
this, -1);
311 ContextArrayIterator<true> begin()
const {
312 return ContextArrayIterator<true>(*
this, 0);
315 ContextArrayIterator<true> end()
const {
316 return ContextArrayIterator<true>(*
this, -1);
319 ContextArrayIterator<true> cbegin()
const {
320 return ContextArrayIterator<true>(*
this, 0);
323 ContextArrayIterator<true> cend()
const {
324 return ContextArrayIterator<true>(*
this, -1);
348 const Ref
operator[](
const std::string& key)
const;
352 Ref at(
const char* key);
353 Ref at(
const std::string& key);
354 Ref at(
const int index);
356 const Ref at(
const char* key)
const;
357 const Ref at(
const std::string& key)
const;
358 const Ref at(
const int index)
const;
371 bool result = dll_handle->TDVContext_contains(handle_, key.data(), &eh_);
372 tdvCheckException(dll_handle, eh_);
388 bool result = dll_handle->TDVContext_compare(handle_, other.handle_, &eh_);
389 tdvCheckException(dll_handle, eh_);
403 size_t length =
size();
405 auto keys = dll_handle->TDVContext_getKeys(handle_, length, &eh_);
406 tdvCheckException(dll_handle, eh_);
408 std::vector<std::string> result(length);
409 for (
size_t i = 0; i < length; ++i)
410 result.emplace_back(keys[i]);
415 ContextArrayIterator<> find(
const std::string& key) {
416 return ContextArrayIterator<>(*
this, key);
419 ContextArrayIterator<true> find(
const std::string& key)
const {
420 return ContextArrayIterator<true>(*
this, key);
424 typename std::enable_if<!std::is_base_of<Context, typename std::decay<T>::type>::value>::type push_back(T&& data) {
426 elem.setValue(std::forward<T>(data));
428 push_back(std::move(elem));
440 dll_handle->TDVContext_pushBack(handle_, data.handle_,
true, &eh_);
441 tdvCheckException(dll_handle, eh_);
444 void push_back(
Context&& data) {
445 dll_handle->TDVContext_pushBack(handle_, data.handle_, weak_, &eh_);
446 tdvCheckException(dll_handle, eh_);
458 double ret = dll_handle->TDVContext_getDouble(handle_, &eh_);
459 tdvCheckException(dll_handle, eh_);
472 long ret = dll_handle->TDVContext_getLong(handle_, &eh_);
473 tdvCheckException(dll_handle, eh_);
486 bool ret = dll_handle->TDVContext_getBool(handle_, &eh_);
487 tdvCheckException(dll_handle, eh_);
500 unsigned long str_size = dll_handle->TDVContext_getStrSize(handle_, &eh_);
501 tdvCheckException(dll_handle, eh_);
502 std::string ret = dll_handle->TDVContext_getStr(handle_, &eh_);
503 tdvCheckException(dll_handle, eh_);
516 unsigned char* ret = dll_handle->TDVContext_getDataPtr(handle_, &eh_);
517 tdvCheckException(dll_handle, eh_);
522 void* index = dll_handle->TDVContext_getDynamicTemplateIndex(handle_, &eh_);
523 tdvCheckException(dll_handle, eh_);
524 return pbio::DynamicTemplateIndex::Ptr::make(dll_handle, index,
true);
528 void* templ = dll_handle->TDVContext_getContextTemplate(handle_, &eh_);
529 tdvCheckException(dll_handle, eh_);
530 return pbio::ContextTemplate::Ptr::make(dll_handle, templ);
542 dll_handle->TDVContext_putStr(handle_, str, &eh_);
543 tdvCheckException(dll_handle, eh_);
555 dll_handle->TDVContext_putStr(handle_, str.c_str(), &eh_);
556 tdvCheckException(dll_handle, eh_);
568 dll_handle->TDVContext_putLong(handle_, val, &eh_);
569 tdvCheckException(dll_handle, eh_);
581 dll_handle->TDVContext_putDouble(handle_, val, &eh_);
582 tdvCheckException(dll_handle, eh_);
594 dll_handle->TDVContext_putBool(handle_, val, &eh_);
595 tdvCheckException(dll_handle, eh_);
609 unsigned char* ret{
nullptr};
611 ret = dll_handle->TDVContext_allocDataPtr(handle_, copy_sz, &eh_);
613 ret = dll_handle->TDVContext_putDataPtr(handle_, static_cast<unsigned char*>(ptr), static_cast<uint64_t>(copy_sz), &eh_);
614 tdvCheckException(dll_handle, eh_);
618 unsigned char*
setDataPtr(
const void* ptr,
int copy_sz) {
619 unsigned char* ret = dll_handle->TDVContext_putConstDataPtr(handle_, static_cast<const unsigned char*>(ptr), copy_sz, &eh_);
620 tdvCheckException(dll_handle, eh_);
626 dll_handle->TDVContext_putDynamicTemplateIndex(handle_, templateIndex->_impl, &eh_);
627 tdvCheckException(dll_handle, eh_);
631 dll_handle->TDVContext_putContextTemplate(handle_, templ->_impl, &eh_);
632 tdvCheckException(dll_handle, eh_);
644 bool value = dll_handle->TDVContext_isNone(handle_, &eh_);
645 tdvCheckException(dll_handle, eh_);
658 bool value = dll_handle->TDVContext_isArray(handle_, &eh_);
659 tdvCheckException(dll_handle, eh_);
672 bool value = dll_handle->TDVContext_isObject(handle_, &eh_);
673 tdvCheckException(dll_handle, eh_);
686 bool val = dll_handle->TDVContext_isBool(handle_, &eh_);
687 tdvCheckException(dll_handle, eh_);
700 bool val = dll_handle->TDVContext_isLong(handle_, &eh_);
701 tdvCheckException(dll_handle, eh_);
714 bool val = dll_handle->TDVContext_isDouble(handle_, &eh_);
715 tdvCheckException(dll_handle, eh_);
728 bool val = dll_handle->TDVContext_isString(handle_, &eh_);
729 tdvCheckException(dll_handle, eh_);
742 bool val = dll_handle->TDVContext_isDataPtr(handle_, &eh_);
743 tdvCheckException(dll_handle, eh_);
747 bool isDynamicTemplateIndex()
const {
748 bool val = dll_handle->TDVContext_isDynamicTemplateIndex(handle_, &eh_);
749 tdvCheckException(dll_handle, eh_);
753 bool isContextTemplate()
const {
754 bool val = dll_handle->TDVContext_isContextTemplate(handle_, &eh_);
755 tdvCheckException(dll_handle, eh_);
759 HContext* getHandle() {
return handle_;}
760 const HContext* getHandle()
const {
return handle_;}
769 dll_handle->TDVContext_clear(handle_, &eh_);
770 tdvCheckException(dll_handle,eh_);
782 dll_handle->TDVContext_erase(handle_, str, &eh_);
783 tdvCheckException(dll_handle,eh_);
794 void erase(
const std::string& str) {
807 dll_handle->TDVContext_reserve(handle_, size, &eh_);
808 tdvCheckException(dll_handle,eh_);
821 dll_handle->TDVContext_saveToJsonFile(handle_, path.c_str(), &eh_);
822 tdvCheckException(dll_handle,eh_);
835 dll_handle->TDVContext_saveToJsonFile(handle_, path, &eh_);
836 tdvCheckException(dll_handle,eh_);
839 std::string serializeToJson()
const
841 const char* data = dll_handle->TDVContext_serializeToJson(handle_, &eh_);
843 tdvCheckException(dll_handle, eh_);
845 std::string result(data);
847 dll_handle->TDVContext_deleteString(data, &eh_);
849 tdvCheckException(dll_handle, eh_);
856 void setValue(
const char* str) {
857 dll_handle->TDVContext_putStr(handle_, str, &eh_);
858 tdvCheckException(dll_handle, eh_);
860 void setValue(
const std::string& str) {
861 dll_handle->TDVContext_putStr(handle_, str.c_str(), &eh_);
862 tdvCheckException(dll_handle, eh_);
865 template<typename T, typename = typename std::enable_if<std::is_enum<T>::value || std::is_integral<T>::value>::type>
866 void setValue(T val) {
867 dll_handle->TDVContext_putLong(handle_, val, &eh_);
868 tdvCheckException(dll_handle, eh_);
871 void setValue(
double val) {
872 dll_handle->TDVContext_putDouble(handle_, val, &eh_);
873 tdvCheckException(dll_handle, eh_);
875 void setValue(
float val) {
876 dll_handle->TDVContext_putDouble(handle_, val, &eh_);
877 tdvCheckException(dll_handle, eh_);
879 void setValue(
bool val) {
880 dll_handle->TDVContext_putBool(handle_, val, &eh_);
881 tdvCheckException(dll_handle, eh_);
883 void setValue(
void* ptr,
int copy_sz = 0) {
884 dll_handle->TDVContext_putDataPtr(handle_, static_cast<unsigned char*>(ptr), copy_sz, &eh_);
885 tdvCheckException(dll_handle, eh_);
888 dll_handle->TDVContext_putDynamicTemplateIndex(handle_, templateIndex->_impl, &eh_);
889 tdvCheckException(dll_handle, eh_);
892 dll_handle->TDVContext_putContextTemplate(handle_, templ->_impl, &eh_);
893 tdvCheckException(dll_handle, eh_);
900 ContextRef(
const DHPtr &dll_handle, HContext* handle) :
Context(dll_handle ,handle,
true) {}
904 template <typename T, typename = typename std::enable_if<!std::is_base_of<Context, typename std::decay<T>::type>::value>::type>
905 void operator=(T&& value) {
906 setValue(std::forward<T>(value));
910 template<
bool isConst>
911 Context::ContextArrayIterator<isConst>::ContextArrayIterator(
const Context& ctx,
long long index) : base_(ctx), curr_(nullptr), isObj_(ctx.isObject())
913 length_ = base_.dll_handle->TDVContext_getLength(base_.handle_, &(base_.eh_));
914 tdvCheckException(base_.dll_handle, base_.eh_);
915 index_ = (index > -1) ? (std::min<size_t>)(
static_cast<size_t>(index), length_) : length_;
916 if(index_ < length_) {
919 auto keys = base_.dll_handle->TDVContext_getKeys(base_.handle_, length_, &(base_.eh_));
920 tdvCheckException(base_.dll_handle, base_.eh_);
921 keys_ = std::shared_ptr<charsList>(
new charsList(length_, keys), std::bind(&ContextArrayIterator::charsList_deleter,
this, std::placeholders::_1));
922 curr_ =
new Context(base_[keys_->operator[](index)]);
925 curr_ =
new Context(base_[index]);
929 template<
bool isConst>
930 Context::ContextArrayIterator<isConst>::ContextArrayIterator(
const Context& ctx,
const std::string& key) : base_(ctx), curr_(nullptr), isObj_(ctx.isObject())
932 length_ = base_.dll_handle->TDVContext_getLength(base_.handle_, &(base_.eh_));
933 tdvCheckException(base_.dll_handle, base_.eh_);
935 if(isObj_ && length_) {
936 auto keys = base_.dll_handle->TDVContext_getKeys(base_.handle_, length_, &(base_.eh_));
937 tdvCheckException(base_.dll_handle, base_.eh_);
938 keys_ = std::shared_ptr<charsList>(
new charsList(length_, keys), std::bind(&ContextArrayIterator::charsList_deleter,
this, std::placeholders::_1));
941 if(!key.compare(keys_->operator[](i))) {
943 curr_ =
new Context(base_[key]);
946 }
while((++i)<length_);
950 template<
bool isConst>
951 Context::ContextArrayIterator<isConst>::ContextArrayIterator(
const ContextArrayIterator& iter) :
952 base_(iter.base_), length_(iter.length_), index_(iter.index_), curr_(iter.curr_ ? new
Context(*(iter.curr_)) : nullptr), isObj_(iter.isObj_), keys_(iter.keys_)
955 template<
bool isConst>
956 Context::ContextArrayIterator<isConst>::ContextArrayIterator(ContextArrayIterator&& iter) :
957 base_(iter.base_), length_(iter.length_), index_(iter.index_), curr_(iter.curr_), isObj_(iter.isObj_), keys_(std::move(iter.keys_)) {
958 iter.curr_ =
nullptr;
961 template<
bool isConst>
962 Context::ContextArrayIterator<isConst>& Context::ContextArrayIterator<isConst>::operator++() {
965 index_ = (std::min<size_t>)(index_+1, length_);
967 curr_ = (index_ < length_) ?
new Context(base_[keys_->operator[](index_)]) :
nullptr;
969 curr_ = (index_ < length_) ?
new Context(base_[index_]) :
nullptr;
973 template<
bool isConst>
974 Context::ContextArrayIterator<isConst> Context::ContextArrayIterator<isConst>::operator++(
int) {
975 ContextArrayIterator tmp = *
this;
976 index_ = (std::min<size_t>)(index_+1, length_);
978 curr_ = (index_ < length_) ?
new Context(base_[keys_->operator[](index_)]) :
nullptr;
980 curr_ = (index_ < length_) ?
new Context(base_[index_]) :
nullptr;
984 inline Context::operator ContextRef()
986 return ContextRef(dll_handle, handle_);
990 HContext* handle = dll_handle->TDVContext_getOrInsertByKey(handle_, key.c_str(), &eh_);
991 tdvCheckException(dll_handle, eh_);
992 return Ref(dll_handle, handle);
996 HContext* handle = dll_handle->TDVContext_getOrInsertByKey(handle_, key, &eh_);
997 tdvCheckException(dll_handle, eh_);
998 return Ref(dll_handle, handle);
1002 HContext* handle = dll_handle->TDVContext_getByIndex(handle_, index, &eh_);
1003 tdvCheckException(dll_handle, eh_);
1004 return Ref(dll_handle, handle);
1008 HContext* handle = dll_handle->TDVContext_getByKey(handle_, key.c_str(), &eh_);
1009 tdvCheckException(dll_handle, eh_);
1010 return Ref(dll_handle, handle);
1014 HContext* handle = dll_handle->TDVContext_getByKey(handle_, key, &eh_);
1015 tdvCheckException(dll_handle, eh_);
1016 return Ref(dll_handle, handle);
1020 HContext* handle = dll_handle->TDVContext_getByIndex(handle_, index, &eh_);
1021 tdvCheckException(dll_handle, eh_);
1022 return Ref(dll_handle, handle);
1025 inline Context::Ref Context::at(
const char* key) {
1026 HContext* handle = dll_handle->TDVContext_getByKey(handle_, key, &eh_);
1027 tdvCheckException(dll_handle, eh_);
1028 return Ref(dll_handle, handle);
1031 inline Context::Ref Context::at(
const std::string& key) {
1032 HContext* handle = dll_handle->TDVContext_getByKey(handle_, key.c_str(), &eh_);
1033 tdvCheckException(dll_handle, eh_);
1034 return Ref(dll_handle, handle);
1037 inline Context::Ref Context::at(
const int index) {
1038 HContext* handle = dll_handle->TDVContext_getByIndex(handle_, index, &eh_);
1039 tdvCheckException(dll_handle, eh_);
1040 return Ref(dll_handle, handle);
1043 inline const Context::Ref Context::at(
const char* key)
const {
1044 HContext* handle = dll_handle->TDVContext_getByKey(handle_, key, &eh_);
1045 tdvCheckException(dll_handle, eh_);
1046 return Ref(dll_handle, handle);
1049 inline const Context::Ref Context::at(
const std::string& key)
const {
1050 HContext* handle = dll_handle->TDVContext_getByKey(handle_, key.c_str(), &eh_);
1051 tdvCheckException(dll_handle, eh_);
1052 return Ref(dll_handle, handle);
1055 inline const Context::Ref Context::at(
const int index)
const {
1056 HContext* handle = dll_handle->TDVContext_getByIndex(handle_, index, &eh_);
1057 tdvCheckException(dll_handle, eh_);
1058 return Ref(dll_handle, handle);
1062 namespace context_utils {
1068 ctx[
"format"] =
"NDARRAY";
1069 ctx[
"color_space"] = color_mode.at(raw_image.format);
1071 size_t copy_sz = raw_image.
height * raw_image.
width * channels *
sizeof(uint8_t);
1072 if (raw_image.with_crop)
1074 unsigned char* buff{
nullptr};
1075 buff = ctx[
"blob"].setDataPtr(buff, copy_sz);
1076 size_t shift = (raw_image.crop_info_offset_y*raw_image.crop_info_data_image_width + raw_image.crop_info_offset_x)*channels*
sizeof(uint8_t);
1077 size_t stride = raw_image.
width*channels*
sizeof(uint8_t);
1078 unsigned char* ptr = buff;
1079 for(
int row=0; row<raw_image.
height; ++row)
1081 std::memcpy(ptr, raw_image.
data+shift, stride);
1082 shift += raw_image.crop_info_data_image_width*channels*
sizeof(uint8_t);
1087 ctx[
"blob"].setDataPtr(raw_image.
data, copy_sz);
1088 ctx[
"dtype"] =
"uint8_t";
1089 ctx[
"shape"].push_back(static_cast<int64_t>(raw_image.
height));
1090 ctx[
"shape"].push_back(static_cast<int64_t>(raw_image.
width));
1091 ctx[
"shape"].push_back(static_cast<int64_t>(channels));
1096 ctx[
"format"] =
"NDARRAY";
1097 ctx[
"color_space"] = color_mode.at(format);
1099 size_t copy_sz = copy ? height * width * channels *
sizeof(uint8_t) : 0;
1100 ctx[
"blob"].setDataPtr(data, copy_sz);
1101 ctx[
"dtype"] =
"uint8_t";
1102 ctx[
"shape"].push_back(static_cast<int64_t>(height));
1103 ctx[
"shape"].push_back(static_cast<int64_t>(width));
1104 ctx[
"shape"].push_back(static_cast<int64_t>(channels));
1110 #endif // WITHOUT_PROCESSING_BLOCK
bool isString() const
проверяет является ли контейнер значением типа string.
Definition: Context.h:727
Интерфейсный объект для создания других интерфейсных объектов.
Definition: FacerecService.h:64
RGB, 24 бита на пиксел, 8 бит на канал.
Definition: IRawImage.h:60
bool isDataPtr() const
проверяет является ли контейнер указателем на данные
Definition: Context.h:741
Интерфейсный объект, хранящий образец лица.
Definition: RawSample.h:49
void saveToJsonFile(std::string &path)
сохраняет содержимое контейнера в json файл
Definition: Context.h:819
void erase(const char *str)
удаляет содержимое контейнера-Context хранящиеся по ключу.
Definition: Context.h:781
void setString(const char *str)
добавляет значение типа string в контейнер
Definition: Context.h:541
void erase(const std::string &str)
удаляет содержимое контейнера-Context хранящиеся по ключу.
Definition: Context.h:794
void saveToJsonFile(const char *path)
сохраняет содержимое контейнера в json файл
Definition: Context.h:833
void reserve(const size_t size)
выделяет память под num элементов в массиве.
Definition: Context.h:806
Оттенки серого, 8 бит на пиксел.
Definition: IRawImage.h:53
void setDouble(double val)
добавляет значение типа double в контейнер
Definition: Context.h:580
std::vector< std::string > getKeys()
возвращает список ключей в контейнере-Context.
Definition: Context.h:402
void setString(const std::string &str)
добавляет значение типа std::string в контейнер
Definition: Context.h:554
unsigned char * getDataPtr() const
возвращает указатель на данные из контейнера
Definition: Context.h:515
bool isDouble() const
проверяет является ли контейнер значением типа double.
Definition: Context.h:713
void push_back(const Context &data)
добавляет объект в контейнер.
Definition: Context.h:439
bool compare(const Context &other) const
сравнивает два объекта Context.
Definition: Context.h:387
bool isBool() const
проверяет является ли контейнер значением типа bool.
Definition: Context.h:685
void clear()
очищает содержимое контейнера-Context.
Definition: Context.h:768
BGR, 24 бита на пиксел, 8 бит на канал.
Definition: IRawImage.h:67
size_t size() const
Получить размер контейнера.
Definition: Context.h:297
bool contains(const std::string &key) const
проверяет существование элемента по определённому ключу
Definition: Context.h:370
bool isNone() const
проверяет нет ли в контейнере элементов
Definition: Context.h:643
Класс исключений, выбрасываемых при возникновении ошибок.
Definition: Error.h:26
Context & operator=(T &&value)
добавляет значение в контейнер
Definition: Context.h:281
bool isLong() const
проверяет является ли контейнер значением типа long.
Definition: Context.h:699
void clear()
очищает содержимое контейнера-Context.
Definition: Context.mm:166
LightSmartPtr< DynamicTemplateIndex >::tPtr Ptr
Псевдоним для типа умного указателя на DynamicTemplateIndex.
Definition: DynamicTemplateIndex.h:34
long getLong() const
возвращает значение типа long из контейнера
Definition: Context.h:471
bool isObject() const
проверяет является ли контейнер объектом
Definition: Context.h:671
Definition: Context.h:897
double getDouble() const
возвращает значение типа double из контейнера
Definition: Context.h:457
void setLong(long val)
добавляет значение типа long в контейнер
Definition: Context.h:567
bool getBool() const
возвращает значение типа bool из контейнера
Definition: Context.h:485
Context - интерфейсный объект для хранения данных и взаимодействия с методами из Processing Block API...
Definition: Context.h:48
unsigned char * setDataPtr(void *ptr, int copy_sz=0)
добавляет указатель на данные в контейнер
Definition: Context.h:608
LightSmartPtr< ContextTemplate >::tPtr Ptr
Псевдоним для типа умного указателя на ContextTemplate.
Definition: ContextTemplate.h:47
std::string getString() const
возвращает значение типа std::string из контейнера
Definition: Context.h:499
void setBool(bool val)
добавляет значение типа bool в контейнер
Definition: Context.h:593
Context - интерфейсный объект для хранения данных и взаимодействия с методами из Processing Block API...
Definition: Context.h:67
bool isArray() const
проверяет является ли контейнере массивом
Definition: Context.h:657
int height
Высота изображения.
Definition: RawImage.h:117
const unsigned char * data
Указатель на данные изображения. Все пикселы должны быть сохранены последовательно, строка за строкой, без разрывов.
Definition: RawImage.h:118
Format
Формат данных изображения.
Definition: IRawImage.h:46
Структура, предоставляющая данные изображения в "сыром" формате и опциональную информацию для обрезки...
Definition: RawImage.h:113
int width
Ширина изображения.
Definition: RawImage.h:116
Ref operator[](const std::string &key)
индексация по ключу.
Definition: Context.h:989