Ask Your Question

How to insert array of <int> into CvArr

asked 2012-08-11 05:35:15 -0600

Mohammad gravatar image

updated 2012-08-11 05:38:30 -0600

I'm trying to develop a Face Recognition app on Android and I'm using JavaCV+OpenCV 2.4.2 to use Philipp Wagner's Face Recognition Class.

The class has a Train Method which accepts arrays of Mat and Integer as input (in C++) :

vector<Mat> images;
vector<int> labels;

Ptr<FaceRecognizer> model = createFisherFaceRecognizer();
model->train(images, labels);

JavaCV accepts the attributes of 'train' method as "train(MatVector arg0, CvArr arg1)" ... AND here is where I'm stuck !

I'm having a little trouble trying to load data into CvArr... I already have the labels as strings of data... but I can't seem to find a way to insert these labels as an array to CvArr... let's call it a lack of OpenCV knowledge... can anybody help me with this issue ?!

P.S : BTW I know that iplImage can be used instead of CvArr in this method but the problem still remains : HOW can I insert an Array of <int> into iplImage ?!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2012-08-11 08:23:06 -0600

updated 2012-08-11 08:24:49 -0600

This is not a JavaCV QA page. There's a very active mailing list for JavaCV at:

I saw you asked your question there, which is the right place to ask. I know Samuel tries to answer the questions there, but you need to give people some time to answer. After all, did you look into the samples? All you need to do is create a CvArr with a given size and integer type (CV_32SC1), and then fill it with the labels.

I bet there are samples in the JavaCV wiki explaining it:

For example:

edit flag offensive delete link more

Question Tools


Asked: 2012-08-11 05:35:15 -0600

Seen: 940 times

Last updated: Aug 11 '12