Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

FaceRecognizer Parameter problem of the train method

Android project environment!

I see the official example, the two parameters passed in are vector< Mat> images and vector< int> labels;
code below:

vector<Mat> images;   
vector<int> labels;
// Read in the data (fails if no valid input filename is given, but you'll get an error message):
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);
}
// Get the height from the first image. We'll need this
// later in code to reshape the images to their original
// size AND we need to reshape incoming faces to this size:
int im_width = images[0].cols;
int im_height = images[0].rows;
// Create a FaceRecognizer and train it on the given images:
Ptr<FisherFaceRecognizer> model = FisherFaceRecognizer::create();
model->train(images, labels);

But in my compiled Opencv4Android library, the definition of the train method is like this.

//
// C++:  void cv::face::FaceRecognizer::train(vector_Mat src, Mat labels)
//
//javadoc: FaceRecognizer::train(src, labels)
public  void train(List<Mat> src, Mat labels)
{
    Mat src_mat = Converters.vector_Mat_to_Mat(src);
    train_0(nativeObj, src_mat.nativeObj, labels.nativeObj);

    return;
}

Why does the second argument of the train method become Mat, shouldn't it be a collection of 'int'?