Changeset 15 in flair-src for trunk/lib/FlairCore/src/cvmatrix_impl.cpp


Ignore:
Timestamp:
04/08/16 15:40:57 (6 years ago)
Author:
Bayard Gildas
Message:

sources reformatted with flair-format-dir script

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairCore/src/cvmatrix_impl.cpp

    r2 r15  
    2424using namespace flair::core;
    2525
    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);
     26cvmatrix_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);
    2932}
    3033
    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);
     34cvmatrix_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);
    3441}
    3542
    36 void cvmatrix_impl::Init(cvmatrix* self,int n) {
    37     this->self=self;
     43void cvmatrix_impl::Init(cvmatrix *self, int n) {
     44  this->self = self;
    3845
    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");
    6065    }
     66  } catch (std::bad_cast e) {
     67    self->Err("type is not a scalar\n");
     68  }
    6169
    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");
    6474}
    6575
    6676cvmatrix_impl::~cvmatrix_impl() {
    67     cvReleaseMat(&mat);
    68     delete descriptor;
     77  cvReleaseMat(&mat);
     78  delete descriptor;
    6979}
Note: See TracChangeset for help on using the changeset viewer.