4

Is it possible to load the model for a FaceRecognizer from memory or a string rather than from a saved file. The API docs do not show a 'FromString or Buffer' version.

The current code loads from file:

model = cv2.createLBPHFaceRecognizer()
model.load('model.xml')

Some more background. The presisted models are stored in S3. I don't want to retrieve from S3 and then save to disk in order to use. I would rather load directly from s3 into the model or load the xml string/document into the model.

IUnknown
  • 2,596
  • 4
  • 35
  • 52

1 Answers1

4

unfortunately, not possible from python ( cv2 ) atm.

while you can do it from c++ ,

string yml; // the whole schlepp in a string
FileStorage fs;
fs.open(yml,FileStorage::READ|FileStorage::MEMORY);
facereco->load(fs);
fs.release();

sad as it is, you can neither access FileStorage api, nor the FaceReco::load(FileStorage&) methods from python

(sidenote : at least you could resave them once from the facereco as yml.gz, to get the traffic down to 1/5 of the uncompressed xml)

berak
  • 39,159
  • 9
  • 91
  • 89
  • Thanks for the info. Too bad I can't do it from python yet - this would be a nice feature to add to cv2. Will also look into using yml. – IUnknown Jan 26 '14 at 18:29
  • yea, i know, been playing around with heroku and such myself, where ther's no treal filesystem, or only an ephemeral one. – berak Jan 26 '14 at 18:52