Changeset 15 in flair-src for trunk/lib/FlairCore/src/cvmatrix_impl.cpp
- Timestamp:
- 04/08/16 15:40:57 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairCore/src/cvmatrix_impl.cpp
r2 r15 24 24 using namespace flair::core; 25 25 26 cvmatrix_impl::cvmatrix_impl(cvmatrix* self,int rows, int cols,flair::core::ScalarType const &_elementDataType,int n):elementDataType(_elementDataType) { 27 descriptor=new cvmatrix_descriptor(rows,cols); 28 Init(self,n); 26 cvmatrix_impl::cvmatrix_impl(cvmatrix *self, int rows, int cols, 27 flair::core::ScalarType const &_elementDataType, 28 int n) 29 : elementDataType(_elementDataType) { 30 descriptor = new cvmatrix_descriptor(rows, cols); 31 Init(self, n); 29 32 } 30 33 31 cvmatrix_impl::cvmatrix_impl(cvmatrix* self,const cvmatrix_descriptor *descriptor,flair::core::ScalarType const &_elementDataType,int n):elementDataType(_elementDataType) { 32 this->descriptor=descriptor; 33 Init(self,n); 34 cvmatrix_impl::cvmatrix_impl(cvmatrix *self, 35 const cvmatrix_descriptor *descriptor, 36 flair::core::ScalarType const &_elementDataType, 37 int n) 38 : elementDataType(_elementDataType) { 39 this->descriptor = descriptor; 40 Init(self, n); 34 41 } 35 42 36 void cvmatrix_impl::Init(cvmatrix * self,int n) {37 this->self=self;43 void cvmatrix_impl::Init(cvmatrix *self, int n) { 44 this->self = self; 38 45 39 mat=nullptr; 40 try { 41 ScalarType const &scalarType=dynamic_cast<ScalarType const &>(elementDataType); 42 if (typeid(scalarType)==typeid(FloatType)) { 43 mat=cvCreateMat(descriptor->Rows(),descriptor->Cols(),CV_32FC1); 44 } else if (typeid(scalarType)==typeid(SignedIntegerType)) { 45 switch(elementDataType.GetSize()) { 46 case 1: 47 mat=cvCreateMat(descriptor->Rows(),descriptor->Cols(),CV_8SC1); 48 break; 49 case 2: 50 mat=cvCreateMat(descriptor->Rows(),descriptor->Cols(),CV_16SC1); 51 break; 52 default: 53 self->Err("unsupported integer scalar type\n"); 54 } 55 } else { 56 self->Err("unsupported scalar type\n"); 57 } 58 } catch(std::bad_cast e) { 59 self->Err("type is not a scalar\n"); 46 mat = nullptr; 47 try { 48 ScalarType const &scalarType = 49 dynamic_cast<ScalarType const &>(elementDataType); 50 if (typeid(scalarType) == typeid(FloatType)) { 51 mat = cvCreateMat(descriptor->Rows(), descriptor->Cols(), CV_32FC1); 52 } else if (typeid(scalarType) == typeid(SignedIntegerType)) { 53 switch (elementDataType.GetSize()) { 54 case 1: 55 mat = cvCreateMat(descriptor->Rows(), descriptor->Cols(), CV_8SC1); 56 break; 57 case 2: 58 mat = cvCreateMat(descriptor->Rows(), descriptor->Cols(), CV_16SC1); 59 break; 60 default: 61 self->Err("unsupported integer scalar type\n"); 62 } 63 } else { 64 self->Err("unsupported scalar type\n"); 60 65 } 66 } catch (std::bad_cast e) { 67 self->Err("type is not a scalar\n"); 68 } 61 69 62 if(mat==nullptr) self->Err("allocating matrix failed\n"); 63 if(n>1) self->Warn("n>1 not supported\n"); 70 if (mat == nullptr) 71 self->Err("allocating matrix failed\n"); 72 if (n > 1) 73 self->Warn("n>1 not supported\n"); 64 74 } 65 75 66 76 cvmatrix_impl::~cvmatrix_impl() { 67 68 77 cvReleaseMat(&mat); 78 delete descriptor; 69 79 }
Note:
See TracChangeset
for help on using the changeset viewer.