ViSP
2.8.0
|
#include <vpMomentObject.h>
Public Types | |
enum | vpObjectType { DENSE_FULL_OBJECT = 0, DENSE_POLYGON = 1, DISCRETE = 2 } |
Public Member Functions | |
vpMomentObject (unsigned int order) | |
void | fromImage (const vpImage< unsigned char > &image, unsigned char threshold, const vpCameraParameters &cam) |
void | fromVector (std::vector< vpPoint > &points) |
std::vector< double > & | get () |
double | get (unsigned int i, unsigned int j) const |
vpObjectType | getType () const |
unsigned int | getOrder () const |
void | setType (vpObjectType type) |
Friends | |
VISP_EXPORT std::ostream & | operator<< (std::ostream &os, const vpMomentObject &v) |
Class for generic objects.
It contains all basic moments often described by of order going from to the order used as parameter in vpMomentObject() constructor. All other moments implemented in ViSP (gravity center, alpha orientation, centered moments...) use this moment object as a combination of its different values.
When constructing a vpMomentObject() you need first to specify the maximum used moment order as parameter.
Then there are three ways to initialize a vpMomentObject. Firstly using fromImage() you can considerer a dense object O defined by a binary image. Secondly, as described in fromVector() you can also define a dense object O by a closed contour. In these two cases, 2D basic moments are defined by:
Lastly, as presented in fromVector() you can consider a discrete set of n points. In that last case, the basic moments are defined by
With setType() method you can specify the object type.
A few tips about which orders to use in different situations:
The following example shows how to create a moment object from 4 discrete points locate on a plane one meter in front of the camera. It shows also how to get the basic moments that are computed and how to compute other classical moments such as the gravity center or the centered moments.
This example produces the following results:
Note that in the continuous case, the moment object corresponds to the surface of the object. In the discrete case, it is the number of discrete points .
Definition at line 213 of file vpMomentObject.h.
Type of object that will be considered.
Definition at line 218 of file vpMomentObject.h.
vpMomentObject::vpMomentObject | ( | unsigned int | order | ) |
Default constructor. Initializes the object with the maximum used order. You cannot use higher order moments than the order of the moment object. The parameter specified is the highest desired included order. All orders up to this values will be computed. In other words, a vpMomentObject will compute all moments with .
order | : Maximum reached order (i+j) to be used. All considered i+j will be of order smaller or equal than this parameter. For example if this parameter is 5, all moment values of order 0 to 5 included will be computed. |
Definition at line 346 of file vpMomentObject.cpp.
void vpMomentObject::fromImage | ( | const vpImage< unsigned char > & | image, |
unsigned char | threshold, | ||
const vpCameraParameters & | cam | ||
) |
Computes basic moments from an image. There is no assumption made about whether the input is dense or discrete but it's more common to use vpMomentObject::DENSE_FULL_OBJECT with this method.
image | : Image to consider. |
threshold | : Pixels with a luminance lower than this threshold will be considered. |
cam | : Camera parameters used to convert pixels coordinates in meters in the image plane. |
The code below shows how to use this function.
Definition at line 264 of file vpMomentObject.cpp.
References vpPixelMeterConversion::convertPoint(), vpImage< Type >::getCols(), and vpImage< Type >::getRows().
void vpMomentObject::fromVector | ( | std::vector< vpPoint > & | points | ) |
Computes basic moments from a vector of points. There are two cases:
points | : Vector of points. |
The code below shows how to use this function to consider a dense object defined by a closed contour.
This other example shows how to consider an object as a discrete set of four points.
Definition at line 209 of file vpMomentObject.cpp.
References DENSE_POLYGON.
std::vector< double > & vpMomentObject::get | ( | ) |
Returns all basic moment values with and .
For example, if the maximal order is 3, the following values are provided:
To access for example to the basic moment m12, you should use this kind of code:
Definition at line 370 of file vpMomentObject.cpp.
Referenced by vpMomentArea::compute(), vpMomentCentered::compute(), vpMomentGravityCenter::compute(), vpMomentAreaNormalized::compute(), vpMomentCInvariant::compute(), vpFeatureMomentArea::compute_interaction(), vpFeatureMomentBasic::compute_interaction(), vpFeatureMomentCentered::compute_interaction(), vpFeatureMomentAreaNormalized::compute_interaction(), vpFeatureMomentCInvariant::compute_interaction(), vpFeatureMomentGravityCenter::compute_interaction(), vpFeatureMomentGravityCenterNormalized::compute_interaction(), and vpMomentBasic::get().
double vpMomentObject::get | ( | unsigned int | i, |
unsigned int | j | ||
) | const |
Returns the basic moment value corresponding to i,j indexes
i | : First moment index, with . |
j | : Second moment index, with . |
Definition at line 381 of file vpMomentObject.cpp.
References vpException::badValue, and getOrder().
|
inline |
Definition at line 236 of file vpMomentObject.h.
Referenced by vpMomentCentered::compute(), vpFeatureMomentBasic::compute_interaction(), vpFeatureMomentCentered::compute_interaction(), vpMomentCentered::get(), get(), vpFeatureMomentBasic::interaction(), and vpFeatureMomentCentered::interaction().
|
inline |
Definition at line 231 of file vpMomentObject.h.
Referenced by vpFeatureMomentArea::compute_interaction(), vpFeatureMomentBasic::compute_interaction(), vpFeatureMomentCentered::compute_interaction(), vpFeatureMomentAlpha::compute_interaction(), vpFeatureMomentAreaNormalized::compute_interaction(), vpFeatureMomentCInvariant::compute_interaction(), vpFeatureMomentGravityCenter::compute_interaction(), and vpFeatureMomentGravityCenterNormalized::compute_interaction().
|
inline |
Specifies the type of the input data.
type | : An input type. |
Definition at line 241 of file vpMomentObject.h.
|
friend |
Outputs the basic moment's values to a stream presented as a matrix. The first line corresponds to , the second one to Values in table corresponding to a higher order are marked with an "x" and not computed.
For example, if the maximal order is 3, the following values are provided:
Definition at line 403 of file vpMomentObject.cpp.