40 #pragma warning(disable:4996)
47#include "opencv2/opencv.hpp"
48#include "opencv2/core/core.hpp"
49#include "opencv2/core/types_c.h"
51#include "../common/sharedStructures.h"
52#include "../common/color.h"
53#include "../common/byteArray.h"
58 template<>
inline ito::float32 saturate_cast<ito::float32>( ito::float64 v)
61 return std::numeric_limits<ito::float32>::infinity();
63 return std::numeric_limits<ito::float32>::quiet_NaN();
64 return static_cast<ito::float32
>(std::max ( (ito::float64)(- (std::numeric_limits<ito::float32>::max)()) , std::min ( v , (ito::float64) ((std::numeric_limits<ito::float32>::max)()) )));
67 template<>
inline ito::float64 saturate_cast<ito::float64>( ito::float32 v)
70 return std::numeric_limits<ito::float64>::infinity();
72 return std::numeric_limits<ito::float64>::quiet_NaN();
73 return static_cast<ito::float64
>(v);
76 template<
typename _Tp>
static inline _Tp saturate_cast(ito::complex128 )
78 cv::error(cv::Exception(CV_StsAssert,
"Not defined for input parameter type",
"", __FILE__, __LINE__));
82 template<
typename _Tp>
static inline _Tp saturate_cast(ito::complex64 )
84 cv::error(cv::Exception(CV_StsAssert,
"Not defined for input parameter type",
"", __FILE__, __LINE__));
88 template<
typename _Tp>
static inline _Tp saturate_cast(
ito::Rgba32 )
90 cv::error(cv::Exception(CV_StsAssert,
"Not defined for input parameter type",
"", __FILE__, __LINE__));
94 template<
typename _Tp>
static inline _Tp saturate_cast(
ito::DateTime )
96 cv::error(cv::Exception(CV_StsAssert,
"Not defined for input parameter type",
"", __FILE__, __LINE__));
100 template<
typename _Tp>
static inline _Tp saturate_cast(
ito::TimeDelta )
102 cv::error(cv::Exception(CV_StsAssert,
"Not defined for input parameter type",
"", __FILE__, __LINE__));
108 cv::error(cv::Exception(CV_StsAssert,
"Not defined for input parameter type",
"", __FILE__, __LINE__));
109 return ito::Rgba32::black();
114 cv::error(cv::Exception(CV_StsAssert,
"Not defined for input parameter type",
"", __FILE__, __LINE__));
115 return ito::Rgba32::black();
121 template<>
inline ito::complex64 saturate_cast(ito::uint8 v){
return ito::complex64(
static_cast<ito::float32
>(v),0.0); }
122 template<>
inline ito::complex64 saturate_cast(ito::int8 v){
return ito::complex64(
static_cast<ito::float32
>(v),0.0); }
123 template<>
inline ito::complex64 saturate_cast(ito::uint16 v){
return ito::complex64(
static_cast<ito::float32
>(v),0.0); }
124 template<>
inline ito::complex64 saturate_cast(ito::int16 v){
return ito::complex64(
static_cast<ito::float32
>(v),0.0); }
125 template<>
inline ito::complex64 saturate_cast(ito::uint32 v){
return ito::complex64(
static_cast<ito::float32
>(v),0.0); }
126 template<>
inline ito::complex64 saturate_cast(ito::int32 v){
return ito::complex64(
static_cast<ito::float32
>(v),0.0); }
127 template<>
inline ito::complex64 saturate_cast(ito::float32 v){
return ito::complex64(v,0.0); }
128 template<>
inline ito::complex64 saturate_cast(ito::float64 v){
return ito::complex64(saturate_cast<ito::float32>(v),0.0); }
129 template<>
inline ito::complex64 saturate_cast(ito::complex64 v){
return v; }
130 template<>
inline ito::complex64 saturate_cast(ito::complex128 v){
return std::complex<ito::float32>(saturate_cast<ito::float32>(v.real()),saturate_cast<ito::float32>(v.imag())); }
132 template<>
inline ito::complex128 saturate_cast(ito::uint8 v){
return ito::complex128(
static_cast<ito::float64
>(v),0.0); }
133 template<>
inline ito::complex128 saturate_cast(ito::int8 v){
return ito::complex128(
static_cast<ito::float64
>(v),0.0); }
134 template<>
inline ito::complex128 saturate_cast(ito::uint16 v){
return ito::complex128(
static_cast<ito::float64
>(v),0.0); }
135 template<>
inline ito::complex128 saturate_cast(ito::int16 v){
return ito::complex128(
static_cast<ito::float64
>(v),0.0); }
136 template<>
inline ito::complex128 saturate_cast(ito::uint32 v){
return ito::complex128(
static_cast<ito::float64
>(v),0.0); }
137 template<>
inline ito::complex128 saturate_cast(ito::int32 v){
return ito::complex128(
static_cast<ito::float64
>(v),0.0); }
138 template<>
inline ito::complex128 saturate_cast(ito::float32 v){
return ito::complex128(saturate_cast<ito::float64>(v),0.0); }
139 template<>
inline ito::complex128 saturate_cast(ito::float64 v){
return ito::complex128(v,0.0); }
140 template<>
inline ito::complex128 saturate_cast(ito::complex64 v){
return ito::complex128(saturate_cast<ito::float64>(v.real()),saturate_cast<ito::float64>(v.imag())); }
141 template<>
inline ito::complex128 saturate_cast(ito::complex128 v){
return v; }
145 template<>
inline ito::Rgba32 saturate_cast(ito::uint16 v){
return ito::Rgba32(saturate_cast<ito::uint8>(v));}
147 template<>
inline ito::Rgba32 saturate_cast(ito::uint32 v)
151 template<>
inline ito::Rgba32 saturate_cast(ito::int32 v)
154 temp.rgba =
static_cast<ito::uint32
>(v);
157 template<>
inline ito::Rgba32 saturate_cast(ito::float32 v){
return ito::Rgba32(saturate_cast<ito::uint8>(v));}
158 template<>
inline ito::Rgba32 saturate_cast(ito::float64 v){
return ito::Rgba32(saturate_cast<ito::uint8>(v));}
161 template<>
inline ito::Rgba32 saturate_cast(ito::int8 ) { cv::error(cv::Exception(CV_StsAssert,
"Cast from int8 to rgba32 not defined.",
"", __FILE__, __LINE__));
return ito::Rgba32(); }
162 template<>
inline ito::Rgba32 saturate_cast(ito::int16 ) { cv::error(cv::Exception(CV_StsAssert,
"Cast from int16 to rgba32 not defined.",
"", __FILE__, __LINE__));
return ito::Rgba32(); }
163 template<>
inline ito::Rgba32 saturate_cast(ito::complex128 ) { cv::error(cv::Exception(CV_StsAssert,
"Cast from complex128 to rgba32 not defined.",
"", __FILE__, __LINE__));
return ito::Rgba32(); }
164 template<>
inline ito::Rgba32 saturate_cast(ito::complex64 ) { cv::error(cv::Exception(CV_StsAssert,
"Cast from complex64 to rgba32 not defined.",
"", __FILE__, __LINE__));
return ito::Rgba32(); }
166 template<>
inline ito::uint8 saturate_cast(
ito::Rgba32 v){
return saturate_cast<ito::uint8>(v.
gray());};
168 template<>
inline ito::uint16 saturate_cast(
ito::Rgba32 v){
return saturate_cast<ito::uint16>(v.
gray());};
169 template<>
inline ito::uint32 saturate_cast(
ito::Rgba32 v){
return v.
argb();};
170 template<>
inline ito::int32 saturate_cast(
ito::Rgba32 v){
return (ito::int32)(v.
argb());};
171 template<>
inline ito::float32 saturate_cast(
ito::Rgba32 v){
return v.
gray();};
172 template<>
inline ito::float64 saturate_cast(
ito::Rgba32 v){
return (ito::float64)v.
gray();};
174#if (CV_MAJOR_VERSION > 3) || (CV_MAJOR_VERSION == 3 && CV_MINOR_VERSION >= 3)
177 template<>
class DataType<
ito::uint32>
180 typedef ito::uint32 value_type;
181 typedef value_type work_type;
182 typedef value_type channel_type;
183 typedef value_type vec_type;
184 enum { generic_type = 1, depth = -1, channels = 1, fmt=0,
185 type = CV_MAKETYPE(depth, channels) };
189 template<>
class DataType<
ito::Rgba32>
193 typedef ito::uint8 channel_type;
194 typedef Vec<channel_type, 4> work_type;
199 depth = cv::DataDepth<channel_type>::value,
201 fmt = ((channels-1)<<8) + cv::DataDepth<channel_type>::fmt,
202 type = CV_MAKETYPE(depth, channels)
206 template<>
class DataType<
ito::RedChannel>
210 typedef ito::uint8 channel_type;
211 typedef Vec<channel_type, 4> work_type;
216 depth = cv::DataDepth<channel_type>::value,
218 fmt = ((channels-1)<<8) + cv::DataDepth<channel_type>::fmt,
219 type = CV_MAKETYPE(depth, channels)
223 template<>
class DataType<
ito::GreenChannel>
227 typedef ito::uint8 channel_type;
228 typedef Vec<channel_type, 4> work_type;
233 depth = cv::DataDepth<channel_type>::value,
235 fmt = ((channels-1)<<8) + cv::DataDepth<channel_type>::fmt,
236 type = CV_MAKETYPE(depth, channels)
240 template<>
class DataType<
ito::BlueChannel>
244 typedef ito::uint8 channel_type;
245 typedef Vec<channel_type, 4> work_type;
250 depth = cv::DataDepth<channel_type>::value,
252 fmt = ((channels-1)<<8) + cv::DataDepth<channel_type>::fmt,
253 type = CV_MAKETYPE(depth, channels)
257 template<>
class DataType<
ito::AlphaChannel>
261 typedef ito::uint8 channel_type;
262 typedef Vec<channel_type, 4> work_type;
267 depth = cv::DataDepth<channel_type>::value,
269 fmt = ((channels-1)<<8) + cv::DataDepth<channel_type>::fmt,
270 type = CV_MAKETYPE(depth, channels)
274 template<>
class DataType<
ito::DateTime>
278 typedef ito::uint8 channel_type;
284 depth = cv::DataDepth<channel_type>::value,
286 fmt = ((channels - 1) << 8) + cv::DataDepth<channel_type>::fmt,
287 type = CV_MAKETYPE(depth, channels)
291 template<>
class DataType<
ito::TimeDelta>
295 typedef ito::uint8 channel_type;
301 depth = cv::DataDepth<channel_type>::value,
303 fmt = ((channels - 1) << 8) + cv::DataDepth<channel_type>::fmt,
304 type = CV_MAKETYPE(depth, channels)
319 class DataObjectTags;
320 class DataObjectTagType;
321 class DataObjectTagsPrivate;
335 Range(
int _start,
int _end) { _start < _end ? (end = _end, start = _start) : (start = _end, end = _start); }
336 inline unsigned int size()
const {
return end - start; }
337 inline bool empty()
const {
return (start == end); }
356 typeInvalid = 0x000000,
357 typeDouble = 0x000008,
358 typeString = 0x000020
370 DataObjectTagType(
const std::string &str) : m_dVal(std::numeric_limits<double>::quiet_NaN()), m_type(DataObjectTagType::typeString){ m_strValue = str.
data(); }
371 DataObjectTagType(
const ByteArray &str) : m_dVal(std::numeric_limits<double>::quiet_NaN()), m_type(DataObjectTagType::typeString){ m_strValue = str; }
379 this->m_dVal = rhs.
m_dVal;
381 this->m_type = rhs.
m_type;
387 inline int getType(
void)
const {
return m_type;}
390 inline bool isValid(
void)
const {
return (m_type == DataObjectTagType::typeInvalid) ?
false:
true;}
399 if(m_type == DataObjectTagType::typeInvalid)
401 return std::numeric_limits<double>::quiet_NaN();
403 else if(m_type == DataObjectTagType::typeDouble)
409 constexpr double dVal = std::numeric_limits<double>::quiet_NaN();
422 if(m_type == DataObjectTagType::typeInvalid)
426 else if(m_type == DataObjectTagType::typeString)
432 if (std::isnan(m_dVal))
return "NaN";
433 if (std::isinf(m_dVal))
return "Inf";
435 std::ostringstream strs;
472 const uchar* operator *()
const;
475 const uchar* operator [](
int i)
const;
504 void seekAbs(
int ofs);
507 void seekRel(
int ofs);
547 uchar* operator [](
int i);
572 template<
typename _Tp>
RetVal CreateFunc(
DataObject *dObj,
const unsigned char dimensions,
const int *sizes,
const unsigned char continuous,
const uchar* continuousDataPtr,
const int* steps);
583 template<
typename _Tp> std::ostream& coutFunc(std::ostream& out,
const DataObject& dObj);
594 void createHeader(
const unsigned char dimensions,
const int *sizes,
const int *steps,
const int elemSize);
597 void createHeaderWithROI(
const unsigned char dimensions,
const int *sizes,
const int *osizes = NULL,
const int *roi = NULL);
599 void create(
const unsigned char dimensions,
const int *sizes,
const int type,
const unsigned char continuous,
const uchar* continuousDataPtr = NULL,
const int* steps = NULL);
600 void create(
const unsigned char dimensions,
const int *sizes,
const int type,
const cv::Mat* planes,
const unsigned int nrOfPlanes);
603 void secureFreeData(
void);
607 ito::RetVal matNumToIdx(
const int matNum,
int *matIdx)
const;
610 ito::RetVal matIdxToNum(
const unsigned int *matIdx,
int *matNum)
const;
615 inline MSize() : m_p(NULL) {}
616 inline int operator [] (
const int dim)
const
620 inline operator const int * ()
const {
return m_p; }
621 inline bool operator == (
const MSize& sz)
const
623 if(m_p == NULL || sz.m_p == NULL)
625 return sz.m_p == m_p;
629 if( d != sz.m_p[-1] )
632 return (memcmp(m_p, sz.m_p, d *
sizeof(
int)) == 0);
635 inline bool operator != (
const MSize& sz)
const {
return !(*
this == sz); }
643 inline MROI() : m_p(NULL) {};
644 inline int operator [] (
const int dim)
const
649 inline bool operator == (
const MROI & rroi)
const
651 if(m_p == NULL || rroi.m_p == NULL)
653 return rroi.m_p == m_p;
657 if( d != rroi.m_p[-1] )
660 return (memcmp(m_p, rroi.m_p, d *
sizeof(
int)) == 0);
662 if (m_p[-1] != rroi.m_p[-1])
683 static const int m_sizeofs;
685 int mdata_realloc(
const int size);
686 int mdata_size(
void)
const;
689 RetVal copyFromData2DInternal(
const uchar* src,
const int sizeOfElem,
const int sizeX,
const int sizeY);
690 RetVal copyFromData2DInternal(
const uchar* src,
const int sizeOfElem,
const int sizeX,
const int x0,
const int y0,
const int width,
const int height);
694 template<
typename _Tp>
friend RetVal CreateFunc(
DataObject *dObj,
const unsigned char dimensions,
const int *sizes,
const unsigned char continuous,
const uchar* continuousDataPtr,
const int* steps);
704 template<
typename _Tp>
friend RetVal EvaluateTransposeFlagFunc(
DataObject *dObj);
705 template<
typename _Tp>
friend std::ostream& coutFunc(std::ostream& out,
const DataObject& dObj);
708 template<
typename _Tp>
friend RetVal GetRangeFunc(
DataObject *dObj,
const int dtop,
const int dbottom,
const int dleft,
const int dright);
719 DataObject(
const int sizeY,
const int sizeX,
const int type);
722 DataObject(
const int sizeZ,
const int sizeY,
const int sizeX,
const int type,
const unsigned char continuous = 0);
725 DataObject(
const int sizeZ,
const int sizeY,
const int sizeX,
const int type,
const uchar* continuousDataPtr,
const int* steps = NULL);
728 DataObject(
const MSize &sizes,
const int type,
const unsigned char continuous = 0);
731 DataObject(
const unsigned char dimensions,
const int *sizes,
const int type,
const unsigned char continuous = 0);
734 DataObject(
const unsigned char dimensions,
const int *sizes,
const int type,
const uchar* continuousDataPtr,
const int* steps = NULL);
737 DataObject(
const unsigned char dimensions,
const int *sizes,
const int type,
const cv::Mat* planes,
const unsigned int nrOfPlanes);
750 double getValueOffset()
const;
753 double getValueScale()
const;
756 const std::string getValueUnit()
const;
759 std::string getValueDescription()
const;
762 double getAxisOffset(
const int axisNum)
const;
765 double getAxisScale(
const int axisNum)
const;
768 const std::string getAxisUnit(
const int axisNum,
bool &validOperation)
const;
771 std::string getAxisDescription(
const int axisNum,
bool &validOperation)
const;
775 bool getTagByIndex(
const int tagNumber, std::string &key,
DataObjectTagType &value)
const;
778 std::string getTagKey(
const int tagNumber,
bool &validOperation)
const;
781 int getTagListSize()
const;
784 int setValueUnit(
const std::string &unit);
787 int setValueDescription(
const std::string &description);
790 int setAxisOffset(
const unsigned int axisNum,
const double offset);
793 int setAxisScale(
const unsigned int axisNum,
const double scale);
796 int setAxisUnit(
const unsigned int axisNum,
const std::string &unit);
799 int setAxisDescription(
const unsigned int axisNum,
const std::string &description);
801 bool existTag(
const std::string &key)
const;
802 bool deleteTag(
const std::string &key);
803 bool deleteAllTags();
804 int addToProtocol(
const std::string &value);
811 double getPhysToPix(
const unsigned int dim,
const double phys,
bool &isInsideImage)
const;
818 double getPhysToPix(
const unsigned int dim,
const double phys)
const;
826 double getPhysToPixUnclipped(
const unsigned int dim,
const double phys)
const;
831 int getPhysToPix2D(
const double physY,
double &tPxY,
bool &isInsideImageY,
const double physX,
double &tPxX,
bool &isInsideImageX)
const;
836 double getPixToPhys(
const unsigned int dim,
const double pix,
bool &isInsideImage)
const;
841 double getPixToPhys(
const unsigned int dim,
const double pix)
const;
856 RetVal setXYRotationalMatrix(
double r11,
double r12,
double r13,
double r21,
double r22,
double r23,
double r31,
double r32,
double r33);
871 RetVal getXYRotationalMatrix(
double &r11,
double &r12,
double &r13,
double &r21,
double &r22,
double &r23,
double &r31,
double &r32,
double &r33)
const;
882 inline int getDims(
void)
const {
return m_dims; }
885 inline int getType(
void)
const {
return m_type; }
894 int seekMat(
const int matNum,
const int numMats)
const;
897 int seekMat(
const int matNum)
const;
900 int calcNumMats(
void)
const;
920 return m_size[0] * m_size[1];
924 for (
int n = 0; n < m_dims - 2; n++)
934 cv::Mat* getCvPlaneMat(
const int planeIndex);
937 const cv::Mat* getCvPlaneMat(
const int planeIndex)
const;
940 const cv::Mat getContinuousCvPlaneMat(
const int planeIndex)
const;
954 return (cv::Mat**)m_data;
969 return (
const cv::Mat**)m_data;
991 if(index < 0 || index >= m_dims)
997 return m_size[index];
1020 if(index < 0 || index >= m_dims)
1026 return m_osize[index];
1038 int getStep(
int index)
const;
1048 int dims = getDims();
1049 int total = dims > 0 ? 1 : 0;
1050 for(
int i = 0 ; i < dims ; i++)
1065 int dims = getDims();
1066 int total = dims > 0 ? 1 : 0;
1067 for(
int i = 0 ; i<dims ; i++)
1069 total *= m_osize[i];
1075 RetVal convertTo(
DataObject &rhs,
const int type,
const double alpha=1,
const double beta=0 )
const;
1106 DataObject & operator = (
const cv::Mat &rhs);
1109 DataObject & operator = (
const uint8 &value);
1110 DataObject & operator = (
const int16 &value);
1111 DataObject & operator = (
const uint16 &value);
1112 DataObject & operator = (
const int32 &value);
1113 DataObject & operator = (
const uint32 &value);
1114 DataObject & operator = (
const float32 &value);
1115 DataObject & operator = (
const float64 &value);
1116 DataObject & operator = (
const complex64 &value);
1117 DataObject & operator = (
const complex128 &value);
1124 DataObject & operator += (
const float64 &value);
1125 DataObject & operator += (
const complex128 &value);
1129 DataObject operator + (
const float64 &value);
1130 DataObject operator + (
const complex128 &value);
1134 DataObject & operator -= (
const float64 &value);
1135 DataObject & operator -= (
const complex128 &value);
1139 DataObject operator - (
const float64 &value);
1140 DataObject operator - (
const complex128 &value);
1144 DataObject & operator *= (
const float64 &factor);
1145 DataObject & operator *= (
const complex128 &factor);
1148 DataObject operator * (
const float64 &factor);
1149 DataObject operator * (
const complex128 &factor);
1159 DataObject operator < (
const float64 &value);
1160 DataObject operator > (
const float64 &value);
1161 DataObject operator <= (
const float64 &value);
1162 DataObject operator >= (
const float64 &value);
1163 DataObject operator == (
const float64 &value);
1164 DataObject operator != (
const float64 &value);
1166 DataObject operator == (
const ito::complex64 &value);
1167 DataObject operator != (
const ito::complex64 &value);
1169 DataObject operator == (
const ito::complex128 &value);
1170 DataObject operator != (
const ito::complex128 &value);
1190 DataObject operator << (
const unsigned int shiftbit);
1191 DataObject & operator <<= (
const unsigned int shiftbit);
1192 DataObject operator >> (
const unsigned int shiftbit);
1193 DataObject & operator >>= (
const unsigned int shiftbit);
1205 RetVal zeros(
const int type);
1206 RetVal zeros(
const int size,
const int type);
1207 RetVal zeros(
const int sizeY,
const int sizeX,
const int type);
1208 RetVal zeros(
const int sizeZ,
const int sizeY,
const int sizeX,
const int type,
const unsigned char continuous = 0);
1209 RetVal zeros(
const unsigned char dimensions,
const int *sizes,
const int type,
const unsigned char continuous = 0);
1212 RetVal ones(
const int type);
1213 RetVal ones(
const int size,
const int type);
1214 RetVal ones(
const int sizeY,
const int sizeX,
const int type);
1215 RetVal ones(
const int sizeZ,
const int sizeY,
const int sizeX,
const int type,
const unsigned char continuous = 0);
1216 RetVal ones(
const unsigned char dimensions,
const int *sizes,
const int type,
const unsigned char continuous = 0);
1219 RetVal nans(
const int type);
1220 RetVal nans(
const int size,
const int type);
1221 RetVal nans(
const int sizeY,
const int sizeX,
const int type);
1222 RetVal nans(
const int sizeZ,
const int sizeY,
const int sizeX,
const int type,
const unsigned char continuous = 0);
1223 RetVal nans(
const unsigned char dimensions,
const int *sizes,
const int type,
const unsigned char continuous = 0);
1226 RetVal rand(
const int type,
const bool randMode =
false);
1227 RetVal rand(
const int size,
const int type,
const bool randMode =
false);
1228 RetVal rand(
const int sizeY,
const int sizeX,
const int type,
const bool randMode =
false);
1229 RetVal rand(
const int sizeZ,
const int sizeY,
const int sizeX,
const int type,
const bool randMode,
const unsigned char continuous = 0);
1230 RetVal rand(
const unsigned char dimensions,
const int *sizes,
const int type,
const bool randMode,
const unsigned char continuous = 0);
1233 RetVal eye(
const int type);
1234 RetVal eye(
const int size,
const int type);
1248 void pow(
const ito::float64 &power,
DataObject &dst);
1254 DataObject reshape(
int newDims,
const int *newSizes)
const;
1256 int elemSize()
const;
1264 template<
typename _Tp>
inline const _Tp&
at(
const unsigned int y,
const unsigned int x)
const
1269 cv::error(cv::Exception(CV_StsAssert,
"Dimension mismatch while addressing data field",
"", __FILE__, __LINE__));
1271 else if (((
int)x >= m_size[1]) || ((
int)y >= m_size[0]) )
1273 cv::error(cv::Exception(CV_StsAssert,
"Index out of bounds",
"", __FILE__ , __LINE__));
1276 return (*
reinterpret_cast<const cv::Mat_<_Tp>*
>(m_data[0]))(y, x);
1285 template<
typename _Tp>
inline _Tp&
at(
const unsigned int y,
const unsigned int x)
1290 cv::error(cv::Exception(CV_StsAssert,
"Dimension mismatch while addressing data field",
"", __FILE__, __LINE__));
1292 else if (((
int)x >= m_size[1]) || ((
int)y >= m_size[0]) )
1294 cv::error(cv::Exception(CV_StsAssert,
"Index out of bounds",
"", __FILE__ , __LINE__));
1297 return (*
reinterpret_cast<cv::Mat_<_Tp>*
>(m_data[0]))(y, x);
1307 template<
typename _Tp>
inline const _Tp&
at(
const unsigned int z,
const unsigned int y,
const unsigned int x)
const
1312 cv::error(cv::Exception(CV_StsAssert,
"Dimension mismatch while addressing data field",
"", __FILE__, __LINE__));
1314 else if (((
int)x >= m_size[2]) || ((
int)y >= m_size[1]) || (((
int)z + m_roi[0]) >= (m_roi[0] + m_size[0])))
1316 cv::error(cv::Exception(CV_StsAssert,
"Index out of bounds",
"", __FILE__ , __LINE__));
1319 return (*
reinterpret_cast<const cv::Mat_<_Tp>*
>(m_data[z + m_roi[0]]))(y, x);
1329 template<
typename _Tp>
inline _Tp&
at(
const unsigned int z,
const unsigned int y,
const unsigned int x)
1334 cv::error(cv::Exception(CV_StsAssert,
"Dimension mismatch while addressing data field",
"", __FILE__, __LINE__));
1336 else if (((
int)x >= m_size[2]) || ((
int)y >= m_size[1]) || (((
int)z + m_roi[0]) >= (m_roi[0] + m_size[0])))
1338 cv::error(cv::Exception(CV_StsAssert,
"Index out of bounds",
"", __FILE__ , __LINE__));
1341 return (*
reinterpret_cast<cv::Mat_<_Tp>*
>(m_data[z + m_roi[0]]))(y, x);
1350 template<
typename _Tp>
inline const _Tp&
at(
const unsigned int *idx)
const
1353 matIdxToNum(idx, &matNum);
1354 return (*
reinterpret_cast<const cv::Mat_<_Tp>*
>(m_data[matNum]))(idx[m_dims - 2], idx[m_dims - 1]);
1363 template<
typename _Tp>
inline _Tp&
at(
const unsigned int *idx)
1366 matIdxToNum(idx, &matNum);
1367 return (*
reinterpret_cast<cv::Mat_<_Tp>*
>(m_data[matNum]))(idx[m_dims - 2], idx[m_dims - 1]);
1381 inline uchar*
rowPtr(
const int matNum,
const int y)
1383 int matIndex = seekMat(matNum);
1384 return ((cv::Mat*)m_data[matIndex])->ptr(y);
1394 inline const uchar*
rowPtr(
const int matNum,
const int y)
const
1396 int matIndex = seekMat(matNum);
1397 return ((
const cv::Mat*)m_data[matIndex])->ptr(y);
1408 template<
typename _Tp>
inline _Tp*
rowPtr(
const int matNum,
const int y)
1410 int matIndex = seekMat(matNum);
1411 return ((cv::Mat*)m_data[matIndex])->ptr<_Tp>(y);
1422 template<
typename _Tp>
inline const _Tp*
rowPtr(
const int matNum,
const int y)
const
1424 int matIndex = seekMat(matNum);
1425 return ((
const cv::Mat*)m_data[matIndex])->ptr<_Tp>(y);
1432 DataObject splitColor(
const char* destinationColor,
const int& dtype)
const;
1433 DataObject lineCut(
const double* coordinates,
const int& len)
const;
1436 DataObject & adjustROI(
const int dtop,
const int dbottom,
const int dleft,
const int dright);
1437 DataObject & adjustROI(
const unsigned char dims,
const int *lims);
1438 RetVal locateROI(
int *wholeSizes,
int *offsets)
const;
1439 RetVal locateROI(
int *lims)
const;
1457 template<
typename _Tp>
RetVal copyFromData2D(
const _Tp* src,
const int sizeX,
const int sizeY) {
return copyFromData2DInternal((
const uchar*)src,
sizeof(_Tp), sizeX, sizeY); }
1484 template<
typename _Tp>
RetVal copyFromData2D(
const _Tp *src,
const int sizeX,
const int sizeY,
const int x0,
const int y0,
const int width,
const int height) {
return copyFromData2DInternal((
const uchar*)src,
sizeof(_Tp), sizeX, x0, y0, width, height); }
1486 template<
typename T2>
operator T2 ();
1488 template<
typename _Tp>
RetVal linspace(
const _Tp start,
const _Tp end,
const _Tp inc,
const int transposed);
1506 DATAOBJ_EXPORT DataObject
abs(
const DataObject &dObj);
1507 DATAOBJ_EXPORT DataObject
arg(
const DataObject &dObj);
1508 DATAOBJ_EXPORT DataObject
real(
const DataObject &dObj);
1509 DATAOBJ_EXPORT DataObject
imag(
const DataObject &dObj);
1511 DATAOBJ_EXPORT DataObject
makeContinuous(
const DataObject &dObj);
1528 retValue = cv::saturate_cast<_Tp>(*(
static_cast<const uint8*
>(scalar)));
1531 retValue = cv::saturate_cast<_Tp>(*(
static_cast<const int8*
>(scalar)));
1534 retValue = cv::saturate_cast<_Tp>(*(
static_cast<const uint16*
>(scalar)));
1537 retValue = cv::saturate_cast<_Tp>(*(
static_cast<const int16*
>(scalar)));
1540 retValue = cv::saturate_cast<_Tp>(*(
static_cast<const uint32*
>(scalar)));
1543 retValue = cv::saturate_cast<_Tp>(*(
static_cast<const int32*
>(scalar)));
1546 retValue = cv::saturate_cast<_Tp>(*(
static_cast<const ito::float32*
>(scalar)));
1549 retValue = cv::saturate_cast<_Tp>(*(
static_cast<const ito::float64*
>(scalar)));
1552 retValue = cv::saturate_cast<_Tp>(*(
static_cast<const ito::complex64*
>(scalar)));
1555 retValue = cv::saturate_cast<_Tp>(*(
static_cast<const ito::complex128*
>(scalar)));
1558 retValue = cv::saturate_cast<_Tp>(*(
static_cast<const ito::Rgba32*
>(scalar)));
1561 retValue = cv::saturate_cast<_Tp>(*(
static_cast<const ito::DateTime*
>(scalar)));
1564 retValue = cv::saturate_cast<_Tp>(*(
static_cast<const ito::TimeDelta*
>(scalar)));
1567 cv::error(cv::Exception(CV_StsAssert,
"Input value type unknown",
"", __FILE__, __LINE__));
1575 DATAOBJ_EXPORT std::ostream& operator << (std::ostream& out,
const DataObject& dObj);
1607 cv::error(cv::Exception(CV_StsAssert,
"Input data type unknown",
"", __FILE__, __LINE__));
1625 case cv::DataType<ito::int8>::type:
1627 case cv::DataType<ito::uint8>::type:
1629 case cv::DataType<ito::int16>::type:
1631 case cv::DataType<ito::uint16>::type:
1633 case cv::DataType<ito::int32>::type:
1635 case cv::DataType<ito::uint32>::type:
1637 case cv::DataType<ito::float32>::type:
1639 case cv::DataType<ito::float64>::type:
1641 case cv::DataType<ito::Rgba32>::type:
1643 case cv::DataType<ito::complex64>::type:
1645 case cv::DataType<ito::complex128>::type:
1647 case cv::DataType<ito::DateTime>::type:
1649 case cv::DataType<ito::TimeDelta>::type:
1674 cv::error(cv::Exception(CV_StsAssert,
"Input value type unknown",
"", __FILE__, __LINE__));
1705 cv::error(cv::Exception(CV_StsAssert,
"Input value type unknown",
"", __FILE__, __LINE__));
This is a Qt-free class for byte arrays (strings) without specific encoding information.
Definition byteArray.h:65
const char * data() const
return the pointer to the internal character array. If it is empty, the returned pointer still points...
Definition byteArray.h:144
constant iterator through data object
Definition dataobj.h:456
const DataObject * dObj
reference to the related data object
Definition dataobj.h:509
uchar * sliceStart
pointer to the first item within the current continuous slice
Definition dataobj.h:513
uchar * ptr
pointer to the current value of the iterator
Definition dataobj.h:512
bool planeContinuous
indicates whether dObj is continuously organized in each plane for faster seek operations
Definition dataobj.h:510
uchar * sliceEnd
pointer to the last item within the current continuous slice
Definition dataobj.h:514
int plane
plane index where the iterator is currently positioned
Definition dataobj.h:515
iterator through data object
Definition dataobj.h:528
dataObject contains a n-dimensional matrix
Definition dataobj.h:591
int * m_pRefCount
Definition dataobj.h:676
int getTotal() const
gets total number of elements within the data object's ROI
Definition dataobj.h:1046
int getDims(void) const
Definition dataobj.h:882
MROI m_roi
Definition dataobj.h:679
MSize getOriginalSize(void)
returns the original size-member. This is equal to getSize() if no roi is set to the dataObject.
Definition dataobj.h:1005
const cv::Mat ** get_mdata(void) const
returns constant array of pointers to cv::_Mat-matrices (planes) of the data object
Definition dataobj.h:967
char m_continuous
Definition dataobj.h:673
MSize m_size
Definition dataobj.h:680
_Tp * rowPtr(const int matNum, const int y)
returns pointer to the data in the y-th row in the 2d-matrix plane matNum
Definition dataobj.h:1408
int getSize(int index) const
gets the size of the given dimension (this is the size within the ROI)
Definition dataobj.h:989
MSize getSize(void)
returns the size-member. m_size fits to the physical organization of data in memory.
Definition dataobj.h:976
const _Tp * rowPtr(const int matNum, const int y) const
returns pointer to the data in the y-th row in the 2d-matrix plane matNum
Definition dataobj.h:1422
uchar ** m_data
Definition dataobj.h:681
char m_owndata
Definition dataobj.h:674
const _Tp & at(const unsigned int z, const unsigned int y, const unsigned int x) const
addressing method for three-dimensional data object.
Definition dataobj.h:1307
const MSize getOriginalSize(void) const
returns the original size-member. This is equal to getSize() if no roi is set to the dataObject.
Definition dataobj.h:1011
MSize m_osize
Definition dataobj.h:678
int getNumPlanes(void) const
calculates numbers of single opencv matrices which are part of the ROI which has previously been set.
Definition dataobj.h:908
char getOwnData(void) const
Definition dataobj.h:891
const _Tp & at(const unsigned int *idx) const
addressing method for n-dimensional data object.
Definition dataobj.h:1350
const MSize getSize(void) const
returns the size-member. This member does not consider the transpose flag, hence, m_size fits to the ...
Definition dataobj.h:982
cv::Mat ** get_mdata(void)
returns array of pointers to cv::_Mat-matrices (planes) of the data object.
Definition dataobj.h:952
_Tp & at(const unsigned int z, const unsigned int y, const unsigned int x)
addressing method for three-dimensional data object.
Definition dataobj.h:1329
int getType(void) const
Definition dataobj.h:885
RetVal copyFromData2D(const _Tp *src, const int sizeX, const int sizeY, const int x0, const int y0, const int width, const int height)
copies the externally given source data inside this data object
Definition dataobj.h:1484
int getOriginalSize(int index) const
gets the original size of the given dimension (this is the size without considering any ROI)
Definition dataobj.h:1018
_Tp & at(const unsigned int y, const unsigned int x)
addressing method for two-dimensional data object.
Definition dataobj.h:1285
char getContinuous(void) const
Definition dataobj.h:888
uchar * rowPtr(const int matNum, const int y)
returns pointer to the data in the y-th row in the 2d-matrix plane matNum
Definition dataobj.h:1381
_Tp & at(const unsigned int *idx)
addressing method for n-dimensional data object.
Definition dataobj.h:1363
DataObjectTagsPrivate * m_pDataObjectTags
Definition dataobj.h:682
int m_type
Definition dataobj.h:675
int getOriginalTotal() const
gets total number of elements of the whole data object
Definition dataobj.h:1063
int m_dims
Definition dataobj.h:677
const uchar * rowPtr(const int matNum, const int y) const
returns pointer to the data in the y-th row in the 2d-matrix plane matNum
Definition dataobj.h:1394
RetVal copyFromData2D(const _Tp *src, const int sizeX, const int sizeY)
copies the externally given source data inside this data object
Definition dataobj.h:1457
const _Tp & at(const unsigned int y, const unsigned int x) const
addressing method for two-dimensional data object.
Definition dataobj.h:1264
Variant storage class for either a double or a string value.
Definition dataobj.h:352
tTagType m_type
type indicator of this class (invalid, double or string)
Definition dataobj.h:363
DataObjectTagType(const char *cVal)
Copy Constructor.
Definition dataobj.h:372
int getType(void) const
returns type of tag (
Definition dataobj.h:387
DataObjectTagType()
< Constructor
Definition dataobj.h:368
ByteArray getVal_ToString(void)
Definition dataobj.h:420
ByteArray m_strValue
if the tag type is string, the string data is stored in this ByteArray variable.
Definition dataobj.h:364
tTagType
Definition dataobj.h:355
double getVal_ToDouble(void)
Definition dataobj.h:397
double m_dVal
if the tag type is double, the real double value is stored here
Definition dataobj.h:362
bool isValid(void) const
returns if tag is valid (double or string) or invalid (e.g. due to use of default constructor)
Definition dataobj.h:390
Definition typeDefs.h:161
each range value has a start and end point. Optionally range can be marked as Range::all(),...
Definition dataobj.h:332
int start
Definition dataobj.h:340
bool empty() const
Definition dataobj.h:337
int end
Definition dataobj.h:341
Range()
Definition dataobj.h:334
unsigned int size() const
Definition dataobj.h:336
static Range all()
Definition dataobj.h:338
Range(int _start, int _end)
Definition dataobj.h:335
Class for managing status values (like errors or warning)
Definition retVal.h:54
This class implements basic functionality for color handling in itom. \detail This class implements A...
Definition color.h:47
uint32 & argb()
Definition color.h:250
float32 gray() const
Definition color.h:235
static Rgba32 fromUnsignedLong(const uint32 val)
static constructor to create Rgba32 from uint32 containing the values argb
Definition color.h:82
Definition typeDefs.h:218
Definition apiFunctionsGraph.cpp:40
ito::tDataType getDataType2()
method which returns the value of enumeration ito::tDataType, which corresponds to the template param...
Definition dataobj.h:1703
DataObject arg(const DataObject &dObj)
Definition dataobj.cpp:12926
RetVal CopyToFunc(const DataObject &lhs, DataObject &rhs, unsigned char regionOnly)
low-level, templated method for deeply copying the data of one matrix to another given matrix
Definition dataobj.cpp:2905
RetVal GetRangeFunc(DataObject *dObj, const int dtop, const int dbottom, const int dleft, const int dright)
Definition dataobj.cpp:9093
ito::tDataType guessDataTypeFromCVMat(const cv::Mat *mat, ito::RetVal &retval)
method which guesses the dataObject type from a given cv::Mat*
Definition dataobj.h:1619
RetVal CreateFunc(DataObject *dObj, const unsigned char dimensions, const int *sizes, const unsigned char continuous, const uchar *continuousDataPtr, const int *steps)
templated method for create
Definition dataobj.cpp:1879
_Tp numberConversion(ito::tDataType fromType, const void *scalar)
templated method for converting a given scalar value to the data type, indicated by the template para...
Definition dataobj.h:1521
ito::tDataType getDataType(const _Tp *)
method which returns the value of enumeration ito::tDataType, which corresponds to the type of the gi...
Definition dataobj.h:1672
DataObject imag(const DataObject &dObj)
Definition dataobj.cpp:13456
RetVal AssignScalarFunc(DataObject *src, const ito::tDataType type, const void *scalar)
Definition dataobj.cpp:4524
RetVal FreeFunc(DataObject *dObj)
low-level, templated method for freeing allocated data blocks
Definition dataobj.cpp:828
ito::tDataType convertCmplxTypeToRealType(ito::tDataType cmplxType)
method which returns the real data type of any given data type
Definition dataobj.h:1585
RetVal ConvertToFunc(const DataObject &lhs, DataObject &rhs, const int dest_type, const double alpha, const double beta)
converts data in DataObject lhs to DataObject rhs with a given type
Definition dataobj.cpp:12120
RetVal AdjustROIFunc(DataObject *dObj, int dtop, int dbottom, int dleft, int dright)
Definition dataobj.cpp:9262
RetVal MakeContinuousFunc(const DataObject &dObj, DataObject &resDObj)
Definition dataobj.cpp:13492
tDataType
Definition typeDefs.h:88
@ tTimeDelta
Definition typeDefs.h:101
@ tInt16
Definition typeDefs.h:91
@ tFloat32
Definition typeDefs.h:95
@ tInt8
Definition typeDefs.h:89
@ tComplex128
Definition typeDefs.h:98
@ tInt32
Definition typeDefs.h:93
@ tUInt16
Definition typeDefs.h:92
@ tFloat64
Definition typeDefs.h:96
@ tComplex64
Definition typeDefs.h:97
@ tRGBA32
Definition typeDefs.h:99
@ tDateTime
Definition typeDefs.h:100
@ tUInt8
Definition typeDefs.h:90
@ tUInt32
Definition typeDefs.h:94
DataObject real(const DataObject &dObj)
Definition dataobj.cpp:13020
DataObject makeContinuous(const DataObject &dObj)
Definition dataobj.cpp:13623
@ retError
Definition typeDefs.h:60
DataObject abs(const DataObject &dObj)
Definition dataobj.cpp:12796
RetVal CreateFuncWithCVPlanes(DataObject *dObj, const unsigned char dimensions, const int *sizes, const cv::Mat *planes, const unsigned int nrOfPlanes)
templated method for creation with given vector of cv::Mat-planes
Definition dataobj.cpp:2152