{"id":2017,"date":"2018-08-18T22:31:45","date_gmt":"2018-08-18T14:31:45","guid":{"rendered":"http:\/\/www.magicandlove.com\/blog\/?p=2017"},"modified":"2018-08-18T22:45:46","modified_gmt":"2018-08-18T14:45:46","slug":"face-detection-with-the-opencv-face-module-in-processing","status":"publish","type":"post","link":"http:\/\/www.magicandlove.com\/blog\/2018\/08\/18\/face-detection-with-the-opencv-face-module-in-processing\/","title":{"rendered":"Face detection with the OpenCV Face module in Processing"},"content":{"rendered":"<p>This will be the series of tutorials to elaborate the OpenCV <a href=\"https:\/\/github.com\/opencv\/opencv_contrib\/blob\/3.4.2\/modules\/face\/samples\/sample_face_swapping.cpp\" target=\"_blank\" rel=\"noopener\">face swap example<\/a>. The 1st one is a demonstration of the face detection of the <a href=\"https:\/\/docs.opencv.org\/3.4.2\/da\/d60\/tutorial_face_main.html\" target=\"_blank\" rel=\"noopener\">Face module<\/a>, instead of using the <a href=\"https:\/\/docs.opencv.org\/3.4.2\/d2\/d64\/tutorial_table_of_content_objdetect.html\" target=\"_blank\" rel=\"noopener\">Object Detection module<\/a>. The sample program will detect faces from 2 photos, using the Haar Cascades file, <a href=\"https:\/\/github.com\/opencv\/opencv\/blob\/master\/data\/haarcascades\/haarcascade_frontalface_default.xml\" target=\"_blank\" rel=\"noopener\">haarcascade_frontalface_default.xml<\/a>, located in the <strong>data<\/strong> folder of the Processing sketch.<\/p>\n<p>The major command is<\/p>\n<pre lang=\"java\">Face.getFacesHAAR(im.getBGR(), faces, dataPath(faceFile));\r\n<\/pre>\n<p>where <strong>im.getBGR()<\/strong> is the photo <strong>Mat<\/strong> returned from the <strong>CVImage<\/strong> object, <strong>im<\/strong>, <strong>faces<\/strong> is a <strong>MatOfRect<\/strong> variable returning the rectangle of all faces detected, and <strong>faceFile<\/strong> is a string variable containing the file name of the Haar Cascades XML file.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2018\" src=\"http:\/\/www.magicandlove.com\/blog\/wp-content\/uploads\/2018\/08\/face0001.png\" alt=\"\" width=\"600\" height=\"300\" srcset=\"http:\/\/www.magicandlove.com\/blog\/wp-content\/uploads\/2018\/08\/face0001.png 600w, http:\/\/www.magicandlove.com\/blog\/wp-content\/uploads\/2018\/08\/face0001-300x150.png 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p>Complete source code is in the website GitHub repository, <a href=\"https:\/\/github.com\/chungbwc\/Magicandlove\/tree\/master\/ml20180818a\" target=\"_blank\" rel=\"noopener\">ml20180818a<\/a>.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This will be the series of tutorials to elaborate the OpenCV face swap example. The 1st one is a demonstration of the face detection of the Face module, instead of using the Object Detection module. The sample program will detect faces from 2 photos, using the Haar Cascades file, haarcascade_frontalface_default.xml, located in the data folder [&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":[164,43,3,62],"class_list":["post-2017","post","type-post","status-publish","format-standard","hentry","category-research","category-software-2","tag-cvimage","tag-face-detection","tag-opencv","tag-processing-org"],"_links":{"self":[{"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/posts\/2017","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=2017"}],"version-history":[{"count":3,"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/posts\/2017\/revisions"}],"predecessor-version":[{"id":2021,"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/posts\/2017\/revisions\/2021"}],"wp:attachment":[{"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/media?parent=2017"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/categories?post=2017"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/tags?post=2017"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}