Ask Your Question
0

FaceRecognizer Parameter problem of the train method

asked 2018-08-24 04:24:34 -0600

rainY gravatar image

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'?

edit retag flag offensive close merge delete

Comments

@berak help please.

rainY gravatar imagerainY ( 2018-08-24 04:25:53 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-08-24 07:03:43 -0600

berak gravatar image

shouldn't it be a collection of 'int'?

no, that's ok. for primitive types, like int, float, uchar, etc it is:

 vector<T> (c++)       ->     Mat   (java)

for "complex" types, like cv::Mat it is:

 vector<Mat> (c++)     ->     List<Mat>   (java)
edit flag offensive delete link more

Comments

@berak how to convert vector<int> to Mat in java ? Can you give me a code sample ?

rainY gravatar imagerainY ( 2018-08-26 07:21:13 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-08-24 04:24:34 -0600

Seen: 148 times

Last updated: Aug 24 '18