Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more: , +

I want to write a eigenface program using C++ with OpenCV but i don't know how to work this function cvTermCriteria();and i wish anybody help me for understand this function and this is portion of code where i use this function

C++
void doPCA()
    {
            int i;
            CvTermCriteria calcLimit;
            CvSize faceImgSize;
     
            // set the number of eigenvalues to use
            nEigens = nTrainFaces-1;
     
            // allocate the eigenvector images
            faceImgSize.width  = faceImgArr[0]->width;
            faceImgSize.height = faceImgArr[0]->height;
            eigenVectArr = (IplImage**)cvAlloc(sizeof(IplImage*) * nEigens);
            for(i=0; i<nEigens; i++)
                    eigenVectArr[i] = cvCreateImage(faceImgSize, IPL_DEPTH_32F, 1);
     
            // allocate the eigenvalue array
            eigenValMat = cvCreateMat( 1, nEigens, CV_32FC1 );
     
            // allocate the averaged image
            pAvgTrainImg = cvCreateImage(faceImgSize, IPL_DEPTH_32F, 1);
     
            // set the PCA termination criterion
            calcLimit = cvTermCriteria( CV_TERMCRIT_ITER, nEigens, 1);
     
            // compute average image, eigenvalues, and eigenvectors
            cvCalcEigenObjects(
                    nTrainFaces,
                    (void*)faceImgArr,
                    (void*)eigenVectArr,
                    CV_EIGOBJ_NO_CALLBACK,
                    0,
                    0,
                   &calcLimit,
                    pAvgTrainImg,
                    eigenValMat->data.fl);
     
            cvNormalize(eigenValMat, eigenValMat, 1, 0, CV_L1, 0);
    }
Posted

1 solution

Please read Open CV documentation:
http://docs.opencv.org/modules/core/doc/old_basic_structures.html[^],
http://docs.opencv.org[^].

The question is not very productive. It's pretty apparent that you are asking on the code which you did not write by yourself. Why trying to dig in it if you did not understand the documentation of the function or the library? You need try to understand it from documentation and then write your own code. Even if you fail to make it working, it will give you a lot more understanding; and then you can ask the question showing your code. At least you will be able to explain what did you try and why, and that could provide a clue for the answering or giving you an advice on how to do it correctly.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900