Problem with cvCalcCovarMatrix

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Problem with cvCalcCovarMatrix

illidan_thedemonhunter
Hi guys,

I'm really new to openCV (and image processing field also). This is my
first post and I really hope you guys can help me. I've been spending
days trying to figure out what's wrong with my code.

I'm trying to implement Aaron and James' "Action recognition using
temporal templates", using Motion History Image for activity recognition.

So I calculate the 7 Hu moments of a MHI template, and put them in the
a array and calculate the CovarMatrix.

But the result matrix is always zero..

The input matrix is

Moments: 29107641.000000 270.881081 261.473285
0.000753894 1.76006e-09 2.88337e-11 1.00063e-12 2.50285e-24
-4.97276e-18 4.75651e-24

The output:
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0

So is there anything wrong with my code (there must be)?

                temporal =  cvLoadImage( "motion.bmp", CV_LOAD_IMAGE_GRAYSCALE);
                temporal1 =  cvLoadImage( "motion1.bmp", CV_LOAD_IMAGE_GRAYSCALE);
                cvShowImage("template", temporal);
               
                calculateHuMoments (temporal1, temporalHu1);
                printHuMoments(temporalHu1);
                calculateHuMoments (temporal, temporalHu);
                printHuMoments(temporalHu);
               
                int i = 0;
               
                CvMat *vec = cvCreateMat(1, 7, CV_64FC1);
               
                CV_MAT_ELEM (*vec, double, 0, 0) = temporalHu.hu1;
                CV_MAT_ELEM (*vec, double, 0, 1) = temporalHu.hu2;
                CV_MAT_ELEM (*vec, double, 0, 2) = temporalHu.hu3;
                CV_MAT_ELEM (*vec, double, 0, 3) = temporalHu.hu4;
                CV_MAT_ELEM (*vec, double, 0, 4) = temporalHu.hu5;
                CV_MAT_ELEM (*vec, double, 0, 5) = temporalHu.hu6;
                CV_MAT_ELEM (*vec, double, 0, 6) = temporalHu.hu7;
               
                vects[0] = vec;

                cvCalcCovarMatrix(vects, 1, C, M, CV_COVAR_NORMAL);
                //cvmSet (C, 0, 0, 1.23);
                printCovar(C);
                               
                cout<<cvmGet(M, 0, 0)<<" "<<cvmGet(M, 0,1)<<" "<<cvmGet(M, 0, 2)<<"
"<<cvmGet(M, 0, 3)<<" "<<cvmGet(C, 0, 4)<<" "<<cvmGet(M, 0, 5)<<"
"<<cvmGet(M, 0, 6)<<"\n";
               
                cvInvert(C, invC, CV_SVD);
               
                printCovar(invC);