42 #include <visp/vpConfig.h>
44 #ifdef VISP_MOMENTS_COMBINE_MATRICES
48 #include <visp/vpMomentObject.h>
49 #include <visp/vpFeatureMomentCentered.h>
50 #include <visp/vpFeatureMomentBasic.h>
51 #include <visp/vpFeatureMomentGravityCenter.h>
52 #include <visp/vpMomentGravityCenter.h>
53 #include <visp/vpFeatureMomentDatabase.h>
64 double A_,
double B_,
double C_,
80 "The requested value has not been computed, you should specify a higher order.");
94 bool found_featuremoment_basic;
95 bool found_feature_gravity_center;
96 bool found_moment_gravity;
108 for(
int i=0;i<6;i++) zeros[0][i]=0;
118 for(
int i=0;i<(int)order;i++){
119 for(
int j=0;j<(int)order-i;j++){
124 for(
int k=0;k<=i;k++){
125 for(
int l=0;l<=j;l++){
126 mat1+= std::abs(momentGravity.
get()[0])<std::numeric_limits<double>::epsilon()?zeros:
vpMath::comb((
unsigned int)i, (
unsigned int)k) *
vpMath::comb((
unsigned int)j, (
unsigned int)l) * pow(-momentGravity.
get()[0], i - k) * (i - k) * LXg / momentGravity.
get()[0] * pow(-momentGravity.
get()[1], j - l) * momentObject.
get((
unsigned int)k, (
unsigned int)l);
127 mat2+= std::abs(momentGravity.
get()[1])<std::numeric_limits<double>::epsilon()?zeros:
vpMath::comb((
unsigned int)i, (
unsigned int)k) *
vpMath::comb((
unsigned int)j, (
unsigned int)l) * pow(-momentGravity.
get()[0], i - k) * pow(-momentGravity.
get()[1], j - l) * (j - l) * LYg / momentGravity.
get()[1] * momentObject.
get((
unsigned int)k, (
unsigned int)l);
128 mat3+=
vpMath::comb((
unsigned int)i, (
unsigned int)k) *
vpMath::comb((
unsigned int)j, (
unsigned int)l) * pow(-momentGravity.
get()[0], i - k) * pow(-momentGravity.
get()[1], j - l) * featureMomentBasic.
interaction((
unsigned int)k, (
unsigned int)l);
141 #include <visp/vpMomentObject.h>
142 #include <visp/vpMomentGravityCenter.h>
143 #include <visp/vpMomentCentered.h>
144 #include <visp/vpFeatureMomentCentered.h>
145 #include <visp/vpFeatureMomentDatabase.h>
183 bool found_moment_centered;
184 bool found_moment_gravity;
206 double n11 = momentCentered.
get(1,1)/momentObject.
get(0,0);
207 double n20 = momentCentered.
get(2,0)/momentObject.
get(0,0);
208 double n02 = momentCentered.
get(0,2)/momentObject.
get(0,0);
209 double Xg = momentGravity.
getXg();
210 double Yg = momentGravity.
getYg();
211 double mu00 = momentCentered.
get(0,0);
232 for (
int i=1; i<(int)order-1; i++){
233 unsigned int i_ = (
unsigned int) i;
234 unsigned int im1_ = i_ - 1;
235 unsigned int ip1_ = i_ + 1;
237 double mu_im10 = momentCentered.
get(im1_,0);
238 double mu_ip10 = momentCentered.
get(ip1_,0);
239 double mu_im11 = momentCentered.
get(im1_,1);
240 double mu_i0 = momentCentered.
get(i_,0);
241 double mu_i1 = momentCentered.
get(i_,1);
243 interaction_matrices[i_][0][VX] = -(i+delta)*
A*mu_i0-(i*
B*mu_im11);
244 interaction_matrices[i_][0][VY] = -(delta)*
B*mu_i0;
246 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;
247 interaction_matrices[i_][0][WY] = -(i+3*delta)*mu_ip10-(2*i+3*delta)*Xg*mu_i0+i*epsilon*n20*mu_im10;
248 interaction_matrices[i_][0][VZ] = -
A*interaction_matrices[i_][0][WY]+
B*interaction_matrices[i_][0][WX]+(i+2*delta)*
C*mu_i0;
249 interaction_matrices[i_][0][WZ] = i*mu_im11;
252 for(
int j=1;j<(int)order-1;j++){
253 unsigned int j_ = (
unsigned int) j;
254 unsigned int jm1_ = j_ - 1;
255 unsigned int jp1_ = j_ + 1;
257 double mu_0jm1 = momentCentered.
get(0,jm1_);
258 double mu_0jp1 = momentCentered.
get(0,jp1_);
259 double mu_1jm1 = momentCentered.
get(1,jm1_);
260 double mu_0j = momentCentered.
get(0,j_);
261 double mu_1j = momentCentered.
get(1,j_);
263 interaction_matrices[j_*
order][0][VX] = -(delta)*
A*mu_0j;
264 interaction_matrices[j_*
order][0][VY] = -j*
A*mu_1jm1-(j+delta)*
B*mu_0j;
266 interaction_matrices[j_*
order][0][WX] = (j+3*delta)*mu_0jp1+(2*j+3*delta)*Yg*mu_0j-j*epsilon*n02*mu_0jm1;
267 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;
268 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;
269 interaction_matrices[j_*
order][0][WZ] = -j*mu_1jm1;
272 for(
int j=1; j<(int)order-1; j++) {
273 unsigned int j_ = (
unsigned int) j;
274 unsigned int jm1_ = j_ - 1;
275 unsigned int jp1_ = j_ + 1;
276 for(
int i=1; i<(int)order-j-1; i++) {
277 unsigned int i_ = (
unsigned int) i;
278 unsigned int im1_ = i_ - 1;
279 unsigned int ip1_ = i_ + 1;
281 double mu_ijm1 = momentCentered.
get(i_,jm1_);
282 double mu_ij = momentCentered.
get(i_,j_);
283 double mu_ijp1 = momentCentered.
get(i_,jp1_);
284 double mu_im1j = momentCentered.
get(im1_,j_);
285 double mu_im1jp1 = momentCentered.
get(im1_,jp1_);
286 double mu_ip1jm1 = momentCentered.
get(ip1_,jm1_);
287 double mu_ip1j = momentCentered.
get(ip1_,j_);
289 interaction_matrices[j_*order+i_][0][VX] = -(i+delta)*
A*mu_ij-i*
B*mu_im1jp1;
290 interaction_matrices[j_*order+i_][0][VY] = -j*
A*mu_ip1jm1-(j+delta)*
B*mu_ij;
292 interaction_matrices[j_*order+i_][0][WX] = (i+j+3*delta)*mu_ijp1+(i+2*j+3*delta)*Yg*mu_ij
293 +i*Xg*mu_im1jp1-i*epsilon*n11*mu_im1j-j*epsilon*n02*mu_ijm1;
294 interaction_matrices[j_*order+i_][0][WY] = -(i+j+3*delta)*mu_ip1j-(2*i+j+3*delta)*Xg*mu_ij
295 -j*Yg*mu_ip1jm1+i*epsilon*n20*mu_im1j+j*epsilon*n11*mu_ijm1;
296 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;
297 interaction_matrices[j_*order+i_][0][WZ] = i*mu_im1jp1-j*mu_ip1jm1;
303 vpTRACE(
" << CENTRED MOMENTS >>");
304 unsigned int order_m_1 = (
unsigned int)(mu.
order - 1);
305 for(
unsigned int i=0; i<order_m_1; i++){
306 for(
unsigned int j=0; j<order_m_1-i; j++){
307 std::cout <<
"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)
Definition of the vpMatrix class.
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
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 .
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)
std::ostream & matlabPrint(std::ostream &os) const
Print using matlab syntax, to be put in matlab later.
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