MomentBasic¶
- class MomentBasic(self)¶
Bases:
Moment
This class defines the 2D basic moment \(m_{ij}\) . This class is a wrapper for vpMomentObject which allows to use it as a moment. This enables all common operations such as adding to a vpMomentDatabase .
In the case of a dense object O , 2D basic moments are defined by:
\[m_{ij} = \int \int_{O} x^j y^j dx dy\]In the case of a discrete set of n points, the basic moments are defined by
\[m_{ij} = \sum_{k=1}^{n} x_k^j y_k^j \]The selection of a dense or discrete object is done in vpMomentObject . The maximum order of vpMomentBasic is the same as that of vpMomentObject (ie: \(i+j \leq\) vpMomentObject::getOrder ).
Note that in the continuous case, the basic moment \(m_{00}\) corresponds to the surface \(a\) of the object. In the discrete case, it is the number of discrete points \(n\) .
Default constructor.
Methods
Default constructor.
Dummy function.
Overloaded function.
Moment name.
Overloaded function.
Inherited Methods
Updates the moment with the current object.
Links the moment to a database of moment primitives.
Operators
__doc__
Default constructor.
__module__
__repr__
Attributes
__annotations__
- __init__(self)¶
Default constructor.
- get(*args, **kwargs)¶
Overloaded function.
get(self: visp._visp.core.MomentBasic) -> list[float]
Same behaviour as vpMomentObject .
- Returns:
all computed moments.
get(self: visp._visp.core.MomentBasic, i: int, j: int) -> float
Same behaviour as vpMomentObject .
- Parameters:
- i
first index of the 2D moment.
- j
second index of the 2D moment.
- Returns:
\(m_{ij}\) moment.
get(self: visp._visp.core.Moment) -> list[float]
- Returns:
vector of values
- getObject(self) visp._visp.core.MomentObject ¶
- linkTo(self, moments: visp._visp.core.MomentDatabase) None ¶
Links the moment to a database of moment primitives. If the moment depends on other moments, these moments must be linked to the same database.
Warning
Two moments of the same class cannot be stored in the same database
#include <visp3/core/vpMomentCentered.h> #include <visp3/core/vpMomentDatabase.h> #include <visp3/core/vpMomentGravityCenter.h> #include <visp3/core/vpMomentObject.h> #include <visp3/core/vpPoint.h> #ifdef ENABLE_VISP_NAMESPACE using namespace VISP_NAMESPACE_NAME; #endif int main() { vpPoint p; std::vector<vpPoint> vec_p; p.set_x(1); p.set_y(1); // coordinates in meters in the image plane (vertex 1) vec_p.push_back(p); p.set_x(2); p.set_y(2); // coordinates in meters in the image plane (vertex 2) vec_p.push_back(p); vpMomentObject obj(2); obj.setType(vpMomentObject::DISCRETE); // Discrete mode. obj.fromVector(vec_p); // Init the dense object with the polygon vpMomentDatabase db; vpMomentGravityCenter G; // declaration of gravity center vpMomentCentered mc; // mc contains centered moments G.linkTo(db); // add gravity center to database mc.linkTo(db); // centered moments depend on gravity, add them to the // database to grant access G.update(obj); // specify the object for gravity center mc.update(obj); // and for centered moments G.compute(); // compute the moment mc.compute(); // compute centered moments AFTER gravity center return 0; }
- printDependencies(*args, **kwargs)¶
Overloaded function.
printDependencies(self: visp._visp.core.MomentBasic, os: std::ostream) -> None
No dependencies on other vpMoments, since basic moments are computed in vpMomentObject Just prints the basic moments in vpMomentObject with indices
printDependencies(self: visp._visp.core.Moment, os: std::ostream) -> None
Prints values of all dependent moments required to calculate a specific vpMoment . Not made pure to maintain compatibility Recommended : Types inheriting from vpMoment should implement this function
- update(self, object: visp._visp.core.MomentObject) None ¶
Updates the moment with the current object. This does not compute any values.