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;
66 for(
size_t indx = 0; indx < length_; ++indx)
77 std::shared_ptr<charsList> keys_;
79 typedef std::ptrdiff_t difference_type;
80 typedef std::forward_iterator_tag iterator_category;
82 typedef typename std::conditional<isConst, const value_type*, value_type*>::type pointer;
83 typedef typename std::conditional<isConst, const value_type&, value_type&>::type reference;
84 typedef const value_type& const_reference;
86 ContextArrayIterator(
const Context& ctx,
long long index);
87 ContextArrayIterator(
const Context& ctx,
const std::string& key);
89 ContextArrayIterator(
const ContextArrayIterator& iter);
90 ContextArrayIterator& operator=(
const ContextArrayIterator& iter) =
delete;
91 ContextArrayIterator(ContextArrayIterator&& iter);
92 ContextArrayIterator& operator=(ContextArrayIterator&& iter) =
delete;
94 ~ContextArrayIterator() {
99 bool operator==(
const ContextArrayIterator& other)
const {
100 return ((this->base_ == other.base_) && (this->curr_ == other.curr_));
103 bool operator!=(
const ContextArrayIterator& other)
const {
104 return (!(this->base_ == other.base_) || !(this->curr_ == other.curr_));
107 ContextArrayIterator& operator++();
108 ContextArrayIterator operator++(
int);
110 reference operator*() {
114 pointer operator->() {
118 std::string key()
const {
119 if (keys_ && index_ < length_)
120 return std::string(keys_->operator[](index_));
121 return std::string();
138 Context(
const DHPtr& dll_handle) : dll_handle(dll_handle), weak_(
false), eh_(
nullptr) {
139 handle_ = dll_handle->TDVContext_create(&eh_);
140 tdvCheckException(dll_handle, eh_);
143 Context(
const DHPtr& dll_handle, HContext* handle,
bool weak =
true) :
144 dll_handle(dll_handle), handle_(handle), weak_(weak), eh_(
nullptr) { }
146 Context(
const DHPtr& dll_handle,
const uint8_t* data, uint64_t dataSize) :
147 dll_handle(dll_handle),
151 handle_ = dll_handle->TDVContext_createFromEncodedImage(data, dataSize, &eh_);
152 tdvCheckException(dll_handle, eh_);
155 Context(
const DHPtr& dll_handle, uint8_t* data, int32_t width, int32_t height, Format format, int32_t baseAngle) :
156 dll_handle(dll_handle),
160 handle_ = dll_handle->TDVContext_createFromFrame(data, width, height, static_cast<int32_t>(format), baseAngle, &eh_);
161 tdvCheckException(dll_handle, eh_);
164 Context(
const DHPtr& dll_handle,
const char* path) :
165 dll_handle(dll_handle),
169 handle_ = dll_handle->TDVContext_createFromJsonFile(path, &eh_);
170 tdvCheckException(dll_handle, eh_);
176 mutable ContextEH* eh_;
185 dll_handle->TDVContext_destroy(handle_, &eh_);
187 #if __cplusplus >= 201703L
188 if (eh_ && std::uncaught_exceptions() > 0)
190 if (eh_ && std::uncaught_exception())
192 std::cerr <<
Error(dll_handle->TDVException_getErrorCode(eh_), dll_handle->TDVException_getMessage(eh_)).what();
194 tdvCheckException(dll_handle, eh_);
198 Context(
const Context& other) : dll_handle(other.dll_handle), weak_(
false), eh_(
nullptr) {
199 handle_ = dll_handle->TDVContext_clone(other.handle_, &eh_);
200 tdvCheckException(dll_handle, eh_);
207 dll_handle->TDVContext_copy(other.handle_, handle_, &eh_);
209 HContext* copy = dll_handle->TDVContext_clone(other.handle_, &eh_);
210 tdvCheckException(dll_handle, eh_);
211 std::swap(handle_, copy);
212 dll_handle->TDVContext_destroy(copy, &eh_);
214 tdvCheckException(dll_handle, eh_);
219 Context(
Context&& other) : dll_handle(other.dll_handle), weak_(
false), eh_(
nullptr) {
222 handle_ = dll_handle->TDVContext_clone(other.handle_, &eh_);
223 tdvCheckException(dll_handle, eh_);
227 handle_ = other.handle_;
228 other.handle_ =
nullptr;
237 dll_handle->TDVContext_copy(other.handle_, handle_, &eh_);
238 tdvCheckException(dll_handle, eh_);
244 HContext* copy = dll_handle->TDVContext_clone(other.handle_, &eh_);
245 tdvCheckException(dll_handle, eh_);
246 std::swap(handle_, copy);
247 dll_handle->TDVContext_destroy(copy, &eh_);
248 tdvCheckException(dll_handle, eh_);
252 handle_ = other.handle_;
253 other.handle_ =
nullptr;
271 template <typename T, typename = typename std::enable_if<!std::is_base_of<Context, typename std::decay<T>::type>::value>::type>
273 setValue(std::forward<T>(value));
277 bool operator==(
const Context& other)
const
278 {
return this->handle_ == other.handle_;}
289 size_t lenght = dll_handle->TDVContext_getLength(handle_, &eh_);
290 tdvCheckException(dll_handle, eh_);
294 ContextArrayIterator<> begin(){
295 return ContextArrayIterator<>(*
this, 0);
298 ContextArrayIterator<> end(){
299 return ContextArrayIterator<>(*
this, -1);
302 ContextArrayIterator<true> begin()
const {
303 return ContextArrayIterator<true>(*
this, 0);
306 ContextArrayIterator<true> end()
const {
307 return ContextArrayIterator<true>(*
this, -1);
310 ContextArrayIterator<true> cbegin()
const {
311 return ContextArrayIterator<true>(*
this, 0);
314 ContextArrayIterator<true> cend()
const {
315 return ContextArrayIterator<true>(*
this, -1);
339 const Ref
operator[](
const std::string& key)
const;
343 Ref at(
const char* key);
344 Ref at(
const std::string& key);
345 Ref at(
const int index);
347 const Ref at(
const char* key)
const;
348 const Ref at(
const std::string& key)
const;
349 const Ref at(
const int index)
const;
362 bool result = dll_handle->TDVContext_contains(handle_, key.data(), &eh_);
363 tdvCheckException(dll_handle, eh_);
379 bool result = dll_handle->TDVContext_compare(handle_, other.handle_, &eh_);
380 tdvCheckException(dll_handle, eh_);
394 size_t length =
size();
396 auto keys = dll_handle->TDVContext_getKeys(handle_, length, &eh_);
397 tdvCheckException(dll_handle, eh_);
399 std::vector<std::string> result;
400 result.reserve(length);
401 for (
size_t i = 0; i < length; ++i)
402 result.emplace_back(keys[i]);
403 for (
size_t i = 0; i < length; ++i)
404 dll_handle->TDVContext_freePtr(keys[i]);
405 dll_handle->TDVContext_freePtr(keys);
410 ContextArrayIterator<> find(
const std::string& key) {
411 return ContextArrayIterator<>(*
this, key);
414 ContextArrayIterator<true> find(
const std::string& key)
const {
415 return ContextArrayIterator<true>(*
this, key);
419 typename std::enable_if<!std::is_base_of<Context, typename std::decay<T>::type>::value>::type push_back(T&& data) {
421 elem.setValue(std::forward<T>(data));
423 push_back(std::move(elem));
435 dll_handle->TDVContext_pushBack(handle_, data.handle_,
true, &eh_);
436 tdvCheckException(dll_handle, eh_);
439 void push_back(
Context&& data) {
440 dll_handle->TDVContext_pushBack(handle_, data.handle_, weak_, &eh_);
441 tdvCheckException(dll_handle, eh_);
453 double ret = dll_handle->TDVContext_getDouble(handle_, &eh_);
454 tdvCheckException(dll_handle, eh_);
467 long ret = dll_handle->TDVContext_getLong(handle_, &eh_);
468 tdvCheckException(dll_handle, eh_);
481 bool ret = dll_handle->TDVContext_getBool(handle_, &eh_);
482 tdvCheckException(dll_handle, eh_);
495 unsigned long str_size = dll_handle->TDVContext_getStrSize(handle_, &eh_);
496 tdvCheckException(dll_handle, eh_);
497 std::string ret = dll_handle->TDVContext_getStr(handle_, &eh_);
498 tdvCheckException(dll_handle, eh_);
511 unsigned char* ret = dll_handle->TDVContext_getDataPtr(handle_, &eh_);
512 tdvCheckException(dll_handle, eh_);
516 std::pair<uint8_t*, size_t> getBlobData()
const {
518 uint8_t* ret = dll_handle->TDVContext_getBlobData(handle_, &length, &eh_);
519 tdvCheckException(dll_handle, eh_);
520 return {ret, length};
524 void* index = dll_handle->TDVContext_getDynamicTemplateIndex(handle_, &eh_);
525 tdvCheckException(dll_handle, eh_);
526 return pbio::DynamicTemplateIndex::Ptr::make(dll_handle, index,
true);
530 void* templ = dll_handle->TDVContext_getContextTemplate(handle_, &eh_);
531 tdvCheckException(dll_handle, eh_);
532 return pbio::ContextTemplate::Ptr::make(dll_handle, templ);
544 dll_handle->TDVContext_putStr(handle_, str, &eh_);
545 tdvCheckException(dll_handle, eh_);
557 dll_handle->TDVContext_putStr(handle_, str.c_str(), &eh_);
558 tdvCheckException(dll_handle, eh_);
570 dll_handle->TDVContext_putLong(handle_, val, &eh_);
571 tdvCheckException(dll_handle, eh_);
583 dll_handle->TDVContext_putDouble(handle_, val, &eh_);
584 tdvCheckException(dll_handle, eh_);
596 dll_handle->TDVContext_putBool(handle_, val, &eh_);
597 tdvCheckException(dll_handle, eh_);
611 unsigned char* ret{
nullptr};
613 ret = dll_handle->TDVContext_allocDataPtr(handle_, copy_sz, &eh_);
615 ret = dll_handle->TDVContext_putDataPtr(handle_, static_cast<unsigned char*>(ptr), static_cast<uint64_t>(copy_sz), &eh_);
616 tdvCheckException(dll_handle, eh_);
620 unsigned char*
setDataPtr(
const void* ptr,
int copy_sz) {
621 unsigned char* ret = dll_handle->TDVContext_putConstDataPtr(handle_, static_cast<const unsigned char*>(ptr), copy_sz, &eh_);
622 tdvCheckException(dll_handle, eh_);
628 dll_handle->TDVContext_putDynamicTemplateIndex(handle_, templateIndex->_impl, &eh_);
629 tdvCheckException(dll_handle, eh_);
633 dll_handle->TDVContext_putContextTemplate(handle_, templ->_impl, &eh_);
634 tdvCheckException(dll_handle, eh_);
646 bool value = dll_handle->TDVContext_isNone(handle_, &eh_);
647 tdvCheckException(dll_handle, eh_);
660 bool value = dll_handle->TDVContext_isArray(handle_, &eh_);
661 tdvCheckException(dll_handle, eh_);
674 bool value = dll_handle->TDVContext_isObject(handle_, &eh_);
675 tdvCheckException(dll_handle, eh_);
688 bool val = dll_handle->TDVContext_isBool(handle_, &eh_);
689 tdvCheckException(dll_handle, eh_);
702 bool val = dll_handle->TDVContext_isLong(handle_, &eh_);
703 tdvCheckException(dll_handle, eh_);
716 bool val = dll_handle->TDVContext_isDouble(handle_, &eh_);
717 tdvCheckException(dll_handle, eh_);
730 bool val = dll_handle->TDVContext_isString(handle_, &eh_);
731 tdvCheckException(dll_handle, eh_);
744 bool val = dll_handle->TDVContext_isDataPtr(handle_, &eh_);
745 tdvCheckException(dll_handle, eh_);
749 bool isDynamicTemplateIndex()
const {
750 bool val = dll_handle->TDVContext_isDynamicTemplateIndex(handle_, &eh_);
751 tdvCheckException(dll_handle, eh_);
755 bool isContextTemplate()
const {
756 bool val = dll_handle->TDVContext_isContextTemplate(handle_, &eh_);
757 tdvCheckException(dll_handle, eh_);
761 HContext* getHandle() {
return handle_;}
762 const HContext* getHandle()
const {
return handle_;}
771 dll_handle->TDVContext_clear(handle_, &eh_);
772 tdvCheckException(dll_handle,eh_);
784 dll_handle->TDVContext_erase(handle_, str, &eh_);
785 tdvCheckException(dll_handle,eh_);
796 void erase(
const std::string& str) {
809 dll_handle->TDVContext_reserve(handle_, size, &eh_);
810 tdvCheckException(dll_handle,eh_);
823 dll_handle->TDVContext_saveToJsonFile(handle_, path.c_str(), &eh_);
824 tdvCheckException(dll_handle,eh_);
837 dll_handle->TDVContext_saveToJsonFile(handle_, path, &eh_);
838 tdvCheckException(dll_handle,eh_);
841 std::string serializeToJson()
const
843 const char* data = dll_handle->TDVContext_serializeToJson(handle_, &eh_);
845 tdvCheckException(dll_handle, eh_);
847 std::string result(data);
849 dll_handle->TDVContext_deleteString(data, &eh_);
851 tdvCheckException(dll_handle, eh_);
858 void setValue(
const char* str) {
859 dll_handle->TDVContext_putStr(handle_, str, &eh_);
860 tdvCheckException(dll_handle, eh_);
862 void setValue(
const std::string& str) {
863 dll_handle->TDVContext_putStr(handle_, str.c_str(), &eh_);
864 tdvCheckException(dll_handle, eh_);
867 template<typename T, typename = typename std::enable_if<std::is_enum<T>::value || std::is_integral<T>::value>::type>
868 void setValue(T val) {
869 dll_handle->TDVContext_putLong(handle_, val, &eh_);
870 tdvCheckException(dll_handle, eh_);
873 void setValue(
double val) {
874 dll_handle->TDVContext_putDouble(handle_, val, &eh_);
875 tdvCheckException(dll_handle, eh_);
877 void setValue(
float val) {
878 dll_handle->TDVContext_putDouble(handle_, val, &eh_);
879 tdvCheckException(dll_handle, eh_);
881 void setValue(
bool val) {
882 dll_handle->TDVContext_putBool(handle_, val, &eh_);
883 tdvCheckException(dll_handle, eh_);
885 void setValue(
void* ptr,
int copy_sz = 0) {
886 dll_handle->TDVContext_putDataPtr(handle_, static_cast<unsigned char*>(ptr), copy_sz, &eh_);
887 tdvCheckException(dll_handle, eh_);
890 dll_handle->TDVContext_putDynamicTemplateIndex(handle_, templateIndex->_impl, &eh_);
891 tdvCheckException(dll_handle, eh_);
894 dll_handle->TDVContext_putContextTemplate(handle_, templ->_impl, &eh_);
895 tdvCheckException(dll_handle, eh_);
902 ContextRef(
const DHPtr &dll_handle, HContext* handle) :
Context(dll_handle ,handle,
true) {}
906 template <typename T, typename = typename std::enable_if<!std::is_base_of<Context, typename std::decay<T>::type>::value>::type>
907 void operator=(T&& value) {
908 setValue(std::forward<T>(value));
912 template<
bool isConst>
913 Context::ContextArrayIterator<isConst>::ContextArrayIterator(
const Context& ctx,
long long index) : base_(ctx), curr_(nullptr), isObj_(ctx.isObject())
915 length_ = base_.dll_handle->TDVContext_getLength(base_.handle_, &(base_.eh_));
916 tdvCheckException(base_.dll_handle, base_.eh_);
917 index_ = (index > -1) ? (std::min<size_t>)(
static_cast<size_t>(index), length_) : length_;
918 if(index_ < length_) {
921 auto keys = base_.dll_handle->TDVContext_getKeys(base_.handle_, length_, &(base_.eh_));
922 tdvCheckException(base_.dll_handle, base_.eh_);
923 keys_ = std::shared_ptr<charsList>(
new charsList(length_, keys));
924 curr_ =
new Context(base_[keys_->operator[](index)]);
927 curr_ =
new Context(base_[index]);
931 template<
bool isConst>
932 Context::ContextArrayIterator<isConst>::ContextArrayIterator(
const Context& ctx,
const std::string& key) : base_(ctx), curr_(nullptr), isObj_(ctx.isObject())
934 length_ = base_.dll_handle->TDVContext_getLength(base_.handle_, &(base_.eh_));
935 tdvCheckException(base_.dll_handle, base_.eh_);
937 if(isObj_ && length_) {
938 auto keys = base_.dll_handle->TDVContext_getKeys(base_.handle_, length_, &(base_.eh_));
939 tdvCheckException(base_.dll_handle, base_.eh_);
940 keys_ = std::shared_ptr<charsList>(
new charsList(length_, keys));
943 if(!key.compare(keys_->operator[](i))) {
945 curr_ =
new Context(base_[key]);
948 }
while((++i)<length_);
952 template<
bool isConst>
953 Context::ContextArrayIterator<isConst>::ContextArrayIterator(
const ContextArrayIterator& iter) :
954 base_(iter.base_), length_(iter.length_), index_(iter.index_), curr_(iter.curr_ ? new
Context(*(iter.curr_)) : nullptr), isObj_(iter.isObj_), keys_(iter.keys_)
957 template<
bool isConst>
958 Context::ContextArrayIterator<isConst>::ContextArrayIterator(ContextArrayIterator&& iter) :
959 base_(iter.base_), length_(iter.length_), index_(iter.index_), curr_(iter.curr_), isObj_(iter.isObj_), keys_(std::move(iter.keys_)) {
960 iter.curr_ =
nullptr;
963 template<
bool isConst>
964 Context::ContextArrayIterator<isConst>& Context::ContextArrayIterator<isConst>::operator++() {
967 index_ = (std::min<size_t>)(index_+1, length_);
969 curr_ = (index_ < length_) ?
new Context(base_[keys_->operator[](index_)]) :
nullptr;
971 curr_ = (index_ < length_) ?
new Context(base_[index_]) :
nullptr;
975 template<
bool isConst>
976 Context::ContextArrayIterator<isConst> Context::ContextArrayIterator<isConst>::operator++(
int) {
977 ContextArrayIterator tmp = *
this;
978 index_ = (std::min<size_t>)(index_+1, length_);
980 curr_ = (index_ < length_) ?
new Context(base_[keys_->operator[](index_)]) :
nullptr;
982 curr_ = (index_ < length_) ?
new Context(base_[index_]) :
nullptr;
986 inline Context::operator ContextRef()
988 return ContextRef(dll_handle, handle_);
992 HContext* handle = dll_handle->TDVContext_getOrInsertByKey(handle_, key.c_str(), &eh_);
993 tdvCheckException(dll_handle, eh_);
994 return Ref(dll_handle, handle);
998 HContext* handle = dll_handle->TDVContext_getOrInsertByKey(handle_, key, &eh_);
999 tdvCheckException(dll_handle, eh_);
1000 return Ref(dll_handle, handle);
1004 HContext* handle = dll_handle->TDVContext_getByIndex(handle_, index, &eh_);
1005 tdvCheckException(dll_handle, eh_);
1006 return Ref(dll_handle, handle);
1010 HContext* handle = dll_handle->TDVContext_getByKey(handle_, key.c_str(), &eh_);
1011 tdvCheckException(dll_handle, eh_);
1012 return Ref(dll_handle, handle);
1016 HContext* handle = dll_handle->TDVContext_getByKey(handle_, key, &eh_);
1017 tdvCheckException(dll_handle, eh_);
1018 return Ref(dll_handle, handle);
1022 HContext* handle = dll_handle->TDVContext_getByIndex(handle_, index, &eh_);
1023 tdvCheckException(dll_handle, eh_);
1024 return Ref(dll_handle, handle);
1027 inline Context::Ref Context::at(
const char* key) {
1028 HContext* handle = dll_handle->TDVContext_getByKey(handle_, key, &eh_);
1029 tdvCheckException(dll_handle, eh_);
1030 return Ref(dll_handle, handle);
1033 inline Context::Ref Context::at(
const std::string& key) {
1034 HContext* handle = dll_handle->TDVContext_getByKey(handle_, key.c_str(), &eh_);
1035 tdvCheckException(dll_handle, eh_);
1036 return Ref(dll_handle, handle);
1039 inline Context::Ref Context::at(
const int index) {
1040 HContext* handle = dll_handle->TDVContext_getByIndex(handle_, index, &eh_);
1041 tdvCheckException(dll_handle, eh_);
1042 return Ref(dll_handle, handle);
1045 inline const Context::Ref Context::at(
const char* key)
const {
1046 HContext* handle = dll_handle->TDVContext_getByKey(handle_, key, &eh_);
1047 tdvCheckException(dll_handle, eh_);
1048 return Ref(dll_handle, handle);
1051 inline const Context::Ref Context::at(
const std::string& key)
const {
1052 HContext* handle = dll_handle->TDVContext_getByKey(handle_, key.c_str(), &eh_);
1053 tdvCheckException(dll_handle, eh_);
1054 return Ref(dll_handle, handle);
1057 inline const Context::Ref Context::at(
const int index)
const {
1058 HContext* handle = dll_handle->TDVContext_getByIndex(handle_, index, &eh_);
1059 tdvCheckException(dll_handle, eh_);
1060 return Ref(dll_handle, handle);
1064 namespace context_utils {
1070 ctx[
"format"] =
"NDARRAY";
1071 ctx[
"color_space"] = color_mode.at(raw_image.format);
1073 size_t copy_sz = raw_image.
height * raw_image.
width * channels *
sizeof(uint8_t);
1074 if (raw_image.with_crop)
1076 unsigned char* buff{
nullptr};
1077 buff = ctx[
"blob"].setDataPtr(buff, copy_sz);
1078 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);
1079 size_t stride = raw_image.
width*channels*
sizeof(uint8_t);
1080 unsigned char* ptr = buff;
1081 for(
int row=0; row<raw_image.
height; ++row)
1083 std::memcpy(ptr, raw_image.
data+shift, stride);
1084 shift += raw_image.crop_info_data_image_width*channels*
sizeof(uint8_t);
1089 ctx[
"blob"].setDataPtr(raw_image.
data, copy_sz);
1090 ctx[
"dtype"] =
"uint8_t";
1091 ctx[
"shape"].push_back(static_cast<int64_t>(raw_image.
height));
1092 ctx[
"shape"].push_back(static_cast<int64_t>(raw_image.
width));
1093 ctx[
"shape"].push_back(static_cast<int64_t>(channels));
1098 ctx[
"format"] =
"NDARRAY";
1099 ctx[
"color_space"] = color_mode.at(format);
1101 size_t copy_sz = copy ? height * width * channels *
sizeof(uint8_t) : 0;
1102 ctx[
"blob"].setDataPtr(data, copy_sz);
1103 ctx[
"dtype"] =
"uint8_t";
1104 ctx[
"shape"].push_back(static_cast<int64_t>(height));
1105 ctx[
"shape"].push_back(static_cast<int64_t>(width));
1106 ctx[
"shape"].push_back(static_cast<int64_t>(channels));
1112 #endif // WITHOUT_PROCESSING_BLOCK
bool isString() const
проверяет является ли контейнер значением типа string.
Definition: Context.h:729
Интерфейсный объект для создания других интерфейсных объектов.
Definition: FacerecService.h:64
RGB, 24 бита на пиксел, 8 бит на канал.
Definition: IRawImage.h:60
bool isDataPtr() const
проверяет является ли контейнер указателем на данные
Definition: Context.h:743
Интерфейсный объект, хранящий образец лица.
Definition: RawSample.h:49
void saveToJsonFile(std::string &path)
сохраняет содержимое контейнера в json файл
Definition: Context.h:821
void erase(const char *str)
удаляет содержимое контейнера-Context хранящиеся по ключу.
Definition: Context.h:783
void setString(const char *str)
добавляет значение типа string в контейнер
Definition: Context.h:543
void erase(const std::string &str)
удаляет содержимое контейнера-Context хранящиеся по ключу.
Definition: Context.h:796
void saveToJsonFile(const char *path)
сохраняет содержимое контейнера в json файл
Definition: Context.h:835
void reserve(const size_t size)
выделяет память под num элементов в массиве.
Definition: Context.h:808
Оттенки серого, 8 бит на пиксел.
Definition: IRawImage.h:53
void setDouble(double val)
добавляет значение типа double в контейнер
Definition: Context.h:582
std::vector< std::string > getKeys()
возвращает список ключей в контейнере-Context.
Definition: Context.h:393
void setString(const std::string &str)
добавляет значение типа std::string в контейнер
Definition: Context.h:556
unsigned char * getDataPtr() const
возвращает указатель на данные из контейнера
Definition: Context.h:510
bool isDouble() const
проверяет является ли контейнер значением типа double.
Definition: Context.h:715
void push_back(const Context &data)
добавляет объект в контейнер.
Definition: Context.h:434
bool compare(const Context &other) const
сравнивает два объекта Context.
Definition: Context.h:378
bool isBool() const
проверяет является ли контейнер значением типа bool.
Definition: Context.h:687
void clear()
очищает содержимое контейнера-Context.
Definition: Context.h:770
BGR, 24 бита на пиксел, 8 бит на канал.
Definition: IRawImage.h:67
size_t size() const
Получить размер контейнера.
Definition: Context.h:288
bool contains(const std::string &key) const
проверяет существование элемента по определённому ключу
Definition: Context.h:361
bool isNone() const
проверяет нет ли в контейнере элементов
Definition: Context.h:645
Класс исключений, выбрасываемых при возникновении ошибок.
Definition: Error.h:26
Context & operator=(T &&value)
добавляет значение в контейнер
Definition: Context.h:272
bool isLong() const
проверяет является ли контейнер значением типа long.
Definition: Context.h:701
void clear()
очищает содержимое контейнера-Context.
Definition: Context.mm:166
LightSmartPtr< DynamicTemplateIndex >::tPtr Ptr
Псевдоним для типа умного указателя на DynamicTemplateIndex.
Definition: DynamicTemplateIndex.h:34
long getLong() const
возвращает значение типа long из контейнера
Definition: Context.h:466
bool isObject() const
проверяет является ли контейнер объектом
Definition: Context.h:673
Definition: Context.h:899
double getDouble() const
возвращает значение типа double из контейнера
Definition: Context.h:452
void setLong(long val)
добавляет значение типа long в контейнер
Definition: Context.h:569
bool getBool() const
возвращает значение типа bool из контейнера
Definition: Context.h:480
Context - интерфейсный объект для хранения данных и взаимодействия с методами из Processing Block API...
Definition: Context.h:48
unsigned char * setDataPtr(void *ptr, int copy_sz=0)
добавляет указатель на данные в контейнер
Definition: Context.h:610
LightSmartPtr< ContextTemplate >::tPtr Ptr
Псевдоним для типа умного указателя на ContextTemplate.
Definition: ContextTemplate.h:47
std::string getString() const
возвращает значение типа std::string из контейнера
Definition: Context.h:494
void setBool(bool val)
добавляет значение типа bool в контейнер
Definition: Context.h:595
Context - интерфейсный объект для хранения данных и взаимодействия с методами из Processing Block API...
Definition: Context.h:67
bool isArray() const
проверяет является ли контейнере массивом
Definition: Context.h:659
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:991