{"id":2047,"date":"2018-08-20T23:30:07","date_gmt":"2018-08-20T15:30:07","guid":{"rendered":"http:\/\/www.magicandlove.com\/blog\/?p=2047"},"modified":"2018-08-20T23:39:02","modified_gmt":"2018-08-20T15:39:02","slug":"face-swap-example-in-opencv-with-processing-v-2","status":"publish","type":"post","link":"http:\/\/www.magicandlove.com\/blog\/2018\/08\/20\/face-swap-example-in-opencv-with-processing-v-2\/","title":{"rendered":"Face swap example in OpenCV with Processing (v.2)"},"content":{"rendered":"<p>To enhance the <a href=\"http:\/\/www.magicandlove.com\/blog\/2018\/08\/20\/face-swap-example-in-opencv-with-processing-v-1\/\">last post in face swap<\/a>, we can make use of the <a href=\"https:\/\/docs.opencv.org\/3.4.2\/df\/da0\/group__photo__clone.html\" target=\"_blank\" rel=\"noopener\">cloning features<\/a> of the Photo module in OpenCV. The command we use is the <strong>seamlessClone()<\/strong> function.<\/p>\n<pre lang=\"java\">Photo.seamlessClone(warp, im2, mask, centre, output, Photo.NORMAL_CLONE);\r\n<\/pre>\n<p>where <strong>warp<\/strong> is the accumulation of all warped triangles; <strong>im2<\/strong> is the original target image; <strong>mask<\/strong> is the masked image of the convex hull of the face contour; <strong>centre<\/strong> is a <strong>Point<\/strong> variable of the centre of the target image; <strong>output<\/strong> will be the blended final image.<\/p>\n<p><a href=\"http:\/\/www.magicandlove.com\/blog\/wp-content\/uploads\/2018\/08\/faceswap0002.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-2048\" src=\"http:\/\/www.magicandlove.com\/blog\/wp-content\/uploads\/2018\/08\/faceswap0002-300x100.png\" alt=\"\" width=\"300\" height=\"100\" srcset=\"http:\/\/www.magicandlove.com\/blog\/wp-content\/uploads\/2018\/08\/faceswap0002-300x100.png 300w, http:\/\/www.magicandlove.com\/blog\/wp-content\/uploads\/2018\/08\/faceswap0002-768x256.png 768w, http:\/\/www.magicandlove.com\/blog\/wp-content\/uploads\/2018\/08\/faceswap0002.png 900w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Complete source code is now in the GitHub repository, <a href=\"https:\/\/github.com\/chungbwc\/Magicandlove\/tree\/master\/ml20180820b\" target=\"_blank\" rel=\"noopener\">ml20180820b<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>To enhance the last post in face swap, we can make use of the cloning features of the Photo module in OpenCV. The command we use is the seamlessClone() function. Photo.seamlessClone(warp, im2, mask, centre, output, Photo.NORMAL_CLONE); where warp is the accumulation of all warped triangles; im2 is the original target image; mask is the masked [&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":[168,3,62],"class_list":["post-2047","post","type-post","status-publish","format-standard","hentry","category-research","category-software-2","tag-face-swap","tag-opencv","tag-processing-org"],"_links":{"self":[{"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/posts\/2047","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=2047"}],"version-history":[{"count":3,"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/posts\/2047\/revisions"}],"predecessor-version":[{"id":2051,"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/posts\/2047\/revisions\/2051"}],"wp:attachment":[{"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/media?parent=2047"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/categories?post=2047"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/tags?post=2047"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}