示例#1
0
/*!
  Has the area \f$ a = m_{00} = \mu_{00} \f$.
  Gets the value of m00 from vpMomentCentered.
*/
void vpMomentArea::compute(){
    /* getObject() returns a reference to a vpMomentObject. This is public member of vpMoment */
    if(getObject().getType()==vpMomentObject::DISCRETE) {
    	bool found_moment_centered;
		/*   getMoments() returns a reference to a vpMomentDatabase. It is a protected member of and is inherited from vpMoment
		 *  .get() is a member function of vpMomentDatabase that returns a specific moment which is linked to it
		 */
		const vpMomentCentered& momentCentered = static_cast<const vpMomentCentered&>(getMoments().get("vpMomentCentered",found_moment_centered));
		if(!found_moment_centered) throw vpException(vpException::notInitialized,"vpMomentCentered not found");
		values[0] = momentCentered.get(2,0) + momentCentered.get(0,2);
    }
    else {
    	values[0] = getObject().get(0,0);
    }
}
示例#2
0
/*!
Prints dependencies namely,
1. Depth at desired pose Z*
2. Area moment at desired pose
   m00* if DENSE moment object, (mu20* + mu02*) if DISCRETE moment object
3. Area moment at current pose
   m00 if DENSE moment object, (mu20 + mu02) if DISCRETE moment object
*/
void vpMomentAreaNormalized::printDependencies(std::ostream& os) const{
    os << (__FILE__) << std::endl;
    os << "Desired depth Z* = " << desiredDepth << std::endl;
    os << "Desired area m00* = " << desiredSurface << std::endl;

    bool found_moment_centered;
    const vpMomentCentered& momentCentered = static_cast<const vpMomentCentered&>(getMoments().get("vpMomentCentered",found_moment_centered));
    if(!found_moment_centered)
        throw vpException(vpException::notInitialized,"vpMomentCentered not found");

    double a;
    if(getObject().getType()==vpMomentObject::DISCRETE)
        a = momentCentered.get(2,0)+momentCentered.get(0,2);
    else
        a = getObject().get(0,0);
    os << "a = " << a << std::endl;
}
示例#3
0
/*!
If the vpMomentObject type is
1. DISCRETE(set of discrete points), uses mu20+mu02
2. DENSE_FULL_OBJECT(from image) used mu00
*/
void vpMomentArea::printDependencies(std::ostream& os) const{
    os << (__FILE__) << std::endl;

    bool found_moment_centered;
    const vpMomentCentered& momentCentered = static_cast<const vpMomentCentered&>(getMoments().get("vpMomentCentered",found_moment_centered));
    if(!found_moment_centered) throw vpException(vpException::notInitialized,"vpMomentCentered not found");

    if(getObject().getType()==vpMomentObject::DISCRETE)
    {
        os << "mu20 = " << momentCentered.get(2, 0) << "\t";
        os << "mu02 = " << momentCentered.get(0, 2) << std::endl;
    }
    else
    {
        os << "mu00 = " << momentCentered.get(0, 0) << std::endl;
    }
}
示例#4
0
/*!
  Computes translation-plane-rotation-scale invariants.
  Depends on vpMomentCentered.
  All possible invariants are computed here. The selection of the invariant is done afterwards.
*/
void vpMomentCInvariant::compute(){
    if(getObject().getOrder()<5) throw vpException(vpException::notInitialized,"Order is not high enough for vpMomentCInvariant. Specify at least order 5.");
    bool found_moment_centered;
    const vpMomentCentered& momentCentered = (static_cast<const vpMomentCentered&>(getMoments().get("vpMomentCentered",found_moment_centered)));

    if(!found_moment_centered) throw vpException(vpException::notInitialized,"vpMomentCentered not found");

    computeI(momentCentered,I);
    double II3_2 = II[3]*II[3];
    double II3_3 = II3_2*II[3];

    double a;
    if(getObject().getType()==vpMomentObject::DISCRETE)
        a = momentCentered.get(2,0)+momentCentered.get(0,2);
    else
        a = getObject().get(0,0);

    values[0] = I[1]/I[2];
    values[1] = I[3]/I[4];

    values[2] = I[5]/I[6];

    values[3] = I[7]/I[6];

    values[4] = I[8]/I[6];

    values[5] = I[9]/I[6];

    values[6] = I[11]/I[10];

    values[7] = I[12]/I[10];

    values[8] = I[13]/I[15];

    values[9] = I[14]/I[15];

    if (flg_sxsynormalization_)
        calcSxSyNormalized(values[10], values[11]);
    else
        calcSxSy(values[10], values[11]);

    values[12] = II[1]/(II3_2);         // Px
    values[13] = a*II[2]/(II3_3);       // Py
}
示例#5
0
/*!
  Computes the normalized area \f$ a_n=Z^* \sqrt{\frac{a^*}{a}} \f$.
  Depends on vpMomentCentered.
*/
void vpMomentAreaNormalized::compute(){
    bool found_moment_centered;        
    
    /* getMoments() returns a reference to a vpMomentDatabase. (a protected member inherited from vpMoment)
      .get() 		is a member function of vpMomentDatabase that returns a specific moment which is linked to it*/
    const vpMomentCentered& momentCentered = static_cast<const vpMomentCentered&>(getMoments().get("vpMomentCentered",found_moment_centered));

    if(!found_moment_centered) throw vpException(vpException::notInitialized,"vpMomentCentered not found");

    double a;
    /* getObject() returns a reference to the vpMomentObject from which
     * the moment values are calculated. (public member of vpMoment)*/
    if(getObject().getType()==vpMomentObject::DISCRETE)
        a = momentCentered.get(2,0)+momentCentered.get(0,2);
    else
        a = getObject().get(0,0);

    values[0] = desiredDepth*sqrt(desiredSurface/a);
}
/*!
Prints the dependent moments,
1. centre of gravity
2. normalized area moment
*/
void  vpMomentGravityCenterNormalized::printDependencies(std::ostream& os) const{
    os << (__FILE__) << std::endl;
    bool found_moment_gravity;
    bool found_moment_surface_normalized;

    const vpMomentAreaNormalized& momentSurfaceNormalized = static_cast<const vpMomentAreaNormalized&>(getMoments().get("vpMomentAreaNormalized",found_moment_surface_normalized));
    const vpMomentGravityCenter& momentGravity = static_cast<const vpMomentGravityCenter&>(getMoments().get("vpMomentGravityCenter",found_moment_gravity));

    if(!found_moment_surface_normalized) throw vpException(vpException::notInitialized,"vpMomentAreaNormalized not found");
    if(!found_moment_gravity) throw vpException(vpException::notInitialized,"vpMomentGravityCenter not found");
    os << "Xg = " << momentGravity.get()[0] << "\t" << "Yg = " << momentGravity.get()[1] << std::endl;
    os << "An = " << momentSurfaceNormalized.get()[0] << std::endl;
}
/*!
  Computes normalized gravity center moment.
  Depends on vpMomentAreaNormalized and on vpMomentGravityCenter.
*/
void vpMomentGravityCenterNormalized::compute(){
    bool found_moment_gravity;    
    bool found_moment_surface_normalized;    
    
    const vpMomentAreaNormalized& momentSurfaceNormalized = static_cast<const vpMomentAreaNormalized&>(getMoments().get("vpMomentAreaNormalized",found_moment_surface_normalized));
    const vpMomentGravityCenter& momentGravity = static_cast<const vpMomentGravityCenter&>(getMoments().get("vpMomentGravityCenter",found_moment_gravity));

    if(!found_moment_surface_normalized) throw vpException(vpException::notInitialized,"vpMomentAreaNormalized not found");
    if(!found_moment_gravity) throw vpException(vpException::notInitialized,"vpMomentGravityCenter not found");

    double Xn = momentGravity.get()[0]*momentSurfaceNormalized.get()[0];
    double Yn = momentGravity.get()[1]*momentSurfaceNormalized.get()[0];

    values[0] = Xn;
    values[1] = Yn;

}
示例#8
0
/*!
  Computes centered moments of all available orders. 
  Depends on vpMomentGravityCenter.
*/
void vpMomentCentered::compute(){    
    bool found_moment_gravity;    
    values.resize((getObject().getOrder()+1)*(getObject().getOrder()+1));

    const vpMomentGravityCenter& momentGravity = static_cast<const vpMomentGravityCenter&>(getMoments().get("vpMomentGravityCenter",found_moment_gravity));
    if(!found_moment_gravity) throw vpException(vpException::notInitialized,"vpMomentGravityCenter not found");

    unsigned int order = getObject().getOrder()+1;
    for(register unsigned int j=0;j<(order);j++){
        for(register unsigned int i=0;i<order-j;i++){
            unsigned int c = order*j+i;
            values[c]=0;
            for(register unsigned int k=0;k<=i;k++){
                double Xg_i_k = pow(-momentGravity.get()[0],(int)(i-k));
                double comb_i_k = static_cast<double>( vpMath::comb(i,k) );
                for(register unsigned int l=0;l<=j;l++){
                    values[c]+= static_cast<double>( comb_i_k*vpMath::comb(j,l)
                      *Xg_i_k
                      *pow(-momentGravity.get()[1],(int)(j-l))*getObject().get(k,l) );
                }
            }
        }
    }

}
示例#9
0
/*!
Prints moments required for calculation of vpMomentCentered,
which are
1. Raw geometric moments (vpMomentObject) and
2. Centre of gravity (vpMomentGravityCentered)
*/
void
vpMomentCentered::printDependencies(std::ostream& os) const {
    os << (__FILE__) << std::endl;
    /*
    Retreive the raw moments
    */
    const vpMomentObject objt = getObject();
    vpMomentObject::printWithIndices(objt, os);

    /*
    Get xg,yg
    */
    bool found_moment_gravity;
    const vpMomentGravityCenter& momentGravity = static_cast<const vpMomentGravityCenter&>(getMoments().get("vpMomentGravityCenter",found_moment_gravity));
    if(!found_moment_gravity)
        throw vpException(vpException::notInitialized,"vpMomentGravityCenter not found");
    os << "Xg = " << momentGravity.getXg() << "\t" << "Yg = " << momentGravity.getYg() << std::endl;
}