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 "opencv2/opencv.hpp"
46 #include "opencv2/core/core.hpp"
47 #include "opencv2/core/types_c.h"
49 #include "../common/sharedStructures.h"
50 #include "../common/color.h"
51 #include "../common/byteArray.h"
56 template<>
inline ito::float32 saturate_cast<ito::float32>( ito::float64 v)
58 if(cvIsInf(v))
return std::numeric_limits<ito::float32>::infinity();
59 if(cvIsNaN(v))
return std::numeric_limits<ito::float32>::quiet_NaN();
60 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)()) )));
63 template<>
inline ito::float64 saturate_cast<ito::float64>( ito::float32 v)
65 if(cvIsInf(v))
return std::numeric_limits<ito::float64>::infinity();
66 if(cvIsNaN(v))
return std::numeric_limits<ito::float64>::quiet_NaN();
67 return static_cast<ito::float64
>(v);
70 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; }
71 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; }
73 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; }
76 template<>
inline ito::complex64 saturate_cast(ito::uint8 v){
return ito::complex64(static_cast<ito::float32>(v),0.0); }
77 template<>
inline ito::complex64 saturate_cast(ito::int8 v){
return ito::complex64(static_cast<ito::float32>(v),0.0); }
78 template<>
inline ito::complex64 saturate_cast(ito::uint16 v){
return ito::complex64(static_cast<ito::float32>(v),0.0); }
79 template<>
inline ito::complex64 saturate_cast(ito::int16 v){
return ito::complex64(static_cast<ito::float32>(v),0.0); }
80 template<>
inline ito::complex64 saturate_cast(ito::uint32 v){
return ito::complex64(static_cast<ito::float32>(v),0.0); }
81 template<>
inline ito::complex64 saturate_cast(ito::int32 v){
return ito::complex64(static_cast<ito::float32>(v),0.0); }
82 template<>
inline ito::complex64 saturate_cast(ito::float32 v){
return ito::complex64(v,0.0); }
83 template<>
inline ito::complex64 saturate_cast(ito::float64 v){
return ito::complex64(saturate_cast<ito::float32>(v),0.0); }
84 template<>
inline ito::complex64 saturate_cast(ito::complex64 v){
return v; }
85 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())); }
87 template<>
inline ito::complex128 saturate_cast(ito::uint8 v){
return ito::complex128(static_cast<ito::float64>(v),0.0); }
88 template<>
inline ito::complex128 saturate_cast(ito::int8 v){
return ito::complex128(static_cast<ito::float64>(v),0.0); }
89 template<>
inline ito::complex128 saturate_cast(ito::uint16 v){
return ito::complex128(static_cast<ito::float64>(v),0.0); }
90 template<>
inline ito::complex128 saturate_cast(ito::int16 v){
return ito::complex128(static_cast<ito::float64>(v),0.0); }
91 template<>
inline ito::complex128 saturate_cast(ito::uint32 v){
return ito::complex128(static_cast<ito::float64>(v),0.0); }
92 template<>
inline ito::complex128 saturate_cast(ito::int32 v){
return ito::complex128(static_cast<ito::float64>(v),0.0); }
93 template<>
inline ito::complex128 saturate_cast(ito::float32 v){
return ito::complex128(saturate_cast<ito::float64>(v),0.0); }
94 template<>
inline ito::complex128 saturate_cast(ito::float64 v){
return ito::complex128(v,0.0); }
95 template<>
inline ito::complex128 saturate_cast(ito::complex64 v){
return ito::complex128(saturate_cast<ito::float64>(v.real()),saturate_cast<ito::float64>(v.imag())); }
96 template<>
inline ito::complex128 saturate_cast(ito::complex128 v){
return v; }
100 template<>
inline ito::Rgba32 saturate_cast(ito::uint16 v){
return ito::Rgba32(saturate_cast<ito::uint8>(v));}
102 template<>
inline ito::Rgba32 saturate_cast(ito::uint32 v)
106 template<>
inline ito::Rgba32 saturate_cast(ito::int32 v)
109 temp.rgba =
static_cast<ito::uint32
>(v);
112 template<>
inline ito::Rgba32 saturate_cast(ito::float32 v){
return ito::Rgba32(saturate_cast<ito::uint8>(v));}
113 template<>
inline ito::Rgba32 saturate_cast(ito::float64 v){
return ito::Rgba32(saturate_cast<ito::uint8>(v));}
116 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(); }
117 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(); }
118 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(); }
119 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(); }
121 template<>
inline ito::uint8 saturate_cast(
ito::Rgba32 v){
return saturate_cast<ito::uint8>(v.
gray());};
123 template<>
inline ito::uint16 saturate_cast(
ito::Rgba32 v){
return saturate_cast<ito::uint16>(v.
gray());};
124 template<>
inline ito::uint32 saturate_cast(
ito::Rgba32 v){
return v.
argb();};
125 template<>
inline ito::int32 saturate_cast(
ito::Rgba32 v){
return (ito::int32)(v.
argb());};
126 template<>
inline ito::float32 saturate_cast(
ito::Rgba32 v){
return v.
gray();};
127 template<>
inline ito::float64 saturate_cast(
ito::Rgba32 v){
return (ito::float64)v.
gray();};
129 #if (CV_MAJOR_VERSION > 3) || (CV_MAJOR_VERSION == 3 && CV_MINOR_VERSION >= 3)
132 template<>
class DataType<
ito::uint32>
135 typedef ito::uint32 value_type;
136 typedef value_type work_type;
137 typedef value_type channel_type;
138 typedef value_type vec_type;
139 enum { generic_type = 1, depth = -1, channels = 1, fmt=0,
140 type = CV_MAKETYPE(depth, channels) };
144 template<>
class DataType<
ito::Rgba32>
148 typedef ito::uint8 channel_type;
149 typedef Vec<channel_type, 4> work_type;
154 depth = cv::DataDepth<channel_type>::value,
156 fmt = ((channels-1)<<8) + cv::DataDepth<channel_type>::fmt,
157 type = CV_MAKETYPE(depth, channels)
161 template<>
class DataType<
ito::RedChannel>
165 typedef ito::uint8 channel_type;
166 typedef Vec<channel_type, 4> work_type;
171 depth = cv::DataDepth<channel_type>::value,
173 fmt = ((channels-1)<<8) + cv::DataDepth<channel_type>::fmt,
174 type = CV_MAKETYPE(depth, channels)
178 template<>
class DataType<
ito::GreenChannel>
182 typedef ito::uint8 channel_type;
183 typedef Vec<channel_type, 4> work_type;
188 depth = cv::DataDepth<channel_type>::value,
190 fmt = ((channels-1)<<8) + cv::DataDepth<channel_type>::fmt,
191 type = CV_MAKETYPE(depth, channels)
195 template<>
class DataType<
ito::BlueChannel>
199 typedef ito::uint8 channel_type;
200 typedef Vec<channel_type, 4> work_type;
205 depth = cv::DataDepth<channel_type>::value,
207 fmt = ((channels-1)<<8) + cv::DataDepth<channel_type>::fmt,
208 type = CV_MAKETYPE(depth, channels)
212 template<>
class DataType<
ito::AlphaChannel>
216 typedef ito::uint8 channel_type;
217 typedef Vec<channel_type, 4> work_type;
222 depth = cv::DataDepth<channel_type>::value,
224 fmt = ((channels-1)<<8) + cv::DataDepth<channel_type>::fmt,
225 type = CV_MAKETYPE(depth, channels)
240 class DataObjectTags;
241 class DataObjectTagType;
242 class DataObjectTagsPrivate;
256 Range(
int _start,
int _end) { _start < _end ? (end = _end, start = _start) : (start = _end, end = _start); }
257 inline unsigned int size()
const {
return end - start; }
258 inline bool empty()
const {
return (start == end); }
277 typeInvalid = 0x000000,
278 typeDouble = 0x000008,
279 typeString = 0x000020
291 DataObjectTagType(
const std::string &str) : m_dVal(std::numeric_limits<double>::quiet_NaN()), m_type(DataObjectTagType::typeString){ m_strValue = str.
data(); }
292 DataObjectTagType(
const ByteArray &str) : m_dVal(std::numeric_limits<double>::quiet_NaN()), m_type(DataObjectTagType::typeString){ m_strValue = str; }
300 this->m_dVal = rhs.
m_dVal;
302 this->m_type = rhs.
m_type;
308 inline int getType(
void)
const {
return m_type;}
322 return std::numeric_limits<double>::quiet_NaN();
330 double dVal = std::numeric_limits<double>::quiet_NaN();
353 if (cvIsNaN(m_dVal))
return "NaN";
354 if (cvIsInf(m_dVal))
return "Inf";
356 std::ostringstream strs;
393 const uchar* operator *()
const;
396 const uchar* operator [](
int i)
const;
425 void seekAbs(
int ofs);
428 void seekRel(
int ofs);
468 uchar* operator [](
int i);
493 template<
typename _Tp>
RetVal CreateFunc(
DataObject *dObj,
const unsigned char dimensions,
const int *sizes,
const unsigned char continuous,
const uchar* continuousDataPtr,
const int* steps);
504 template<
typename _Tp> std::ostream& coutFunc(std::ostream& out,
const DataObject& dObj);
515 void createHeader(
const unsigned char dimensions,
const int *sizes,
const int *steps,
const int elemSize);
518 void createHeaderWithROI(
const unsigned char dimensions,
const int *sizes,
const int *osizes = NULL,
const int *roi = NULL);
520 void create(
const unsigned char dimensions,
const int *sizes,
const int type,
const unsigned char continuous,
const uchar* continuousDataPtr = NULL,
const int* steps = NULL);
521 void create(
const unsigned char dimensions,
const int *sizes,
const int type,
const cv::Mat* planes,
const unsigned int nrOfPlanes);
524 void secureFreeData(
void);
528 ito::RetVal matNumToIdx(
const int matNum,
int *matIdx)
const;
531 ito::RetVal matIdxToNum(
const unsigned int *matIdx,
int *matNum)
const;
536 inline MSize() : m_p(NULL) {}
537 inline int operator [] (
const int dim)
const
541 inline operator const int * ()
const {
return m_p; }
544 if(m_p == NULL || sz.m_p == NULL)
546 return sz.m_p == m_p;
550 if( d != sz.m_p[-1] )
553 return (memcmp(m_p, sz.m_p, d *
sizeof(
int)) == 0);
556 inline bool operator != (
const MSize& sz)
const {
return !(*
this == sz); }
564 inline MROI() : m_p(NULL) {};
565 inline int operator [] (
const int dim)
const
572 if(m_p == NULL || rroi.m_p == NULL)
574 return rroi.m_p == m_p;
578 if( d != rroi.m_p[-1] )
581 return (memcmp(m_p, rroi.m_p, d *
sizeof(
int)) == 0);
583 if (m_p[-1] != rroi.m_p[-1])
604 static const int m_sizeofs;
606 int mdata_realloc(
const int size);
607 int mdata_size(
void)
const;
610 RetVal copyFromData2DInternal(
const uchar* src,
const int sizeOfElem,
const int sizeX,
const int sizeY);
611 RetVal copyFromData2DInternal(
const uchar* src,
const int sizeOfElem,
const int sizeX,
const int x0,
const int y0,
const int width,
const int height);
615 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);
625 template<
typename _Tp>
friend RetVal EvaluateTransposeFlagFunc(
DataObject *dObj);
626 template<
typename _Tp>
friend std::ostream& coutFunc(std::ostream& out,
const DataObject& dObj);
629 template<
typename _Tp>
friend RetVal GetRangeFunc(
DataObject *dObj,
const int dtop,
const int dbottom,
const int dleft,
const int dright);
640 DataObject(
const int sizeY,
const int sizeX,
const int type);
643 DataObject(
const int sizeZ,
const int sizeY,
const int sizeX,
const int type,
const unsigned char continuous = 0);
646 DataObject(
const int sizeZ,
const int sizeY,
const int sizeX,
const int type,
const uchar* continuousDataPtr,
const int* steps = NULL);
649 DataObject(
const MSize &sizes,
const int type,
const unsigned char continuous = 0);
652 DataObject(
const unsigned char dimensions,
const int *sizes,
const int type,
const unsigned char continuous = 0);
655 DataObject(
const unsigned char dimensions,
const int *sizes,
const int type,
const uchar* continuousDataPtr,
const int* steps = NULL);
658 DataObject(
const unsigned char dimensions,
const int *sizes,
const int type,
const cv::Mat* planes,
const unsigned int nrOfPlanes);
671 double getValueOffset()
const;
674 double getValueScale()
const;
677 const std::string getValueUnit()
const;
680 std::string getValueDescription()
const;
683 double getAxisOffset(
const int axisNum)
const;
686 double getAxisScale(
const int axisNum)
const;
689 const std::string getAxisUnit(
const int axisNum,
bool &validOperation)
const;
692 std::string getAxisDescription(
const int axisNum,
bool &validOperation)
const;
696 bool getTagByIndex(
const int tagNumber, std::string &key,
DataObjectTagType &value)
const;
699 std::string getTagKey(
const int tagNumber,
bool &validOperation)
const;
702 int getTagListSize()
const;
705 int setValueUnit(
const std::string &unit);
708 int setValueDescription(
const std::string &description);
711 int setAxisOffset(
const unsigned int axisNum,
const double offset);
714 int setAxisScale(
const unsigned int axisNum,
const double scale);
717 int setAxisUnit(
const unsigned int axisNum,
const std::string &unit);
720 int setAxisDescription(
const unsigned int axisNum,
const std::string &description);
722 bool existTag(
const std::string &key)
const;
723 bool deleteTag(
const std::string &key);
724 bool deleteAllTags();
725 int addToProtocol(
const std::string &value);
730 double getPhysToPix(
const unsigned int dim,
const double phys,
bool &isInsideImage)
const;
735 double getPhysToPix(
const unsigned int dim,
const double phys)
const;
740 int getPhysToPix2D(
const double physY,
double &tPxY,
bool &isInsideImageY,
const double physX,
double &tPxX,
bool &isInsideImageX)
const;
745 double getPixToPhys(
const unsigned int dim,
const double pix,
bool &isInsideImage)
const;
750 double getPixToPhys(
const unsigned int dim,
const double pix)
const;
765 RetVal setXYRotationalMatrix(
double r11,
double r12,
double r13,
double r21,
double r22,
double r23,
double r31,
double r32,
double r33);
780 RetVal getXYRotationalMatrix(
double &r11,
double &r12,
double &r13,
double &r21,
double &r22,
double &r23,
double &r31,
double &r32,
double &r33)
const;
791 inline int getDims(
void)
const {
return m_dims; }
794 inline int getType(
void)
const {
return m_type; }
803 int seekMat(
const int matNum,
const int numMats)
const;
806 int seekMat(
const int matNum)
const;
809 int calcNumMats(
void)
const;
829 return m_size[0] * m_size[1];
833 for (
int n = 0; n < m_dims - 2; n++)
843 cv::Mat* getCvPlaneMat(
const int planeIndex);
846 const cv::Mat* getCvPlaneMat(
const int planeIndex)
const;
849 const cv::Mat getContinuousCvPlaneMat(
const int planeIndex)
const;
863 return (cv::Mat**)m_data;
878 return (
const cv::Mat**)m_data;
900 if(index < 0 || index >= m_dims)
906 return m_size[index];
929 if(index < 0 || index >= m_dims)
935 return m_osize[index];
947 int getStep(
int index)
const;
957 int dims = getDims();
958 int total = dims > 0 ? 1 : 0;
959 for(
int i = 0 ; i < dims ; i++)
974 int dims = getDims();
975 int total = dims > 0 ? 1 : 0;
976 for(
int i = 0 ; i<dims ; i++)
984 RetVal convertTo(
DataObject &rhs,
const int type,
const double alpha=1,
const double beta=0 )
const;
1013 DataObject & operator = (
const cv::Mat &rhs);
1016 DataObject & operator = (
const uint8 &value);
1017 DataObject & operator = (
const int16 &value);
1018 DataObject & operator = (
const uint16 &value);
1019 DataObject & operator = (
const int32 &value);
1020 DataObject & operator = (
const uint32 &value);
1021 DataObject & operator = (
const float32 &value);
1022 DataObject & operator = (
const float64 &value);
1023 DataObject & operator = (
const complex64 &value);
1024 DataObject & operator = (
const complex128 &value);
1029 DataObject & operator += (
const float64 &value);
1030 DataObject & operator += (
const complex128 &value);
1033 DataObject operator + (
const float64 &value);
1034 DataObject operator + (
const complex128 &value);
1037 DataObject & operator -= (
const float64 &value);
1038 DataObject & operator -= (
const complex128 &value);
1041 DataObject operator - (
const float64 &value);
1042 DataObject operator - (
const complex128 &value);
1045 DataObject & operator *= (
const float64 &factor);
1046 DataObject & operator *= (
const complex128 &factor);
1049 DataObject operator * (
const float64 &factor);
1050 DataObject operator * (
const complex128 &factor);
1060 DataObject operator < (
const float64 &value);
1061 DataObject operator > (
const float64 &value);
1062 DataObject operator <= (
const float64 &value);
1063 DataObject operator >= (
const float64 &value);
1073 DataObject operator << (
const unsigned int shiftbit);
1074 DataObject & operator <<= (
const unsigned int shiftbit);
1075 DataObject operator >> (
const unsigned int shiftbit);
1076 DataObject & operator >>= (
const unsigned int shiftbit);
1088 RetVal zeros(
const int type);
1089 RetVal zeros(
const int size,
const int type);
1090 RetVal zeros(
const int sizeY,
const int sizeX,
const int type);
1091 RetVal zeros(
const int sizeZ,
const int sizeY,
const int sizeX,
const int type,
const unsigned char continuous = 0);
1092 RetVal zeros(
const unsigned char dimensions,
const int *sizes,
const int type,
const unsigned char continuous = 0);
1095 RetVal ones(
const int type);
1096 RetVal ones(
const int size,
const int type);
1097 RetVal ones(
const int sizeY,
const int sizeX,
const int type);
1098 RetVal ones(
const int sizeZ,
const int sizeY,
const int sizeX,
const int type,
const unsigned char continuous = 0);
1099 RetVal ones(
const unsigned char dimensions,
const int *sizes,
const int type,
const unsigned char continuous = 0);
1102 RetVal nans(
const int type);
1103 RetVal nans(
const int size,
const int type);
1104 RetVal nans(
const int sizeY,
const int sizeX,
const int type);
1105 RetVal nans(
const int sizeZ,
const int sizeY,
const int sizeX,
const int type,
const unsigned char continuous = 0);
1106 RetVal nans(
const unsigned char dimensions,
const int *sizes,
const int type,
const unsigned char continuous = 0);
1109 RetVal rand(
const int type,
const bool randMode =
false);
1110 RetVal rand(
const int size,
const int type,
const bool randMode =
false);
1111 RetVal rand(
const int sizeY,
const int sizeX,
const int type,
const bool randMode =
false);
1112 RetVal rand(
const int sizeZ,
const int sizeY,
const int sizeX,
const int type,
const bool randMode,
const unsigned char continuous = 0);
1113 RetVal rand(
const unsigned char dimensions,
const int *sizes,
const int type,
const bool randMode,
const unsigned char continuous = 0);
1116 RetVal eye(
const int type);
1117 RetVal eye(
const int size,
const int type);
1131 void pow(
const ito::float64 &power,
DataObject &dst);
1137 DataObject reshape(
int newDims,
const int *newSizes)
const;
1139 int elemSize()
const;
1147 template<
typename _Tp>
inline const _Tp&
at(
const unsigned int y,
const unsigned int x)
const
1152 cv::error(cv::Exception(CV_StsAssert,
"Dimension mismatch while addressing data field",
"", __FILE__, __LINE__));
1154 else if (((
int)x >= m_size[1]) || ((
int)y >= m_size[0]) )
1156 cv::error(cv::Exception(CV_StsAssert,
"Index out of bounds",
"", __FILE__ , __LINE__));
1159 return (*
reinterpret_cast<const cv::Mat_<_Tp>*
>(m_data[0]))(y, x);
1168 template<
typename _Tp>
inline _Tp&
at(
const unsigned int y,
const unsigned int x)
1173 cv::error(cv::Exception(CV_StsAssert,
"Dimension mismatch while addressing data field",
"", __FILE__, __LINE__));
1175 else if (((
int)x >= m_size[1]) || ((
int)y >= m_size[0]) )
1177 cv::error(cv::Exception(CV_StsAssert,
"Index out of bounds",
"", __FILE__ , __LINE__));
1180 return (*
reinterpret_cast<cv::Mat_<_Tp>*
>(m_data[0]))(y, x);
1190 template<
typename _Tp>
inline const _Tp&
at(
const unsigned int z,
const unsigned int y,
const unsigned int x)
const
1195 cv::error(cv::Exception(CV_StsAssert,
"Dimension mismatch while addressing data field",
"", __FILE__, __LINE__));
1197 else if (((
int)x >= m_size[2]) || ((
int)y >= m_size[1]) || (((
int)z + m_roi[0]) >= (m_roi[0] + m_size[0])))
1199 cv::error(cv::Exception(CV_StsAssert,
"Index out of bounds",
"", __FILE__ , __LINE__));
1202 return (*
reinterpret_cast<const cv::Mat_<_Tp>*
>(m_data[z + m_roi[0]]))(y, x);
1212 template<
typename _Tp>
inline _Tp&
at(
const unsigned int z,
const unsigned int y,
const unsigned int x)
1217 cv::error(cv::Exception(CV_StsAssert,
"Dimension mismatch while addressing data field",
"", __FILE__, __LINE__));
1219 else if (((
int)x >= m_size[2]) || ((
int)y >= m_size[1]) || (((
int)z + m_roi[0]) >= (m_roi[0] + m_size[0])))
1221 cv::error(cv::Exception(CV_StsAssert,
"Index out of bounds",
"", __FILE__ , __LINE__));
1224 return (*
reinterpret_cast<cv::Mat_<_Tp>*
>(m_data[z + m_roi[0]]))(y, x);
1233 template<
typename _Tp>
inline const _Tp&
at(
const unsigned int *idx)
const
1236 matIdxToNum(idx, &matNum);
1237 return (*
reinterpret_cast<const cv::Mat_<_Tp>*
>(m_data[matNum]))(idx[m_dims - 2], idx[m_dims - 1]);
1246 template<
typename _Tp>
inline _Tp&
at(
const unsigned int *idx)
1249 matIdxToNum(idx, &matNum);
1250 return (*
reinterpret_cast<cv::Mat_<_Tp>*
>(m_data[matNum]))(idx[m_dims - 2], idx[m_dims - 1]);
1264 inline uchar*
rowPtr(
const int matNum,
const int y)
1266 int matIndex = seekMat(matNum);
1267 return ((cv::Mat*)m_data[matIndex])->ptr(y);
1277 inline const uchar*
rowPtr(
const int matNum,
const int y)
const
1279 int matIndex = seekMat(matNum);
1280 return ((
const cv::Mat*)m_data[matIndex])->ptr(y);
1291 template<
typename _Tp>
inline _Tp*
rowPtr(
const int matNum,
const int y)
1293 int matIndex = seekMat(matNum);
1294 return ((cv::Mat*)m_data[matIndex])->ptr<_Tp>(y);
1305 template<
typename _Tp>
inline const _Tp*
rowPtr(
const int matNum,
const int y)
const
1307 int matIndex = seekMat(matNum);
1308 return ((
const cv::Mat*)m_data[matIndex])->ptr<_Tp>(y);
1315 DataObject splitColor(
const char* destinationColor,
const int& dtype)
const;
1316 DataObject lineCut(
const double* coordinates,
const int& len)
const;
1319 DataObject & adjustROI(
const int dtop,
const int dbottom,
const int dleft,
const int dright);
1320 DataObject & adjustROI(
const unsigned char dims,
const int *lims);
1321 RetVal locateROI(
int *wholeSizes,
int *offsets)
const;
1322 RetVal locateROI(
int *lims)
const;
1340 template<
typename _Tp>
RetVal copyFromData2D(
const _Tp* src,
const int sizeX,
const int sizeY) {
return copyFromData2DInternal((
const uchar*)src,
sizeof(_Tp), sizeX, sizeY); }
1367 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); }
1369 template<
typename T2>
operator T2 ();
1371 template<
typename _Tp>
RetVal linspace(
const _Tp start,
const _Tp end,
const _Tp inc,
const int transposed);
1389 DATAOBJ_EXPORT DataObject
abs(
const DataObject &dObj);
1390 DATAOBJ_EXPORT DataObject
arg(
const DataObject &dObj);
1391 DATAOBJ_EXPORT DataObject
real(
const DataObject &dObj);
1392 DATAOBJ_EXPORT DataObject
imag(
const DataObject &dObj);
1394 DATAOBJ_EXPORT DataObject
makeContinuous(
const DataObject &dObj);
1411 retValue = cv::saturate_cast<_Tp>(*(
static_cast<const uint8*
>(scalar)));
1414 retValue = cv::saturate_cast<_Tp>(*(
static_cast<const int8*
>(scalar)));
1417 retValue = cv::saturate_cast<_Tp>(*(
static_cast<const uint16*
>(scalar)));
1420 retValue = cv::saturate_cast<_Tp>(*(
static_cast<const int16*
>(scalar)));
1423 retValue = cv::saturate_cast<_Tp>(*(
static_cast<const uint32*
>(scalar)));
1426 retValue = cv::saturate_cast<_Tp>(*(
static_cast<const int32*
>(scalar)));
1429 retValue = cv::saturate_cast<_Tp>(*(
static_cast<const ito::float32*
>(scalar)));
1432 retValue = cv::saturate_cast<_Tp>(*(
static_cast<const ito::float64*
>(scalar)));
1435 retValue = cv::saturate_cast<_Tp>(*(
static_cast<const ito::complex64*
>(scalar)));
1438 retValue = cv::saturate_cast<_Tp>(*(
static_cast<const ito::complex128*
>(scalar)));
1441 retValue = cv::saturate_cast<_Tp>(*(
static_cast<const ito::Rgba32*
>(scalar)));
1444 cv::error(cv::Exception(CV_StsAssert,
"Input value type unkown",
"", __FILE__, __LINE__));
1452 DATAOBJ_EXPORT std::ostream& operator << (std::ostream& out,
const DataObject& dObj);
1482 cv::error(cv::Exception(CV_StsAssert,
"Input data type unknown",
"", __FILE__, __LINE__));
1500 case cv::DataType<ito::int8>::type:
1502 case cv::DataType<ito::uint8>::type:
1504 case cv::DataType<ito::int16>::type:
1506 case cv::DataType<ito::uint16>::type:
1508 case cv::DataType<ito::int32>::type:
1510 case cv::DataType<ito::uint32>::type:
1512 case cv::DataType<ito::float32>::type:
1514 case cv::DataType<ito::float64>::type:
1516 case cv::DataType<ito::Rgba32>::type:
1518 case cv::DataType<ito::complex64>::type:
1520 case cv::DataType<ito::complex128>::type:
1545 cv::error(cv::Exception(CV_StsAssert,
"Input value type unkown",
"", __FILE__, __LINE__));
1574 cv::error(cv::Exception(CV_StsAssert,
"Input value type unkown",
"", __FILE__, __LINE__));
int getType(void) const
returns type of tag (
Definition: dataobj.h:308
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:311
double m_dVal
if the tag type is double, the real double value is stored here
Definition: dataobj.h:283
_Tp & at(const unsigned int z, const unsigned int y, const unsigned int x)
addressing method for three-dimensional data object.
Definition: dataobj.h:1212
iterator through data object
Definition: dataobj.h:448
dataObject contains a n-dimensional matrix
Definition: dataobj.h:511
Range(int _start, int _end)
Definition: dataobj.h:256
Definition: typeDefs.h:99
MSize getSize(void)
returns the size-member. m_size fits to the physical organization of data in memory.
Definition: dataobj.h:885
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:10131
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:2447
MSize m_osize
Definition: dataobj.h:599
int start
Definition: dataobj.h:261
ByteArray m_strValue
if the tag type is string, the string data is stored in this ByteArray variable.
Definition: dataobj.h:285
_Tp & at(const unsigned int y, const unsigned int x)
addressing method for two-dimensional data object.
Definition: dataobj.h:1168
tTagType
Definition: dataobj.h:275
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:3815
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:1543
Definition: dataobj.h:534
Definition: typeDefs.h:91
Definition: typeDefs.h:60
const DataObject * dObj
reference to the related data object
Definition: dataobj.h:430
Definition: typeDefs.h:96
MROI m_roi
Definition: dataobj.h:600
uchar * ptr
pointer to the current value of the iterator
Definition: dataobj.h:433
Class for managing status values (like errors or warning)
Definition: retVal.h:54
unsigned int size() const
Definition: dataobj.h:257
Definition: typeDefs.h:98
Definition: typeDefs.h:97
DataObjectTagsPrivate * m_pDataObjectTags
Definition: dataobj.h:603
_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:1291
int getType(void) const
Definition: dataobj.h:794
const _Tp & at(const unsigned int y, const unsigned int x) const
addressing method for two-dimensional data object.
Definition: dataobj.h:1147
uchar * sliceEnd
pointer to the last item within the current continuous slice
Definition: dataobj.h:435
Definition: typeDefs.h:94
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:876
bool empty() const
Definition: dataobj.h:258
This is a Qt-free class for byte arrays (strings) without specific encoding information.
Definition: byteArray.h:64
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:1190
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:10648
Definition: typeDefs.h:89
DataObjectTagType(const char *cVal)
Copy Constructor.
Definition: dataobj.h:293
_Tp & at(const unsigned int *idx)
addressing method for n-dimensional data object.
Definition: dataobj.h:1246
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:10622
ito::tDataType guessDataTypeFromCVMat(const cv::Mat *mat, ito::RetVal &retval)
method which guesses the dataObject type from a given cv::Mat*
Definition: dataobj.h:1494
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:1726
ByteArray getVal_ToString(void)
Definition: dataobj.h:341
char getOwnData(void) const
Definition: dataobj.h:800
RetVal copyFromData2D(const _Tp *src, const int sizeX, const int sizeY)
copies the externally given source data inside this data object
Definition: dataobj.h:1340
_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:1404
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:920
int * m_pRefCount
Definition: dataobj.h:597
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:10012
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:1277
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:252
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:927
ito::tDataType convertCmplxTypeToRealType(ito::tDataType cmplxType)
method which returns the real data type of any given data type
Definition: dataobj.h:1462
int getDims(void) const
Definition: dataobj.h:791
Definition: typeDefs.h:93
int plane
plane index where the iterator is currently positioned
Definition: dataobj.h:436
tag type double
Definition: dataobj.h:278
RetVal FreeFunc(DataObject *dObj)
low-level, templated method for freeing allocated data blocks
Definition: dataobj.cpp:781
int getTotal() const
gets total number of elements within the data object's ROI
Definition: dataobj.h:955
Variant storage class for either a double or a string value.
Definition: dataobj.h:272
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:1367
Definition: typeDefs.h:95
int m_type
Definition: dataobj.h:596
uchar ** m_data
Definition: dataobj.h:602
int m_dims
Definition: dataobj.h:598
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:6961
char m_continuous
Definition: dataobj.h:594
Definition: dataobj.h:562
bool operator==(const ByteArray &a1, const char *a2)
comparison operator that returns true if the content of a1 is equal to the given zero-terminated stri...
Definition: byteArray.h:185
const _Tp & at(const unsigned int *idx) const
addressing method for n-dimensional data object.
Definition: dataobj.h:1233
MSize getOriginalSize(void)
returns the original size-member. This is equal to getSize() if no roi is set to the dataObject...
Definition: dataobj.h:914
int getSize(int index) const
gets the size of the given dimension (this is the size within the ROI)
Definition: dataobj.h:898
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:1305
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:891
Definition: typeDefs.h:92
bool planeContinuous
indicates whether dObj is continuously organized in each plane for faster seek operations ...
Definition: dataobj.h:431
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:10774
int end
Definition: dataobj.h:262
constant iterator through data object
Definition: dataobj.h:376
cv::Mat ** get_mdata(void)
returns array of pointers to cv::_Mat-matrices (planes) of the data object.
Definition: dataobj.h:861
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:6817
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:1939
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:10215
tag type string (
Definition: dataobj.h:279
bool operator!=(const ByteArray &a1, const char *a2)
comparison operator that returns true if the content of a1 is not equal to the given zero-terminated ...
Definition: byteArray.h:197
char getContinuous(void) const
Definition: dataobj.h:797
char m_owndata
Definition: dataobj.h:595
DataObjectTagType()
< Constructor
Definition: dataobj.h:289
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:255
tDataType
Definition: typeDefs.h:87
int getNumPlanes(void) const
calculates numbers of single opencv matrices which are part of the ROI which has previously been set...
Definition: dataobj.h:817
ito::tDataType getDataType2()
method which returns the value of enumeration ito::tDataType, which corresponds to the template param...
Definition: dataobj.h:1572
Definition: typeDefs.h:90
tTagType m_type
type indicator of this class (invalid, double or string)
Definition: dataobj.h:284
int getOriginalTotal() const
gets total number of elements of the whole data object
Definition: dataobj.h:972
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:1264
const char * data() const
return the pointer to the internal character array. If it is empty, the returned pointer still points...
Definition: byteArray.h:131
static Range all()
Definition: dataobj.h:259
double getVal_ToDouble(void)
Definition: dataobj.h:318
MSize m_size
Definition: dataobj.h:601
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:9509
invalid tag type
Definition: dataobj.h:277
uchar * sliceStart
pointer to the first item within the current continuous slice
Definition: dataobj.h:434