Changeset 214 in flair-src for trunk/lib/FlairCore
- Timestamp:
- Feb 7, 2018, 5:49:27 PM (7 years ago)
- Location:
- trunk/lib/FlairCore/src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairCore/src/FrameworkManager_impl.cpp
r213 r214 211 211 } 212 212 213 UDT::startup( );213 UDT::startup(1024*256,1024*256,1024*256); 214 214 this->rcv_buf_size = rcv_buf_size; 215 215 -
trunk/lib/FlairCore/src/Matrix.cpp
r213 r214 19 19 #include <typeinfo> 20 20 #include <string.h> 21 22 //#include <iostream>23 21 24 22 using std::string; … … 37 35 this->col = col; 38 36 if (row >= matrix->Rows() || col >= matrix->Cols()) { 39 matrix->Err("index (%i,%i) out of bound (%i,%i)\n", row, col,37 matrix->Err("index (%i,%i) out of bound, max (%i,%i)\n", row, col, 40 38 matrix->Rows() - 1, matrix->Cols() - 1); 41 39 size = 0; … … 71 69 } break; 72 70 } 71 } else if (typeid(matrix->GetDataType().GetElementDataType()) == 72 typeid(UnsignedIntegerType)) { 73 switch (matrix->GetDataType().GetElementDataType().GetSize()) { 74 case 1: { 75 uint8_t uint8Value = matrix->Value(row, col); 76 memcpy(dst, &uint8Value, 1); 77 } break; 78 case 2: { 79 uint16_t uint16Value = matrix->Value(row, col); 80 memcpy(dst, &uint16Value, 2); 81 } break; 82 } 73 83 } 74 84 } … … 133 143 if (row >= (uint32_t)pimpl_->descriptor->Rows() || 134 144 col >= (uint32_t)pimpl_->descriptor->Cols()) { 135 Warn("index (%i,%i) out of bound (%i,%i)\n", row, col,145 Warn("index (%i,%i) out of bound, max (%i,%i)\n", row, col, 136 146 pimpl_->descriptor->Rows() - 1, pimpl_->descriptor->Cols() - 1); 137 147 return 0; … … 139 149 140 150 GetMutex(); 141 value = pimpl_-> datas[row][col];151 value = pimpl_->ValueNoMutex(row, col); 142 152 ReleaseMutex(); 143 153 … … 148 158 if (row >= (uint32_t)pimpl_->descriptor->Rows() || 149 159 col >= (uint32_t)pimpl_->descriptor->Cols()) { 150 Warn("index (%i,%i) out of bound (%i,%i)\n", row, col,160 Warn("index (%i,%i) out of bound, max (%i,%i)\n", row, col, 151 161 pimpl_->descriptor->Rows() - 1, pimpl_->descriptor->Cols() - 1); 152 162 return 0; 153 163 } 154 164 155 return pimpl_-> datas[row][col];165 return pimpl_->ValueNoMutex(row, col); 156 166 } 157 167 … … 159 169 if (row >= (uint32_t)pimpl_->descriptor->Rows() || 160 170 col >= (uint32_t)pimpl_->descriptor->Cols()) { 161 Warn("index (%i,%i) out of bound (%i,%i)\n", row, col,171 Warn("index (%i,%i) out of bound, max (%i,%i)\n", row, col, 162 172 pimpl_->descriptor->Rows() - 1, pimpl_->descriptor->Cols() - 1); 163 173 } else { 164 174 GetMutex(); 165 pimpl_-> datas[row][col]=value;175 pimpl_->SetValueNoMutex(row, col,value); 166 176 ReleaseMutex(); 167 177 } … … 171 181 if (row >= (uint32_t)pimpl_->descriptor->Rows() || 172 182 col >= (uint32_t)pimpl_->descriptor->Cols()) { 173 Warn("index (%i,%i) out of bound (%i,%i)\n", row, col,183 Warn("index (%i,%i) out of bound, max (%i,%i)\n", row, col, 174 184 pimpl_->descriptor->Rows() - 1, pimpl_->descriptor->Cols() - 1); 175 185 } else { 176 pimpl_-> datas[row][col]=value;186 pimpl_->SetValueNoMutex(row, col,value); 177 187 } 178 188 } … … 180 190 void Matrix::CopyDatas(char *dst) const { 181 191 GetMutex(); 182 // printf("%f %x %i\n",cvGetReal2D(pimpl_->mat,0,0),dst,Size());183 192 memcpy(dst, pimpl_->datas, dataType.GetSize()); 184 193 ReleaseMutex(); -
trunk/lib/FlairCore/src/Matrix.h
r213 r214 27 27 * \brief Class defining a matrix 28 28 * 29 * Only supports float for the moment30 * TODO: write a template31 29 * 32 30 */ … … 196 194 197 195 Type const &GetDataType() const { return dataType; }; 198 196 void CopyDatas(char *dst) const; 199 197 private: 200 198 /*! … … 206 204 * \param dst destination buffer 207 205 */ 208 void CopyDatas(char *dst) const;206 //void CopyDatas(char *dst) const; 209 207 210 208 class Matrix_impl *pimpl_; -
trunk/lib/FlairCore/src/Matrix_impl.cpp
r213 r214 54 54 dynamic_cast<ScalarType const &>(elementDataType); 55 55 if (typeid(scalarType) == typeid(FloatType)) { 56 datas = (float **)malloc(descriptor->Rows() * sizeof(float*)); 57 if(datas==NULL) { 58 self->Err("error allocating matrix\n"); 59 return; 60 } 61 for(uint32_t i=0 ; i < descriptor->Rows() ; i++){ 62 datas[i] = (float*)malloc(descriptor->Cols() * sizeof(float) ); 63 if(datas[i]==NULL) { 64 self->Err("error allocating matrix\n"); 65 for(uint32_t j = i-1 ; j >= 0 ; j--) free(datas[j]); 66 free(datas); 67 return; 68 } 69 } 70 /* 71 } else if (typeid(scalarType) == typeid(SignedIntegerType)) { 56 datas =malloc(descriptor->Rows() * descriptor->Cols() * sizeof(float)); 57 } else if (typeid(scalarType) == typeid(SignedIntegerType) || typeid(scalarType) == typeid(UnsignedIntegerType) ) { 72 58 switch (elementDataType.GetSize()) { 73 59 case 1: 74 mat = cvCreateMat(descriptor->Rows(), descriptor->Cols(), CV_8SC1);60 datas=malloc(descriptor->Rows() * descriptor->Cols() * sizeof(uint8_t)); 75 61 break; 76 62 case 2: 77 mat = cvCreateMat(descriptor->Rows(), descriptor->Cols(), CV_16SC1);63 datas=malloc(descriptor->Rows() * descriptor->Cols() * sizeof(uint16_t)); 78 64 break; 79 65 default: 80 66 self->Err("unsupported integer scalar type\n"); 81 } */67 } 82 68 } else { 83 69 self->Err("unsupported scalar type\n"); … … 94 80 95 81 Matrix_impl::~Matrix_impl() { 96 for (uint32_t i = 0; i < descriptor->Rows();i++) {97 free(datas[i]);98 }99 82 free(datas); 100 83 delete descriptor; 101 84 } 85 86 float Matrix_impl::ValueNoMutex(uint32_t row, uint32_t col) const { 87 ScalarType const &scalarType = 88 dynamic_cast<ScalarType const &>(elementDataType); 89 if (typeid(scalarType) == typeid(FloatType)) { 90 return ((float*)datas)[row*descriptor->Cols()+col]; 91 } else if (typeid(scalarType) == typeid(SignedIntegerType)) { 92 switch (elementDataType.GetSize()) { 93 case 1: 94 return ((int8_t*)datas)[row*descriptor->Cols()+col]; 95 break; 96 case 2: 97 return ((int16_t*)datas)[row*descriptor->Cols()+col]; 98 break; 99 default: 100 self->Err("unsupported signed integer scalar type\n"); 101 } 102 } else if (typeid(scalarType) == typeid(UnsignedIntegerType)) { 103 switch (elementDataType.GetSize()) { 104 case 1: 105 return ((uint8_t*)datas)[row*descriptor->Cols()+col]; 106 break; 107 case 2: 108 return ((uint16_t*)datas)[row*descriptor->Cols()+col]; 109 break; 110 default: 111 self->Err("unsupported unsigned integer scalar type\n"); 112 } 113 } else { 114 self->Err("unsupported scalar type\n"); 115 } 116 return 0; 117 } 118 119 void Matrix_impl::SetValueNoMutex(uint32_t row, uint32_t col, float value) { 120 ScalarType const &scalarType = 121 dynamic_cast<ScalarType const &>(elementDataType); 122 if (typeid(scalarType) == typeid(FloatType)) { 123 ((float*)datas)[row*descriptor->Cols()+col]=value; 124 } else if (typeid(scalarType) == typeid(SignedIntegerType)) { 125 switch (elementDataType.GetSize()) { 126 case 1: 127 ((int8_t*)datas)[row*descriptor->Cols()+col]=value; 128 break; 129 case 2: 130 ((int16_t*)datas)[row*descriptor->Cols()+col]=value; 131 break; 132 default: 133 self->Err("unsupported signed integer scalar type\n"); 134 } 135 } else if (typeid(scalarType) == typeid(UnsignedIntegerType)) { 136 switch (elementDataType.GetSize()) { 137 case 1: 138 ((uint8_t*)datas)[row*descriptor->Cols()+col]=value; 139 break; 140 case 2: 141 ((uint16_t*)datas)[row*descriptor->Cols()+col]=value; 142 break; 143 default: 144 self->Err("unsupported unsigned integer scalar type\n"); 145 } 146 } else { 147 self->Err("unsupported scalar type\n"); 148 } 149 } -
trunk/lib/FlairCore/src/RangeFinderPlot.cpp
r137 r214 18 18 19 19 #include "RangeFinderPlot.h" 20 #include "cvmatrix.h" 21 #include "Layout.h" 20 #include "Matrix.h" 22 21 #include "LayoutPosition.h" 23 22 #include <cxcore.h> … … 32 31 string x_name, float xmin, float xmax, 33 32 string y_name, float ymin, float ymax, 34 const cvmatrix *datas, float start_angle,33 const Matrix *datas, float start_angle, 35 34 float end_angle, uint32_t nb_samples) 36 35 : SendData(position, name, "RangeFinderPlot", 200) { 37 36 this->datas = datas; 38 37 Warn("RangeFinderPlot::CopyDatas needs to be written\n"); 39 38 SetSendSize(datas->GetDataType().GetSize()); 40 39 … … 59 58 60 59 void RangeFinderPlot::CopyDatas(char *buf) const { 61 datas->GetMutex(); 62 memcpy(buf, datas->getCvMat()->data.ptr, datas->GetDataType().GetSize()); 63 datas->ReleaseMutex(); 60 //datas->CopyDatas(buf); 64 61 } 65 62 -
trunk/lib/FlairCore/src/RangeFinderPlot.h
r15 r214 20 20 namespace flair { 21 21 namespace core { 22 class cvmatrix;22 class Matrix; 23 23 } 24 24 } … … 61 61 std::string x_name, float xmin, float xmax, 62 62 std::string y_name, float ymin, float ymax, 63 const core:: cvmatrix *datas, float start_angle,63 const core::Matrix *datas, float start_angle, 64 64 float end_angle, uint32_t nb_samples); 65 65 … … 87 87 void ExtraXmlEvent(void){}; 88 88 89 const core:: cvmatrix *datas;89 const core::Matrix *datas; 90 90 }; 91 91 -
trunk/lib/FlairCore/src/cvmatrix.cpp
r15 r214 37 37 this->col = col; 38 38 if (row >= matrix->Rows() || col >= matrix->Cols()) { 39 matrix->Err("index (%i,%i) out of bound (%i,%i)\n", row, col,39 matrix->Err("index (%i,%i) out of bound, max (%i,%i)\n", row, col, 40 40 matrix->Rows() - 1, matrix->Cols() - 1); 41 41 size = 0; … … 133 133 if (row >= (uint32_t)pimpl_->mat->rows || 134 134 col >= (uint32_t)pimpl_->mat->cols) { 135 Warn("index (%i,%i) out of bound (%i,%i)\n", row, col,135 Warn("index (%i,%i) out of bound, max (%i,%i)\n", row, col, 136 136 pimpl_->mat->rows - 1, pimpl_->mat->cols - 1); 137 137 return 0; … … 148 148 if (row >= (uint32_t)pimpl_->mat->rows || 149 149 col >= (uint32_t)pimpl_->mat->cols) { 150 Warn("index (%i,%i) out of bound (%i,%i)\n", row, col,150 Warn("index (%i,%i) out of bound, max (%i,%i)\n", row, col, 151 151 pimpl_->mat->rows - 1, pimpl_->mat->cols - 1); 152 152 return 0; … … 159 159 if (row >= (uint32_t)pimpl_->mat->rows || 160 160 col >= (uint32_t)pimpl_->mat->cols) { 161 Warn("index (%i,%i) out of bound (%i,%i)\n", row, col,161 Warn("index (%i,%i) out of bound, max (%i,%i)\n", row, col, 162 162 pimpl_->mat->rows - 1, pimpl_->mat->cols - 1); 163 163 } else { … … 171 171 if (row >= (uint32_t)pimpl_->mat->rows || 172 172 col >= (uint32_t)pimpl_->mat->cols) { 173 Warn("index (%i,%i) out of bound (%i,%i)\n", row, col,173 Warn("index (%i,%i) out of bound, max (%i,%i)\n", row, col, 174 174 pimpl_->mat->rows - 1, pimpl_->mat->cols - 1); 175 175 } else { -
trunk/lib/FlairCore/src/cvmatrix_descriptor.cpp
r15 r214 46 46 string name) { 47 47 if (row >= rows || col >= cols) { 48 getFrameworkManager()->Err("index out of bound %s (%i,%i), range(%i,%i)\n",48 getFrameworkManager()->Err("index out of bound %s (%i,%i), max (%i,%i)\n", 49 49 name.c_str(), row, col, rows - 1, cols - 1); 50 50 return; … … 55 55 string cvmatrix_descriptor::ElementName(uint32_t row, uint32_t col) const { 56 56 if (row >= rows || col >= cols) { 57 getFrameworkManager()->Err("index out of bound (%i,%i), range(%i,%i)\n",57 getFrameworkManager()->Err("index out of bound (%i,%i), max (%i,%i)\n", 58 58 row, col, rows - 1, cols - 1); 59 59 return *element_names[0]; // safe value... -
trunk/lib/FlairCore/src/unexported/Matrix_impl.h
r213 r214 33 33 flair::core::ScalarType const &elementDataType; 34 34 flair::core::cvmatrix_descriptor *descriptor; 35 float **datas; 35 void *datas; 36 void SetValueNoMutex(uint32_t row, uint32_t col, float value); 37 float ValueNoMutex(uint32_t row, uint32_t col) const; 36 38 37 39 private: -
trunk/lib/FlairCore/src/unexported/config.h
r213 r214 27 27 28 28 // nrt pipe size 29 #define NRT_PIPE_SIZE 1024 * 100 29 #define NRT_PIPE_SIZE 1024 * 100*10 30 30 31 31 // rt log heap size
Note:
See TracChangeset
for help on using the changeset viewer.