{"id":107,"date":"2010-09-30T21:10:00","date_gmt":"2010-09-30T11:10:00","guid":{"rendered":"http:\/\/www.samontab.com\/web\/?p=107"},"modified":"2021-03-03T09:52:44","modified_gmt":"2021-03-02T22:52:44","slug":"face-detection-using-torch3vision-library-in-ubuntu","status":"publish","type":"post","link":"https:\/\/www.samontab.com\/web\/2010\/09\/face-detection-using-torch3vision-library-in-ubuntu\/","title":{"rendered":"Face detection using torch3vision library in Ubuntu"},"content":{"rendered":"<p><a href=\"https:\/\/torch3vision.idiap.ch\/\">Torch3vision<\/a> is a nice machine vision library. It implements some features and algorithms that are not present in other libraries (especially the ones based on illumination). In this post I will show you how to install it and how to detect faces with it. A nice thing about this library is that is it released under the BSD license, which makes it usable for commercial projects.<\/p>\n<p>OK, let&#8217;s install this library. These instructions should work on any version of Ubuntu, but I tested them under Ubuntu 10.04.<\/p>\n<p>Execute the following commands in the Terminal:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo apt-get install build-essential\r\ncd\r\nmkdir faceDetectors\r\ncd faceDetectors\r\nwget https:\/\/torch3vision.idiap.ch\/sources\/vision2.1\/Torch3vision2.1.tgz\r\ntar -xvzf Torch3vision2.1.tgz\r\nrm Torch3vision2.1.tgz\r\ncd Torch3vision2.1\r\ncp Linux_i686.cfg.vision2.1 Linux_i686.cfg\r\ncp Makefile_options_Linux.vision2.1 Makefile_options_Linux\r\ncp vision2.1\/Makefile_vision_Linux.example.basic vision2.1\/Makefile_vision_Linux\r\nmake clean; make depend; make\r\n<\/pre>\n<p>That&#8217;s it, we can use the library now. Let&#8217;s build and run some examples:<\/p>\n<p>Note: Ignore the &#8220;Try to compile Torch&#8221; messages when compiling the examples; everything is fine.<\/p>\n<p>First, let&#8217;s apply a <a href=\"https:\/\/en.wikipedia.org\/wiki\/Retinex#Retinex_Theory\">retinex<\/a> algorithm. The idea here is to remove extreme shadows and highlights so that the objects in the scene appear under a more uniform illumination than the original.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ncd vision2.1\/examples\/illumination\r\nmake\r\nmv Linux_DBG_FLOAT\/* .\r\n.\/multiscaleRetinex ..\/data\/1002.pgm ..\/data\/result.pgm\r\n<\/pre>\n<p>The previous example runs multiscale retinex on the first image (..\/data\/1002.pgm) and stores the result in the second (..\/data\/result.pgm). You can see the results of this retinex algorithm in the following image:<\/p>\n<p><a href=\"https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2010\/09\/retinex1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-109\" title=\"retinex\" src=\"https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2010\/09\/retinex1.png\" alt=\"\" width=\"282\" height=\"160\" \/><\/a><\/p>\n<p>Now, let&#8217;s detect some faces:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ncd ..\/facedetect\r\nmake\r\nmv Linux_DBG_FLOAT\/* .\r\n.\/mlpcascadescan ..\/data\/9001_f_wm_s01_9001_en_1.ppm -minWsize 79 -draw -savepos\r\n<\/pre>\n<p>In this example, a cascade of multilayer perceptrons (<a href=\"https:\/\/en.wikipedia.org\/wiki\/Multilayer_perceptron\">MLP<\/a>)\u00c2\u00a0 is used. The library also provides a face detector based on a cascade of Haar-like wavelets (similar to the ones in the OpenCV face detector). An image is created in the same directory if at least one face is detected. You can see an example of this procedure in the following image:<\/p>\n<p><a href=\"https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2010\/09\/face.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-110\" title=\"face\" src=\"https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2010\/09\/face-256x300.png\" alt=\"\" width=\"256\" height=\"300\" srcset=\"https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2010\/09\/face-256x300.png 256w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2010\/09\/face.png 385w\" sizes=\"auto, (max-width: 256px) 100vw, 256px\" \/><\/a><\/p>\n<p>As you can see, the face was correctly detected. This library also provides many other examples for face detection and other features. Take a look at the other examples provided, it is definitely a nice library to have around.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Torch3vision is a nice machine vision library. It implements some features and algorithms that are not present in other libraries (especially the ones based on illumination). In this post I will show you how to install it and how to detect faces with it. A nice thing about this library is that is it released [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29,21,4],"tags":[],"class_list":["post-107","post","type-post","status-publish","format-standard","hentry","category-computer-vision","category-open-source","category-programming"],"_links":{"self":[{"href":"https:\/\/www.samontab.com\/web\/wp-json\/wp\/v2\/posts\/107","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.samontab.com\/web\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.samontab.com\/web\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.samontab.com\/web\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.samontab.com\/web\/wp-json\/wp\/v2\/comments?post=107"}],"version-history":[{"count":0,"href":"https:\/\/www.samontab.com\/web\/wp-json\/wp\/v2\/posts\/107\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.samontab.com\/web\/wp-json\/wp\/v2\/media?parent=107"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.samontab.com\/web\/wp-json\/wp\/v2\/categories?post=107"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.samontab.com\/web\/wp-json\/wp\/v2\/tags?post=107"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}