40 #pragma warning(disable:4996) 43 #define NOMINMAX //see: http://social.msdn.microsoft.com/Forums/sv/vclanguage/thread/d986a370-d856-4f9e-9f14-53f3b18ab63e, this is only an issue with OpenCV 2.4.3, not 2.3.x 45 #include "opencv/cv.h" 46 #include "opencv2/core/core.hpp" 48 #include "../common/sharedStructures.h" 49 #include "../common/color.h" 50 #include "../common/byteArray.h" 55 template<>
inline ito::float32 saturate_cast<ito::float32>( ito::float64 v)
57 if(cvIsInf(v))
return std::numeric_limits<ito::float32>::infinity();
58 if(cvIsNaN(v))
return std::numeric_limits<ito::float32>::quiet_NaN();
59 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() )));
62 template<>
inline ito::float64 saturate_cast<ito::float64>( ito::float32 v)
64 if(cvIsInf(v))
return std::numeric_limits<ito::float64>::infinity();
65 if(cvIsNaN(v))
return std::numeric_limits<ito::float64>::quiet_NaN();
66 return static_cast<ito::float64
>(v);
69 template<
typename _Tp>
static inline _Tp saturate_cast(ito::complex128 ) { cv::error(cv::Exception(CV_StsAssert,
"Not defined for input parameter type",
"", __FILE__, __LINE__));
return 0; }
70 template<
typename _Tp>
static inline _Tp saturate_cast(ito::complex64 ) { cv::error(cv::Exception(CV_StsAssert,
"Not defined for input parameter type",
"", __FILE__, __LINE__));
return 0; }
72 template<
typename _Tp>
static inline _Tp saturate_cast(
ito::Rgba32 ) { cv::error(cv::Exception(CV_StsAssert,
"Not defined for input parameter type",
"", __FILE__, __LINE__));
return 0; }
75 template<>
inline ito::complex64 saturate_cast(ito::uint8 v){
return ito::complex64(static_cast<ito::float32>(v),0.0); }
76 template<>
inline ito::complex64 saturate_cast(ito::int8 v){
return ito::complex64(static_cast<ito::float32>(v),0.0); }
77 template<>
inline ito::complex64 saturate_cast(ito::uint16 v){
return ito::complex64(static_cast<ito::float32>(v),0.0); }
78 template<>
inline ito::complex64 saturate_cast(ito::int16 v){
return ito::complex64(static_cast<ito::float32>(v),0.0); }
79 template<>
inline ito::complex64 saturate_cast(ito::uint32 v){
return ito::complex64(static_cast<ito::float32>(v),0.0); }
80 template<>
inline ito::complex64 saturate_cast(ito::int32 v){
return ito::complex64(static_cast<ito::float32>(v),0.0); }
81 template<>
inline ito::complex64 saturate_cast(ito::float32 v){
return ito::complex64(v,0.0); }
82 template<>
inline ito::complex64 saturate_cast(ito::float64 v){
return ito::complex64(saturate_cast<ito::float32>(v),0.0); }
83 template<>
inline ito::complex64 saturate_cast(ito::complex64 v){
return v; }
84 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())); }
86 template<>
inline ito::complex128 saturate_cast(ito::uint8 v){
return ito::complex128(static_cast<ito::float64>(v),0.0); }
87 template<>
inline ito::complex128 saturate_cast(ito::int8 v){
return ito::complex128(static_cast<ito::float64>(v),0.0); }
88 template<>
inline ito::complex128 saturate_cast(ito::uint16 v){
return ito::complex128(static_cast<ito::float64>(v),0.0); }
89 template<>
inline ito::complex128 saturate_cast(ito::int16 v){
return ito::complex128(static_cast<ito::float64>(v),0.0); }
90 template<>
inline ito::complex128 saturate_cast(ito::uint32 v){
return ito::complex128(static_cast<ito::float64>(v),0.0); }
91 template<>
inline ito::complex128 saturate_cast(ito::int32 v){
return ito::complex128(static_cast<ito::float64>(v),0.0); }
92 template<>
inline ito::complex128 saturate_cast(ito::float32 v){
return ito::complex128(saturate_cast<ito::float64>(v),0.0); }
93 template<>
inline ito::complex128 saturate_cast(ito::float64 v){
return ito::complex128(v,0.0); }
94 template<>
inline ito::complex128 saturate_cast(ito::complex64 v){
return ito::complex128(saturate_cast<ito::float64>(v.real()),saturate_cast<ito::float64>(v.imag())); }
95 template<>
inline ito::complex128 saturate_cast(ito::complex128 v){
return v; }
99 template<>
inline ito::Rgba32 saturate_cast(ito::uint16 v){
return ito::Rgba32(saturate_cast<ito::uint8>(v));}
101 template<>
inline ito::Rgba32 saturate_cast(ito::uint32 v)
105 template<>
inline ito::Rgba32 saturate_cast(ito::int32 v)
108 temp.rgba =
static_cast<ito::uint32
>(v);
111 template<>
inline ito::Rgba32 saturate_cast(ito::float32 v){
return ito::Rgba32(saturate_cast<ito::uint8>(v));}
112 template<>
inline ito::Rgba32 saturate_cast(ito::float64 v){
return ito::Rgba32(saturate_cast<ito::uint8>(v));}
115 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(); }
116 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(); }
117 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(); }
118 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(); }
120 template<>
inline ito::uint8 saturate_cast(
ito::Rgba32 v){
return saturate_cast<ito::uint8>(v.
gray());};
122 template<>
inline ito::uint16 saturate_cast(
ito::Rgba32 v){
return saturate_cast<ito::uint16>(v.
gray());};
123 template<>
inline ito::uint32 saturate_cast(
ito::Rgba32 v){
return v.
argb();};
124 template<>
inline ito::int32 saturate_cast(
ito::Rgba32 v){
return (ito::int32)(v.
argb());};
125 template<>
inline ito::float32 saturate_cast(
ito::Rgba32 v){
return v.
gray();};
126 template<>
inline ito::float64 saturate_cast(
ito::Rgba32 v){
return (ito::float64)v.
gray();};
129 template<>
class DataType<
ito::Rgba32>
133 typedef ito::uint8 channel_type;
134 typedef Vec<channel_type, 4> work_type;
139 depth = cv::DataDepth<channel_type>::value,
141 fmt = ((channels-1)<<8) + cv::DataDepth<channel_type>::fmt,
142 type = CV_MAKETYPE(depth, channels)
146 template<>
class DataType<
ito::RedChannel>
150 typedef ito::uint8 channel_type;
151 typedef Vec<channel_type, 4> work_type;
156 depth = cv::DataDepth<channel_type>::value,
158 fmt = ((channels-1)<<8) + cv::DataDepth<channel_type>::fmt,
159 type = CV_MAKETYPE(depth, channels)
163 template<>
class DataType<
ito::GreenChannel>
167 typedef ito::uint8 channel_type;
168 typedef Vec<channel_type, 4> work_type;
173 depth = cv::DataDepth<channel_type>::value,
175 fmt = ((channels-1)<<8) + cv::DataDepth<channel_type>::fmt,
176 type = CV_MAKETYPE(depth, channels)
180 template<>
class DataType<
ito::BlueChannel>
184 typedef ito::uint8 channel_type;
185 typedef Vec<channel_type, 4> work_type;
190 depth = cv::DataDepth<channel_type>::value,
192 fmt = ((channels-1)<<8) + cv::DataDepth<channel_type>::fmt,
193 type = CV_MAKETYPE(depth, channels)
197 template<>
class DataType<
ito::AlphaChannel>
201 typedef ito::uint8 channel_type;
202 typedef Vec<channel_type, 4> work_type;
207 depth = cv::DataDepth<channel_type>::value,
209 fmt = ((channels-1)<<8) + cv::DataDepth<channel_type>::fmt,
210 type = CV_MAKETYPE(depth, channels)
225 class DataObjectTags;
226 class DataObjectTagType;
227 class DataObjectTagsPrivate;
241 Range(
int _start,
int _end) { _start < _end ? (end = _end, start = _start) : (start = _end, end = _start); }
242 inline unsigned int size()
const {
return end - start; }
243 inline bool empty()
const {
return (start == end); }
262 typeInvalid = 0x000000,
263 typeDouble = 0x000008,
264 typeString = 0x000020
275 DataObjectTagType(
double dVal) : m_dVal(dVal), m_strValue(
""), m_type(DataObjectTagType::typeDouble){}
276 DataObjectTagType(
const std::string &str) : m_dVal(std::numeric_limits<double>::quiet_NaN()), m_type(DataObjectTagType::typeString){ m_strValue = str.
data(); }
277 DataObjectTagType(
const ByteArray &str) : m_dVal(std::numeric_limits<double>::quiet_NaN()), m_type(DataObjectTagType::typeString){ m_strValue = str; }
285 this->m_dVal = rhs.
m_dVal;
287 this->m_type = rhs.
m_type;
293 inline int getType(
void)
const {
return m_type;}
296 inline bool isValid(
void)
const {
return (m_type == DataObjectTagType::typeInvalid) ?
false:
true;}
305 if(m_type == DataObjectTagType::typeInvalid)
307 return std::numeric_limits<double>::quiet_NaN();
309 else if(m_type == DataObjectTagType::typeDouble)
315 double dVal = std::numeric_limits<double>::quiet_NaN();
328 if(m_type == DataObjectTagType::typeInvalid)
332 else if(m_type == DataObjectTagType::typeString)
338 if (cvIsNaN(m_dVal))
return "NaN";
339 if (cvIsInf(m_dVal))
return "Inf";
341 std::ostringstream strs;
378 const uchar* operator *()
const;
381 const uchar* operator [](
int i)
const;
410 void seekAbs(
int ofs);
413 void seekRel(
int ofs);
453 uchar* operator [](
int i);
478 template<
typename _Tp>
RetVal CreateFunc(
DataObject *dObj,
const unsigned char dimensions,
const int *sizes,
const unsigned char continuous,
const uchar* continuousDataPtr,
const int* steps);
485 template<
typename _Tp>
RetVal MinMaxLocFunc(
const DataObject &dObj,
double *minVal,
double *maxVal,
int *minPos,
int *maxPos);
489 template<
typename _Tp> std::ostream& coutFunc(std::ostream& out,
const DataObject& dObj);
493 template<
typename _Tp>
RetVal AdjustROIFunc(
DataObject *dObj,
int dtop,
int dbottom,
int dleft,
int dright);
500 void createHeader(
const unsigned char dimensions,
const int *sizes,
const int *steps,
const int elemSize);
503 void createHeaderWithROI(
const unsigned char dimensions,
const int *sizes,
const int *osizes = NULL,
const int *roi = NULL);
505 void create(
const unsigned char dimensions,
const int *sizes,
const int type,
const unsigned char continuous,
const uchar* continuousDataPtr = NULL,
const int* steps = NULL);
506 void create(
const unsigned char dimensions,
const int *sizes,
const int type,
const cv::Mat* planes,
const unsigned int nrOfPlanes);
509 void secureFreeData(
void);
513 ito::RetVal matNumToIdx(
const int matNum,
int *matIdx)
const;
516 ito::RetVal matIdxToNum(
const unsigned int *matIdx,
int *matNum)
const;
521 inline MSize() : m_p(NULL) {}
522 inline int operator [] (
const int dim)
const 526 inline operator const int * ()
const {
return m_p; }
527 inline bool operator == (
const MSize& sz)
const 529 if(m_p == NULL || sz.m_p == NULL)
531 return sz.m_p == m_p;
535 if( d != sz.m_p[-1] )
538 return (memcmp(m_p, sz.m_p, d *
sizeof(
int)) == 0);
541 inline bool operator != (
const MSize& sz)
const {
return !(*
this == sz); }
549 inline MROI() : m_p(NULL) {};
550 inline int operator [] (
const int dim)
const 555 inline bool operator == (
const MROI & rroi)
const 557 if(m_p == NULL || rroi.m_p == NULL)
559 return rroi.m_p == m_p;
563 if( d != rroi.m_p[-1] )
566 return (memcmp(m_p, rroi.m_p, d *
sizeof(
int)) == 0);
568 if (m_p[-1] != rroi.m_p[-1])
589 static const int m_sizeofs;
591 int mdata_realloc(
const int size);
592 int mdata_size(
void)
const;
595 RetVal copyFromData2DInternal(
const uchar* src,
const int sizeOfElem,
const int sizeX,
const int sizeY);
596 RetVal copyFromData2DInternal(
const uchar* src,
const int sizeOfElem,
const int sizeX,
const int x0,
const int y0,
const int width,
const int height);
600 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);
601 template<
typename _Tp>
friend RetVal CreateFuncWithCVPlanes(
DataObject *dObj,
const unsigned char dimensions,
const int *sizes,
const cv::Mat* planes,
const unsigned int nrOfPlanes);
605 template<
typename _Tp>
friend RetVal ConvertToFunc(
const DataObject &lhs,
DataObject &rhs,
const int type,
const double alpha,
const double beta);
606 template<
typename _Tp>
friend RetVal AdjustROIFunc(
DataObject *dObj,
const int *lims);
607 template<
typename _Tp>
friend RetVal MinMaxLocFunc(
const DataObject &dObj,
double *minVal,
double *maxVal,
int *minPos,
int *maxPos);
610 template<
typename _Tp>
friend RetVal EvaluateTransposeFlagFunc(
DataObject *dObj);
611 template<
typename _Tp>
friend std::ostream& coutFunc(std::ostream& out,
const DataObject& dObj);
614 template<
typename _Tp>
friend RetVal GetRangeFunc(
DataObject *dObj,
const int dtop,
const int dbottom,
const int dleft,
const int dright);
615 template<
typename _Tp>
friend RetVal AdjustROIFunc(
DataObject *dObj,
int dtop,
int dbottom,
int dleft,
int dright);
625 DataObject(
const int sizeY,
const int sizeX,
const int type);
628 DataObject(
const int sizeZ,
const int sizeY,
const int sizeX,
const int type,
const unsigned char continuous = 0);
631 DataObject(
const int sizeZ,
const int sizeY,
const int sizeX,
const int type,
const uchar* continuousDataPtr,
const int* steps = NULL);
634 DataObject(
const MSize &sizes,
const int type,
const unsigned char continuous = 0);
637 DataObject(
const unsigned char dimensions,
const int *sizes,
const int type,
const unsigned char continuous = 0);
640 DataObject(
const unsigned char dimensions,
const int *sizes,
const int type,
const uchar* continuousDataPtr,
const int* steps = NULL);
643 DataObject(
const unsigned char dimensions,
const int *sizes,
const int type,
const cv::Mat* planes,
const unsigned int nrOfPlanes);
656 double getValueOffset()
const;
659 double getValueScale()
const;
662 const std::string getValueUnit()
const;
665 std::string getValueDescription()
const;
668 double getAxisOffset(
const int axisNum)
const;
671 double getAxisScale(
const int axisNum)
const;
674 const std::string getAxisUnit(
const int axisNum,
bool &validOperation)
const;
677 std::string getAxisDescription(
const int axisNum,
bool &validOperation)
const;
681 bool getTagByIndex(
const int tagNumber, std::string &key,
DataObjectTagType &value)
const;
684 std::string getTagKey(
const int tagNumber,
bool &validOperation)
const;
687 int getTagListSize()
const;
690 int setValueUnit(
const std::string &unit);
693 int setValueDescription(
const std::string &description);
696 int setAxisOffset(
const unsigned int axisNum,
const double offset);
699 int setAxisScale(
const unsigned int axisNum,
const double scale);
702 int setAxisUnit(
const unsigned int axisNum,
const std::string &unit);
705 int setAxisDescription(
const unsigned int axisNum,
const std::string &description);
707 bool existTag(
const std::string &key)
const;
708 bool deleteTag(
const std::string &key);
709 bool deleteAllTags();
710 int addToProtocol(
const std::string &value);
716 double getPhysToPix(
const unsigned int dim,
const double phys,
bool &isInsideImage)
const;
721 double getPhysToPix(
const unsigned int dim,
const double phys)
const;
726 int getPhysToPix2D(
const double physY,
double &tPxY,
bool &isInsideImageY,
const double physX,
double &tPxX,
bool &isInsideImageX)
const;
731 double getPixToPhys(
const unsigned int dim,
const double pix,
bool &isInsideImage)
const;
736 double getPixToPhys(
const unsigned int dim,
const double pix)
const;
751 RetVal setXYRotationalMatrix(
double r11,
double r12,
double r13,
double r21,
double r22,
double r23,
double r31,
double r32,
double r33);
766 RetVal getXYRotationalMatrix(
double &r11,
double &r12,
double &r13,
double &r21,
double &r22,
double &r23,
double &r31,
double &r32,
double &r33)
const;
774 inline int getDims(
void)
const {
return m_dims; }
777 inline int getType(
void)
const {
return m_type; }
786 int seekMat(
const int matNum,
const int numMats)
const;
789 int seekMat(
const int matNum)
const;
792 int calcNumMats(
void)
const;
812 return m_size[0] * m_size[1];
816 for (
int n = 0; n < m_dims - 2; n++)
826 cv::Mat* getCvPlaneMat(
const int planeIndex);
829 const cv::Mat* getCvPlaneMat(
const int planeIndex)
const;
832 const cv::Mat getContinuousCvPlaneMat(
const int planeIndex)
const;
846 return (cv::Mat**)m_data;
861 return (
const cv::Mat**)m_data;
883 if(index < 0 || index >= m_dims)
889 return m_size[index];
912 if(index < 0 || index >= m_dims)
918 return m_osize[index];
930 int getStep(
int index)
const;
940 int dims = getDims();
941 int total = dims > 0 ? 1 : 0;
942 for(
int i = 0 ; i < dims ; i++)
957 int dims = getDims();
958 int total = dims > 0 ? 1 : 0;
959 for(
int i = 0 ; i<dims ; i++)
967 RetVal convertTo(
DataObject &rhs,
const int type,
const double alpha=1,
const double beta=0 )
const;
1000 DataObject & operator = (
const int16 &value);
1001 DataObject & operator = (
const uint16 &value);
1002 DataObject & operator = (
const int32 &value);
1003 DataObject & operator = (
const uint32 &value);
1004 DataObject & operator = (
const float32 &value);
1005 DataObject & operator = (
const float64 &value);
1006 DataObject & operator = (
const complex64 &value);
1007 DataObject & operator = (
const complex128 &value);
1012 DataObject & operator += (
const float64 &value);
1013 DataObject & operator += (
const complex128 &value);
1016 DataObject operator + (
const float64 &value);
1017 DataObject operator + (
const complex128 &value);
1020 DataObject & operator -= (
const float64 &value);
1021 DataObject & operator -= (
const complex128 &value);
1024 DataObject operator - (
const float64 &value);
1025 DataObject operator - (
const complex128 &value);
1028 DataObject & operator *= (
const float64 &factor);
1029 DataObject & operator *= (
const complex128 &factor);
1032 DataObject operator * (
const float64 &factor);
1033 DataObject operator * (
const complex128 &factor);
1043 DataObject operator < (
const float64 &value);
1044 DataObject operator > (
const float64 &value);
1045 DataObject operator <= (
const float64 &value);
1046 DataObject operator >= (
const float64 &value);
1047 DataObject operator == (
const float64 &value);
1048 DataObject operator != (
const float64 &value);
1051 DataObject operator << (
const unsigned int shiftbit);
1052 DataObject & operator <<= (
const unsigned int shiftbit);
1053 DataObject operator >> (
const unsigned int shiftbit);
1054 DataObject & operator >>= (
const unsigned int shiftbit);
1066 RetVal zeros(
const int type);
1067 RetVal zeros(
const int size,
const int type);
1068 RetVal zeros(
const int sizeY,
const int sizeX,
const int type);
1069 RetVal zeros(
const int sizeZ,
const int sizeY,
const int sizeX,
const int type,
const unsigned char continuous = 0);
1070 RetVal zeros(
const unsigned char dimensions,
const int *sizes,
const int type,
const unsigned char continuous = 0);
1073 RetVal ones(
const int type);
1074 RetVal ones(
const int size,
const int type);
1075 RetVal ones(
const int sizeY,
const int sizeX,
const int type);
1076 RetVal ones(
const int sizeZ,
const int sizeY,
const int sizeX,
const int type,
const unsigned char continuous = 0);
1077 RetVal ones(
const unsigned char dimensions,
const int *sizes,
const int type,
const unsigned char continuous = 0);
1080 RetVal rand(
const int type,
const bool randMode =
false);
1081 RetVal rand(
const int size,
const int type,
const bool randMode =
false);
1082 RetVal rand(
const int sizeY,
const int sizeX,
const int type,
const bool randMode =
false);
1083 RetVal rand(
const int sizeZ,
const int sizeY,
const int sizeX,
const int type,
const bool randMode,
const unsigned char continuous = 0);
1084 RetVal rand(
const unsigned char dimensions,
const int *sizes,
const int type,
const bool randMode,
const unsigned char continuous = 0);
1087 RetVal eye(
const int type);
1088 RetVal eye(
const int size,
const int type);
1102 void pow(
const ito::float64 &power,
DataObject &dst);
1108 DataObject reshape(
int newDims,
const int *newSizes)
const;
1110 int elemSize()
const;
1118 template<
typename _Tp>
inline const _Tp&
at(
const unsigned int y,
const unsigned int x)
const 1123 cv::error(cv::Exception(CV_StsAssert,
"Dimension mismatch while addressing data field",
"", __FILE__, __LINE__));
1125 else if (((
int)x >= m_size[1]) || ((
int)y >= m_size[0]) )
1127 cv::error(cv::Exception(CV_StsAssert,
"Index out of bounds",
"", __FILE__ , __LINE__));
1130 return (*
reinterpret_cast<const cv::Mat_<_Tp>*
>(m_data[0]))(y, x);
1139 template<
typename _Tp>
inline _Tp&
at(
const unsigned int y,
const unsigned int x)
1144 cv::error(cv::Exception(CV_StsAssert,
"Dimension mismatch while addressing data field",
"", __FILE__, __LINE__));
1146 else if (((
int)x >= m_size[1]) || ((
int)y >= m_size[0]) )
1148 cv::error(cv::Exception(CV_StsAssert,
"Index out of bounds",
"", __FILE__ , __LINE__));
1151 return (*
reinterpret_cast<cv::Mat_<_Tp>*
>(m_data[0]))(y, x);
1161 template<
typename _Tp>
inline const _Tp&
at(
const unsigned int z,
const unsigned int y,
const unsigned int x)
const 1166 cv::error(cv::Exception(CV_StsAssert,
"Dimension mismatch while addressing data field",
"", __FILE__, __LINE__));
1168 else if (((
int)x >= m_size[2]) || ((
int)y >= m_size[1]) || (((
int)z + m_roi[0]) >= (m_roi[0] + m_size[0])))
1170 cv::error(cv::Exception(CV_StsAssert,
"Index out of bounds",
"", __FILE__ , __LINE__));
1173 return (*
reinterpret_cast<const cv::Mat_<_Tp>*
>(m_data[z + m_roi[0]]))(y, x);
1183 template<
typename _Tp>
inline _Tp&
at(
const unsigned int z,
const unsigned int y,
const unsigned int x)
1188 cv::error(cv::Exception(CV_StsAssert,
"Dimension mismatch while addressing data field",
"", __FILE__, __LINE__));
1190 else if (((
int)x >= m_size[2]) || ((
int)y >= m_size[1]) || (((
int)z + m_roi[0]) >= (m_roi[0] + m_size[0])))
1192 cv::error(cv::Exception(CV_StsAssert,
"Index out of bounds",
"", __FILE__ , __LINE__));
1195 return (*
reinterpret_cast<cv::Mat_<_Tp>*
>(m_data[z + m_roi[0]]))(y, x);
1204 template<
typename _Tp>
inline const _Tp&
at(
const unsigned int *idx)
const 1207 matIdxToNum(idx, &matNum);
1208 return (*
reinterpret_cast<const cv::Mat_<_Tp>*
>(m_data[matNum]))(idx[m_dims - 2], idx[m_dims - 1]);
1217 template<
typename _Tp>
inline _Tp&
at(
const unsigned int *idx)
1220 matIdxToNum(idx, &matNum);
1221 return (*
reinterpret_cast<cv::Mat_<_Tp>*
>(m_data[matNum]))(idx[m_dims - 2], idx[m_dims - 1]);
1235 inline uchar*
rowPtr(
const int matNum,
const int y)
1237 int matIndex = seekMat(matNum);
1238 return ((cv::Mat*)m_data[matIndex])->ptr(y);
1248 inline const uchar*
rowPtr(
const int matNum,
const int y)
const 1250 int matIndex = seekMat(matNum);
1251 return ((
const cv::Mat*)m_data[matIndex])->ptr(y);
1262 template<
typename _Tp>
inline _Tp*
rowPtr(
const int matNum,
const int y)
1264 int matIndex = seekMat(matNum);
1265 return ((cv::Mat*)m_data[matIndex])->ptr<_Tp>(y);
1276 template<
typename _Tp>
inline const _Tp*
rowPtr(
const int matNum,
const int y)
const 1278 int matIndex = seekMat(matNum);
1279 return ((
const cv::Mat*)m_data[matIndex])->ptr<_Tp>(y);
1286 DataObject splitColor(
const char* destinationColor,
const int& dtype)
const;
1289 DataObject & adjustROI(
const int dtop,
const int dbottom,
const int dleft,
const int dright);
1290 DataObject & adjustROI(
const unsigned char dims,
const int *lims);
1291 RetVal locateROI(
int *wholeSizes,
int *offsets)
const;
1292 RetVal locateROI(
int *lims)
const;
1310 template<
typename _Tp>
RetVal copyFromData2D(
const _Tp* src,
const int sizeX,
const int sizeY) {
return copyFromData2DInternal((
const uchar*)src,
sizeof(_Tp), sizeX, sizeY); }
1337 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); }
1339 template<
typename T2>
operator T2 ();
1341 template<
typename _Tp>
RetVal linspace(
const _Tp start,
const _Tp end,
const _Tp inc,
const int transposed);
1381 retValue = cv::saturate_cast<_Tp>(*(
static_cast<const uint8*
>(scalar)));
1384 retValue = cv::saturate_cast<_Tp>(*(
static_cast<const int8*
>(scalar)));
1387 retValue = cv::saturate_cast<_Tp>(*(
static_cast<const uint16*
>(scalar)));
1390 retValue = cv::saturate_cast<_Tp>(*(
static_cast<const int16*
>(scalar)));
1393 retValue = cv::saturate_cast<_Tp>(*(
static_cast<const uint32*
>(scalar)));
1396 retValue = cv::saturate_cast<_Tp>(*(
static_cast<const int32*
>(scalar)));
1399 retValue = cv::saturate_cast<_Tp>(*(
static_cast<const ito::float32*
>(scalar)));
1402 retValue = cv::saturate_cast<_Tp>(*(
static_cast<const ito::float64*
>(scalar)));
1405 retValue = cv::saturate_cast<_Tp>(*(
static_cast<const ito::complex64*
>(scalar)));
1408 retValue = cv::saturate_cast<_Tp>(*(
static_cast<const ito::complex128*
>(scalar)));
1411 retValue = cv::saturate_cast<_Tp>(*(
static_cast<const ito::Rgba32*
>(scalar)));
1414 cv::error(cv::Exception(CV_StsAssert,
"Input value type unkown",
"", __FILE__, __LINE__));
1422 DATAOBJ_EXPORT std::ostream& operator << (std::ostream& out,
const DataObject& dObj);
1452 cv::error(cv::Exception(CV_StsAssert,
"Input data type unknown",
"", __FILE__, __LINE__));
1470 case cv::DataType<ito::int8>::type:
1472 case cv::DataType<ito::uint8>::type:
1474 case cv::DataType<ito::int16>::type:
1476 case cv::DataType<ito::uint16>::type:
1478 case cv::DataType<ito::int32>::type:
1480 case cv::DataType<ito::uint32>::type:
1482 case cv::DataType<ito::float32>::type:
1484 case cv::DataType<ito::float64>::type:
1486 case cv::DataType<ito::Rgba32>::type:
1488 case cv::DataType<ito::complex64>::type:
1490 case cv::DataType<ito::complex128>::type:
1515 cv::error(cv::Exception(CV_StsAssert,
"Input value type unkown",
"", __FILE__, __LINE__));
1544 cv::error(cv::Exception(CV_StsAssert,
"Input value type unkown",
"", __FILE__, __LINE__));
int getType(void) const
returns type of tag (
Definition: dataobj.h:293
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:296
double m_dVal
if the tag type is double, the real double value is stored here
Definition: dataobj.h:268
_Tp & at(const unsigned int z, const unsigned int y, const unsigned int x)
addressing method for three-dimensional data object.
Definition: dataobj.h:1183
iterator through data object
Definition: dataobj.h:433
dataObject contains a n-dimensional matrix
Definition: dataobj.h:496
Range(int _start, int _end)
Definition: dataobj.h:241
Definition: typeDefs.h:89
MSize getSize(void)
returns the size-member. m_size fits to the physical organization of data in memory.
Definition: dataobj.h:868
DataObject arg(const DataObject &dObj)
high-level value which calculates the argument value of each element of the input source data object ...
Definition: dataobj.cpp:8901
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:2377
MSize m_osize
Definition: dataobj.h:584
int start
Definition: dataobj.h:246
ByteArray m_strValue
if the tag type is string, the string data is stored in this ByteArray variable.
Definition: dataobj.h:270
_Tp & at(const unsigned int y, const unsigned int x)
addressing method for two-dimensional data object.
Definition: dataobj.h:1139
tTagType
Definition: dataobj.h:260
RetVal AssignScalarFunc(DataObject *src, const ito::tDataType type, const void *scalar)
low-level, templated helper method to assign the given scalar to every element within its ROI in Data...
Definition: dataobj.cpp:3556
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:1513
Definition: dataobj.h:519
Definition: typeDefs.h:81
Definition: typeDefs.h:60
const DataObject * dObj
reference to the related data object
Definition: dataobj.h:415
Definition: typeDefs.h:86
MROI m_roi
Definition: dataobj.h:585
uchar * ptr
pointer to the current value of the iterator
Definition: dataobj.h:418
Class for managing status values (like errors or warning)
Definition: retVal.h:54
unsigned int size() const
Definition: dataobj.h:242
Definition: typeDefs.h:88
Definition: typeDefs.h:87
DataObjectTagsPrivate * m_pDataObjectTags
Definition: dataobj.h:588
_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:1262
int getType(void) const
Definition: dataobj.h:777
const _Tp & at(const unsigned int y, const unsigned int x) const
addressing method for two-dimensional data object.
Definition: dataobj.h:1118
uchar * sliceEnd
pointer to the last item within the current continuous slice
Definition: dataobj.h:420
Definition: typeDefs.h:84
uint32 & argb()
Definition: color.h:250
const cv::Mat ** get_mdata(void) const
returns constant array of pointers to cv::_Mat-matrices (planes) of the data object ...
Definition: dataobj.h:859
bool empty() const
Definition: dataobj.h:243
This is a Qt-free class for byte arrays (strings) without specific encoding information.
Definition: byteArray.h:69
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:1161
RetVal MakeContinuousFunc(const DataObject &dObj, DataObject &resDObj)
low-level, templated method which copies an incontinuously organized data object to a continuously or...
Definition: dataobj.cpp:9095
Definition: typeDefs.h:79
DataObjectTagType(const char *cVal)
Copy Constructor.
Definition: dataobj.h:278
_Tp & at(const unsigned int *idx)
addressing method for n-dimensional data object.
Definition: dataobj.h:1217
DataObject imag(const DataObject &dObj)
high-level value which calculates the imaginary value of each element of the input source data object...
Definition: dataobj.cpp:9069
ito::tDataType guessDataTypeFromCVMat(const cv::Mat *mat, ito::RetVal &retval)
method which guesses the dataObject type from a given cv::Mat*
Definition: dataobj.h:1464
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:1692
ByteArray getVal_ToString(void)
Definition: dataobj.h:326
char getOwnData(void) const
Definition: dataobj.h:783
RetVal copyFromData2D(const _Tp *src, const int sizeX, const int sizeY)
copies the externally given source data inside this data object
Definition: dataobj.h:1310
_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:1374
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:903
int * m_pRefCount
Definition: dataobj.h:582
DataObject abs(const DataObject &dObj)
high-level value which calculates the absolute value of each element of the input source data object ...
Definition: dataobj.cpp:8782
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:1248
each range value has a start and end point. Optionally range can be marked as Range::all(), which indicates a full range
Definition: dataobj.h:237
Definition: apiFunctionsGraph.cpp:39
int getOriginalSize(int index) const
gets the original size of the given dimension (this is the size without considering any ROI) ...
Definition: dataobj.h:910
ito::tDataType convertCmplxTypeToRealType(ito::tDataType cmplxType)
method which returns the real data type of any given data type
Definition: dataobj.h:1432
int getDims(void) const
Definition: dataobj.h:774
Definition: typeDefs.h:83
int plane
plane index where the iterator is currently positioned
Definition: dataobj.h:421
RetVal FreeFunc(DataObject *dObj)
low-level, templated method for freeing allocated data blocks
Definition: dataobj.cpp:759
int getTotal() const
gets total number of elements within the data object's ROI
Definition: dataobj.h:938
Variant storage class for either a double or a string value.
Definition: dataobj.h:257
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:1337
Definition: typeDefs.h:85
int m_type
Definition: dataobj.h:581
uchar ** m_data
Definition: dataobj.h:587
int m_dims
Definition: dataobj.h:583
RetVal AdjustROIFunc(DataObject *dObj, int dtop, int dbottom, int dleft, int dright)
low-level, templated method for adjusting the ROI of a data object by the given incremental values ...
Definition: dataobj.cpp:6191
char m_continuous
Definition: dataobj.h:579
Definition: dataobj.h:547
const _Tp & at(const unsigned int *idx) const
addressing method for n-dimensional data object.
Definition: dataobj.h:1204
MSize getOriginalSize(void)
returns the original size-member. This is equal to getSize() if no roi is set to the dataObject...
Definition: dataobj.h:897
int getSize(int index) const
gets the size of the given dimension (this is the size within the ROI)
Definition: dataobj.h:881
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:1276
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:874
Definition: typeDefs.h:82
bool planeContinuous
indicates whether dObj is continuously organized in each plane for faster seek operations ...
Definition: dataobj.h:416
static Rgba32 fromUnsignedLong(const uint32 val)
static constructor to create Rgba32 from uint32 containing the values argb
Definition: color.h:82
DataObject makeContinuous(const DataObject &dObj)
high-level method which copies an incontinuously organized data object to a continuously organized re...
Definition: dataobj.cpp:9221
int end
Definition: dataobj.h:247
constant iterator through data object
Definition: dataobj.h:361
cv::Mat ** get_mdata(void)
returns array of pointers to cv::_Mat-matrices (planes) of the data object.
Definition: dataobj.h:844
RetVal GetRangeFunc(DataObject *dObj, const int dtop, const int dbottom, const int dleft, const int dright)
low-level, templated method for saving a shallow copy of a source cv::Mat_ to a destination cv::Mat_ ...
Definition: dataobj.cpp:6047
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:1893
DataObject real(const DataObject &dObj)
high-level value which calculates the real value of each element of the input source data object and ...
Definition: dataobj.cpp:8985
char getContinuous(void) const
Definition: dataobj.h:780
char m_owndata
Definition: dataobj.h:580
DataObjectTagType()
< Constructor
Definition: dataobj.h:274
This class implements basic functionality for color handling in itom. This class implements ARGB32 i...
Definition: color.h:46
float32 gray() const
Definition: color.h:235
Range()
Definition: dataobj.h:240
tDataType
Definition: typeDefs.h:77
int getNumPlanes(void) const
calculates numbers of single opencv matrices which are part of the ROI which has previously been set...
Definition: dataobj.h:800
ito::tDataType getDataType2()
method which returns the value of enumeration ito::tDataType, which corresponds to the template param...
Definition: dataobj.h:1542
Definition: typeDefs.h:80
tTagType m_type
type indicator of this class (invalid, double or string)
Definition: dataobj.h:269
int getOriginalTotal() const
gets total number of elements of the whole data object
Definition: dataobj.h:955
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:1235
const char * data() const
return the pointer to the internal character array. If it is empty, the returned pointer still points...
Definition: byteArray.h:136
static Range all()
Definition: dataobj.h:244
double getVal_ToDouble(void)
Definition: dataobj.h:303
MSize m_size
Definition: dataobj.h:586
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:8279
uchar * sliceStart
pointer to the first item within the current continuous slice
Definition: dataobj.h:419