last update 20 Sep 2009 |
#include <cvrParametersManager.h>
Classes | |
class | parameters |
Base class for all lti parameter objects. More... | |
Public Member Functions | |
parametersManager () | |
parametersManager (const parametersManager &other) | |
virtual | ~parametersManager () |
virtual bool | setParameters (const parameters &theParam) |
virtual bool | useParameters (parameters &theParam) |
virtual bool | attachParameters (parameters &theParam) |
virtual bool | updateParameters () |
const parameters & | getParameters () const |
virtual bool | validParameters () const |
parametersManager & | copy (const parametersManager &other) |
virtual bool | write (ioHandler &handler, const bool complete=true) const |
virtual bool | read (ioHandler &handler, const bool complete=true) |
Protected Member Functions | |
parameters & | getParameters () |
Many classes in the CVR-Libmake use of internal parameter objects. This has proven to be a very flexible concept, not only useful in the serialization of the configuration of algorithms used, but also extremely practical in the reuse of functors and parameterizable objects within other parameterizable objects.
The parameters can then be set in this classes with help of several methods, where the setParameters() is the most important.
cvr::parametersManager::parametersManager | ( | ) |
Default constructor.
cvr::parametersManager::parametersManager | ( | const parametersManager & | other | ) |
Copy constructor.
virtual cvr::parametersManager::~parametersManager | ( | ) | [virtual] |
Destructor.
virtual bool cvr::parametersManager::attachParameters | ( | parameters & | theParam | ) | [virtual] |
Use the given parameters as they are but take control of the memory management.
This method is very similar to useParameters() and therefore you must pay attention to all warnings specified in the documentation of that method. The main difference is that this method takes control of the memory management of the given parameters instance. In other words, this method is used in extremely time critical situations when you must avoid that the parameters are copied, but you also want this manager to administrate the memory allocation for the given object.
This method always calls updateParameters(), task that will determine if here it is reported success or not. This means, even if the method returns false, the instance will have acquired control of the parameters instance and you must not remove the given instance yourself.
parametersManager& cvr::parametersManager::copy | ( | const parametersManager & | other | ) |
Copy data of "other" parametersManager.
Please note that the status string will _NOT_ be copied!
parameters& cvr::parametersManager::getParameters | ( | ) | [protected] |
Returns current parameters.
(non const! -> protected)
Reimplemented in cvr::viewer2DPainter, cvr::geometricTransformBase, cvr::geometricTransform< I >, cvr::matrixTransform< I >, cvr::noise, cvr::uniformDiscreteDistribution, and cvr::geometricTransform< I >.
const parameters& cvr::parametersManager::getParameters | ( | ) | const |
Returns current parameters.
Reimplemented in cvr::bresenhamCircle, cvr::bresenhamLine, cvr::viewer2DPainter, cvr::bilinearInterpolation< T >, cvr::boundaryExpansion, cvr::colorQuantization, cvr::contrastEnhancement, cvr::convexHull, cvr::fastHessianDetection, cvr::filledUpsampling, cvr::genericInterpolation< T >, cvr::geometricTransformBase, cvr::geometricTransform< I >, cvr::histogramEqualization, cvr::integralImage, cvr::kMColorQuantization, cvr::labelAdjacencyMap, cvr::locationDetection, cvr::locationMatch, cvr::matrixTransform< I >, cvr::nearestNeighborInterpolation< T >, cvr::splitImage, cvr::splitImageToRGB, cvr::surfLocalDescriptor, cvr::usePalette, cvr::ioBMP, cvr::ioImage, cvr::ioImageInterface, cvr::ioJPEG, cvr::ioPNG, cvr::loadImageList, cvr::affineTransformation2D, cvr::decompositionSolution< T >, cvr::distanceFunctor< T >, cvr::euclideanDistanceFunctor< T >, cvr::euclideanTransformation2D, cvr::fixedGridInterpolation< T >, cvr::linearAlgebraFunctor, cvr::linearLeastSquares, cvr::luDecomposition< T >, cvr::minimizeBasis, cvr::noise, cvr::normalDistribution, cvr::pca< T >, cvr::qrDecomposition< T >, cvr::qrSolution< T >, cvr::quickMedian, cvr::quickMedian2, cvr::randomDistribution, cvr::ransacEstimation< E >, cvr::secondOrderStatistics< T, U >, cvr::similarityTransformation2D, cvr::sort, cvr::sort2, cvr::svd, cvr::symmetricEigenSystem< T >, cvr::uniformContinuousDistribution, cvr::uniformDiscreteDistribution, cvr::validator, cvr::externViewer2D, cvr::viewer2D, cvr::viewerBase, cvr::geometricTransform< I >, cvr::decompositionSolution< T >, cvr::distanceFunctor< T >, and cvr::fixedGridInterpolation< T >.
virtual bool cvr::parametersManager::read | ( | ioHandler & | handler, | |
const bool | complete = true | |||
) | [virtual] |
Read the parametersManager from the given ioHandler.
The default implementation is to read just the parameters object.
Since this virtual method needs to know the exact type of the parameters to call the proper read method, it will just assume that the current parametersManager instance has a valid, consistent parameter set. If this is not the case, you need to reimplement the read method to set first a dummy parameter object or the correct type.
handler | the ioHandler to be used | |
complete | if true (the default) the enclosing begin/end will be also written, otherwise only the data block will be written. |
Reimplemented in cvr::functor, cvr::pca< T >, and cvr::randomDistribution.
virtual bool cvr::parametersManager::setParameters | ( | const parameters & | theParam | ) | [virtual] |
Set parametersManager's parameters.
This member makes a copy of theParam: the parametersManager will keep its own copy of the parameters!
Additionally, the updateParameters will be called, which in some classes is used to initialize some Look-Up Tables, or filters, etc., in order to improve the execution times later in the apply methods.
Since the CVR-Libfollows a deep-copy philosophy, if you copy the functor or other from parametersManager inherited class, the copy will create an exact copy of the parameters, no matter if they have been specified with useParameters() or with setParameters().
You should always prefer this method over useParameters(). The latter one is used only in very special cases, when the user needs to control an instance of parameters outside the functor/classifier or other inherited class, and he/she wants to take care of the memory management.
This method should never be overloaded. If you want to make some precomputations when setting the parameters, please overload updateParameters() instead.
virtual bool cvr::parametersManager::updateParameters | ( | ) | [virtual] |
Update parameters.
Some functors (or other classes inherited from parametersManagers) make some pre-computations when the parameters are set. For example, they initialize look-up tables, build some filter kernels, initialize some data structures, etc. This job is always done by updateParameters().
In principle, you only need to overload this method if you need such initializations, as setParameters() and useParameters() will always call this method.
For disobedient people, who ignore the recomendation of using setParameters() over useParameters(), this method should be called if attributes of the parameters instance are changed, before calling the apply() method. Otherwise, the internal functor state will be inconsistent with the parameters.
The useParameters() interface is provided to solve some critical efficiency issues in very complex functor structures and helping in the implementation of GUI based tools, in which you maybe want to change parameters on-line in an efficient way.
bool yourClass::updateParameters() { // get the set of parameters just indicated by the user const parameters& par = getParameters(); // do whatever you need to initialize with par bool success=true; ... // return true only if everything was ok. return success; }
The default implementation just returns true if the parameters have been set before, which is always the normal case.
Reimplemented in cvr::viewer2DPainter, cvr::fastHessianDetection, cvr::genericInterpolation< T >, cvr::geometricTransform< I >, cvr::histogramEqualization, cvr::integralImage, cvr::matrixTransform< I >, cvr::surfLocalDescriptor, cvr::usePalette, cvr::loadImageList, cvr::affineTransformation2D, cvr::euclideanTransformation2D, cvr::noise, cvr::normalDistribution, cvr::pca< T >, cvr::randomDistribution, cvr::ransacEstimation< E >, cvr::similarityTransformation2D, cvr::sort, cvr::uniformContinuousDistribution, cvr::uniformDiscreteDistribution, cvr::univariateContinuousDistribution, cvr::viewerBase, and cvr::geometricTransform< I >.
virtual bool cvr::parametersManager::useParameters | ( | parameters & | theParam | ) | [virtual] |
Use the given parameters exactly as they are.
The difference of this method with setParameters() is that the parameters will not be copied. They will be used exactly as they are given. It is therefore your responsability to ensure that the parameters instance you give exists as long as the parameterManager instace is being used.
Of course, if the parameters content is changed while the derived functor/classifier makes its computations, unpredictable behaviour has to be expected. It is also your responsibility to take care of all multi-threading details.
Since the CVR-Libfollows a deep-copy philosophy, if you copy the classes inherited from parametersManager, the copy will create an exact copy of the parameters, no matter if they have been specified with useParameters() or with setParameters().
The manager will not administrate the instance given through this method. If you create it with new, you have to take care about the deletion.
If you are not sure what to use, always prefer setParameters() since it is more secure than useParameters(), as the parametersManager will take care of all memory issues.
This method always calls updateParameters().
virtual bool cvr::parametersManager::validParameters | ( | ) | const [virtual] |
Returns true if the parameters are valid.
virtual bool cvr::parametersManager::write | ( | ioHandler & | handler, | |
const bool | complete = true | |||
) | const [virtual] |
Write the parametersManager in the given ioHandler.
The default implementation is to write just the parameters object.
handler | the ioHandler to be used | |
complete | if true (the default) the enclosing begin/end will be also written, otherwise only the data block will be written. |
Reimplemented in cvr::functor, cvr::pca< T >, and cvr::randomDistribution.