Face.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  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. #else
  9. #define CV_EXPORTS
  10. #endif
  11. #import <Foundation/Foundation.h>
  12. @class Facemark;
  13. @class Mat;
  14. @class Point2f;
  15. @class Scalar;
  16. NS_ASSUME_NONNULL_BEGIN
  17. // C++: class Face
  18. /**
  19. * The Face module
  20. *
  21. * Member classes: `FaceRecognizer`, `Facemark`, `PredictCollector`, `StandardCollector`, `FacemarkKazemi`, `FacemarkAAM`, `BIF`, `MACE`, `FacemarkTrain`, `FacemarkLBF`, `BasicFaceRecognizer`, `EigenFaceRecognizer`, `FisherFaceRecognizer`, `LBPHFaceRecognizer`
  22. *
  23. */
  24. CV_EXPORTS @interface Face : NSObject
  25. #pragma mark - Methods
  26. //
  27. // Ptr_Facemark cv::face::createFacemarkAAM()
  28. //
  29. + (Facemark*)createFacemarkAAM NS_SWIFT_NAME(createFacemarkAAM());
  30. //
  31. // Ptr_Facemark cv::face::createFacemarkLBF()
  32. //
  33. + (Facemark*)createFacemarkLBF NS_SWIFT_NAME(createFacemarkLBF());
  34. //
  35. // Ptr_Facemark cv::face::createFacemarkKazemi()
  36. //
  37. + (Facemark*)createFacemarkKazemi NS_SWIFT_NAME(createFacemarkKazemi());
  38. //
  39. // bool cv::face::getFacesHAAR(Mat image, Mat& faces, String face_cascade_name)
  40. //
  41. /**
  42. * Default face detector
  43. * This function is mainly utilized by the implementation of a Facemark Algorithm.
  44. * End users are advised to use function Facemark::getFaces which can be manually defined
  45. * and circumvented to the algorithm by Facemark::setFaceDetector.
  46. *
  47. * @param image The input image to be processed.
  48. * @param faces Output of the function which represent region of interest of the detected faces.
  49. * Each face is stored in cv::Rect container.
  50. *
  51. * <B>Example of usage</B>
  52. *
  53. * std::vector<cv::Rect> faces;
  54. * CParams params("haarcascade_frontalface_alt.xml");
  55. * cv::face::getFaces(frame, faces, &params);
  56. * for(int j=0;j<faces.size();j++){
  57. * cv::rectangle(frame, faces[j], cv::Scalar(255,0,255));
  58. * }
  59. * cv::imshow("detection", frame);
  60. *
  61. */
  62. + (BOOL)getFacesHAAR:(Mat*)image faces:(Mat*)faces face_cascade_name:(NSString*)face_cascade_name NS_SWIFT_NAME(getFacesHAAR(image:faces:face_cascade_name:));
  63. //
  64. // bool cv::face::loadDatasetList(String imageList, String annotationList, vector_String images, vector_String annotations)
  65. //
  66. /**
  67. * A utility to load list of paths to training image and annotation file.
  68. * @param imageList The specified file contains paths to the training images.
  69. * @param annotationList The specified file contains paths to the training annotations.
  70. * @param images The loaded paths of training images.
  71. * @param annotations The loaded paths of annotation files.
  72. *
  73. * Example of usage:
  74. *
  75. * String imageFiles = "images_path.txt";
  76. * String ptsFiles = "annotations_path.txt";
  77. * std::vector<String> images_train;
  78. * std::vector<String> landmarks_train;
  79. * loadDatasetList(imageFiles,ptsFiles,images_train,landmarks_train);
  80. *
  81. */
  82. + (BOOL)loadDatasetList:(NSString*)imageList annotationList:(NSString*)annotationList images:(NSArray<NSString*>*)images annotations:(NSArray<NSString*>*)annotations NS_SWIFT_NAME(loadDatasetList(imageList:annotationList:images:annotations:));
  83. //
  84. // bool cv::face::loadTrainingData(String filename, vector_String images, Mat& facePoints, char delim = ' ', float offset = 0.0f)
  85. //
  86. /**
  87. * A utility to load facial landmark dataset from a single file.
  88. *
  89. * @param filename The filename of a file that contains the dataset information.
  90. * Each line contains the filename of an image followed by
  91. * pairs of x and y values of facial landmarks points separated by a space.
  92. * Example
  93. *
  94. * /home/user/ibug/image_003_1.jpg 336.820955 240.864510 334.238298 260.922709 335.266918 ...
  95. * /home/user/ibug/image_005_1.jpg 376.158428 230.845712 376.736984 254.924635 383.265403 ...
  96. *
  97. * @param images A vector where each element represent the filename of image in the dataset.
  98. * Images are not loaded by default to save the memory.
  99. * @param facePoints The loaded landmark points for all training data.
  100. * @param delim Delimiter between each element, the default value is a whitespace.
  101. * @param offset An offset value to adjust the loaded points.
  102. *
  103. * <B>Example of usage</B>
  104. *
  105. * cv::String imageFiles = "../data/images_train.txt";
  106. * cv::String ptsFiles = "../data/points_train.txt";
  107. * std::vector<String> images;
  108. * std::vector<std::vector<Point2f> > facePoints;
  109. * loadTrainingData(imageFiles, ptsFiles, images, facePoints, 0.0f);
  110. *
  111. */
  112. + (BOOL)loadTrainingData:(NSString*)filename images:(NSArray<NSString*>*)images facePoints:(Mat*)facePoints delim:(char)delim offset:(float)offset NS_SWIFT_NAME(loadTrainingData(filename:images:facePoints:delim:offset:));
  113. /**
  114. * A utility to load facial landmark dataset from a single file.
  115. *
  116. * @param filename The filename of a file that contains the dataset information.
  117. * Each line contains the filename of an image followed by
  118. * pairs of x and y values of facial landmarks points separated by a space.
  119. * Example
  120. *
  121. * /home/user/ibug/image_003_1.jpg 336.820955 240.864510 334.238298 260.922709 335.266918 ...
  122. * /home/user/ibug/image_005_1.jpg 376.158428 230.845712 376.736984 254.924635 383.265403 ...
  123. *
  124. * @param images A vector where each element represent the filename of image in the dataset.
  125. * Images are not loaded by default to save the memory.
  126. * @param facePoints The loaded landmark points for all training data.
  127. * @param delim Delimiter between each element, the default value is a whitespace.
  128. *
  129. * <B>Example of usage</B>
  130. *
  131. * cv::String imageFiles = "../data/images_train.txt";
  132. * cv::String ptsFiles = "../data/points_train.txt";
  133. * std::vector<String> images;
  134. * std::vector<std::vector<Point2f> > facePoints;
  135. * loadTrainingData(imageFiles, ptsFiles, images, facePoints, 0.0f);
  136. *
  137. */
  138. + (BOOL)loadTrainingData:(NSString*)filename images:(NSArray<NSString*>*)images facePoints:(Mat*)facePoints delim:(char)delim NS_SWIFT_NAME(loadTrainingData(filename:images:facePoints:delim:));
  139. /**
  140. * A utility to load facial landmark dataset from a single file.
  141. *
  142. * @param filename The filename of a file that contains the dataset information.
  143. * Each line contains the filename of an image followed by
  144. * pairs of x and y values of facial landmarks points separated by a space.
  145. * Example
  146. *
  147. * /home/user/ibug/image_003_1.jpg 336.820955 240.864510 334.238298 260.922709 335.266918 ...
  148. * /home/user/ibug/image_005_1.jpg 376.158428 230.845712 376.736984 254.924635 383.265403 ...
  149. *
  150. * @param images A vector where each element represent the filename of image in the dataset.
  151. * Images are not loaded by default to save the memory.
  152. * @param facePoints The loaded landmark points for all training data.
  153. *
  154. * <B>Example of usage</B>
  155. *
  156. * cv::String imageFiles = "../data/images_train.txt";
  157. * cv::String ptsFiles = "../data/points_train.txt";
  158. * std::vector<String> images;
  159. * std::vector<std::vector<Point2f> > facePoints;
  160. * loadTrainingData(imageFiles, ptsFiles, images, facePoints, 0.0f);
  161. *
  162. */
  163. + (BOOL)loadTrainingData:(NSString*)filename images:(NSArray<NSString*>*)images facePoints:(Mat*)facePoints NS_SWIFT_NAME(loadTrainingData(filename:images:facePoints:));
  164. //
  165. // bool cv::face::loadTrainingData(String imageList, String groundTruth, vector_String images, Mat& facePoints, float offset = 0.0f)
  166. //
  167. /**
  168. * A utility to load facial landmark information from the dataset.
  169. *
  170. * @param imageList A file contains the list of image filenames in the training dataset.
  171. * @param groundTruth A file contains the list of filenames
  172. * where the landmarks points information are stored.
  173. * The content in each file should follow the standard format (see face::loadFacePoints).
  174. * @param images A vector where each element represent the filename of image in the dataset.
  175. * Images are not loaded by default to save the memory.
  176. * @param facePoints The loaded landmark points for all training data.
  177. * @param offset An offset value to adjust the loaded points.
  178. *
  179. * <B>Example of usage</B>
  180. *
  181. * cv::String imageFiles = "../data/images_train.txt";
  182. * cv::String ptsFiles = "../data/points_train.txt";
  183. * std::vector<String> images;
  184. * std::vector<std::vector<Point2f> > facePoints;
  185. * loadTrainingData(imageFiles, ptsFiles, images, facePoints, 0.0f);
  186. *
  187. *
  188. * example of content in the images_train.txt
  189. *
  190. * /home/user/ibug/image_003_1.jpg
  191. * /home/user/ibug/image_004_1.jpg
  192. * /home/user/ibug/image_005_1.jpg
  193. * /home/user/ibug/image_006.jpg
  194. *
  195. *
  196. * example of content in the points_train.txt
  197. *
  198. * /home/user/ibug/image_003_1.pts
  199. * /home/user/ibug/image_004_1.pts
  200. * /home/user/ibug/image_005_1.pts
  201. * /home/user/ibug/image_006.pts
  202. *
  203. */
  204. + (BOOL)loadTrainingData:(NSString*)imageList groundTruth:(NSString*)groundTruth images:(NSArray<NSString*>*)images facePoints:(Mat*)facePoints offset:(float)offset NS_SWIFT_NAME(loadTrainingData(imageList:groundTruth:images:facePoints:offset:));
  205. /**
  206. * A utility to load facial landmark information from the dataset.
  207. *
  208. * @param imageList A file contains the list of image filenames in the training dataset.
  209. * @param groundTruth A file contains the list of filenames
  210. * where the landmarks points information are stored.
  211. * The content in each file should follow the standard format (see face::loadFacePoints).
  212. * @param images A vector where each element represent the filename of image in the dataset.
  213. * Images are not loaded by default to save the memory.
  214. * @param facePoints The loaded landmark points for all training data.
  215. *
  216. * <B>Example of usage</B>
  217. *
  218. * cv::String imageFiles = "../data/images_train.txt";
  219. * cv::String ptsFiles = "../data/points_train.txt";
  220. * std::vector<String> images;
  221. * std::vector<std::vector<Point2f> > facePoints;
  222. * loadTrainingData(imageFiles, ptsFiles, images, facePoints, 0.0f);
  223. *
  224. *
  225. * example of content in the images_train.txt
  226. *
  227. * /home/user/ibug/image_003_1.jpg
  228. * /home/user/ibug/image_004_1.jpg
  229. * /home/user/ibug/image_005_1.jpg
  230. * /home/user/ibug/image_006.jpg
  231. *
  232. *
  233. * example of content in the points_train.txt
  234. *
  235. * /home/user/ibug/image_003_1.pts
  236. * /home/user/ibug/image_004_1.pts
  237. * /home/user/ibug/image_005_1.pts
  238. * /home/user/ibug/image_006.pts
  239. *
  240. */
  241. + (BOOL)loadTrainingData:(NSString*)imageList groundTruth:(NSString*)groundTruth images:(NSArray<NSString*>*)images facePoints:(Mat*)facePoints NS_SWIFT_NAME(loadTrainingData(imageList:groundTruth:images:facePoints:));
  242. //
  243. // bool cv::face::loadTrainingData(vector_String filename, vector_vector_Point2f trainlandmarks, vector_String trainimages)
  244. //
  245. /**
  246. * This function extracts the data for training from .txt files which contains the corresponding image name and landmarks.
  247. * The first file in each file should give the path of the image whose
  248. * landmarks are being described in the file. Then in the subsequent
  249. * lines there should be coordinates of the landmarks in the image
  250. * i.e each line should be of the form x,y
  251. * where x represents the x coordinate of the landmark and y represents
  252. * the y coordinate of the landmark.
  253. *
  254. * For reference you can see the files as provided in the
  255. * <a href="http://www.ifp.illinois.edu/~vuongle2/helen/">HELEN dataset</a>
  256. *
  257. * @param filename A vector of type cv::String containing name of the .txt files.
  258. * @param trainlandmarks A vector of type cv::Point2f that would store shape or landmarks of all images.
  259. * @param trainimages A vector of type cv::String which stores the name of images whose landmarks are tracked
  260. * @return A boolean value. It returns true when it reads the data successfully and false otherwise
  261. */
  262. + (BOOL)loadTrainingData:(NSArray<NSString*>*)filename trainlandmarks:(NSArray<NSArray<Point2f*>*>*)trainlandmarks trainimages:(NSArray<NSString*>*)trainimages NS_SWIFT_NAME(loadTrainingData(filename:trainlandmarks:trainimages:));
  263. //
  264. // bool cv::face::loadFacePoints(String filename, Mat& points, float offset = 0.0f)
  265. //
  266. /**
  267. * A utility to load facial landmark information from a given file.
  268. *
  269. * @param filename The filename of file contains the facial landmarks data.
  270. * @param points The loaded facial landmark points.
  271. * @param offset An offset value to adjust the loaded points.
  272. *
  273. * <B>Example of usage</B>
  274. *
  275. * std::vector<Point2f> points;
  276. * face::loadFacePoints("filename.txt", points, 0.0f);
  277. *
  278. *
  279. * The annotation file should follow the default format which is
  280. *
  281. * version: 1
  282. * n_points: 68
  283. * {
  284. * 212.716603 499.771793
  285. * 230.232816 566.290071
  286. * ...
  287. * }
  288. *
  289. * where n_points is the number of points considered
  290. * and each point is represented as its position in x and y.
  291. */
  292. + (BOOL)loadFacePoints:(NSString*)filename points:(Mat*)points offset:(float)offset NS_SWIFT_NAME(loadFacePoints(filename:points:offset:));
  293. /**
  294. * A utility to load facial landmark information from a given file.
  295. *
  296. * @param filename The filename of file contains the facial landmarks data.
  297. * @param points The loaded facial landmark points.
  298. *
  299. * <B>Example of usage</B>
  300. *
  301. * std::vector<Point2f> points;
  302. * face::loadFacePoints("filename.txt", points, 0.0f);
  303. *
  304. *
  305. * The annotation file should follow the default format which is
  306. *
  307. * version: 1
  308. * n_points: 68
  309. * {
  310. * 212.716603 499.771793
  311. * 230.232816 566.290071
  312. * ...
  313. * }
  314. *
  315. * where n_points is the number of points considered
  316. * and each point is represented as its position in x and y.
  317. */
  318. + (BOOL)loadFacePoints:(NSString*)filename points:(Mat*)points NS_SWIFT_NAME(loadFacePoints(filename:points:));
  319. //
  320. // void cv::face::drawFacemarks(Mat& image, Mat points, Scalar color = Scalar(255,0,0))
  321. //
  322. /**
  323. * Utility to draw the detected facial landmark points
  324. *
  325. * @param image The input image to be processed.
  326. * @param points Contains the data of points which will be drawn.
  327. * @param color The color of points in BGR format represented by cv::Scalar.
  328. *
  329. * <B>Example of usage</B>
  330. *
  331. * std::vector<Rect> faces;
  332. * std::vector<std::vector<Point2f> > landmarks;
  333. * facemark->getFaces(img, faces);
  334. * facemark->fit(img, faces, landmarks);
  335. * for(int j=0;j<rects.size();j++){
  336. * face::drawFacemarks(frame, landmarks[j], Scalar(0,0,255));
  337. * }
  338. *
  339. */
  340. + (void)drawFacemarks:(Mat*)image points:(Mat*)points color:(Scalar*)color NS_SWIFT_NAME(drawFacemarks(image:points:color:));
  341. /**
  342. * Utility to draw the detected facial landmark points
  343. *
  344. * @param image The input image to be processed.
  345. * @param points Contains the data of points which will be drawn.
  346. *
  347. * <B>Example of usage</B>
  348. *
  349. * std::vector<Rect> faces;
  350. * std::vector<std::vector<Point2f> > landmarks;
  351. * facemark->getFaces(img, faces);
  352. * facemark->fit(img, faces, landmarks);
  353. * for(int j=0;j<rects.size();j++){
  354. * face::drawFacemarks(frame, landmarks[j], Scalar(0,0,255));
  355. * }
  356. *
  357. */
  358. + (void)drawFacemarks:(Mat*)image points:(Mat*)points NS_SWIFT_NAME(drawFacemarks(image:points:));
  359. @end
  360. NS_ASSUME_NONNULL_END