Ask Your Question

How to create,update,delete an face stored .xml

asked 2014-05-14 09:22:05 -0500

molina gravatar image

updated 2014-05-14 09:27:47 -0500

berak gravatar image

Hi ,

How I could to do update / insert (new face) in file .xml already stored ?

My propose is delete, insert and update.

I tried to to update an face in file .xml I used the class FaceRecognition of javacv's example

What I did ? I use APPEND (CV_STORAGE_APPEND) at file, to preserve face already trained.

fileStorage = cvOpenFileStorage("facedata.xml", // filename
            null, // memstorage
            CV_STORAGE_APPEND, // flags APPEND instead of CV_STORAGE_WRITE
            null); // encoding

The CV_STORAGE_APPEND was successfuly, But the TAG from XML called: <avgTrainImg> and <projectedTrainFaceMat> is created once for all faces, and this method APPEND it create more than one tag <avgTrainImg>... occured Error when Load xml again.

Finding out another alternatives: I read an question about it How to add more data in previously stored trained data file? , but not has the solution. So I tried use


But: I was faced with the Exception, In this point described below:

faceRecognizer.train(trainImages, trainLabels);


Training Binary model ....OpenCV Error: The function/feature is not implemented (Using Original Local Binary Patterns for feature extraction only works on single-channel images (given 16). Please pass the image data as a grayscale image!) in cv::elbp, file \opencv\modules\contrib\src\facerec.cpp, line 646 java.lang.RuntimeException: ........\opencv\modules\contrib\src\facerec.cpp:646: error: (-213) Using Original Local Binary Patterns for feature extraction only works on single-channel images (given 16). Please pass the image data as a grayscale image! in function cv::elbp

at com.googlecode.javacv.cpp.opencv_contrib$FaceRecognizer.train(Native Method)

Some expert could help me ?

Any suggestion is welcome !

edit retag flag offensive close merge delete


most of the answer is already in your errormsg - you only can update the lbph model.

also, please don't try to edit the xml file, instead:

  • load the existing trainset into your lbph model
  • call train() with the images/labels to add
  • save the resulting model
berak gravatar imageberak ( 2014-05-14 09:30:35 -0500 )edit

I'm newbie in opencv , could you show me some solution; at least lbph model ? please ?

molina gravatar imagemolina ( 2014-05-14 09:40:37 -0500 )edit

pardon ? i did not understand.

also sorry, i can help you only with general opencv issues, but not with things related to javacv's api

berak gravatar imageberak ( 2014-05-14 09:46:43 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2016-08-23 15:57:32 -0500

The LBPH is the only algorithm that alow us update our training data stored in xml file. I work with c++ and now i'm looking some way to delete a representation of one person, but i still looking for. I promess you if a found it that i share with you guys.

The LBPH use 2 vectors to train the model. The first vector contains the Mat as faces and the second vector contains the integers as ids. Once created the model you can update it with the function of same name (update(param1, param2)) This parameters are the same of the Train function but only with the new person information.

After update the model you most save it (model->save("path")) and latter load it (model->load("path")) again; I hope has been usefull to you.

edit flag offensive delete link more

Question Tools


Asked: 2014-05-14 09:22:05 -0500

Seen: 1,111 times

Last updated: May 14 '14