MACE.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. //
  2. // This file is auto-generated. Please don't modify it!
  3. //
  4. #pragma once
  5. #ifdef __cplusplus
  6. //#import "opencv.hpp"
  7. #import "opencv2/face.hpp"
  8. #import "opencv2/face/mace.hpp"
  9. #else
  10. #define CV_EXPORTS
  11. #endif
  12. #import <Foundation/Foundation.h>
  13. #import "Algorithm.h"
  14. @class Mat;
  15. NS_ASSUME_NONNULL_BEGIN
  16. // C++: class MACE
  17. /**
  18. * Minimum Average Correlation Energy Filter
  19. * useful for authentication with (cancellable) biometrical features.
  20. * (does not need many positives to train (10-50), and no negatives at all, also robust to noise/salting)
  21. *
  22. * see also: CITE: Savvides04
  23. *
  24. * this implementation is largely based on: https://code.google.com/archive/p/pam-face-authentication (GSOC 2009)
  25. *
  26. * use it like:
  27. *
  28. *
  29. * Ptr<face::MACE> mace = face::MACE::create(64);
  30. *
  31. * vector<Mat> pos_images = ...
  32. * mace->train(pos_images);
  33. *
  34. * Mat query = ...
  35. * bool same = mace->same(query);
  36. *
  37. *
  38. *
  39. * you can also use two-factor authentication, with an additional passphrase:
  40. *
  41. *
  42. * String owners_passphrase = "ilikehotdogs";
  43. * Ptr<face::MACE> mace = face::MACE::create(64);
  44. * mace->salt(owners_passphrase);
  45. * vector<Mat> pos_images = ...
  46. * mace->train(pos_images);
  47. *
  48. * // now, users have to give a valid passphrase, along with the image:
  49. * Mat query = ...
  50. * cout << "enter passphrase: ";
  51. * string pass;
  52. * getline(cin, pass);
  53. * mace->salt(pass);
  54. * bool same = mace->same(query);
  55. *
  56. *
  57. * save/load your model:
  58. *
  59. * Ptr<face::MACE> mace = face::MACE::create(64);
  60. * mace->train(pos_images);
  61. * mace->save("my_mace.xml");
  62. *
  63. * // later:
  64. * Ptr<MACE> reloaded = MACE::load("my_mace.xml");
  65. * reloaded->same(some_image);
  66. *
  67. *
  68. * Member of `Face`
  69. */
  70. CV_EXPORTS @interface MACE : Algorithm
  71. #ifdef __cplusplus
  72. @property(readonly)cv::Ptr<cv::face::MACE> nativePtrMACE;
  73. #endif
  74. #ifdef __cplusplus
  75. - (instancetype)initWithNativePtr:(cv::Ptr<cv::face::MACE>)nativePtr;
  76. + (instancetype)fromNative:(cv::Ptr<cv::face::MACE>)nativePtr;
  77. #endif
  78. #pragma mark - Methods
  79. //
  80. // void cv::face::MACE::salt(String passphrase)
  81. //
  82. /**
  83. * optionally encrypt images with random convolution
  84. * @param passphrase a crc64 random seed will get generated from this
  85. */
  86. - (void)salt:(NSString*)passphrase NS_SWIFT_NAME(salt(passphrase:));
  87. //
  88. // void cv::face::MACE::train(vector_Mat images)
  89. //
  90. /**
  91. * train it on positive features
  92. * compute the mace filter: `h = D(-1) * X * (X(+) * D(-1) * X)(-1) * C`
  93. * also calculate a minimal threshold for this class, the smallest self-similarity from the train images
  94. * @param images a vector<Mat> with the train images
  95. */
  96. - (void)train:(NSArray<Mat*>*)images NS_SWIFT_NAME(train(images:));
  97. //
  98. // bool cv::face::MACE::same(Mat query)
  99. //
  100. /**
  101. * correlate query img and threshold to min class value
  102. * @param query a Mat with query image
  103. */
  104. - (BOOL)same:(Mat*)query NS_SWIFT_NAME(same(query:));
  105. //
  106. // static Ptr_MACE cv::face::MACE::load(String filename, String objname = String())
  107. //
  108. /**
  109. * constructor
  110. * @param filename build a new MACE instance from a pre-serialized FileStorage
  111. * @param objname (optional) top-level node in the FileStorage
  112. */
  113. + (MACE*)load:(NSString*)filename objname:(NSString*)objname NS_SWIFT_NAME(load(filename:objname:));
  114. /**
  115. * constructor
  116. * @param filename build a new MACE instance from a pre-serialized FileStorage
  117. */
  118. + (MACE*)load:(NSString*)filename NS_SWIFT_NAME(load(filename:));
  119. //
  120. // static Ptr_MACE cv::face::MACE::create(int IMGSIZE = 64)
  121. //
  122. /**
  123. * constructor
  124. * @param IMGSIZE images will get resized to this (should be an even number)
  125. */
  126. + (MACE*)create:(int)IMGSIZE NS_SWIFT_NAME(create(IMGSIZE:));
  127. /**
  128. * constructor
  129. */
  130. + (MACE*)create NS_SWIFT_NAME(create());
  131. @end
  132. NS_ASSUME_NONNULL_END