Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/158.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 人脸识别openCV visual studio理解_C++_Visual Studio 2010_Algorithm_Opencv - Fatal编程技术网

C++ 人脸识别openCV visual studio理解

C++ 人脸识别openCV visual studio理解,c++,visual-studio-2010,algorithm,opencv,C++,Visual Studio 2010,Algorithm,Opencv,我有一个问题。。 我试图在VisualStudio2010中使用OpenCCv2.4.6制作人脸检测/识别程序。 我对openCV文档中的人脸识别算法有问题。 算法本身对我来说没有任何错误,但是我不确定我是否理解它的输出,或者它是否真的正确。。我正在使用AT&T数据库进行培训和识别。。 我的csv文件(at.txt)如下所示: C:\face\s1/1.pgm;0 C:\face\s1/2.pgm;0 C:\face\s1/3.pgm;0 C:\face\s1/4.pgm;0 C:\face\s

我有一个问题。。 我试图在VisualStudio2010中使用OpenCCv2.4.6制作人脸检测/识别程序。 我对openCV文档中的人脸识别算法有问题。 算法本身对我来说没有任何错误,但是我不确定我是否理解它的输出,或者它是否真的正确。。我正在使用AT&T数据库进行培训和识别。。 我的csv文件(at.txt)如下所示:

C:\face\s1/1.pgm;0
C:\face\s1/2.pgm;0
C:\face\s1/3.pgm;0
C:\face\s1/4.pgm;0
C:\face\s1/5.pgm;0
C:\face\s1/6.pgm;0
C:\face\s1/7.pgm;0
C:\face\s1/8.pgm;0
C:\face\s1/9.pgm;0
C:\face\s1/10.pgm;0
C:\face\s2/1.pgm;1
C:\face\s2/2.pgm;1
C:\face\s2/3.pgm;1
C:\face\s2/4.pgm;1
C:\face\s2/5.pgm;1
C:\face\s2/6.pgm;1
C:\face\s2/7.pgm;1
C:\face\s2/8.pgm;1
C:\face\s2/9.pgm;1
C:\face\s2/10.pgm;1
C:\face\s3/1.pgm;2
C:\face\s3/2.pgm;2
C:\face\s3/3.pgm;2
C:\face\s3/4.pgm;2
C:\face\s3/5.pgm;2
C:\face\s3/6.pgm;2
C:\face\s3/7.pgm;2
C:\face\s3/8.pgm;2
C:\face\s3/9.pgm;2
C:\face\s3/10.pgm;2
C:\face\s4/1.pgm;3
C:\face\s4/2.pgm;3
C:\face\s4/3.pgm;3
C:\face\s4/4.pgm;3
C:\face\s4/5.pgm;3
C:\face\s4/6.pgm;3
C:\face\s4/7.pgm;3
C:\face\s4/8.pgm;3
C:\face\s4/9.pgm;3
C:\face\s4/10.pgm;3
C:\face\s5/1.pgm;4
C:\face\s5/2.pgm;4
C:\face\s5/3.pgm;4
C:\face\s5/4.pgm;4
C:\face\s5/5.pgm;4
C:\face\s5/6.pgm;4
C:\face\s5/7.pgm;4
C:\face\s5/8.pgm;4
C:\face\s5/9.pgm;4
C:\face\s5/10.pgm;4
C:\face\s6/1.pgm;5
C:\face\s6/2.pgm;5
C:\face\s6/3.pgm;5
C:\face\s6/4.pgm;5
C:\face\s6/5.pgm;5
C:\face\s6/6.pgm;5
C:\face\s6/7.pgm;5
C:\face\s6/8.pgm;5
C:\face\s6/9.pgm;5
C:\face\s6/10.pgm;5
C:\face\s7/1.pgm;6
C:\face\s7/2.pgm;6
C:\face\s7/3.pgm;6
C:\face\s7/4.pgm;6
C:\face\s7/5.pgm;6
C:\face\s7/6.pgm;6
C:\face\s7/7.pgm;6
C:\face\s7/8.pgm;6
C:\face\s7/9.pgm;6
C:\face\s7/10.pgm;6
C:\face\s8/1.pgm;7
C:\face\s8/2.pgm;7
C:\face\s8/3.pgm;7
C:\face\s8/4.pgm;7
C:\face\s8/5.pgm;7
C:\face\s8/6.pgm;7
C:\face\s8/7.pgm;7
C:\face\s8/8.pgm;7
C:\face\s8/9.pgm;7
C:\face\s8/10.pgm;7
C:\face\s9/1.pgm;8
C:\face\s9/2.pgm;8
C:\face\s9/3.pgm;8
C:\face\s9/4.pgm;8
C:\face\s9/5.pgm;8
C:\face\s9/6.pgm;8
C:\face\s9/7.pgm;8
C:\face\s9/8.pgm;8
C:\face\s9/9.pgm;8
C:\face\s9/10.pgm;8
C:\face\s10/1.pgm;9
C:\face\s10/2.pgm;9
C:\face\s10/3.pgm;9
C:\face\s10/4.pgm;9
C:\face\s10/5.pgm;9
C:\face\s10/6.pgm;9
C:\face\s10/7.pgm;9
C:\face\s10/8.pgm;9
C:\face\s10/9.pgm;9
C:\face\s10/10.pgm;9
#include "stdafx.h"

#include "opencv2/core/core.hpp"
#include "opencv2/contrib/contrib.hpp"
#include "opencv2/highgui/highgui.hpp"

#include <iostream>
#include <fstream>
#include <sstream>

using namespace cv;
using namespace std;

static Mat norm_0_255(InputArray _src) {
    Mat src = _src.getMat();
    // Create and return normalized image:
    Mat dst;
    switch(src.channels()) {
    case 1:
        cv::normalize(_src, dst, 0, 255, NORM_MINMAX, CV_8UC1);
        break;
    case 3:
        cv::normalize(_src, dst, 0, 255, NORM_MINMAX, CV_8UC3);
        break;
    default:
        src.copyTo(dst);
        break;
    }
    return dst;
}

static void read_csv(const string& filename, vector<Mat>& images, vector<int>& labels, char separator = ';') {
    std::ifstream file(filename.c_str(), ifstream::in);
    if (!file) {
        string error_message = "No valid input file was given, please check the given filename.";
        CV_Error(CV_StsBadArg, error_message);
    }
    string line, path, classlabel;
    while (getline(file, line)) {
        stringstream liness(line);
        getline(liness, path, separator);
        getline(liness, classlabel);
        if(!path.empty() && !classlabel.empty()) {
            images.push_back(imread(path, 0));
            labels.push_back(atoi(classlabel.c_str()));
        }
    }
}

int main(int argc, const char *argv[]) {
    // Check for valid command line arguments, print usage
    // if no arguments were given.
    if (argc < 2) {
        cout << "usage: " << argv[0] << " <csv.ext> <output_folder> " << endl;
        exit(1);
    }
    string output_folder;
    if (argc == 3) {
        output_folder = string(argv[2]);
    }
    // Get the path to your CSV.
    string fn_csv = string(argv[1]);
    // These vectors hold the images and corresponding labels.
    vector<Mat> images;
    vector<int> labels;
    // Read in the data. This can fail if no valid
    // input filename is given.
    try {
        read_csv(fn_csv, images, labels);
    } catch (cv::Exception& e) {
        cerr << "Error opening file \"" << fn_csv << "\". Reason: " << e.msg << endl;
        // nothing more we can do
        exit(1);
    }
    // Quit if there are not enough images for this demo.
    if(images.size() <= 1) {
        string error_message = "This demo needs at least 2 images to work. Please add more images to your data set!";
        CV_Error(CV_StsError, error_message);
    }
    // Get the height from the first image. We'll need this
    // later in code to reshape the images to their original
    // size:
    int height = images[0].rows;
    // The following lines simply get the last images from
    // your dataset and remove it from the vector. This is
    // done, so that the training data (which we learn the
    // cv::FaceRecognizer on) and the test data we test
    // the model with, do not overlap.
    Mat testSample = images[images.size() - 1];
    int testLabel = labels[labels.size() - 1];
    images.pop_back();
    labels.pop_back();
    // The following lines create an Eigenfaces model for
    // face recognition and train it with the images and
    // labels read from the given CSV file.
    // This here is a full PCA, if you just want to keep
    // 10 principal components (read Eigenfaces), then call
    // the factory method like this:
    //
    //      cv::createEigenFaceRecognizer(10);
    //
    // If you want to create a FaceRecognizer with a
    // confidence threshold (e.g. 123.0), call it with:
    //
    //      cv::createEigenFaceRecognizer(10, 123.0);
    //
    // If you want to use _all_ Eigenfaces and have a threshold,
    // then call the method like this:
    //
    //      cv::createEigenFaceRecognizer(0, 123.0);
    //
    Ptr<FaceRecognizer> model = createEigenFaceRecognizer();
    model->train(images, labels);
    // The following line predicts the label of a given
    // test image:
    int predictedLabel = model->predict(testSample);
    //
    // To get the confidence of a prediction call the model with:
    //
    //      int predictedLabel = -1;
    //      double confidence = 0.0;
    //      model->predict(testSample, predictedLabel, confidence);
    //
    string result_message = format("Predicted class = %d / Actual class = %d.", predictedLabel, testLabel);
    cout << result_message << endl;
    // Here is how to get the eigenvalues of this Eigenfaces model:
    Mat eigenvalues = model->getMat("eigenvalues");
    // And we can do the same to display the Eigenvectors (read Eigenfaces):
    Mat W = model->getMat("eigenvectors");
    // Get the sample mean from the training data
    Mat mean = model->getMat("mean");
    // Display or save:
    if(argc == 2) {
        imshow("mean", norm_0_255(mean.reshape(1, images[0].rows)));
    } else {
        imwrite(format("%s/mean.png", output_folder.c_str()), norm_0_255(mean.reshape(1, images[0].rows)));
    }
    // Display or save the Eigenfaces:
    for (int i = 0; i < min(10, W.cols); i++) {
        string msg = format("Eigenvalue #%d = %.5f", i, eigenvalues.at<double>(i));
        cout << msg << endl;
        // get eigenvector #i
        Mat ev = W.col(i).clone();
        // Reshape to original size & normalize to [0...255] for imshow.
        Mat grayscale = norm_0_255(ev.reshape(1, height));
        // Show the image & apply a Jet colormap for better sensing.
        Mat cgrayscale;
        applyColorMap(grayscale, cgrayscale, COLORMAP_JET);
        // Display or save:
        if(argc == 2) {
            imshow(format("eigenface_%d", i), cgrayscale);
        } else {
            imwrite(format("%s/eigenface_%d.png", output_folder.c_str(), i), norm_0_255(cgrayscale));
        }
    }

    // Display or save the image reconstruction at some predefined steps:
    for(int num_components = min(W.cols, 10); num_components < min(W.cols, 300); num_components+=15) {
        // slice the eigenvectors from the model
        Mat evs = Mat(W, Range::all(), Range(0, num_components));
        Mat projection = subspaceProject(evs, mean, images[0].reshape(1,1));
        Mat reconstruction = subspaceReconstruct(evs, mean, projection);
        // Normalize the result:
        reconstruction = norm_0_255(reconstruction.reshape(1, images[0].rows));
        // Display or save:
        if(argc == 2) {
            imshow(format("eigenface_reconstruction_%d", num_components), reconstruction);
        } else {
            imwrite(format("%s/eigenface_reconstruction_%d.png", output_folder.c_str(), num_components), reconstruction);
        }
    }
    // Display if we are not writing to an output folder:
    if(argc == 2) {
        waitKey(0);
    }
    return 0;
}
我的人脸识别器代码如下所示:

C:\face\s1/1.pgm;0
C:\face\s1/2.pgm;0
C:\face\s1/3.pgm;0
C:\face\s1/4.pgm;0
C:\face\s1/5.pgm;0
C:\face\s1/6.pgm;0
C:\face\s1/7.pgm;0
C:\face\s1/8.pgm;0
C:\face\s1/9.pgm;0
C:\face\s1/10.pgm;0
C:\face\s2/1.pgm;1
C:\face\s2/2.pgm;1
C:\face\s2/3.pgm;1
C:\face\s2/4.pgm;1
C:\face\s2/5.pgm;1
C:\face\s2/6.pgm;1
C:\face\s2/7.pgm;1
C:\face\s2/8.pgm;1
C:\face\s2/9.pgm;1
C:\face\s2/10.pgm;1
C:\face\s3/1.pgm;2
C:\face\s3/2.pgm;2
C:\face\s3/3.pgm;2
C:\face\s3/4.pgm;2
C:\face\s3/5.pgm;2
C:\face\s3/6.pgm;2
C:\face\s3/7.pgm;2
C:\face\s3/8.pgm;2
C:\face\s3/9.pgm;2
C:\face\s3/10.pgm;2
C:\face\s4/1.pgm;3
C:\face\s4/2.pgm;3
C:\face\s4/3.pgm;3
C:\face\s4/4.pgm;3
C:\face\s4/5.pgm;3
C:\face\s4/6.pgm;3
C:\face\s4/7.pgm;3
C:\face\s4/8.pgm;3
C:\face\s4/9.pgm;3
C:\face\s4/10.pgm;3
C:\face\s5/1.pgm;4
C:\face\s5/2.pgm;4
C:\face\s5/3.pgm;4
C:\face\s5/4.pgm;4
C:\face\s5/5.pgm;4
C:\face\s5/6.pgm;4
C:\face\s5/7.pgm;4
C:\face\s5/8.pgm;4
C:\face\s5/9.pgm;4
C:\face\s5/10.pgm;4
C:\face\s6/1.pgm;5
C:\face\s6/2.pgm;5
C:\face\s6/3.pgm;5
C:\face\s6/4.pgm;5
C:\face\s6/5.pgm;5
C:\face\s6/6.pgm;5
C:\face\s6/7.pgm;5
C:\face\s6/8.pgm;5
C:\face\s6/9.pgm;5
C:\face\s6/10.pgm;5
C:\face\s7/1.pgm;6
C:\face\s7/2.pgm;6
C:\face\s7/3.pgm;6
C:\face\s7/4.pgm;6
C:\face\s7/5.pgm;6
C:\face\s7/6.pgm;6
C:\face\s7/7.pgm;6
C:\face\s7/8.pgm;6
C:\face\s7/9.pgm;6
C:\face\s7/10.pgm;6
C:\face\s8/1.pgm;7
C:\face\s8/2.pgm;7
C:\face\s8/3.pgm;7
C:\face\s8/4.pgm;7
C:\face\s8/5.pgm;7
C:\face\s8/6.pgm;7
C:\face\s8/7.pgm;7
C:\face\s8/8.pgm;7
C:\face\s8/9.pgm;7
C:\face\s8/10.pgm;7
C:\face\s9/1.pgm;8
C:\face\s9/2.pgm;8
C:\face\s9/3.pgm;8
C:\face\s9/4.pgm;8
C:\face\s9/5.pgm;8
C:\face\s9/6.pgm;8
C:\face\s9/7.pgm;8
C:\face\s9/8.pgm;8
C:\face\s9/9.pgm;8
C:\face\s9/10.pgm;8
C:\face\s10/1.pgm;9
C:\face\s10/2.pgm;9
C:\face\s10/3.pgm;9
C:\face\s10/4.pgm;9
C:\face\s10/5.pgm;9
C:\face\s10/6.pgm;9
C:\face\s10/7.pgm;9
C:\face\s10/8.pgm;9
C:\face\s10/9.pgm;9
C:\face\s10/10.pgm;9
#include "stdafx.h"

#include "opencv2/core/core.hpp"
#include "opencv2/contrib/contrib.hpp"
#include "opencv2/highgui/highgui.hpp"

#include <iostream>
#include <fstream>
#include <sstream>

using namespace cv;
using namespace std;

static Mat norm_0_255(InputArray _src) {
    Mat src = _src.getMat();
    // Create and return normalized image:
    Mat dst;
    switch(src.channels()) {
    case 1:
        cv::normalize(_src, dst, 0, 255, NORM_MINMAX, CV_8UC1);
        break;
    case 3:
        cv::normalize(_src, dst, 0, 255, NORM_MINMAX, CV_8UC3);
        break;
    default:
        src.copyTo(dst);
        break;
    }
    return dst;
}

static void read_csv(const string& filename, vector<Mat>& images, vector<int>& labels, char separator = ';') {
    std::ifstream file(filename.c_str(), ifstream::in);
    if (!file) {
        string error_message = "No valid input file was given, please check the given filename.";
        CV_Error(CV_StsBadArg, error_message);
    }
    string line, path, classlabel;
    while (getline(file, line)) {
        stringstream liness(line);
        getline(liness, path, separator);
        getline(liness, classlabel);
        if(!path.empty() && !classlabel.empty()) {
            images.push_back(imread(path, 0));
            labels.push_back(atoi(classlabel.c_str()));
        }
    }
}

int main(int argc, const char *argv[]) {
    // Check for valid command line arguments, print usage
    // if no arguments were given.
    if (argc < 2) {
        cout << "usage: " << argv[0] << " <csv.ext> <output_folder> " << endl;
        exit(1);
    }
    string output_folder;
    if (argc == 3) {
        output_folder = string(argv[2]);
    }
    // Get the path to your CSV.
    string fn_csv = string(argv[1]);
    // These vectors hold the images and corresponding labels.
    vector<Mat> images;
    vector<int> labels;
    // Read in the data. This can fail if no valid
    // input filename is given.
    try {
        read_csv(fn_csv, images, labels);
    } catch (cv::Exception& e) {
        cerr << "Error opening file \"" << fn_csv << "\". Reason: " << e.msg << endl;
        // nothing more we can do
        exit(1);
    }
    // Quit if there are not enough images for this demo.
    if(images.size() <= 1) {
        string error_message = "This demo needs at least 2 images to work. Please add more images to your data set!";
        CV_Error(CV_StsError, error_message);
    }
    // Get the height from the first image. We'll need this
    // later in code to reshape the images to their original
    // size:
    int height = images[0].rows;
    // The following lines simply get the last images from
    // your dataset and remove it from the vector. This is
    // done, so that the training data (which we learn the
    // cv::FaceRecognizer on) and the test data we test
    // the model with, do not overlap.
    Mat testSample = images[images.size() - 1];
    int testLabel = labels[labels.size() - 1];
    images.pop_back();
    labels.pop_back();
    // The following lines create an Eigenfaces model for
    // face recognition and train it with the images and
    // labels read from the given CSV file.
    // This here is a full PCA, if you just want to keep
    // 10 principal components (read Eigenfaces), then call
    // the factory method like this:
    //
    //      cv::createEigenFaceRecognizer(10);
    //
    // If you want to create a FaceRecognizer with a
    // confidence threshold (e.g. 123.0), call it with:
    //
    //      cv::createEigenFaceRecognizer(10, 123.0);
    //
    // If you want to use _all_ Eigenfaces and have a threshold,
    // then call the method like this:
    //
    //      cv::createEigenFaceRecognizer(0, 123.0);
    //
    Ptr<FaceRecognizer> model = createEigenFaceRecognizer();
    model->train(images, labels);
    // The following line predicts the label of a given
    // test image:
    int predictedLabel = model->predict(testSample);
    //
    // To get the confidence of a prediction call the model with:
    //
    //      int predictedLabel = -1;
    //      double confidence = 0.0;
    //      model->predict(testSample, predictedLabel, confidence);
    //
    string result_message = format("Predicted class = %d / Actual class = %d.", predictedLabel, testLabel);
    cout << result_message << endl;
    // Here is how to get the eigenvalues of this Eigenfaces model:
    Mat eigenvalues = model->getMat("eigenvalues");
    // And we can do the same to display the Eigenvectors (read Eigenfaces):
    Mat W = model->getMat("eigenvectors");
    // Get the sample mean from the training data
    Mat mean = model->getMat("mean");
    // Display or save:
    if(argc == 2) {
        imshow("mean", norm_0_255(mean.reshape(1, images[0].rows)));
    } else {
        imwrite(format("%s/mean.png", output_folder.c_str()), norm_0_255(mean.reshape(1, images[0].rows)));
    }
    // Display or save the Eigenfaces:
    for (int i = 0; i < min(10, W.cols); i++) {
        string msg = format("Eigenvalue #%d = %.5f", i, eigenvalues.at<double>(i));
        cout << msg << endl;
        // get eigenvector #i
        Mat ev = W.col(i).clone();
        // Reshape to original size & normalize to [0...255] for imshow.
        Mat grayscale = norm_0_255(ev.reshape(1, height));
        // Show the image & apply a Jet colormap for better sensing.
        Mat cgrayscale;
        applyColorMap(grayscale, cgrayscale, COLORMAP_JET);
        // Display or save:
        if(argc == 2) {
            imshow(format("eigenface_%d", i), cgrayscale);
        } else {
            imwrite(format("%s/eigenface_%d.png", output_folder.c_str(), i), norm_0_255(cgrayscale));
        }
    }

    // Display or save the image reconstruction at some predefined steps:
    for(int num_components = min(W.cols, 10); num_components < min(W.cols, 300); num_components+=15) {
        // slice the eigenvectors from the model
        Mat evs = Mat(W, Range::all(), Range(0, num_components));
        Mat projection = subspaceProject(evs, mean, images[0].reshape(1,1));
        Mat reconstruction = subspaceReconstruct(evs, mean, projection);
        // Normalize the result:
        reconstruction = norm_0_255(reconstruction.reshape(1, images[0].rows));
        // Display or save:
        if(argc == 2) {
            imshow(format("eigenface_reconstruction_%d", num_components), reconstruction);
        } else {
            imwrite(format("%s/eigenface_reconstruction_%d.png", output_folder.c_str(), num_components), reconstruction);
        }
    }
    // Display if we are not writing to an output folder:
    if(argc == 2) {
        waitKey(0);
    }
    return 0;
}
#包括“stdafx.h”
#包括“opencv2/core/core.hpp”
#包括“opencv2/contrib/contrib.hpp”
#包括“opencv2/highgui/highgui.hpp”
#包括
#包括
#包括
使用名称空间cv;
使用名称空间std;
静态Mat norm_0_255(输入阵列_src){
Mat src=_src.getMat();
//创建并返回标准化图像:
Mat-dst;
开关(src.channels()){
案例1:
cv::normalize(_src,dst,0,255,NORM_MINMAX,cv_8UC1);
打破
案例3:
cv::normalize(_src,dst,0,255,NORM_MINMAX,cv_8UC3);
打破
违约:
src.copyTo(dst);
打破
}
返回dst;
}
静态void read_csv(常量字符串和文件名、向量和图像、向量和标签、字符分隔符=“;”){
std::ifstream文件(filename.c_str(),ifstream::in);
如果(!文件){
字符串错误\u message=“未提供有效的输入文件,请检查给定的文件名。”;
CV_错误(CV_StsBadArg,错误消息);
}
字符串行、路径、类标签;
while(getline(文件,行)){
细度(线);
getline(路径、分隔符);
getline(名称、类别标签);
如果(!path.empty()&&!classlabel.empty()){
图像。推回(imread(路径,0));
labels.push_back(atoi(classlabel.c_str());
}
}
}
int main(int argc,const char*argv[]{
//检查有效的命令行参数、打印使用情况
//如果没有给出任何论据。
如果(argc<2){

cout看来你需要对算法有一个基本的了解

我建议你阅读《利用Turk&Pentland的特征脸进行人脸识别》一书和论文,该书可以找到


如果你能告诉我们你的目标是什么,这也会有帮助。也许你使用这个算法走错了方向。

嗨,安德里娅。听起来你需要学习很多关于机器学习的知识。我不是专家,但人脸识别是一项分类任务。在这些任务中,有一个正确的答案,那就是“这是谁的脸?”?’。这个正确的答案是实际的类。你的计算机的猜测是预测的类。正如你所看到的,你的计算机预测错了:(“所有看起来都像鬼”没关系。把每一个“鬼魂”想象成一个基本向量,重建是所有这些“特征向量”的组合。遗憾的是,这个预测是错误的。不知道为什么。是的,我确实这样做了。我正在进一步研究。我正试着制作一个程序,识别已经学习过的人脸,并显示给该人脸的名字作为输出。我要吗方向正确?是的,你可能是。特征脸的问题是,只有当数据库中的图像(训练图像)和你想要识别的图像(样本图像)之间存在差异时,你才能识别出一个人都很小。所以这取决于你真正想做什么。但是如果你刚刚开始搞人脸识别,特征脸和OpenCV使用的其他方法是一个很好的起点。