使用Moments Opencv的手势

时间:2014-05-05 02:52:25

标签: opencv feature-extraction

我正在使用openCV对语音进行手势识别,我正在使用时刻找到手的方向,但是计算方向的结果对我来说不够有意义,所以我需要帮助理解它们。我也不知道我该怎么回事 找到图像的方向角。

此零件找到方向角:

    cvMoments( tempDB, &moments, 1 );   

u11=cvGetCentralMoment( &moments, 1,1 ); 
u20=cvGetCentralMoment( &moments, 2,0 ); 
u02=cvGetCentralMoment( &moments, 0,2 ); 
cout<<moments.m00<<"moo"<<endl;
cout<<moments.m11<<"m11"<<endl;
cout<<moments.m02<<"m02"<<endl;
cout<<moments.m20<<"m21"<<endl;
/////////////////////////////////////// EQ 1 //////////////////////////////////////////////////
theta=2*u11/(u20-u02); 

cout <<" The ANGLE theta in radians  = " <<theta <<endl; 
theta = 180*theta/pi;
cout <<" The ANGLE theta in degree  = " <<theta <<endl; 

if ((theta >=0) & (theta <=45)) {
//Page 65of 83 
theta2 = 0.5*atan(2*u11/(u20-u02));
cout<<"1"<<endl;
cout<<theta2<<"theta2 in radians in 1st cond"<<endl;
}
else {
if ((theta > -45) & (theta < 0)) {
    cout<<"2"<<endl;
    theta2 =  0.5*atan(2*u11/(u20-u02));
cout<<theta2<<"theta2 in radians in 2nd cond"<<endl;
}
else{ 
    if ((theta > 45) & (theta < 90)) {
    cout<<"3"<<endl;
    theta2 =  0.5*atan(2*u11/(u20-u02)) +( pi/2);
cout<<theta2<<"theta2 in radians in 3nd cond"<<endl;
} else {
    if ((theta > -90) & (theta < -45)) {
    cout<<"4"<<endl;
    theta2 =  0.5*atan(2*u11/(u20-u02)) -( pi/2);
cout<<theta2<<"theta2 in radians in 4nd cond"<<endl;
    } else  { cout << " u didnt handle this condition "<<endl; } 

 }

}

}
theta2 = 180*theta2/pi;
cout <<"angle theta2 of secnod image in degrees = " <<theta2 <<endl; 
cout <<"a b4 while loop = " <<a<<endl; 


Results : 
--------

widthis159heght is 189
60980 Non Zero Pixels in TEST
done first rotation

Angle of first image 0
60980 moo
1.93244e+009 m11
3.70591e+009 m02
2.11377e+009 m21
 The ANGLE theta in radians  = 1.12166
 The ANGLE theta in degree  = 64.2666
3
1.99214theta2 in radians in 3rd cond
angle theta2 of secnod image in degrees = 114.141
a b4 while loop = 0

![我从这里得到了这些等式1

1 个答案:

答案 0 :(得分:0)

以下是我看到的问题:

    cvMoments( tempDB, &moments, 1 );   

u11=cvGetCentralMoment( &moments, 1,1 ); 
u20=cvGetCentralMoment( &moments, 2,0 ); 
u02=cvGetCentralMoment( &moments, 0,2 ); 
cout<<moments.m00<<"moo"<<endl;
cout<<moments.m11<<"m11"<<endl;
cout<<moments.m02<<"m02"<<endl;
cout<<moments.m20<<"m21"<<endl;
/////////////////////////////////////// EQ 1 //////////////////////////////////////////////////
theta=2*u11/(u20-u02); 

cout <<" The ANGLE theta in radians  = " <<theta <<endl; 
theta = 180*theta/pi;
cout <<" The ANGLE theta in degree  = " <<theta <<endl; 

if ((theta >=0) && (theta <=45)) /*single & is binary (each bit individually) instead of the whole thing*/ {
//Page 65of 83 
theta2 = 0.5*atan(2*u11/(u20-u02));
cout<<"1"<<endl;
cout<<theta2<<"theta2 in radians in 1st cond"<<endl;
}
else {
if ((theta > -45) && (theta < 0)) /*same issue here*/ {
    cout<<"2"<<endl;
    theta2 =  0.5*atan(2*u11/(u20-u02));
cout<<theta2<<"theta2 in radians in 2nd cond"<<endl;
}
else{ 
    if ((theta > 45) && (theta < 90)) /*the brace placement sucks, but use && instead of &*/{ 
    cout<<"3"<<endl;
    theta2 =  0.5*atan(2*u11/(u20-u02)) +( pi/2);
cout<<theta2<<"theta2 in radians in 3nd cond"<<endl;
} else {
    if ((theta > -90) && (theta < -45)) {
    cout<<"4"<<endl;
    theta2 =  0.5*atan(2*u11/(u20-u02)) -( pi/2);
cout<<theta2<<"theta2 in radians in 4nd cond"<<endl;
    } else  { cout << " u didnt handle this condition "<<endl; } 

 }

}

}
theta2 = 180*theta2/pi;
cout <<"angle theta2 of secnod image in degrees = " <<theta2 <<endl; 
cout <<"a b4 while loop = " <<a<<endl; 

你正在使用&amp;而不是&amp;&amp;,基本上掩盖了比特。唯一可能是错误的方法是,如果theta是与theta相反的完全二元(不可能)。第一个if总是如此。