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_);
521 std::pair<uint8_t*, size_t> getBlobData()
const {
523 uint8_t* ret = dll_handle->TDVContext_getBlobData(handle_, &length, &eh_);
524 tdvCheckException(dll_handle, eh_);
525 return {ret, length};
529 void* index = dll_handle->TDVContext_getDynamicTemplateIndex(handle_, &eh_);
530 tdvCheckException(dll_handle, eh_);
531 return pbio::DynamicTemplateIndex::Ptr::make(dll_handle, index,
true);
535 void* templ = dll_handle->TDVContext_getContextTemplate(handle_, &eh_);
536 tdvCheckException(dll_handle, eh_);
537 return pbio::ContextTemplate::Ptr::make(dll_handle, templ);
549 dll_handle->TDVContext_putStr(handle_, str, &eh_);
550 tdvCheckException(dll_handle, eh_);
562 dll_handle->TDVContext_putStr(handle_, str.c_str(), &eh_);
563 tdvCheckException(dll_handle, eh_);
575 dll_handle->TDVContext_putLong(handle_, val, &eh_);
576 tdvCheckException(dll_handle, eh_);
588 dll_handle->TDVContext_putDouble(handle_, val, &eh_);
589 tdvCheckException(dll_handle, eh_);
601 dll_handle->TDVContext_putBool(handle_, val, &eh_);
602 tdvCheckException(dll_handle, eh_);
616 unsigned char* ret{
nullptr};
618 ret = dll_handle->TDVContext_allocDataPtr(handle_, copy_sz, &eh_);
620 ret = dll_handle->TDVContext_putDataPtr(handle_, static_cast<unsigned char*>(ptr), static_cast<uint64_t>(copy_sz), &eh_);
621 tdvCheckException(dll_handle, eh_);
625 unsigned char*
setDataPtr(
const void* ptr,
int copy_sz) {
626 unsigned char* ret = dll_handle->TDVContext_putConstDataPtr(handle_, static_cast<const unsigned char*>(ptr), copy_sz, &eh_);
627 tdvCheckException(dll_handle, eh_);
633 dll_handle->TDVContext_putDynamicTemplateIndex(handle_, templateIndex->_impl, &eh_);
634 tdvCheckException(dll_handle, eh_);
638 dll_handle->TDVContext_putContextTemplate(handle_, templ->_impl, &eh_);
639 tdvCheckException(dll_handle, eh_);
651 bool value = dll_handle->TDVContext_isNone(handle_, &eh_);
652 tdvCheckException(dll_handle, eh_);
665 bool value = dll_handle->TDVContext_isArray(handle_, &eh_);
666 tdvCheckException(dll_handle, eh_);
679 bool value = dll_handle->TDVContext_isObject(handle_, &eh_);
680 tdvCheckException(dll_handle, eh_);
693 bool val = dll_handle->TDVContext_isBool(handle_, &eh_);
694 tdvCheckException(dll_handle, eh_);
707 bool val = dll_handle->TDVContext_isLong(handle_, &eh_);
708 tdvCheckException(dll_handle, eh_);
721 bool val = dll_handle->TDVContext_isDouble(handle_, &eh_);
722 tdvCheckException(dll_handle, eh_);
735 bool val = dll_handle->TDVContext_isString(handle_, &eh_);
736 tdvCheckException(dll_handle, eh_);
749 bool val = dll_handle->TDVContext_isDataPtr(handle_, &eh_);
750 tdvCheckException(dll_handle, eh_);
754 bool isDynamicTemplateIndex()
const {
755 bool val = dll_handle->TDVContext_isDynamicTemplateIndex(handle_, &eh_);
756 tdvCheckException(dll_handle, eh_);
760 bool isContextTemplate()
const {
761 bool val = dll_handle->TDVContext_isContextTemplate(handle_, &eh_);
762 tdvCheckException(dll_handle, eh_);
766 HContext* getHandle() {
return handle_;}
767 const HContext* getHandle()
const {
return handle_;}
776 dll_handle->TDVContext_clear(handle_, &eh_);
777 tdvCheckException(dll_handle,eh_);
789 dll_handle->TDVContext_erase(handle_, str, &eh_);
790 tdvCheckException(dll_handle,eh_);
801 void erase(
const std::string& str) {
814 dll_handle->TDVContext_reserve(handle_, size, &eh_);
815 tdvCheckException(dll_handle,eh_);
828 dll_handle->TDVContext_saveToJsonFile(handle_, path.c_str(), &eh_);
829 tdvCheckException(dll_handle,eh_);
842 dll_handle->TDVContext_saveToJsonFile(handle_, path, &eh_);
843 tdvCheckException(dll_handle,eh_);
846 std::string serializeToJson()
const
848 const char* data = dll_handle->TDVContext_serializeToJson(handle_, &eh_);
850 tdvCheckException(dll_handle, eh_);
852 std::string result(data);
854 dll_handle->TDVContext_deleteString(data, &eh_);
856 tdvCheckException(dll_handle, eh_);
863 void setValue(
const char* str) {
864 dll_handle->TDVContext_putStr(handle_, str, &eh_);
865 tdvCheckException(dll_handle, eh_);
867 void setValue(
const std::string& str) {
868 dll_handle->TDVContext_putStr(handle_, str.c_str(), &eh_);
869 tdvCheckException(dll_handle, eh_);
872 template<typename T, typename = typename std::enable_if<std::is_enum<T>::value || std::is_integral<T>::value>::type>
873 void setValue(T val) {
874 dll_handle->TDVContext_putLong(handle_, val, &eh_);
875 tdvCheckException(dll_handle, eh_);
878 void setValue(
double val) {
879 dll_handle->TDVContext_putDouble(handle_, val, &eh_);
880 tdvCheckException(dll_handle, eh_);
882 void setValue(
float val) {
883 dll_handle->TDVContext_putDouble(handle_, val, &eh_);
884 tdvCheckException(dll_handle, eh_);
886 void setValue(
bool val) {
887 dll_handle->TDVContext_putBool(handle_, val, &eh_);
888 tdvCheckException(dll_handle, eh_);
890 void setValue(
void* ptr,
int copy_sz = 0) {
891 dll_handle->TDVContext_putDataPtr(handle_, static_cast<unsigned char*>(ptr), copy_sz, &eh_);
892 tdvCheckException(dll_handle, eh_);
895 dll_handle->TDVContext_putDynamicTemplateIndex(handle_, templateIndex->_impl, &eh_);
896 tdvCheckException(dll_handle, eh_);
899 dll_handle->TDVContext_putContextTemplate(handle_, templ->_impl, &eh_);
900 tdvCheckException(dll_handle, eh_);
907 ContextRef(
const DHPtr &dll_handle, HContext* handle) :
Context(dll_handle ,handle,
true) {}
911 template <typename T, typename = typename std::enable_if<!std::is_base_of<Context, typename std::decay<T>::type>::value>::type>
912 void operator=(T&& value) {
913 setValue(std::forward<T>(value));
917 template<
bool isConst>
918 Context::ContextArrayIterator<isConst>::ContextArrayIterator(
const Context& ctx,
long long index) : base_(ctx), curr_(nullptr), isObj_(ctx.isObject())
920 length_ = base_.dll_handle->TDVContext_getLength(base_.handle_, &(base_.eh_));
921 tdvCheckException(base_.dll_handle, base_.eh_);
922 index_ = (index > -1) ? (std::min<size_t>)(
static_cast<size_t>(index), length_) : length_;
923 if(index_ < length_) {
926 auto keys = base_.dll_handle->TDVContext_getKeys(base_.handle_, length_, &(base_.eh_));
927 tdvCheckException(base_.dll_handle, base_.eh_);
928 keys_ = std::shared_ptr<charsList>(
new charsList(length_, keys), std::bind(&ContextArrayIterator::charsList_deleter,
this, std::placeholders::_1));
929 curr_ =
new Context(base_[keys_->operator[](index)]);
932 curr_ =
new Context(base_[index]);
936 template<
bool isConst>
937 Context::ContextArrayIterator<isConst>::ContextArrayIterator(
const Context& ctx,
const std::string& key) : base_(ctx), curr_(nullptr), isObj_(ctx.isObject())
939 length_ = base_.dll_handle->TDVContext_getLength(base_.handle_, &(base_.eh_));
940 tdvCheckException(base_.dll_handle, base_.eh_);
942 if(isObj_ && length_) {
943 auto keys = base_.dll_handle->TDVContext_getKeys(base_.handle_, length_, &(base_.eh_));
944 tdvCheckException(base_.dll_handle, base_.eh_);
945 keys_ = std::shared_ptr<charsList>(
new charsList(length_, keys), std::bind(&ContextArrayIterator::charsList_deleter,
this, std::placeholders::_1));
948 if(!key.compare(keys_->operator[](i))) {
950 curr_ =
new Context(base_[key]);
953 }
while((++i)<length_);
957 template<
bool isConst>
958 Context::ContextArrayIterator<isConst>::ContextArrayIterator(
const ContextArrayIterator& iter) :
959 base_(iter.base_), length_(iter.length_), index_(iter.index_), curr_(iter.curr_ ? new
Context(*(iter.curr_)) : nullptr), isObj_(iter.isObj_), keys_(iter.keys_)
962 template<
bool isConst>
963 Context::ContextArrayIterator<isConst>::ContextArrayIterator(ContextArrayIterator&& iter) :
964 base_(iter.base_), length_(iter.length_), index_(iter.index_), curr_(iter.curr_), isObj_(iter.isObj_), keys_(std::move(iter.keys_)) {
965 iter.curr_ =
nullptr;
968 template<
bool isConst>
969 Context::ContextArrayIterator<isConst>& Context::ContextArrayIterator<isConst>::operator++() {
972 index_ = (std::min<size_t>)(index_+1, length_);
974 curr_ = (index_ < length_) ?
new Context(base_[keys_->operator[](index_)]) :
nullptr;
976 curr_ = (index_ < length_) ?
new Context(base_[index_]) :
nullptr;
980 template<
bool isConst>
981 Context::ContextArrayIterator<isConst> Context::ContextArrayIterator<isConst>::operator++(
int) {
982 ContextArrayIterator tmp = *
this;
983 index_ = (std::min<size_t>)(index_+1, length_);
985 curr_ = (index_ < length_) ?
new Context(base_[keys_->operator[](index_)]) :
nullptr;
987 curr_ = (index_ < length_) ?
new Context(base_[index_]) :
nullptr;
991 inline Context::operator ContextRef()
993 return ContextRef(dll_handle, handle_);
997 HContext* handle = dll_handle->TDVContext_getOrInsertByKey(handle_, key.c_str(), &eh_);
998 tdvCheckException(dll_handle, eh_);
999 return Ref(dll_handle, handle);
1003 HContext* handle = dll_handle->TDVContext_getOrInsertByKey(handle_, key, &eh_);
1004 tdvCheckException(dll_handle, eh_);
1005 return Ref(dll_handle, handle);
1009 HContext* handle = dll_handle->TDVContext_getByIndex(handle_, index, &eh_);
1010 tdvCheckException(dll_handle, eh_);
1011 return Ref(dll_handle, handle);
1015 HContext* handle = dll_handle->TDVContext_getByKey(handle_, key.c_str(), &eh_);
1016 tdvCheckException(dll_handle, eh_);
1017 return Ref(dll_handle, handle);
1021 HContext* handle = dll_handle->TDVContext_getByKey(handle_, key, &eh_);
1022 tdvCheckException(dll_handle, eh_);
1023 return Ref(dll_handle, handle);
1027 HContext* handle = dll_handle->TDVContext_getByIndex(handle_, index, &eh_);
1028 tdvCheckException(dll_handle, eh_);
1029 return Ref(dll_handle, handle);
1032 inline Context::Ref Context::at(
const char* key) {
1033 HContext* handle = dll_handle->TDVContext_getByKey(handle_, key, &eh_);
1034 tdvCheckException(dll_handle, eh_);
1035 return Ref(dll_handle, handle);
1038 inline Context::Ref Context::at(
const std::string& key) {
1039 HContext* handle = dll_handle->TDVContext_getByKey(handle_, key.c_str(), &eh_);
1040 tdvCheckException(dll_handle, eh_);
1041 return Ref(dll_handle, handle);
1044 inline Context::Ref Context::at(
const int index) {
1045 HContext* handle = dll_handle->TDVContext_getByIndex(handle_, index, &eh_);
1046 tdvCheckException(dll_handle, eh_);
1047 return Ref(dll_handle, handle);
1050 inline const Context::Ref Context::at(
const char* key)
const {
1051 HContext* handle = dll_handle->TDVContext_getByKey(handle_, key, &eh_);
1052 tdvCheckException(dll_handle, eh_);
1053 return Ref(dll_handle, handle);
1056 inline const Context::Ref Context::at(
const std::string& key)
const {
1057 HContext* handle = dll_handle->TDVContext_getByKey(handle_, key.c_str(), &eh_);
1058 tdvCheckException(dll_handle, eh_);
1059 return Ref(dll_handle, handle);
1062 inline const Context::Ref Context::at(
const int index)
const {
1063 HContext* handle = dll_handle->TDVContext_getByIndex(handle_, index, &eh_);
1064 tdvCheckException(dll_handle, eh_);
1065 return Ref(dll_handle, handle);
1069 namespace context_utils {
1075 ctx[
"format"] =
"NDARRAY";
1076 ctx[
"color_space"] = color_mode.at(raw_image.format);
1078 size_t copy_sz = raw_image.
height * raw_image.
width * channels *
sizeof(uint8_t);
1079 if (raw_image.with_crop)
1081 unsigned char* buff{
nullptr};
1082 buff = ctx[
"blob"].setDataPtr(buff, copy_sz);
1083 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);
1084 size_t stride = raw_image.
width*channels*
sizeof(uint8_t);
1085 unsigned char* ptr = buff;
1086 for(
int row=0; row<raw_image.
height; ++row)
1088 std::memcpy(ptr, raw_image.
data+shift, stride);
1089 shift += raw_image.crop_info_data_image_width*channels*
sizeof(uint8_t);
1094 ctx[
"blob"].setDataPtr(raw_image.
data, copy_sz);
1095 ctx[
"dtype"] =
"uint8_t";
1096 ctx[
"shape"].push_back(static_cast<int64_t>(raw_image.
height));
1097 ctx[
"shape"].push_back(static_cast<int64_t>(raw_image.
width));
1098 ctx[
"shape"].push_back(static_cast<int64_t>(channels));
1103 ctx[
"format"] =
"NDARRAY";
1104 ctx[
"color_space"] = color_mode.at(format);
1106 size_t copy_sz = copy ? height * width * channels *
sizeof(uint8_t) : 0;
1107 ctx[
"blob"].setDataPtr(data, copy_sz);
1108 ctx[
"dtype"] =
"uint8_t";
1109 ctx[
"shape"].push_back(static_cast<int64_t>(height));
1110 ctx[
"shape"].push_back(static_cast<int64_t>(width));
1111 ctx[
"shape"].push_back(static_cast<int64_t>(channels));
1117 #endif // WITHOUT_PROCESSING_BLOCK
bool isString() const
checks whether the container is a long type string
Definition: Context.h:734
Interface object for creating other interface objects.
Definition: FacerecService.h:64
RGB, 24 bit per pixel, 8 bit per channel.
Definition: IRawImage.h:60
bool isDataPtr() const
checks whether the container is a pointer to the data
Definition: Context.h:748
Interface object that stores a captured face sample.
Definition: RawSample.h:49
void saveToJsonFile(std::string &path)
saves the contents of the container to a json file
Definition: Context.h:826
void erase(const char *str)
deletes the contents of the container-Context stored by key.
Definition: Context.h:788
void setString(const char *str)
adds a value of type string to the container
Definition: Context.h:548
void erase(const std::string &str)
deletes the contents of the container-Context stored by key.
Definition: Context.h:801
void saveToJsonFile(const char *path)
saves the contents of the container to a json file
Definition: Context.h:840
void reserve(const size_t size)
allocates memory for num elements in the array.
Definition: Context.h:813
Grayscale, 8 bit per pixel.
Definition: IRawImage.h:53
void setDouble(double val)
adds a value of type double to the container
Definition: Context.h:587
std::vector< std::string > getKeys()
returns a list of keys in the container-Context
Definition: Context.h:402
void setString(const std::string &str)
adds a value of type std::string to the container
Definition: Context.h:561
unsigned char * getDataPtr() const
returns a pointer to data from the container
Definition: Context.h:515
bool isDouble() const
checks whether the container is a long type double
Definition: Context.h:720
void push_back(const Context &data)
adds a object to the container.
Definition: Context.h:439
bool compare(const Context &other) const
compares two Context objects
Definition: Context.h:387
bool isBool() const
checks whether the container is a bool type value
Definition: Context.h:692
void clear()
clears the contents of the container-Context.
Definition: Context.h:775
BGR, 24 bit per pixel, 8 bit per channel.
Definition: IRawImage.h:67
size_t size() const
Get the size of the container.
Definition: Context.h:297
bool contains(const std::string &key) const
checks the existence of an element by a specific key
Definition: Context.h:370
bool isNone() const
checks if there are no elements in the container
Definition: Context.h:650
The class of exceptions thrown when errors occur.
Definition: Error.h:26
Context & operator=(T &&value)
adds a value to the container
Definition: Context.h:281
bool isLong() const
проверяет является ли контейнер значением типа long.
Definition: Context.h:706
void clear()
clears the contents of the container-Context.
Definition: Context.mm:166
LightSmartPtr< DynamicTemplateIndex >::tPtr Ptr
Alias for the type of a smart pointer to DynamicTemplateIndex.
Definition: DynamicTemplateIndex.h:34
long getLong() const
returns a long value from the container
Definition: Context.h:471
bool isObject() const
checks whether the container is an object
Definition: Context.h:678
Definition: Context.h:904
double getDouble() const
returns a double value from the container
Definition: Context.h:457
void setLong(long val)
adds a value of type long to the container
Definition: Context.h:574
bool getBool() const
returns a bool value from the container
Definition: Context.h:485
Context is an interface object for storing data and interacting with methods from the Processing Bloc...
Definition: Context.h:48
unsigned char * setDataPtr(void *ptr, int copy_sz=0)
adds a pointer to the data in the container
Definition: Context.h:615
LightSmartPtr< ContextTemplate >::tPtr Ptr
Alias for the type of a smart pointer to ContextTemplate.
Definition: ContextTemplate.h:47
std::string getString() const
returns a std::string value from the container
Definition: Context.h:499
void setBool(bool val)
adds a value of type bool to the container
Definition: Context.h:600
Context is an interface object for storing data and interacting with methods from the Processing Bloc...
Definition: Context.h:67
bool isArray() const
checks whether the container is an array
Definition: Context.h:664
int height
Image height.
Definition: RawImage.h:117
const unsigned char * data
Pointer to the image data buffer. All pixels must be stored continuously, row by row, without gaps at the end of each row.
Definition: RawImage.h:118
Format
Format of image data.
Definition: IRawImage.h:46
Struct that provides raw image data and optional cropping information.
Definition: RawImage.h:113
int width
Image width.
Definition: RawImage.h:116
Ref operator[](const std::string &key)
indexing by key.
Definition: Context.h:996