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

Last change on this file since 28 was 13, checked in by Bayard Gildas, 9 years ago

formatting script + include reformatted

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