38 #include <visp3/core/vpConfig.h>
43 #include <visp3/core/vpMomentCentered.h>
44 #include <visp3/core/vpMomentGravityCenter.h>
45 #include <visp3/core/vpMomentObject.h>
46 #include <visp3/visual_features/vpFeatureMomentBasic.h>
47 #include <visp3/visual_features/vpFeatureMomentCentered.h>
48 #include <visp3/visual_features/vpFeatureMomentDatabase.h>
49 #include <visp3/visual_features/vpFeatureMomentGravityCenter.h>
61 double A_,
double B_,
double C_,
76 "The requested value has not been computed, you should specify a higher order.");
96 double pcombkqcombl = 0.0;
103 double minus1pow = 0.;
106 for (
unsigned int k = 0; k <=p; ++k)
110 for (
unsigned int l = 0; l <= q; ++l)
112 qml = (int)q - (
int)l;
114 minus1pow = pow((
double)-1, (
double)(pmk + qml));
115 pcombkqcombl = pcombk * qcombl;
117 pintom = pcombkqcombl * mkl;
120 term1 += pintom * pmk * pow(xg, pmk-1) * pow(yg, qml) * minus1pow;
122 term2 += pintom * qml * pow(xg, pmk) * pow(yg, qml-1) * minus1pow;
123 Lterm3 += pcombkqcombl * pow(xg, pmk) * pow(yg, qml) * L_mkl * minus1pow;
128 vpMatrix L_mupq = L_xg*term1 + L_yg*term2 + Lterm3;
144 #ifdef VISP_MOMENTS_COMBINE_MATRICES
151 bool found_moment_gravity;
154 double xg = momentGravity.
get()[0];
155 double yg = momentGravity.
get()[1];
157 bool found_feature_gravity_center;
163 bool found_moment_basic;
167 bool found_featuremoment_basic;
172 for(
int i=0;i<(int)order-1;i++){
173 for(
int j=0;j<(int)order-1-i;j++){
177 #else // #ifdef VISP_MOMENTS_COMBINE_MATRICES
178 bool found_moment_centered;
179 bool found_moment_gravity;
201 double n11 = momentCentered.
get(1,1)/momentObject.
get(0,0);
202 double n20 = momentCentered.
get(2,0)/momentObject.
get(0,0);
203 double n02 = momentCentered.
get(0,2)/momentObject.
get(0,0);
204 double Xg = momentGravity.
getXg();
205 double Yg = momentGravity.
getYg();
206 double mu00 = momentCentered.
get(0,0);
227 for (
int i=1; i<(int)order-1; i++){
228 unsigned int i_ = (
unsigned int) i;
229 unsigned int im1_ = i_ - 1;
230 unsigned int ip1_ = i_ + 1;
232 double mu_im10 = momentCentered.
get(im1_,0);
233 double mu_ip10 = momentCentered.
get(ip1_,0);
234 double mu_im11 = momentCentered.
get(im1_,1);
235 double mu_i0 = momentCentered.
get(i_,0);
236 double mu_i1 = momentCentered.
get(i_,1);
238 interaction_matrices[i_][0][VX] = -(i+delta)*
A*mu_i0-(i*
B*mu_im11);
239 interaction_matrices[i_][0][VY] = -(delta)*
B*mu_i0;
241 interaction_matrices[i_][0][WX] = (i+3*delta)*mu_i1+(i+3*delta)*Yg*mu_i0+i*Xg*mu_im11-i*epsilon*n11*mu_im10;
242 interaction_matrices[i_][0][WY] = -(i+3*delta)*mu_ip10-(2*i+3*delta)*Xg*mu_i0+i*epsilon*n20*mu_im10;
243 interaction_matrices[i_][0][VZ] = -
A*interaction_matrices[i_][0][WY]+
B*interaction_matrices[i_][0][WX]+(i+2*delta)*
C*mu_i0;
244 interaction_matrices[i_][0][WZ] = i*mu_im11;
247 for(
int j=1;j<(int)order-1;j++){
248 unsigned int j_ = (
unsigned int) j;
249 unsigned int jm1_ = j_ - 1;
250 unsigned int jp1_ = j_ + 1;
252 double mu_0jm1 = momentCentered.
get(0,jm1_);
253 double mu_0jp1 = momentCentered.
get(0,jp1_);
254 double mu_1jm1 = momentCentered.
get(1,jm1_);
255 double mu_0j = momentCentered.
get(0,j_);
256 double mu_1j = momentCentered.
get(1,j_);
258 interaction_matrices[j_*
order][0][VX] = -(delta)*
A*mu_0j;
259 interaction_matrices[j_*
order][0][VY] = -j*
A*mu_1jm1-(j+delta)*
B*mu_0j;
261 interaction_matrices[j_*
order][0][WX] = (j+3*delta)*mu_0jp1+(2*j+3*delta)*Yg*mu_0j-j*epsilon*n02*mu_0jm1;
262 interaction_matrices[j_*
order][0][WY] = -(j+3*delta)*mu_1j-(j+3*delta)*Xg*mu_0j-j*Yg*mu_1jm1+j*epsilon*n11*mu_0jm1;
263 interaction_matrices[j_*
order][0][VZ] = -
A*interaction_matrices[j_*
order][0][WY]+
B*interaction_matrices[j_*
order][0][WX]+(j+2*delta)*
C*mu_0j;
264 interaction_matrices[j_*
order][0][WZ] = -j*mu_1jm1;
267 for(
int j=1; j<(int)order-1; j++) {
268 unsigned int j_ = (
unsigned int) j;
269 unsigned int jm1_ = j_ - 1;
270 unsigned int jp1_ = j_ + 1;
271 for(
int i=1; i<(int)order-j-1; i++) {
272 unsigned int i_ = (
unsigned int) i;
273 unsigned int im1_ = i_ - 1;
274 unsigned int ip1_ = i_ + 1;
276 double mu_ijm1 = momentCentered.
get(i_,jm1_);
277 double mu_ij = momentCentered.
get(i_,j_);
278 double mu_ijp1 = momentCentered.
get(i_,jp1_);
279 double mu_im1j = momentCentered.
get(im1_,j_);
280 double mu_im1jp1 = momentCentered.
get(im1_,jp1_);
281 double mu_ip1jm1 = momentCentered.
get(ip1_,jm1_);
282 double mu_ip1j = momentCentered.
get(ip1_,j_);
284 interaction_matrices[j_*order+i_][0][VX] = -(i+delta)*
A*mu_ij-i*
B*mu_im1jp1;
285 interaction_matrices[j_*order+i_][0][VY] = -j*
A*mu_ip1jm1-(j+delta)*
B*mu_ij;
287 interaction_matrices[j_*order+i_][0][WX] = (i+j+3*delta)*mu_ijp1+(i+2*j+3*delta)*Yg*mu_ij
288 +i*Xg*mu_im1jp1-i*epsilon*n11*mu_im1j-j*epsilon*n02*mu_ijm1;
289 interaction_matrices[j_*order+i_][0][WY] = -(i+j+3*delta)*mu_ip1j-(2*i+j+3*delta)*Xg*mu_ij
290 -j*Yg*mu_ip1jm1+i*epsilon*n20*mu_im1j+j*epsilon*n11*mu_ijm1;
291 interaction_matrices[j_*order+i_][0][VZ] = -
A*interaction_matrices[j_*order+i_][0][WY]+
B*interaction_matrices[j_*order+i_][0][WX]+(i+j+2*delta)*
C*mu_ij;
292 interaction_matrices[j_*order+i_][0][WZ] = i*mu_im1jp1-j*mu_ip1jm1;
295 #endif // #ifdef VISP_MOMENTS_COMBINE_MATRICES
300 vpTRACE(
" << Ls - CENTRED MOMENTS >>");
301 unsigned int order_m_1 = (
unsigned int)(mu.
order - 1);
302 for(
unsigned int i=0; i<order_m_1; i++){
303 for(
unsigned int j=0; j<order_m_1-i; j++){
304 os <<
"L_mu[" << i <<
"," << j <<
"] = ";
Functionality computation for basic moment feature. Computes the interaction matrix associated with v...
vpFeatureMomentCentered(vpMomentDatabase &moments, double A, double B, double C, vpFeatureMomentDatabase *featureMoments=NULL)
Implementation of a matrix and operations on matrices.
This class defines the 2D basic moment . This class is a wrapper for vpMomentObject wich allows to us...
Functionality computation for centered moment feature. Computes the interaction matrix associated wit...
error that can be emited by ViSP classes.
Class for generic objects.
const std::vector< double > & get() const
const std::vector< double > & get() const
std::vector< vpMatrix > interaction_matrices
vpMatrix interaction(unsigned int select_one, unsigned int select_two) const
vpMatrix interaction(unsigned int select_one, unsigned int select_two) const
void compute_interaction()
This class allows to register all vpMoments so they can access each other according to their dependen...
vpMatrix interaction(const unsigned int select=FEATURE_ALL)
This class defines shared system methods/attributes for 2D moment features but no functional code...
const vpMoment & get(const char *type, bool &found) const
vpMomentDatabase & moments
This class defines the double-indexed centered moment descriptor .
friend std::ostream & operator<<(std::ostream &s, const vpArray2D< Type > &A)
double get(unsigned int i, unsigned int j) const
Class describing 2D gravity center moment.
vpObjectType getType() const
const std::vector< double > & get() const
vpFeatureMomentDatabase * featureMomentsDataBase
static long double comb(unsigned int n, unsigned int p)
vpMatrix compute_Lmu_pq(const unsigned int &p, const unsigned int &q, const double &xg, const double &yg, const vpMatrix &L_xg, const vpMatrix &L_yg, const vpMomentBasic &m, const vpFeatureMomentBasic &feature_moment_m) const
std::ostream & matlabPrint(std::ostream &os) const
const vpMomentObject & getObject() const
Functionality computation for gravity center moment feature. Computes the interaction matrix associat...
vpFeatureMoment & get(const char *type, bool &found)
This class allows to register all feature moments (implemented in vpFeatureMoment... classes) so they can access each other according to their dependencies.
unsigned int getOrder() const