{"id":2022,"date":"2018-08-19T22:50:49","date_gmt":"2018-08-19T14:50:49","guid":{"rendered":"http:\/\/www.magicandlove.com\/blog\/?p=2022"},"modified":"2018-08-20T00:14:00","modified_gmt":"2018-08-19T16:14:00","slug":"face-landmark-detection-in-opencv-face-module-with-processing","status":"publish","type":"post","link":"http:\/\/www.magicandlove.com\/blog\/2018\/08\/19\/face-landmark-detection-in-opencv-face-module-with-processing\/","title":{"rendered":"Face landmark detection in OpenCV Face module with Processing"},"content":{"rendered":"<p>The 2nd exercise is a demonstration using the Face module of the OpenCV contribution libraries. The official documentation for OpenCV 3.4.2 has a tutorial on <a href=\"https:\/\/docs.opencv.org\/3.4.2\/d2\/d42\/tutorial_face_landmark_detection_in_an_image.html\" target=\"_blank\" rel=\"noopener\">face landmark detection<\/a>. The Face module distribution also has a sample &#8211; <a href=\"https:\/\/github.com\/opencv\/opencv_contrib\/blob\/3.4.2\/modules\/face\/samples\/Facemark.java\" target=\"_blank\" rel=\"noopener\">Facemark.java<\/a>.\u00a0 This exercise is derived from this sample. There are 2 extra parameter files. One is the Haar Cascades file,\u00a0 haarcascade_frontalface_default.xml we used in <a href=\"http:\/\/www.magicandlove.com\/blog\/2018\/08\/18\/face-detection-with-the-opencv-face-module-in-processing\/\">the last post<\/a> for general face detection. The other one is the face landmark model file face_landmark_model.dat that will be downloaded during the building process of the OpenCV. Otherwise, it is also available at this <a href=\"https:\/\/github.com\/opencv\/opencv_3rdparty\/tree\/contrib_face_alignment_20170818\" target=\"_blank\" rel=\"noopener\">GitHub link<\/a>.<\/p>\n<p>The program uses the <strong>Facemark<\/strong> class with the instance variable <strong>fm<\/strong>.<\/p>\n<pre lang=\"java\">Facemark fm;\r\n<\/pre>\n<p>It is created by the command.<\/p>\n<pre lang=\"java\">fm = Face.createFacemarkKazemi();\r\n<\/pre>\n<p>And load in the model file with the following,<\/p>\n<pre lang=\"java\">\r\nfm.loadModel(datPath(modelFile));\r\n<\/pre>\n<p>where <strong>modelFile<\/strong> is the string variable containing the model file name.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2023\" src=\"http:\/\/www.magicandlove.com\/blog\/wp-content\/uploads\/2018\/08\/face0002.png\" alt=\"\" width=\"600\" height=\"300\" srcset=\"http:\/\/www.magicandlove.com\/blog\/wp-content\/uploads\/2018\/08\/face0002.png 600w, http:\/\/www.magicandlove.com\/blog\/wp-content\/uploads\/2018\/08\/face0002-300x150.png 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p>Complete source code is in this <a href=\"https:\/\/github.com\/chungbwc\/Magicandlove\/tree\/master\/ml20180818b\" target=\"_blank\" rel=\"noopener\">GitHub repository<\/a>.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The 2nd exercise is a demonstration using the Face module of the OpenCV contribution libraries. The official documentation for OpenCV 3.4.2 has a tutorial on face landmark detection. The Face module distribution also has a sample &#8211; Facemark.java.\u00a0 This exercise is derived from this sample. There are 2 extra parameter files. One is the Haar [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[89,79],"tags":[165,3,62],"class_list":["post-2022","post","type-post","status-publish","format-standard","hentry","category-research","category-software-2","tag-face-landmark","tag-opencv","tag-processing-org"],"_links":{"self":[{"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/posts\/2022","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/comments?post=2022"}],"version-history":[{"count":6,"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/posts\/2022\/revisions"}],"predecessor-version":[{"id":2029,"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/posts\/2022\/revisions\/2029"}],"wp:attachment":[{"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/media?parent=2022"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/categories?post=2022"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/tags?post=2022"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}