source: flair-dev/trunk/include/FlairCore/cvmatrix.h@ 12

Last change on this file since 12 was 2, checked in by Sanahuja Guillaume, 9 years ago

initial commit flaircore

File size: 6.0 KB
Line 
1// %flair:license{
2// This file is part of the Flair framework distributed under the
3// CECILL-C License, Version 1.0.
4// %flair:license}
5/*!
6 * \file cvmatrix.h
7 * \brief Class defining a matrix of kind CvMat
8 * \author Guillaume Sanahuja, Copyright Heudiasyc UMR UTC/CNRS 7253
9 * \date 2012/03/21
10 * \version 4.0
11 */
12
13#ifndef CVMATRIX_H
14#define CVMATRIX_H
15
16#include <io_data.h>
17#include <IODataElement.h>
18#include <cvmatrix_descriptor.h>
19
20class cvmatrix_impl;
21struct CvMat;
22
23namespace flair { namespace core {
24
25 /*! \class cvmatrix
26 *
27 * \brief Class defining a matrix of kind CvMat
28 *
29 * CvMat is a matrix struct defined in OpenCV.
30 *
31 */
32 class cvmatrix: public io_data {
33 public:
34 class Type: public DataType {
35 public:
36 Type(size_t _nbRows,size_t _nbCols,ScalarType const &_elementDataType):nbRows(_nbRows),nbCols(_nbCols),elementDataType(_elementDataType) {}
37 size_t GetSize() const {
38 return nbRows*nbCols*elementDataType.GetSize();
39 }
40 std::string GetDescription() const {return "matrix";}
41 size_t GetNbRows() const {return nbRows;}
42 size_t GetNbCols() const {return nbCols;}
43 ScalarType const &GetElementDataType() const {return elementDataType;}
44
45 private:
46 size_t nbRows,nbCols;
47 ScalarType const &elementDataType;
48 };
49
50 /*!
51 * \brief Constructor
52 *
53 * Construct an io_data representing a CvMat. \n
54 * It uses a cvmatrix_descriptor to get size and elements' names. \n
55 * Names are used for graphs and logs.
56 *
57 * \param parent parent
58 * \param descriptor matrix description
59 * \param type type of matrix elements
60 * \param name name
61 * \param n number of samples
62 */
63 cvmatrix(const Object* parent,const cvmatrix_descriptor *descriptor, ScalarType const &elementDataType,std::string name="",uint32_t n=1);
64
65 /*!
66 * \brief Constructor
67 *
68 * Construct an io_data representing a CvMat. \n
69 * Elements are unamed.
70 *
71 * \param parent parent
72 * \param rows matrix rows
73 * \param cols matrix cols
74 * \param type type of matrix elements
75 * \param name name
76 * \param n number of samples
77 */
78 cvmatrix(const Object* parent,uint32_t rows, uint32_t cols, ScalarType const &elementDataType,std::string name="",uint32_t n=1);
79
80 /*!
81 * \brief Destructor
82 *
83 */
84 ~cvmatrix();
85
86 /*!
87 * \brief Element value
88 *
89 * Element is accessed by locking and unlocking the io_data Mutex.
90 *
91 * \param row element row
92 * \param col element col
93 *
94 * \return element value
95 */
96 float Value(uint32_t row, uint32_t col) const;
97
98 /*!
99 * \brief Element value
100 *
101 * Element is not accessed by locking and unlocking the io_data Mutex. \n
102 * Thus, this function should be called with Mutex locked. \n
103 * This function is usefull when multiple successive access are done to the
104 * elments of the matrix. It avoids unnecessary locking and unlocking.
105 *
106 * \param row element row
107 * \param col element col
108 *
109 * \return element value
110 */
111 float ValueNoMutex(uint32_t row, uint32_t col) const;
112
113 /*!
114 * \brief Set element value
115 *
116 * Element is accessed by locking and unlocking the io_data Mutex.
117 *
118 * \param row element row
119 * \param col element col
120 * \param value element value
121 */
122 void SetValue(uint32_t row, uint32_t col,float value);
123
124 /*!
125 * \brief Set element value
126 *
127 * Element is not accessed by locking and unlocking the io_data Mutex. \n
128 * Thus, this function should be called with Mutex locked. \n
129 * This function is usefull when multiple successive access are done to the
130 * elments of the matrix. It avoids unnecessary locking and unlocking.
131 *
132 * \param row element row
133 * \param col element col
134 * \param value element value
135 */
136 void SetValueNoMutex(uint32_t row, uint32_t col,float value);
137
138 /*!
139 * \brief get CvMat
140 *
141 * The io_data Mutex must be used by the user.
142 */
143 CvMat* getCvMat(void) const;
144
145 /*!
146 * \brief Element name
147 *
148 * If cvmatrix was created without cvmatrix_descriptor, element name is empty.
149 *
150 * \param row element row
151 * \param col element col
152 *
153 * \return element name
154 */
155 std::string Name(uint32_t row, uint32_t col) const;
156
157 /*!
158 * \brief Element
159 *
160 * Get a pointer to a specific element. This pointer can be used for plotting.
161 *
162 * \param row element row
163 * \param col element col
164 *
165 * \return pointer to the element
166 */
167 IODataElement* Element(uint32_t row, uint32_t col) const;
168
169 /*!
170 * \brief Element
171 *
172 * Get a pointer to a specific element. This pointer can be used for plotting. \n
173 * This function can be used for a 1D matrix.
174 *
175 * \param index element index
176 *
177 * \return pointer to the element
178 */
179 IODataElement* Element(uint32_t index) const;
180
181 /*!
182 * \brief Number of rows
183 *
184 * \return rows
185 */
186 uint32_t Rows(void) const;
187
188 /*!
189 * \brief Number of colomns
190 *
191 * \return colomns
192 */
193 uint32_t Cols(void) const;
194
195 Type const &GetDataType() const {return dataType;};
196
197 private:
198 /*!
199 * \brief Copy datas
200 *
201 * Reimplemented from io_data. \n
202 * See io_data::CopyDatas.
203 *
204 * \param dst destination buffer
205 */
206 void CopyDatas(char* dst) const;
207
208 class cvmatrix_impl* pimpl_;
209 Type dataType;
210 };
211
212} // end namespace core
213} // end namespace flair
214
215#endif // CVMATRIX_H
Note: See TracBrowser for help on using the repository browser.