Click here to Skip to main content
15,890,995 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)


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 somebody help me for understand this 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

If you wrote it, why would you need it explained?
If you didn't write it, why not ask the person that did?

We don't do line-by-line explanations. If you have a specific problem, then ask a question about it. But think first - would you want to sit down for 45 minutes and type up a line-by-line description for no good reason?
 
Share this answer
 
Comments
Member 11007697 7-Sep-14 7:14am    
thank you very much for your attention and your advice, in my question i look for what do this function cvTermCriteria()
thank you again
Did you read the documentation[^] ?
 
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