{"id":3380,"date":"2021-06-09T21:30:04","date_gmt":"2021-06-09T13:30:04","guid":{"rendered":"http:\/\/www.magicandlove.com\/blog\/?p=3380"},"modified":"2021-06-11T09:43:05","modified_gmt":"2021-06-11T01:43:05","slug":"face-detection-with-dlib-in-touchdesigner","status":"publish","type":"post","link":"http:\/\/www.magicandlove.com\/blog\/2021\/06\/09\/face-detection-with-dlib-in-touchdesigner\/","title":{"rendered":"Face detection with Dlib in TouchDesigner"},"content":{"rendered":"\n<p>The example will continue to use a <a rel=\"noreferrer noopener\" href=\"https:\/\/docs.derivative.ca\/Script_CHOP\" target=\"_blank\">Script CHOP<\/a>, Python and TouchDesigner for a face detection function. Instead of using the <a rel=\"noreferrer noopener\" href=\"https:\/\/google.github.io\/mediapipe\/solutions\/face_detection.html\" target=\"_blank\">MediaPipe<\/a> library, it will use the <a rel=\"noreferrer noopener\" href=\"http:\/\/dlib.net\/\" target=\"_blank\">Dlib<\/a> Python binding. It refers to the <a rel=\"noreferrer noopener\" href=\"http:\/\/dlib.net\/face_detector.py.html\" target=\"_blank\">face detector<\/a> example program from the Dlib distribution. Dlib is a popular C++ based programming toolkit for various applications. Its image processing library contains a number of face detection functions. Python binding is also available.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"595\" src=\"http:\/\/www.magicandlove.com\/blog\/wp-content\/uploads\/2021\/06\/FaceDetectionDlib-1024x595.png\" alt=\"\" class=\"wp-image-3383\" srcset=\"http:\/\/www.magicandlove.com\/blog\/wp-content\/uploads\/2021\/06\/FaceDetectionDlib-1024x595.png 1024w, http:\/\/www.magicandlove.com\/blog\/wp-content\/uploads\/2021\/06\/FaceDetectionDlib-300x174.png 300w, http:\/\/www.magicandlove.com\/blog\/wp-content\/uploads\/2021\/06\/FaceDetectionDlib-768x446.png 768w, http:\/\/www.magicandlove.com\/blog\/wp-content\/uploads\/2021\/06\/FaceDetectionDlib-1536x893.png 1536w, http:\/\/www.magicandlove.com\/blog\/wp-content\/uploads\/2021\/06\/FaceDetectionDlib-690x401.png 690w, http:\/\/www.magicandlove.com\/blog\/wp-content\/uploads\/2021\/06\/FaceDetectionDlib-980x569.png 980w, http:\/\/www.magicandlove.com\/blog\/wp-content\/uploads\/2021\/06\/FaceDetectionDlib.png 1800w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>The main face detection capability is defined in the following statements.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import dlib\n\ndetector = dlib.get_frontal_face_detector()\n\nrects = detector(image, 0)<\/pre>\n\n\n\n<p>The Script CHOP will generate the following channels<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>cx (centre of the rectangle &#8211; horizontal)<\/li><li>cy (centre of the rectangle &#8211; vertical)<\/li><li>width<\/li><li>height<\/li><\/ul>\n\n\n\n<p>for the largest face it detected from the live image.<\/p>\n\n\n\n<p>The complete project is available in the <a href=\"https:\/\/github.com\/chungbwc\/TouchDesigner\/tree\/main\/FaceDetectionDlib1\" target=\"_blank\" rel=\"noreferrer noopener\">FaceDetectionDlib1<\/a> GitHub folder.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The example will continue to use a Script CHOP, Python and TouchDesigner for a face detection function. Instead of using the MediaPipe library, it will use the Dlib Python binding. It refers to the face detector example program from the Dlib distribution. Dlib is a popular C++ based programming toolkit for various applications. Its image [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[179],"tags":[186,43,182,84],"class_list":["post-3380","post","type-post","status-publish","format-standard","hentry","category-tutorials","tag-dlib","tag-face-detection","tag-python","tag-touchdesigner"],"_links":{"self":[{"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/posts\/3380","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=3380"}],"version-history":[{"count":10,"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/posts\/3380\/revisions"}],"predecessor-version":[{"id":3392,"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/posts\/3380\/revisions\/3392"}],"wp:attachment":[{"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/media?parent=3380"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/categories?post=3380"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/tags?post=3380"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}