1

我在这里遇到了一些问题

// compute average image, eigenvalues, and eigenvectors
    cvCalcEigenObjects(nTrainFaces, // nObjects
            new PointerPointer(trainingFaceImgArr), // input
            new PointerPointer(eigenVectArr), // output
            CV_EIGOBJ_NO_CALLBACK, // ioFlags
            0, // ioBufSize
            null, // userData
            calcLimit, pAvgTrainImg, // avg
            eigenValMat.data_fl()); // eigVals

有什么想法吗?我只是在我的 IplImage[] 数组中加载彩色 jpg 脸,但我卡在这行代码上。

这是我的示例代码

public void learn(final String trainingFileName) {
    int i;
    long startTime = System.nanoTime();

    trainingFaceImgArr = loadFaceImgArray(trainingFileName);
    nTrainFaces = trainingFaceImgArr.length;
    L.wtf("trainFaceImgArr length"+trainingFaceImgArr.length);
    if (nTrainFaces < 3) {
        L.wtf( "Need 3 or more training faces\n"
                + "Input file contains only " + nTrainFaces);
        return;
    }
    // do Principal Component Analysis on the training faces
    doPCA();
}
private void doPCA() {
    int i;
    CvTermCriteria calcLimit;
    CvSize faceImgSize = new CvSize();

    // set the number of eigenvalues to use
    nEigens = nTrainFaces - 1;

    L.wtf("allocating images for principal component analysis, using "
            + nEigens + (nEigens == 1 ? " eigenvalue" : " eigenvalues"));

    // allocate the eigenvector images
    faceImgSize.width(trainingFaceImgArr[0].width());
    faceImgSize.height(trainingFaceImgArr[0].height());
    eigenVectArr = new IplImage[nEigens];
    for (i = 0; i < nEigens; i++) {
        eigenVectArr[i] = cvCreateImage(faceImgSize, // size
                IPL_DEPTH_32F, // depth
                1); // channels
    }

    // allocate the eigenvalue array
    eigenValMat = cvCreateMat(1, // rows
            nEigens, // cols
            CV_32FC1); // type, 32-bit float, 1 channel

    // allocate the averaged image
    pAvgTrainImg = cvCreateImage(faceImgSize, // size
            IPL_DEPTH_32F, // depth
            1); // channels

    // set the PCA termination criterion
    calcLimit = cvTermCriteria(CV_TERMCRIT_ITER, // type
            nEigens, // max_iter
            1); // epsilon

    L.wtf("computing average image, eigenvalues and eigenvectors");
    // compute average image, eigenvalues, and eigenvectors
    cvCalcEigenObjects(nTrainFaces, // nObjects
            new PointerPointer(trainingFaceImgArr), // input
            new PointerPointer(eigenVectArr), // output
            CV_EIGOBJ_NO_CALLBACK, // ioFlags
            0, // ioBufSize
            null, // userData
            calcLimit, pAvgTrainImg, // avg
            eigenValMat.data_fl()); // eigVals
4

0 回答 0