MACE

Objective-C

@interface MACE : Algorithm

Swift

class MACE : Algorithm

Minimum Average Correlation Energy Filter useful for authentication with (cancellable) biometrical features. (does not need many positives to train (10-50), and no negatives at all, also robust to noise/salting)

 see also: CITE: Savvides04

 this implementation is largely based on: https://code.google.com/archive/p/pam-face-authentication (GSOC 2009)

 use it like:


 Ptr<face::MACE> mace = face::MACE::create(64);

 vector<Mat> pos_images = ...
 mace->train(pos_images);

 Mat query = ...
 bool same = mace->same(query);



 you can also use two-factor authentication, with an additional passphrase:


 String owners_passphrase = "ilikehotdogs";
 Ptr<face::MACE> mace = face::MACE::create(64);
 mace->salt(owners_passphrase);
 vector<Mat> pos_images = ...
 mace->train(pos_images);

 // now, users have to give a valid passphrase, along with the image:
 Mat query = ...
 cout << "enter passphrase: ";
 string pass;
 getline(cin, pass);
 mace->salt(pass);
 bool same = mace->same(query);


 save/load your model:

 Ptr<face::MACE> mace = face::MACE::create(64);
 mace->train(pos_images);
 mace->save("my_mace.xml");

 // later:
 Ptr<MACE> reloaded = MACE::load("my_mace.xml");
 reloaded->same(some_image);

Member of Face

Methods

  • constructor

    Declaration

    Objective-C

    + (nonnull MACE *)create:(int)IMGSIZE;

    Swift

    class func create(IMGSIZE: Int32) -> MACE

    Parameters

    IMGSIZE

    images will get resized to this (should be an even number)

  • constructor

    Declaration

    Objective-C

    + (nonnull MACE *)create;

    Swift

    class func create() -> MACE
  • constructor

    Declaration

    Objective-C

    + (nonnull MACE *)load:(nonnull NSString *)filename
                   objname:(nonnull NSString *)objname;

    Swift

    class func load(filename: String, objname: String) -> MACE

    Parameters

    filename

    build a new MACE instance from a pre-serialized FileStorage

    objname

    (optional) top-level node in the FileStorage

  • constructor

    Declaration

    Objective-C

    + (nonnull MACE *)load:(nonnull NSString *)filename;

    Swift

    class func load(filename: String) -> MACE

    Parameters

    filename

    build a new MACE instance from a pre-serialized FileStorage

  • correlate query img and threshold to min class value

    Declaration

    Objective-C

    - (BOOL)same:(nonnull Mat *)query;

    Swift

    func same(query: Mat) -> Bool

    Parameters

    query

    a Mat with query image

  • optionally encrypt images with random convolution

    Declaration

    Objective-C

    - (void)salt:(nonnull NSString *)passphrase;

    Swift

    func salt(passphrase: String)

    Parameters

    passphrase

    a crc64 random seed will get generated from this

  • train it on positive features compute the mace filter: h = D(-1) * X * (X(+) * D(-1) * X)(-1) * C also calculate a minimal threshold for this class, the smallest self-similarity from the train images

    Declaration

    Objective-C

    - (void)train:(nonnull NSArray<Mat *> *)images;

    Swift

    func train(images: [Mat])

    Parameters

    images

    a vector with the train images