[14] | 1 | // created: 2013/06/27
|
---|
| 2 | // filename: MeanFilter.h
|
---|
| 3 | //
|
---|
| 4 | // author: Guillaume Sanahuja
|
---|
| 5 | // Copyright Heudiasyc UMR UTC/CNRS 7253
|
---|
| 6 | //
|
---|
| 7 | // version: $Id: $
|
---|
| 8 | //
|
---|
| 9 | // purpose: object computing a mean filter
|
---|
| 10 | //
|
---|
| 11 | //
|
---|
| 12 | /*********************************************************************/
|
---|
| 13 |
|
---|
| 14 | #ifndef MEANFILTER_H
|
---|
| 15 | #define MEANFILTER_H
|
---|
| 16 |
|
---|
[16] | 17 | // we fix the max number of elements to compute the mean
|
---|
| 18 | // this is a simple example, it should be dynamical
|
---|
[14] | 19 | #define MAX_NUMBER_OF_ELEMENTS 200
|
---|
| 20 |
|
---|
[16] | 21 | // necessary include, as IODevice is a base of our class
|
---|
[14] | 22 | #include <IODevice.h>
|
---|
| 23 |
|
---|
[16] | 24 | // forward declaration for other classes
|
---|
[14] | 25 | namespace flair {
|
---|
[16] | 26 | namespace core {
|
---|
| 27 | class cvmatrix;
|
---|
[14] | 28 | }
|
---|
[16] | 29 | namespace gui {
|
---|
| 30 | class LayoutPosition;
|
---|
| 31 | class GroupBox;
|
---|
| 32 | class SpinBox;
|
---|
| 33 | }
|
---|
| 34 | }
|
---|
[14] | 35 |
|
---|
[16] | 36 | // MeanFilter is a class computing a mean
|
---|
[14] | 37 | // based on a parametrizable number of elements
|
---|
| 38 | // it derives on IODevice as it as an input and an output
|
---|
| 39 | // it is a filter, we extend the namespace
|
---|
[16] | 40 | namespace flair {
|
---|
| 41 | namespace filter {
|
---|
| 42 | class MeanFilter : public core::IODevice {
|
---|
[14] | 43 |
|
---|
[16] | 44 | public:
|
---|
| 45 | /*!
|
---|
| 46 | * \brief Constructor
|
---|
| 47 | *
|
---|
| 48 | * Builds a mean filter. \n
|
---|
| 49 | * After calling this function, position will be deleted as it is no longer
|
---|
| 50 | *usefull. \n
|
---|
| 51 | *
|
---|
| 52 | * \param parent IODevice to use as parent
|
---|
| 53 | * \param position where to place settings
|
---|
| 54 | * \param name name of the object
|
---|
| 55 | */
|
---|
| 56 | MeanFilter(const core::IODevice *parent, const gui::LayoutPosition *position,
|
---|
| 57 | std::string name);
|
---|
[14] | 58 |
|
---|
[16] | 59 | /*!
|
---|
| 60 | * \brief Destructor
|
---|
| 61 | */
|
---|
| 62 | ~MeanFilter();
|
---|
[14] | 63 |
|
---|
[16] | 64 | /*!
|
---|
| 65 | * \brief Output matrix
|
---|
| 66 | *
|
---|
| 67 | * allows to access output matrix, to get signal value or to put it in a graph.
|
---|
| 68 | *\n
|
---|
| 69 | *
|
---|
| 70 | * \return pointer to the output matrix
|
---|
| 71 | */
|
---|
| 72 | core::cvmatrix *GetMatrix(void) const;
|
---|
[14] | 73 |
|
---|
[16] | 74 | /*!
|
---|
| 75 | * \brief Value
|
---|
| 76 | *
|
---|
| 77 | * this method is equivalent to GetMatrix()->Value(0,0)
|
---|
| 78 | *
|
---|
| 79 | * \return actual mean value
|
---|
| 80 | */
|
---|
| 81 | float GetValue(void) const;
|
---|
[14] | 82 |
|
---|
[16] | 83 | private:
|
---|
| 84 | // UpdateFrom method from base class IODevice
|
---|
| 85 | void UpdateFrom(const core::io_data *data);
|
---|
| 86 | gui::GroupBox *groupBox;
|
---|
| 87 | gui::SpinBox *numberOfElements;
|
---|
| 88 | core::cvmatrix *output;
|
---|
| 89 | float previousValues[MAX_NUMBER_OF_ELEMENTS]; // previous values storage
|
---|
| 90 | };
|
---|
| 91 | } // end namespace filter
|
---|
| 92 | } // end namespace flair
|
---|
[14] | 93 | #endif // MEANFILTER_H
|
---|