<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Sebastian Montabone</title>
	<atom:link href="http://www.samontab.com/web/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.samontab.com/web</link>
	<description>My past and current projects</description>
	<lastBuildDate>Fri, 18 Jan 2013 05:04:32 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>How to make HD screencasts using free tools</title>
		<link>http://www.samontab.com/web/2013/01/how-to-make-hd-screencasts-using-free-tools/</link>
		<comments>http://www.samontab.com/web/2013/01/how-to-make-hd-screencasts-using-free-tools/#comments</comments>
		<pubDate>Wed, 09 Jan 2013 18:33:52 +0000</pubDate>
		<dc:creator>samontab</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Open Source]]></category>

		<guid isPermaLink="false">http://www.samontab.com/web/?p=241</guid>
		<description><![CDATA[A screencast is basically a video of your computer screen with your voice as the audio. A screencast is very useful for tutorials or teaching how to use something with your computer. There are a couple of paid programs that allow you to create screencasts, but in this post I will show you how to [...]]]></description>
				<content:encoded><![CDATA[<p>A <a title="Screencast" href="http://en.wikipedia.org/wiki/Screencast">screencast</a> is basically a video of your computer screen with your voice as the audio. A screencast is very useful for tutorials or teaching how to use something with your computer.<br />
There are a couple of paid programs that allow you to create screencasts, but in this post I will show you how to make them using only free tools(although you need to be running Windows for this tutorial, which is not free, sorry about that).</p>
<p>The first step is to download and install the codec that will allow us to compress the video. We are going to use one of the best standards for HD video: <strong>H.264/MPEG-4 AVC</strong>. The specific implementation to install here is <strong>x264vfw</strong>.</p>
<p>You need to install the <a href="http://sourceforge.net/projects/x264vfw/files/x264vfw/" title="32 bits x264vfw" target="_blank">32 bits version</a> (even if you have a 64 bits system). After you install the 32 bits version, try to install the <a href="http://sourceforge.net/projects/x264vfw/files/x264vfw64/" title="64 bits x264vfw" target="_blank">64 bits version</a> as well (you may not be able to do it in a 32 bit system).</p>
<p>Now, install the latest version of <a title="camstudio" href="http://camstudio.org/" target="_blank">camstudio</a>. It is a great program that will allow you to record your voice and your desktop. Make sure that you also install the <strong>Lossless Video Codec</strong> as well.</p>
<p>OK, now you should have camstudio and its Lossless Video Codec installed. <strong>Make sure that you have your mic and/or video camera connected to your computer</strong>. Now we are going to configure camstudio to make it screencast ready.</p>
<p>Start camstudio and set the following options:</p>
<ul>
<li>Options-&gt; Record audio from microphone</li>
<li>Options-&gt; Program Options -&gt; Play AVI file when recording stops -&gt; Do not play AVI file</li>
<li>Options-&gt; Program Options -&gt; Name of AVI file -&gt; Automatic file naming (use date and time)</li>
<li>Options-&gt; Program Options -&gt; Minimize program on start recording (not checked)</li>
<li>Options-&gt; Program Options -&gt; Directory for recording -&gt; Use user specified directory&#8230; (and specify a directory where you want your videos to be saved)</li>
</ul>
<p>Now, go to Options-&gt; Video options, and select the following:<br />
<a href="http://www.samontab.com/web/2013/01/how-to-make-an-hd-screencast-using-free-tools/camstudio_lossless/" rel="attachment wp-att-263"><img src="http://www.samontab.com/web/wp-content/uploads/2013/01/camstudio_lossless.png" alt="camstudio_lossless" width="471" height="457" class="alignnone size-full wp-image-263" /></a></p>
<ul>
<li>Compressor: CamStudio Lossless Codec 1.5 (<em>or newer</em>)</li>
<li>Quality 100</li>
<li>Select Auto Adjust</li>
<li>Move the slider to where you have a Playback rate of 25 frames / second (the default one is 200 fps!)</li>
</ul>
<p>Now go to Options-> Audio options-> Audio options for microphone, and select the following:<br />
<a href="http://www.samontab.com/web/2013/01/how-to-make-an-hd-screencast-using-free-tools/camstudio_audio/" rel="attachment wp-att-264"><img src="http://www.samontab.com/web/wp-content/uploads/2013/01/camstudio_audio.png" alt="camstudio_audio" width="316" height="451" class="alignnone size-full wp-image-264" /></a></p>
<ul>
<li>Audio Capture Device: Select your device</li>
<li>Recording Format, select 44.1kHz, stereo, 16 bit.</li>
<li>Compressed format: PCM</li>
</ul>
<p>Now we are going to set which area of the screen to record. Go to Region-&gt;Fixed Region and set these values:<br />
<a href="http://www.samontab.com/web/2013/01/how-to-make-an-hd-screencast-using-free-tools/camstudio_fixedregion/" rel="attachment wp-att-265"><img src="http://www.samontab.com/web/wp-content/uploads/2013/01/camstudio_fixedregion.png" alt="camstudio_fixedregion" width="259" height="318" class="alignnone size-full wp-image-265" /></a></p>
<ul>
<li>Left: 80</li>
<li>Top: 25</li>
<li><strong>Width: 1280</strong></li>
<li><strong>Height: 720</strong></li>
</ul>
<p>The most important thing to note here is the width and height of 1280 and 720 respectively. This is <a href="http://en.wikipedia.org/wiki/High-definition_television#High-definition_display_resolutions" title="HD resolutions" target="_blank">widescreen HD format</a> (720p) and it is very important that you use these values. If you use other, non standard values, you will end up with problems in your video. If you have a larger screen, you may want to use a width of 1920 and a height of 1080, which is even better (1080p). The other values, left and top, should be set depending on the actual area that you want to record of your desktop. Remember that <strong>left</strong> plus <strong>width</strong> and <strong>top</strong> plus <strong>height</strong> should be less or equal to your total screen width and height respectively.</p>
<p>Alternatively to selecting a specific region in your screen, you can first adjust your screen resolution to 1280&#215;720 (or 1920&#215;1080), and select Region-> Full Screen instead. I prefer using a region because you can show your software in your native resolution, and also you have the option to not show the clock, and the menu bar, etc. This is specially important for continuity when editing videos later.</p>
<p>OK, now go ahead and make a couple of quick tests. Click on the record button(red circle), start talking, moving your mouse, opening folders, etc. After some seconds, press stop(blue square). After a moment, a video should be waiting for you in the location you specified earlier without you having to do anything else. Go there and check it. Make sure that the video came out OK, that you can see the areas that you want, that your voice is loud and clear, that the video resolution and frame rate are what you expected, and that you are comfortable with this recording procedure. Also, always make sure that you have at least a couple of seconds at the beginning and at the end of your recordings. Specially at the end, because the encoding technique that we will use cuts one or two seconds at the end, depending on the length of your video.</p>
<p>Before you start doing real screencasts, let&#8217;s check a couple of issues. Camstudio is a great program, but sometimes it crashes, and it forgets all your settings, which is unfortunate (incredibly annoying and frustrating). That&#8217;s why it is good to save your preferences, which are stored in four files located at the installation directory (<strong>C:\Program Files (x86)\CamStudio 2.6b</strong>). Once you have set all your preferences, just copy these four files: <strong>Camdata.ini</strong>, <strong>CamLayout.ini</strong>, <strong>CamShapes.ini</strong>, <strong>CamStudio.ini</strong> into a safe place (C:\Users\Public\Documents\camstudioconfig for example). If camstudio crashes and forgets your preferences, simply close the software, copy your files back and continue normally.</p>
<p>After you record a couple of videos, you can edit them. We are going to use a video editor called <a title="Virtualdub" href="http://sourceforge.net/projects/virtualdub/?source=directory" target="_blank">virtualdub</a>. Download and open it. Drag and drop a video there. You can now see all the frames that compose the video. You can select some frames and delete them for example. Also, you can append another video. You can also do many other things, but appending videos and removing frames is all you need to create a nice screencast. It is important that all your videos are recorded with the same settings, like width, height, even sound should be the same. </p>
<p>Before you edit a video, always check these settings in virtualdub:</p>
<ul>
<li>Make sure that Video-&gt;Full processing mode is selected</li>
<li>Make sure that Audio-&gt;Direct stream copy is selected</li>
</ul>
<p>Now, go to Video-> compression and select x264vfw:<br />
<a href="http://www.samontab.com/web/2013/01/how-to-make-an-hd-screencast-using-free-tools/virtualdub_compression/" rel="attachment wp-att-266"><img src="http://www.samontab.com/web/wp-content/uploads/2013/01/virtualdub_compression-300x176.png" alt="virtualdub_compression" width="300" height="176" class="alignnone size-medium wp-image-266" /></a></p>
<p>Click on configure and set the following options:<br />
<a href="http://www.samontab.com/web/2013/01/how-to-make-an-hd-screencast-using-free-tools/virtualdub_configuration/" rel="attachment wp-att-267"><img src="http://www.samontab.com/web/wp-content/uploads/2013/01/virtualdub_configuration-300x263.png" alt="virtualdub_configuration" width="300" height="263" class="alignnone size-medium wp-image-267" /></a></p>
<ul>
<li>enable zero latency</li>
<li>enable virtualdub hack</li>
</ul>
<p>Click OK, OK<br />
Now you can edit the screencast by appending your videos, and removing frames. You can take a look at what virtualdub has to offer <a href="http://www.virtualdub.org/features.html" title="virtualdub features" target="_blank">here</a>.<br />
Once you are finished editing your screencast, you can go to File-&gt;save as avi. It will generate the first version of your screencast, but we need to compress it even further and change it into a different format.</p>
<p>Now comes the final step. Install and open <a title="VLC" href="http://www.videolan.org/vlc/index.html" target="_blank">vlc</a> and select Media-&gt;Convert/Save. Under file selection, click Add and select the AVI file you just created with virtualdub. Click on Convert/Save. On Destination folder, copy the same file path as the source, but <strong>end the filename with mp4 instead of avi</strong>. Under profile, make sure that <strong>Video H.264 + AAC (MP4)</strong> is selected. Click on start, and after some minutes, you will have your HD screencast ready in the same folder that you selected at the beginning.</p>
<p>Note:<br />
If you need to make a screencast of Linux, or other operating system, you can use <a title="VirtualBox" href="https://www.virtualbox.org/" target="_blank">virtualbox</a>. Just use it as a normal windows application, and everything will be recorded. Make sure that your region is set so that it covers the area that you want to record. If you are interested in a native application, you can take a look at <a href="http://recordmydesktop.sourceforge.net/about.php" title="recordmydesktop" target="_blank">recordmydesktop</a>.</p>
<p>Note 2:<br />
If you already have a recording in camstudio and want to change the frame rate, you can do that easily with virtualdub. Open the video in virtualdub, go to video, select direct stream copy. Go to video, select frame rate.<br />
Under frame rate conversion, select convert to fps, and put 25 (or the desired value). Go to file, select save as avi. It should process the file quickly.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.samontab.com/web/2013/01/how-to-make-hd-screencasts-using-free-tools/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Technical reviewer of a book about computer vision projects solved using OpenCV</title>
		<link>http://www.samontab.com/web/2013/01/technical-reviewer-of-a-book-about-computer-vision-projects-solved-using-opencv/</link>
		<comments>http://www.samontab.com/web/2013/01/technical-reviewer-of-a-book-about-computer-vision-projects-solved-using-opencv/#comments</comments>
		<pubDate>Tue, 01 Jan 2013 21:55:30 +0000</pubDate>
		<dc:creator>samontab</dc:creator>
				<category><![CDATA[Image Processing]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.samontab.com/web/?p=243</guid>
		<description><![CDATA[There is a new book about OpenCV: Mastering OpenCV with Practical Computer Vision Projects. I was honored to be invited to participate as a technical reviewer of the book, and it was really fun to read. Each chapter shows a specific real world problem and teaches you how it can be solved using OpenCV. This [...]]]></description>
				<content:encoded><![CDATA[<p>There is a new book about OpenCV:</p>
<p><strong>Mastering OpenCV with Practical Computer Vision Projects</strong>.</p>
<p><a href="http://www.packtpub.com/cool-projects-with-opencv/book" rel="attachment wp-att-261"><img class="size-full wp-image-261 alignleft" title="Mastering OpenCV with Practical Computer Vision Projects" alt="7829OS_Mastering OpenCV with Practical Computer Vision Projects.jpg" src="http://www.samontab.com/web/wp-content/uploads/2013/01/7829OS_Mastering-OpenCV-with-Practical-Computer-Vision-Projects.jpg.png" width="175" height="213" /></a>I was honored to be invited to participate as a technical reviewer of the book, and it was really fun to read. Each chapter shows a specific real world problem and teaches you how it can be solved using OpenCV. This is the work of seven authors, and the projects are great. I really recommend this book if you are already using OpenCV, because it deals with more advanced details, and in some cases it shows you how to use other libraries to fill in where OpenCV lacks for specific purposes.</p>
<p>Some of the cool things that this book covers are how to make OpenCV powered apps for Android and iOS, interfacing OpenCV with the Kinect, number plate detection, optical character recognition (OCR), augmented reality, structure from motion, face detection and tracking.</p>
<p>If you are interested in using OpenCV in real world scenarios, this book will definitely help you. Although you will need to know the basics of image processing or computer vision and programming first as this book is mostly focused on the actual practical projects.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.samontab.com/web/2013/01/technical-reviewer-of-a-book-about-computer-vision-projects-solved-using-opencv/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Playing with astrophotography</title>
		<link>http://www.samontab.com/web/2012/12/playing-with-astrophotography/</link>
		<comments>http://www.samontab.com/web/2012/12/playing-with-astrophotography/#comments</comments>
		<pubDate>Wed, 26 Dec 2012 15:36:14 +0000</pubDate>
		<dc:creator>samontab</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Photography]]></category>

		<guid isPermaLink="false">http://www.samontab.com/web/?p=244</guid>
		<description><![CDATA[One of the easiest subjects to photograph in the night sky is the Moon. Everyone knows where it is, and it looks large and bright from the earth(well, unless it is in the new moon phase). Yesterday, Jupiter was passing close to the Moon, as seen from the Earth. I tried to get a close [...]]]></description>
				<content:encoded><![CDATA[<p>One of the easiest subjects to photograph in the night sky is the Moon. Everyone knows where it is, and it looks large and bright from the earth(well, unless it is in the new moon phase).<br />
<a href="http://www.samontab.com/web/2012/12/playing-with-astrophotography/moon/" rel="attachment wp-att-248"><img src="http://www.samontab.com/web/wp-content/uploads/2012/12/moon-300x200.jpg" alt="moon" width="300" height="200" class="alignnone size-medium wp-image-248" /></a></p>
<p>Yesterday, <a href="http://www.cbsnews.com/8301-205_162-57560744/jupiter-moon-align-in-christmas-skywatching-treat/" title="Jupiter close to the Moon" target="_blank">Jupiter was passing close to the Moon</a>, as seen from the Earth.<br />
<a href="http://www.samontab.com/web/2012/12/playing-with-astrophotography/jupiter_close_to_the_moon/" rel="attachment wp-att-249"><img src="http://www.samontab.com/web/wp-content/uploads/2012/12/jupiter_close_to_the_moon-300x200.jpg" alt="jupiter_close_to_the_moon" width="300" height="200" class="alignnone size-medium wp-image-249" /></a></p>
<p>I tried to get a close up of Jupiter and the Moon in the same frame, but the brightness of the Moon was overexposing the photograph.<br />
<a href="http://www.samontab.com/web/2012/12/playing-with-astrophotography/jupiter_moon_too_bright/" rel="attachment wp-att-250"><img src="http://www.samontab.com/web/wp-content/uploads/2012/12/jupiter_moon_too_bright-300x200.jpg" alt="jupiter_moon_too_bright" width="300" height="200" class="alignnone size-medium wp-image-250" /></a></p>
<p>When I properly exposed the Moon, Jupiter was not very visible.<br />
<a href="http://www.samontab.com/web/2012/12/playing-with-astrophotography/jupiter_moon_too_dark/" rel="attachment wp-att-251"><img src="http://www.samontab.com/web/wp-content/uploads/2012/12/jupiter_moon_too_dark-300x200.jpg" alt="jupiter_moon_too_dark" width="300" height="200" class="alignnone size-medium wp-image-251" /></a></p>
<p>I could have used <a href="http://www.samontab.com/web/2010/11/free-photo-editing-software/" title="HDR free photo techniques" target="_blank">HDR techniques</a> here to merge differently exposed photos into a single one that had Jupiter and the Moon properly exposed, but I changed my mind and started focusing on Jupiter alone. </p>
<p>Removing the Moon from the frame allowed me to gather more light from Jupiter and its surroundings, and that&#8217;s when four other objects appeared in my picture.<br />
<a href="http://www.samontab.com/web/2012/12/playing-with-astrophotography/jupiter_four_moons/" rel="attachment wp-att-252"><img src="http://www.samontab.com/web/wp-content/uploads/2012/12/jupiter_four_moons-300x200.jpg" alt="jupiter_four_moons" width="300" height="200" class="alignnone size-medium wp-image-252" /></a></p>
<p>Checking with <a href="http://www.stellarium.org/" title="Stellarium" target="_blank">Stellarium</a>, I confirmed that these objects were Europa, Io, Ganymede, and Callisto. They are the four largest moons of Jupiter!.</p>
<p>I never thought that I would be able to photograph the moons of Jupiter from the Earth using my own camera, but there they are!.<br />
<a href="http://www.samontab.com/web/2012/12/playing-with-astrophotography/moons_of_jupiter/" rel="attachment wp-att-254"><img src="http://www.samontab.com/web/wp-content/uploads/2012/12/moons_of_jupiter-300x200.jpg" alt="moons_of_jupiter" width="300" height="200" class="alignnone size-medium wp-image-254" /></a></p>
<p>Here is the previous photo aligned with the simulated sky from Stellarium. Cool!<br />
<a href="http://www.samontab.com/web/2012/12/playing-with-astrophotography/jupiter_moons_aligned/" rel="attachment wp-att-259"><img src="http://www.samontab.com/web/wp-content/uploads/2012/12/jupiter_moons_aligned-210x300.png" alt="jupiter_moons_aligned" width="210" height="300" class="alignnone size-medium wp-image-259" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.samontab.com/web/2012/12/playing-with-astrophotography/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Using OpenCV in Sage</title>
		<link>http://www.samontab.com/web/2012/12/using-opencv-in-sage/</link>
		<comments>http://www.samontab.com/web/2012/12/using-opencv-in-sage/#comments</comments>
		<pubDate>Tue, 18 Dec 2012 07:44:28 +0000</pubDate>
		<dc:creator>samontab</dc:creator>
				<category><![CDATA[Image Processing]]></category>
		<category><![CDATA[Open Source]]></category>

		<guid isPermaLink="false">http://www.samontab.com/web/?p=234</guid>
		<description><![CDATA[OpenCV is an awesome free open source library for computer vision, image processing, and even some machine learning. Sage is an awesome free open source mathematical software system that integrates many other libraries and software into a single, easy to use interface for all your math needs. I really like both projects, and have been [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.opencv.org" title="OpenCV official web site" target="_blank">OpenCV</a> is an awesome free open source library for computer vision, image processing, and even some machine learning.<br />
<a href="http://www.sagemath.org" title="Sage Math official web site" target="_blank">Sage</a> is an awesome free open source mathematical software system that integrates many other libraries and software into a single, easy to use interface for all your math needs.</p>
<p>I really like both projects, and have been using them separately, but in this post I will show you how you can use OpenCV in the Sage environment. This means that you will be able to use all the power of the Sage Notebook Server, NumPy, SciPy, Matplotlib, PIL (Python Imaging Library), R, and almost a hundred other open source packages for all your image processing needs.</p>
<p><a href="http://www.samontab.com/web/2012/12/using-opencv-in-sage/sage0/" rel="attachment wp-att-238"><img src="http://www.samontab.com/web/wp-content/uploads/2012/12/sage0-300x292.png" alt="sage0" width="300" height="292" class="alignnone size-medium wp-image-238" /></a></p>
<p>The first step is to install the latest version of OpenCV in your system <strong>with the new Python bindings</strong>. You must have the Python bindings working correctly for this to work. The easiest way of doing this is to follow my own <a href="http://www.samontab.com/web/2012/06/installing-opencv-2-4-1-ubuntu-12-04-lts/" title="Installing OpenCV in Ubuntu" target="_blank">tutorial for installing OpenCV</a>. You can easily change the version for installing the latest OpenCV version that is out there, the tutorial should still work. I used it to install OpenCV 2.4.3 in Ubuntu 12.10, and it worked perfectly.</p>
<p>To make sure that OpenCV is installed correctly, go to the console and start Python by running this command:</p>
<pre class="brush: plain; title: ; notranslate">python</pre>
<p>You should see the python console waiting for you. There, write the following:</p>
<pre class="brush: plain; title: ; notranslate">import cv2</pre>
<p><a href="http://www.samontab.com/web/2012/12/using-opencv-in-sage/cv2/" rel="attachment wp-att-235"><img src="http://www.samontab.com/web/wp-content/uploads/2012/12/cv2-300x191.png" alt="Importing OpenCV cv2 module into python" width="300" height="191" class="alignnone size-medium wp-image-235" /></a><br />
If no error appeared, everything is great, you can continue. If there are some errors, you need to fix them first. You can exit with Control-D, or by typing exit(). </p>
<p>By the way, currently there are two OpenCV Python modules, <strong>cv</strong> and <strong>cv2</strong>. The legacy C version API of OpenCV can be accessed via cv, and the new C++ interface of OpenCV is available via cv2. Therefore, you are encouraged to use cv2 because that&#8217;s where the good stuff is.</p>
<p>Now that we have OpenCV with Python correctly installed, we need to install Sage.<br />
First, check if you are running a 32 or 64 bit system by using this command:</p>
<pre class="brush: plain; title: ; notranslate">uname -m</pre>
<p>You will see <strong>x86_64</strong>, which means 64 bits or something like <strong>i686</strong> or <strong>i386</strong>, which means 32 bits.</p>
<p>Now we need to download Sage from <a href="http://www.sagemath.org/download-linux.html" title="Sage for Linux download" target="_blank">here</a>. You can pick where to download from, as well as if you want the 32 or 64 bits version. I usually download it from the University of Washington which is where the lead developer of Sage, William Stein, teaches math but you can choose any other location that you like. You are looking for a file that has a name similar to this one: <strong>sage-5.4.1-linux-32bit-ubuntu_12.04.1_lts-i686-Linux.tar.lzma</strong>. For the next steps, I will be using that file. Remember that you may need to change the file or folder names for your specific situation.</p>
<p>After you download the file, you will need to extract it. On the console, change your directory to where you downloaded the file and extract it:</p>
<pre class="brush: plain; title: ; notranslate">
cd ~/Downloads
tar --lzma -xf sage-*
</pre>
<p>Now you will have to wait for a few minutes for it to decompress a lot of files. Notice how I did not use the verbose option for extracting (I used -xf instead of -xvf). This is because it takes a lot longer to decompress when it has to output every file name. Since nothing is being printed on the screen, it is faster but you may think that nothing is happening. Don&#8217;t worry, everything is fine. Just leave it alone until it finishes decompressing.</p>
<p>Now we are going to configure it so that we can call it from anywhere.</p>
<pre class="brush: plain; title: ; notranslate">
mv sage-5.4.1-linux-32bit-ubuntu_12.04.1_lts-i686-Linux sage-5.4.1
sudo mv sage-5.4.1 /opt/
sudo cp /opt/sage-5.4.1/sage /usr/local/bin/
sudo gedit /usr/local/bin/sage
</pre>
<ol>
<li>Copy the line that says <strong>#SAGE_ROOT=/path/to/sage-version</strong>.</li>
<li>Remove the comment character (<strong>#</strong>) in the line you just copied.</li>
<li>Change the path to <strong>/opt/sage-5.4.1</strong> (or the version you are installing). </li>
<li>Save the file and close the editor.</li>
</ol>
<p><a href="http://www.samontab.com/web/2012/12/using-opencv-in-sage/sage_root/" rel="attachment wp-att-237"><img src="http://www.samontab.com/web/wp-content/uploads/2012/12/sage_root-300x229.png" alt="sage_root" width="300" height="229" class="alignnone size-medium wp-image-237" /></a></p>
<p>And now you can start Sage by using this command anywhere:</p>
<pre class="brush: plain; title: ; notranslate">
sage
</pre>
<p>You will have to wait for a few moments this first time you run it. You should then see the command prompt of Sage waiting for your input. Exit for now by running this command:</p>
<pre class="brush: plain; title: ; notranslate">
exit
</pre>
<p>If everything is fine, you can now delete the downloaded file to save some space:</p>
<pre class="brush: plain; title: ; notranslate">
rm ~/Downloads/sage-5.4.1-linux-32bit-ubuntu_12.04.1_lts-i686-Linux.tar.lzma
</pre>
<p>OK, so now we also have Sage correctly installed in the system. </p>
<p>Let&#8217;s install OpenCV into Sage:</p>
<pre class="brush: plain; title: ; notranslate">
cd /usr/local/lib/python2.7/dist-packages/
cp cv2.so /opt/sage-5.4.1/local/lib/python2.7/site-packages/
cp cv.py /opt/sage-5.4.1/local/lib/python2.7/site-packages/
cd ~
</pre>
<p>To make sure that OpenCV is correctly installed in Sage, go to the console and start Sage by running this command:</p>
<pre class="brush: plain; title: ; notranslate">sage</pre>
<p>You should see the Sage console waiting for you. There, write the following:</p>
<pre class="brush: plain; title: ; notranslate">import cv2</pre>
<p>If no error appeared, everything is great, you can continue. If there are some errors, you need to fix them first.  At this point, it should report the following error:</p>
<pre class="brush: plain; title: ; notranslate">
RuntimeError: module compiled against API version 6 but this version of numpy is 4.
</pre>
<p>This happens because Sage(as of v5.4.1) still comes with an older version of NumPy(v1.5.1). You can tell which is the included version of NumPy by doing this in Sage:</p>
<pre class="brush: plain; title: ; notranslate">
import numpy
numpy.version.version
exit
</pre>
<p>So, if you have a newer version of Sage (<a href="http://trac.sagemath.org/sage_trac/ticket/11334" title="Sage with NumPy 1.7" target="_blank">this fix is scheduled for v5.6</a>), and did not get the error, you can skip the next step.</p>
<p>Let&#8217;s update Sage&#8217;s NumPy to v1.7.0b2 so that we can use OpenCV with it:</p>
<pre class="brush: plain; title: ; notranslate">
cd ~
wget https://spkg-upload.googlecode.com/files/numpy-1.7.0b2.spkg
sage -f numpy-1.7.0b2.spkg
</pre>
<p>Now you should be able to run OpenCV functions in Sage.</p>
<p>Let&#8217;s use the Sage Notebook interface with OpenCV.<br />
Start <strong>sage</strong>, run <strong>notebook()</strong>, and follow the instructions for using the notebook interface. For more advanced options for the notebook server, you can check <a href="http://www.sagemath.org/doc/reference/sagenb/notebook/notebook_object.html" title="Sage notebook" target="_blank">here</a>.</p>
<p>Once you have a new worksheet open, define some functions to convert arrays between NumPy, OpenCV and PIL:</p>
<pre class="brush: plain; title: ; notranslate">
import cv2, numpy, Image, ImageDraw

def cv2np(image):    
    rgbimage = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
    return rgbimage/255.
    
def pil2np(image):
    rgbimage = numpy.array(image)
    return rgbimage/255.
    
def cv2pil(image):
    rgbimage = cv2.cvtColor(lenna, cv2.COLOR_BGR2RGB)
    pilimage = Image.fromarray(rgbimage)
    return pilimage
</pre>
<p>Now, in another cell let&#8217;s load an image and find a face using the trained frontal face model. (Make sure that you change the path to your image):</p>
<pre class="brush: plain; title: ; notranslate">
image_path = &quot;/home/username/OpenCV-2.4.3/samples/c/lena.jpg&quot;
lenna = cv2.imread(image_path, cv2.CV_LOAD_IMAGE_COLOR)
cascade_fn = &quot;/usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_alt.xml&quot;
cascade = cv2.CascadeClassifier(cascade_fn)
gray = cv2.cvtColor(lenna, cv2.COLOR_BGR2GRAY)
rects = cascade.detectMultiScale(gray, scaleFactor=1.2, minNeighbors=4, minSize=(30,30))
for x1, y1, width, height in rects:    
    faces_rectangle = [x1, y1, x1 + width, y1 + height]
faces_rectangle
</pre>
<p>If you use lena.jpg, you should see the following result:</p>
<pre class="brush: plain; title: ; notranslate">
[217, 203, 386, 372]
</pre>
<p>Which is the location of the bounding box of the detected face of Lenna.<br />
Now, let&#8217;s use PIL to draw the detection:</p>
<pre class="brush: plain; title: ; notranslate">
lenna_pil = cv2pil(lenna)
draw = ImageDraw.Draw(lenna_pil)
draw.ellipse((x1, y1, x1+width, y1+height), outline=&quot;green&quot;)
draw.ellipse((x1+1, y1+1, x1+width-1, y1+height-1), outline=&quot;green&quot;)
draw.ellipse((x1+2, y1+2, x1+width-2, y1+height-2), outline=&quot;green&quot;)
</pre>
<p>To be able of changing the thickness of the ellipse in PIL, you need to install the <a href="http://effbot.org/zone/aggdraw-index.htm" target="_blank">aggdraw</a> module, so I just drew three ellipses instead.</p>
<p>Finally, it is time to show the detection:</p>
<pre class="brush: plain; title: ; notranslate">
matrix_plot(pil2np(lenna_pil)).show( axes=True, frame=True, figsize=8, aspect_ratio=1)
</pre>
<p><a href="http://www.samontab.com/web/2012/12/using-opencv-in-sage/sage_opencv/" rel="attachment wp-att-239"><img src="http://www.samontab.com/web/wp-content/uploads/2012/12/sage_opencv-300x182.png" alt="sage_opencv" width="300" height="182" class="alignnone size-medium wp-image-239" /></a><br />
And that&#8217;s it. This is just a simple example of object detection in OpenCV using the Sage environment. Feel free to explore Sage and OpenCV now that you can use them in the same interface.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.samontab.com/web/2012/12/using-opencv-in-sage/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Installing OpenCV in the Nokia N900 (maemo)</title>
		<link>http://www.samontab.com/web/2012/12/installing-opencv-in-the-nokia-n900-maemo/</link>
		<comments>http://www.samontab.com/web/2012/12/installing-opencv-in-the-nokia-n900-maemo/#comments</comments>
		<pubDate>Sat, 01 Dec 2012 21:48:07 +0000</pubDate>
		<dc:creator>samontab</dc:creator>
				<category><![CDATA[Image Processing]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.samontab.com/web/?p=220</guid>
		<description><![CDATA[In this post, I will describe the entire procedure needed to install OpenCV and compile your computer vision applications in the Nokia N900 from scratch. This means that you can make advanced computer vision processing on the go. First of all make sure that you back up all your N900 data. No kidding. We are [...]]]></description>
				<content:encoded><![CDATA[<p>In this post, I will describe the entire procedure needed to install OpenCV and compile your computer vision applications in the Nokia N900 from scratch. This means that you can make advanced computer vision processing on the go.</p>
<p><a href="http://www.samontab.com/web/wp-content/uploads/2012/10/opencv-in-the-nokia-n900.jpg"><img class="size-medium wp-image-223 alignleft" title="opencv-in-the-nokia-n900" src="http://www.samontab.com/web/wp-content/uploads/2012/10/opencv-in-the-nokia-n900-300x200.jpg" alt="" width="300" height="200" /></a>First of all make sure that you <strong>back up all your N900 data</strong>. No kidding. We are going to make some changes that could possibly <strong>brick your phone</strong>. This means that you may need to re flash your firmware if anything goes wrong. If you are not OK with this, stop reading. I will not be held responsible for any problems you may encounter. You have been warned.</p>
<p>The N900 is an awesome device, it is a Linux computer in the form of a smartphone. Because of that, you can do pretty much anything you could do on a regular Linux computer and more, since you have all the extra features of a smartphone like sensors and a battery. One of the things a regular Linux computer can do is to use an advanced computer vision library (<a href="http://opencv.org/">OpenCV</a>), which is the library we are going to install on the N900.</p>
<p>The first step is to configure the repositories. A repository is a place where programs are stored. You can have different repositories available on your system. Each repository that you have enabled in your system allows you to install different sets of programs. Note that on the N900, repositories are called catalogs.</p>
<p>To manage your repositories on your N900, go to the <em>App. Manager</em> and click on the menu on top (where it says <em>Application manager</em>). There, select <em>Application Catalogs</em>.</p>
<p>Here (maybe after waiting a little) you will see the current list of enabled and disabled catalogs. Disabled catalogs are not considered by the system, so all the applications you can install come from the enabled catalogs. Write down which catalogs are enabled and which ones are disabled as this is your original configuration and you may want to go back to it after we are finished.</p>
<p>Now, let&#8217;s add some catalogs. Click on the <em>New</em> button and fill in the information provided for the three following catalogs:</p>
<p><strong>Maemo SDK</strong>: This catalog provides core system utilities that we will need to build programs.</p>
<pre class="brush: plain; title: ; notranslate">
Catalog Name: Maemo SDK
Web address: http://repository.maemo.org/
Distribution: fremantle/sdk
Components: free non-free
Disabled: Unchecked
</pre>
<p><strong>Maemo tools</strong>: This catalog provides tools that are very useful, like nano or wget.</p>
<pre class="brush: plain; title: ; notranslate">
Catalog Name: Maemo tools
Web address: http://repository.maemo.org/
Distribution: fremantle/tools
Components: free non-free
Disabled: Unchecked
</pre>
<p><strong>Maemo extras-testing</strong>: This catalog provides more applications than the ones in the default Maemo catalog (extras), although they are not as thoroughly tested.</p>
<pre class="brush: plain; title: ; notranslate">
Catalog Name: Maemo extras-testing
Web address: http://repository.maemo.org/extras-testing/
Distribution: fremantle
Components: free non-free
Disabled: Unchecked
</pre>
<p>These catalogs provide different applications that we will need later. Enable all of them.</p>
<p>Now exit the <em>Application Catalogs</em> screen. The N900 will automatically update the list of applications after you changed the repositories. If you didn&#8217;t see any update, click on the <em>Update</em> button just to be sure. Now click on <em>Download-&gt;All</em> to see the list of applications available to install. You should install the following apps:</p>
<pre class="brush: plain; title: ; notranslate">openssh client and server
rootsh
sudser
Personal IP Address</pre>
<p>When you install OpenSSH, you will be asked for a password. This is the <em>root</em> password, so keep it safe.</p>
<p>Now close the application manager and open the console (<em>X Terminal</em>). In there, you will setup a password for the default user, which is <em>user</em>. Write this:</p>
<pre class="brush: plain; title: ; notranslate">
sudo passwd user
</pre>
<p>And write a password for the user <em>user</em>, which is the default user (non root privileges). Close the console or write <em>exit</em> to exit.</p>
<p><a href="http://www.samontab.com/web/wp-content/uploads/2012/01/n900.jpg"><img class="size-medium wp-image-200 alignleft" title="n900" src="http://www.samontab.com/web/wp-content/uploads/2012/01/n900-300x234.jpg" alt="" width="300" height="234" /></a>OK, on the N900 desktop you now should be able to see your current IP address. You can use that IP to connect via SSH or FTP to your N900 with either <em>root</em> or <em>user</em> using the passwords you just set for them. If you don&#8217;t have Linux installed on your computer, you can use <em><a href="http://filezilla-project.org/">Filezilla</a></em> for FTP and <em><a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/">PuTTy</a></em> for SSH. Make sure that you can connect to your N900 with the <em>user</em> account.</p>
<p>Now we will be working with the command line only, so I suggest you to connect from your computer via SSH (as <em>user</em>) for easier writing (or copy pasting). Make sure that the <em>App. Manager</em> is closed before continuing.</p>
<p>On the console, write the following:</p>
<pre class="brush: plain; title: ; notranslate">
sudo apt-get install build-essential wget grep-gnu libglibmm-2.4-dev nano libpng12-dev libjpeg62-dev libtiff4-dev libgtk2.0-dev unzip
</pre>
<p>It should install all these packages without a problem. If it asks &#8220;<em>Install these packages without verification?</em>&#8221; Answer <strong>yes</strong>.</p>
<p>OK, your N900 is ready to compile software. We are now going to get and install <em>OpenCV</em> by writing the following:</p>
<pre class="brush: plain; title: ; notranslate">sudo apt-get install libcv4 libhighgui4 libcvaux4 opencv-doc libcv-dev libhighgui-dev libcvaux-dev</pre>
<p>Once it is finished installing the packages, go to the <em>App. Manager</em> and <strong>disable all of the three repositories we used</strong> (<em>Maemo SDK</em>, <em>Maemo Tools</em>, <em>Maemo extras-testing</em>).</p>
<p>Now let&#8217;s check that everything is correctly installed. Run this command:</p>
<pre class="brush: plain; title: ; notranslate">
pkg-config --libs --cflags opencv
</pre>
<p>You should see something similar to:</p>
<pre class="brush: plain; title: ; notranslate">-I/usr/include/opencv  -lcv -lhighgui -lcvaux -lml -lcxcore</pre>
<p>Now you have OpenCV correctly installed in your N900. Great!, now what?.</p>
<p>Let&#8217;s compile something. First, download this example that I prepared:</p>
<pre class="brush: plain; title: ; notranslate">
wget http://www.samontab.com/web/files/opencv-n900-test.zip
unzip opencv-n900-test.zip
</pre>
<p>Compile the project with this line:</p>
<pre class="brush: plain; title: ; notranslate">g++ -o test main.c `pkg-config --libs --cflags opencv`</pre>
<p>And now you can run it with this command:</p>
<pre class="brush: plain; title: ; notranslate">./test lena.jpg</pre>
<p>It will read an image (<em>lena.jpg</em> by default if none is given in the command line), invert the value of the pixels, and save the processed image as <em>processedImage.png</em>.</p>
<p>You should see something like this:</p>
<p><a href="http://www.samontab.com/web/wp-content/uploads/2012/10/opencv-test.jpg"><img class="alignnone size-medium wp-image-222" title="opencv-test" src="http://www.samontab.com/web/wp-content/uploads/2012/10/opencv-test-300x200.jpg" alt="" width="300" height="200" /></a></p>
<p>And that&#8217;s it. Now you can use OpenCV in your Nokia N900!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.samontab.com/web/2012/12/installing-opencv-in-the-nokia-n900-maemo/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>How I went from obese to normal weight by changing my behavior to lose 20kg (44 pounds)</title>
		<link>http://www.samontab.com/web/2012/11/how-i-went-from-obese-to-normal-weight-by-changing-my-behavior-to-lose-20kg-44-pounds/</link>
		<comments>http://www.samontab.com/web/2012/11/how-i-went-from-obese-to-normal-weight-by-changing-my-behavior-to-lose-20kg-44-pounds/#comments</comments>
		<pubDate>Sat, 01 Dec 2012 00:05:24 +0000</pubDate>
		<dc:creator>samontab</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.samontab.com/web/?p=231</guid>
		<description><![CDATA[I was fat, and I was getting fatter every day. On the day that I found out that I was literally obese, I decided to change my behavior so that I could live with a normal weight. Being the nerd that I am, I started searching for scientific articles that I could use to lose [...]]]></description>
				<content:encoded><![CDATA[<p>I was fat, and I was getting fatter every day. On the day that I found out that I was literally obese, I decided to change my behavior so that I could live with a normal weight.<br />
Being the nerd that I am, I started searching for scientific articles that I could use to lose weight and change my behavior. One of the best and simple suggestions that I found about which type of food I should be eating was the <a href="http://www.health.harvard.edu/plate/healthy-eating-plate" title="Healthy Eating Plate" target="_blank">healthy eating plate</a>, and since it comes from a respectable source, I decided to test it. Here is the result after basing my food intake on that advice.<br />
[weight]<br />
Success!. I got into the normal weight range by losing 20kg (44 pounds), and I continue losing weight. By looking at the graph, you may notice that my weight actually increased around May, September, and November. I was traveling abroad those days. That means that it was harder to weigh myself as well as controlling what I was eating. The result of those two things combined?, weight increase. When I got back home, I could weigh myself every day, and control what I was eating, which instantly made me start decreasing my weight again.</p>
<p>After researching on these topics, applying the concepts and actually getting to my goal, I think that these are some of the most important ideas that I learned:</p>
<h3>Keep your goal on focus to motivate yourself</h3>
<p>It has been <a href="http://www.sciencedirect.com/science/article/pii/S0022103111000333" title="Eyes on the prize: The longitudinal benefits of goal focus on progress toward a weight loss goal" target="_blank">reported</a> that focusing on a specific goal gives you better results compared to focusing on accomplishments or not having a goal at all.<br />
Your goal should be something that you can measure, like losing X kg, or staying inside the normal weight BMI range, etc. It is important that your goal can be measured so that every time you weigh yourself you know how close or far away you are from your goal. Also, it allows you to test how good or bad specific behavior changes are for your goal. For example, you could quit drinking alcohol, eat more vegetables, or do more exercises, and see how they affect your specific goal. That way, you will be more motivated to keep the positive behavior changes, and discard the negative ones because you can actually see how they affect your goal.</p>
<h3>Weigh yourself everyday, roughly at the same time</h3>
<p>You should not be afraid to look at the numbers the scale is showing to you. Those numbers help you to reach your goal, so make sure that you weigh yourself every day and keep a log of it. You can use pen and paper, or a worksheet, or Google Docs, or anything else that you prefer, but make it as simple as possible because otherwise you will not use it.<br />
Your weight changes constantly through the day, so it is best to always measure it at the same time every day. To keep you motivated, I recommend you to weigh yourself in the mornings because that is when you are the lightest. If you are wondering why, take a look at this cool video by Derek from veritasium.</p>
<object data="http://www.youtube.com/v/lL2e0rWvjKI?version=3&rel=0&fs=1&showinfo=0" type="application/x-shockwave-flash" width="480" height="370">
	<param name="movie" value="http://www.youtube.com/v/lL2e0rWvjKI?version=3&rel=0&fs=1&showinfo=0"></param>
	<param name="wmode" value="opaque"></param>
	<param name="allowFullScreen" value="true"></param>
	<param name="allowScriptAccess" value="always"></param>
</object>
<p></p>
<h3>You can eat whatever you like, as long as it is an exception</h3>
<p>You should only feed yourself with healthy food on a daily basis. That&#8217;s the key. If you have that lifestyle, you can also eat anything you want on certain special occasions, as long as you keep those occasions as exceptions and not as your main food source. Think about it, it doesn&#8217;t really matter if you eat a couple slices of pizza and soda once or twice a month, but if you eat it almost every day, you will get fat. Simple. Just keep your daily food intake healthy, and you can eat anything you want on certain occasions. Some examples of this idea are the &#8220;cheat day&#8221; from the <a href="http://www.fourhourworkweek.com/blog/2007/04/06/how-to-lose-20-lbs-of-fat-in-30-days-without-doing-any-exercise/" title="Slow Carb diet" target="_blank">slow-carb diet</a> of Tim Ferris, as well as the concept behind the BBC documentary <a href="http://www.bbc.co.uk/programmes/b01lxyzc" title="Eat, fast, and live longer" target="_blank">Eat, fast, &#038; live longer</a> where they suggest very low calorie intake days followed by days where you can eat whatever you want. Remember to check your weight data log to see how those special days affect your goal, so that you can set their frequency correctly. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.samontab.com/web/2012/11/how-i-went-from-obese-to-normal-weight-by-changing-my-behavior-to-lose-20kg-44-pounds/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Installing OpenCV 2.4.1 in Ubuntu 12.04 LTS</title>
		<link>http://www.samontab.com/web/2012/06/installing-opencv-2-4-1-ubuntu-12-04-lts/</link>
		<comments>http://www.samontab.com/web/2012/06/installing-opencv-2-4-1-ubuntu-12-04-lts/#comments</comments>
		<pubDate>Sun, 24 Jun 2012 06:35:12 +0000</pubDate>
		<dc:creator>samontab</dc:creator>
				<category><![CDATA[Image Processing]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.samontab.com/web/?p=205</guid>
		<description><![CDATA[The latest Long Term Support version of Ubuntu(12.04 LTS) is out and a new version of OpenCV was released as well. This means that now is a great opportunity to update my OpenCV installation guide to the latest versions, Ubuntu 12.04 LTS and OpenCV 2.4.1. We are going to setup OpenCV to use the new [...]]]></description>
				<content:encoded><![CDATA[<p>The latest Long Term Support version of Ubuntu(12.04 LTS) is out and a new version of OpenCV was released as well. This means that now is a great opportunity to update my OpenCV installation guide to the latest versions, Ubuntu 12.04 LTS and OpenCV 2.4.1.</p>
<p>We are going to setup OpenCV to use the new Qt highgui interface, which is much better than the simple highgui interface. Also, we will install OpenCV with support for OpenGL, as well as reading and writing videos, access to a webcam, Python, C and C++ interfaces, and Intel Threading Building Blocks (TBB).</p>
<p>OK, so the first step is to make sure that everything in the system is updated and upgraded:</p>
<pre class="brush: bash; title: ; notranslate">
sudo apt-get update
sudo apt-get upgrade
</pre>
<p>Now, you need to install many dependencies, such as support for reading and writing image files, drawing on the screen, some needed tools, etc&#8230; This step is very easy, you only need to write the following command in the Terminal:</p>
<pre class="brush: bash; title: ; notranslate">
sudo apt-get install build-essential libgtk2.0-dev libjpeg-dev libtiff4-dev libjasper-dev libopenexr-dev cmake python-dev python-numpy python-tk libtbb-dev libeigen2-dev yasm libfaac-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev libqt4-dev libqt4-opengl-dev sphinx-common texlive-latex-extra libv4l-dev libdc1394-22-dev libavcodec-dev libavformat-dev libswscale-dev
</pre>
<p>Time to get the OpenCV 2.4.1 source code:</p>
<pre class="brush: bash; title: ; notranslate">
cd ~
wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.1/OpenCV-2.4.1.tar.bz2
tar -xvf OpenCV-2.4.1.tar.bz2
cd OpenCV-2.4.1
</pre>
<p>Now we have to generate the Makefile by using cmake. In here we can define which parts of OpenCV we want to compile. Since we want to use Python, TBB, OpenGL, Qt, work with videos, etc, here is where we need to set that. Just execute the following line at the terminal to create the appropriate Makefile. Note that there are two dots at the end of the line, it is an argument for the cmake program and it means the parent directory (because we are inside the build directory, and we want to refer to the OpenCV directory, which is its parent).</p>
<pre class="brush: bash; title: ; notranslate">
mkdir build
cd build
cmake -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..
</pre>
<p>Check that the above command produces no error and that in particular it reports FFMPEG as YES. If this is not the case you will not be able to read or write videos. Also, check that Python, TBB, OpenGL, V4L, OpenGL and Qt are detected.</p>
<p>If anything is wrong, go back, correct the errors by maybe installing extra packages and then run cmake again. You should see something similar to this:</p>
<p><a href="http://www.samontab.com/web/wp-content/uploads/2012/06/checkConfig.png"><img src="http://www.samontab.com/web/wp-content/uploads/2012/06/checkConfig-296x300.png" alt="" title="checkConfig" width="296" height="300" class="alignnone size-medium wp-image-207" /></a></p>
<p>Now, you are ready to compile and install OpenCV 2.4.1:</p>
<pre class="brush: bash; title: ; notranslate">
make
sudo make install
</pre>
<p>Now you have to configure OpenCV. First, open the opencv.conf file with the following code:</p>
<pre class="brush: bash; title: ; notranslate">
sudo gedit /etc/ld.so.conf.d/opencv.conf
</pre>
<p>Add the following line at the end of the file(it may be an empty file, that is ok) and then save it:</p>
<pre class="brush: bash; title: ; notranslate">
/usr/local/lib
</pre>
<p><a href="http://www.samontab.com/web/wp-content/uploads/2012/06/openCVConf1.png"><img src="http://www.samontab.com/web/wp-content/uploads/2012/06/openCVConf1-300x243.png" alt="" title="openCVConf" width="300" height="243" class="alignnone size-medium wp-image-209" /></a><br />
Run the following code to configure the library:</p>
<pre class="brush: bash; title: ; notranslate">
sudo ldconfig
</pre>
<p>Now you have to open another file:</p>
<pre class="brush: bash; title: ; notranslate">
sudo gedit /etc/bash.bashrc
</pre>
<p>Add these two lines at the end of the file and save it:</p>
<pre class="brush: bash; title: ; notranslate">
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH
</pre>
<p><a href="http://www.samontab.com/web/wp-content/uploads/2012/06/bashRC.png"><img src="http://www.samontab.com/web/wp-content/uploads/2012/06/bashRC-300x243.png" alt="" title="bashRC" width="300" height="243" class="alignnone size-medium wp-image-210" /></a></p>
<p>Finally, <strong>close the console and open a new one, restart the computer or logout and then login again</strong>. OpenCV will not work correctly until you do this.</p>
<p>Now you have OpenCV 2.4.1 installed in your computer with Python, TBB, OpenGL, video, and Qt support.</p>
<p>Check out the cool Qt interface which provides image viewing capabilities with zoom, as well as the ability to save the current image with just one click.</p>
<p><a href="http://www.samontab.com/web/wp-content/uploads/2012/06/lenaZoom.png"><img src="http://www.samontab.com/web/wp-content/uploads/2012/06/lenaZoom-261x300.png" alt="" title="lenaZoom" width="261" height="300" class="alignnone size-medium wp-image-217" /></a></p>
<p>If you zoom in enough, you can see the RGB (or intensity) values for each pixel.</p>
<p><a href="http://www.samontab.com/web/wp-content/uploads/2012/06/lenaZoom2.png"><img src="http://www.samontab.com/web/wp-content/uploads/2012/06/lenaZoom2-262x300.png" alt="" title="lenaZoom2" width="262" height="300" class="alignnone size-medium wp-image-218" /></a></p>
<p>Now let&#8217;s build some samples included in OpenCV:</p>
<pre class="brush: bash; title: ; notranslate">
cd ~/OpenCV-2.4.1/samples/c
chmod +x build_all.sh
./build_all.sh
</pre>
<p>Now we are ready to run the examples:</p>
<pre class="brush: bash; title: ; notranslate">./facedetect --cascade=&quot;/usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_alt.xml&quot; --scale=1.5 lena.jpg
</pre>
<p><a href="http://www.samontab.com/web/wp-content/uploads/2012/06/lenaSample.png"><img src="http://www.samontab.com/web/wp-content/uploads/2012/06/lenaSample-300x300.png" alt="" title="lenaSample" width="300" height="300" class="alignnone size-medium wp-image-211" /></a></p>
<pre class="brush: bash; title: ; notranslate">
./facedetect --cascade=&quot;/usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_alt.xml&quot; --nested-cascade=&quot;/usr/local/share/OpenCV/haarcascades/haarcascade_eye.xml&quot; --scale=1.5 lena.jpg
</pre>
<p><a href="http://www.samontab.com/web/wp-content/uploads/2012/06/lena2.png"><img src="http://www.samontab.com/web/wp-content/uploads/2012/06/lena2-300x300.png" alt="" title="lena2" width="300" height="300" class="alignnone size-medium wp-image-212" /></a></p>
<pre class="brush: plain; title: ; notranslate">~/OpenCV-2.4.1/build/bin/grabcut ~/OpenCV-2.4.1/samples/cpp/lena.jpg
</pre>
<p><a href="http://www.samontab.com/web/wp-content/uploads/2012/06/lena3.png"><img src="http://www.samontab.com/web/wp-content/uploads/2012/06/lena3-300x300.png" alt="" title="lena3" width="300" height="300" class="alignnone size-medium wp-image-213" /></a></p>
<pre class="brush: plain; title: ; notranslate">
~/OpenCV-2.4.1/build/bin/calibration_artificial
</pre>
<p><a href="http://www.samontab.com/web/wp-content/uploads/2012/06/chessboard.png"><img src="http://www.samontab.com/web/wp-content/uploads/2012/06/chessboard-300x225.png" alt="" title="chessboard" width="300" height="225" class="alignnone size-medium wp-image-215" /></a></p>
<pre class="brush: plain; title: ; notranslate">python ~/OpenCV-2.4.1/samples/python2/turing.py</pre>
<p><a href="http://www.samontab.com/web/wp-content/uploads/2012/06/turing.png"><img src="http://www.samontab.com/web/wp-content/uploads/2012/06/turing-300x300.png" alt="" title="turing" width="300" height="300" class="alignnone size-medium wp-image-214" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.samontab.com/web/2012/06/installing-opencv-2-4-1-ubuntu-12-04-lts/feed/</wfw:commentRss>
		<slash:comments>294</slash:comments>
		</item>
		<item>
		<title>MPD on the N900 or how to use your Nokia N900 as a Wireless Home Music System</title>
		<link>http://www.samontab.com/web/2012/01/mpd-on-the-n900-or-how-to-use-your-nokia-n900-as-a-wireless-home-music-system/</link>
		<comments>http://www.samontab.com/web/2012/01/mpd-on-the-n900-or-how-to-use-your-nokia-n900-as-a-wireless-home-music-system/#comments</comments>
		<pubDate>Thu, 26 Jan 2012 00:21:10 +0000</pubDate>
		<dc:creator>samontab</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.samontab.com/web/?p=198</guid>
		<description><![CDATA[In a previous post, I showed you how to listen on any device the music you have stored on a Symbian phone. In this post, I will teach you to do the opposite: control the music being played on your N900 with any device. The nice thing about this is that you can connect your [...]]]></description>
				<content:encoded><![CDATA[<p>In a previous <a href="http://www.samontab.com/web/2011/08/use-your-old-nokia-symbian-phone-as-a-music-web-server/">post</a>, I showed you how to listen on any device the music you have stored on a Symbian phone. In this post, I will teach you to do the opposite: control the music being played on your N900 with any device. The nice thing about this is that you can connect your N900 to your main speakers. That way, you will be using your Nokia N900 as a wireless home music system that is small, quiet and portable. After finishing this tutorial, you will also be able to connect to your N900 via SSH and FTP, manage your software repositories, compile applications, and setup scripts to be run at boot time.</p>
<p>First of all make sure that you <strong>back up all your N900 data</strong>. No kidding. We are going to make some changes that could possibly <strong>brick your phone</strong>. This means that you may need to re flash your firmware if anything goes wrong. If you are not OK with this, stop reading. I will not be held responsible for any problems you may encounter. You have been warned.</p>
<p><a href="http://www.samontab.com/web/wp-content/uploads/2012/01/n900.jpg"><img class="size-medium wp-image-200 alignleft" title="n900" src="http://www.samontab.com/web/wp-content/uploads/2012/01/n900-300x234.jpg" alt="" width="300" height="234" /></a>The N900 is an awesome device, it is a Linux computer in the form of a smartphone. Because of that, you can do pretty much anything you could do on a regular Linux computer and more, since you have all the extra features of a smartphone like sensors and a battery. One of the things a regular Linux computer can do is to play music with a great program called Music Player Daemon (<a href="http://mpd.wikia.com/wiki/Music_Player_Daemon_Wiki">MPD</a>), which is the program we are going to install on the N900.</p>
<p>The first step is to configure the repositories. A repository is a place where programs are stored. You can have different repositories available on your system. Each repository that you have enabled in your system allows you to install different sets of programs. Note that on the N900, repositories are called catalogs.</p>
<p>To manage your repositories on your N900, go to the <em>App. Manager</em> and click on the menu on top. There, select <em>Application Catalogs</em>.</p>
<p>Here (maybe after waiting a little) you will see the current list of enabled and disabled catalogs. Disabled catalogs are not considered by the system, so all the applications you can install come from the enabled catalogs. Write down which catalogs are enabled and which ones are disabled as this is your original configuration and you may want to go back to it after we are finished.</p>
<p>Now, let&#8217;s add some catalogs. Click on the <em>New</em> button and fill in the information provided for the four following catalogs:</p>
<p><strong>Maemo SDK</strong>: This catalog provides core system utilities that  we will need to build programs.</p>
<pre class="brush: plain; title: ; notranslate">
Catalog Name: Maemo SDK
Web address: http://repository.maemo.org/
Distribution: fremantle/sdk
Components: free non-free
Disabled: Unchecked
</pre>
<p><strong>Maemo tools</strong>: This catalog provides tools that are very useful, like nano or wget.</p>
<pre class="brush: plain; title: ; notranslate">
Catalog Name: Maemo tools
Web address: http://repository.maemo.org/
Distribution: fremantle/tools
Components: free non-free
Disabled: Unchecked
</pre>
<p><strong>Maemo extras-testing</strong>: This catalog provides more applications than the ones in the default Maemo catalog (extras), although they are not as thoroughly tested.</p>
<pre class="brush: plain; title: ; notranslate">
Catalog Name: Maemo extras-testing
Web address: http://repository.maemo.org/extras-testing/
Distribution: fremantle
Components: free non-free
Disabled: Unchecked
</pre>
<p><strong>Maemo extras-devel</strong>: This catalog contains many useful applications but some of them are in heavy development. This catalog should be disabled by default and enabled only temporarily to install specific applications.<strong> Make sure that you disable Maemo extras-devel when you add it</strong>.</p>
<pre class="brush: plain; title: ; notranslate">
Catalog Name: Maemo extras-devel
Web address: http://repository.maemo.org/extras-devel/
Distribution: fremantle
Components: free non-free
Disabled: Checked
</pre>
<p>These catalogs provide different applications that we will need later. <strong>Disable Maemo extras-devel and enable the other three.<br />
</strong></p>
<p>Now exit the <em>Application Catalogs</em> screen. The N900 will automatically update the list of applications after you changed the repositories. If you didn&#8217;t see any update, click on the <em>Update</em> button just to be sure. Now click on <em>Download-&gt;All</em> to see the list of applications available to install. You should install the following apps:</p>
<pre class="brush: plain; title: ; notranslate">openssh client and server
rootsh
sudser
Personal IP Address</pre>
<p>When you install OpenSSH, you will be asked for a password. This is the <em>root</em> password, so keep it safe.</p>
<p>Now close the application manager and open the console (<em>X Terminal</em>). In there, you will setup a password for the default user, which is <em>user</em>. Write this:</p>
<pre class="brush: plain; title: ; notranslate">
sudo passwd user
</pre>
<p>And write a password for the user <em>user</em>, which is the default user (non root privileges). Close the console or write <em>exit</em> to exit.</p>
<p>OK, on the desktop you now should be able to see your current IP address. You can use that IP to connect via SSH or FTP to your N900 with either <em>root</em> or <em>user</em> using the passwords you just set for them. If you don&#8217;t have Linux installed on your computer, you can use <em><a href="http://filezilla-project.org/">Filezilla</a></em> for FTP and <em><a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/">PuTTy</a></em> for SSH. Make sure that you can connect to your N900 with the <em>user</em> account.</p>
<p>Now we will be working with the command line only, so I suggest you to connect from your computer via SSH (as <em>user</em>) for easier writing (or copy pasting). Make sure that the <em>App. Manager</em> is closed before continuing.</p>
<p>On the console, write the following:</p>
<pre class="brush: plain; title: ; notranslate">
sudo apt-get install build-essential wget grep-gnu libglibmm-2.4-dev nano mpc libao0 libaudiofile-dev libaudiofile0 libcurl3-dev libcurl3 libpulse-dev pulseaudio libavcodec-dev
</pre>
<p>It should install all these packages without a problem. When it is finished, go to the <em>App. Manager</em>, <strong>enable Maemo extras-devel</strong> and then close the <em>App. Manager</em>. <strong>Ignore any updates that are offered by your phone at this point</strong>.</p>
<p>Now go back to the console, and write the following (make sure that the <em>App. Manager</em> is closed before you do so):</p>
<pre class="brush: plain; title: ; notranslate">sudo apt-get install libasound2-dev libmad0-dev libid3tag0-dev libflac-dev libflac++-dev</pre>
<p>If  it asks &#8220;<em>Install these packages without verification?</em>&#8221; Answer <strong>yes</strong>.</p>
<p>Once it is finished installing the packages, go to the <em>App. Manager</em> and <strong>disable all of the four repositories we used</strong> (<em>Maemo SDK</em>, <em>Maemo Tools</em>, <em>Maemo extras-testing</em>, <em>Maemo extras-devel</em>).</p>
<p>OK, now your N900 is ready to compile software. We are now going to get and compile <em>Music Player Daemon</em> (MPD).</p>
<p>Open the console (<em>X Terminal</em>) and write the following:</p>
<pre class="brush: plain; title: ; notranslate">
cd
mkdir tempdelme
cd tempdelme
wget http://downloads.sourceforge.net/project/musicpd/mpd/0.16.6/mpd-0.16.6.tar.gz
tar -xvzf mpd-0.16.6.tar.gz
cd mpd-0.16.6/
./configure
make
sudo make install
</pre>
<p>After some time, it should be ready. Now MPD is installed in <em>/usr/local/bin/mpd</em>. Check that everything is OK with this command <em>(Thanks Martin for suggesting the &#8211;no-daemon option)</em>:</p>
<pre class="brush: plain; title: ; notranslate">
/usr/local/bin/mpd --version --no-daemon
</pre>
<p>It should display the formats it is able to play (i.e. mp3, flac, wav, etc). If you need more functionality than what is presented, install the extra needed libraries and then run <em>./configure; make; sudo make install</em> again. Most people should be OK with the current settings.</p>
<p>Now that we have MPD installed, we need to configure it. Write this:</p>
<pre class="brush: plain; title: ; notranslate">nano /home/user/.mpdconf</pre>
<p>This will open a text editor. Write the following in there:</p>
<pre class="brush: plain; title: ; notranslate">
port                    &quot;6600&quot;
music_directory         &quot;/home/user/MyDocs/music&quot;
playlist_directory      &quot;/home/user/.mpd/playlists&quot;
db_file                 &quot;/home/user/.mpd/mpd.db&quot;
log_file                &quot;/home/user/.mpd/mpd.log&quot;

user &quot;user&quot;

bind_to_address &quot;any&quot;

audio_output {
        type            &quot;alsa&quot;
        name            &quot;MPD ALSA&quot;
        mixer_type      &quot;software&quot;
}
</pre>
<p>Make sure that all your music files and folders are inside the defined <strong>music_directory</strong>.</p>
<p>Now let&#8217;s create those directories</p>
<pre class="brush: plain; title: ; notranslate">
mkdir -p /home/user/.mpd/playlists
mkdir -p /home/user/MyDocs/music
</pre>
<p>And now put some music files in the <em>music_directory</em> that you defined previously. You can use FTP to easily transfer music from your PC to that folder in the N900. After you put some music,  generate the MPD database:</p>
<pre class="brush: plain; title: ; notranslate">
sudo /usr/local/bin/mpd --create-db
</pre>
<p>Now we can start MPD with this:</p>
<pre class="brush: plain; title: ; notranslate">
sudo /usr/local/bin/mpd /home/user/.mpdconf
</pre>
<p>Test that everything is working:</p>
<pre class="brush: plain; title: ; notranslate">
mpc update
mpc add /
mpc play
</pre>
<p>If you hear music, then everything is great. You can stop the music with:</p>
<pre class="brush: plain; title: ; notranslate">
mpc stop
</pre>
<p>You can now delete the temporary files we used for the compilation:</p>
<pre class="brush: plain; title: ; notranslate">
cd
rm -r tempdelme
</pre>
<p>OK, so now MPD is installed on your N900. You can connect with any client to it. Actually, we just connected with one of them, <em>mpc</em>, a console client for MPD.</p>
<p>If you are using firefox, you can use <em><a href="https://addons.mozilla.org/en-US/firefox/addon/music-player-minion/">Music Player Minion</a></em>. If you have an IPod/IPhone/IPad/etc&#8230; you can use <em><a href="http://itunes.apple.com/us/app/mpod/id285063020?mt=8">MPoD</a></em>. There are many <a href="http://mpd.wikia.com/wiki/Clients">clients for MPD</a>, virtually for any device that you may have at your house.</p>
<p>Enjoy playing with your cool new wireless home sound system.</p>
<p>The last (optional) step is to launch MPD automatically when you power up your phone. The N900 uses <a title="Upstart" href="http://en.wikipedia.org/wiki/Upstart">upstart</a> to control the boot scripts, so let&#8217;s create an upstart script for MPD:</p>
<pre class="brush: plain; title: ; notranslate">
sudo nano /etc/event.d/mpd
</pre>
<p>In that file, write the following:</p>
<pre class="brush: plain; title: ; notranslate">
start on started hildon-desktop

script
exec /usr/local/bin/mpd /home/user/.mpdconf
end script

stop on starting shutdown
</pre>
<p>That&#8217;s it. Reboot your phone and MPD should be running. You can check it by using the same music test from before, or directly looking at the process:</p>
<pre class="brush: plain; title: ; notranslate">
ps aux | grep mpd
</pre>
<p>If it says something like this:</p>
<pre class="brush: plain; title: ; notranslate">
1630 user     46276 S    /usr/local/bin/mpd /home/user/.mpdconf
1642 user      2088 S    grep mpd
</pre>
<p>It means that MPD is running. If on the other hand only the second line appears, it means it is not running.</p>
<p>You can close MPD by killing the process like this:</p>
<pre class="brush: plain; title: ; notranslate">
killall mpd
</pre>
<p>Finally, note that depending on your battery saving settings your N900 may disable wifi connections initiated from outside (like your SSH or FTP connections) after some inactivity time. You can make sure that the wifi connection keeps open by just pinging the router:</p>
<pre class="brush: plain; title: ; notranslate">
sudo ping 192.168.0.1
</pre>
<p>Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.samontab.com/web/2012/01/mpd-on-the-n900-or-how-to-use-your-nokia-n900-as-a-wireless-home-music-system/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Use your old Nokia symbian phone as a music web server</title>
		<link>http://www.samontab.com/web/2011/08/use-your-old-nokia-symbian-phone-as-a-music-web-server/</link>
		<comments>http://www.samontab.com/web/2011/08/use-your-old-nokia-symbian-phone-as-a-music-web-server/#comments</comments>
		<pubDate>Fri, 19 Aug 2011 02:35:39 +0000</pubDate>
		<dc:creator>samontab</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.samontab.com/web/?p=187</guid>
		<description><![CDATA[If you have a Wi-Fi capable Nokia Symbian phone with a memory card and also a Wi-Fi router, you can use them to serve your music at home. This is a great way of having all your music in just one place and access it from any wireless capable device (i.e. laptops) as well as [...]]]></description>
				<content:encoded><![CDATA[<p>If you have a Wi-Fi capable Nokia Symbian phone with a memory card and also a Wi-Fi router, you can use them to serve your music at home. This is a great way of having all your music in just one place and access it from any wireless capable device (i.e. laptops) as well as sharing it with others at your house. Also, you could still enjoy the same music on the go since it is stored on your mobile phone. This means that you can turn an old unused mobile phone into a very small and noiseless music server for free.</p>
<p>OK, the first step is to install PAMP. This is a web server for mobile phones. It contains <a title="Apache" href="http://en.wikipedia.org/wiki/Apache_HTTP_Server">Apache</a>, <a title="MySQL" href="http://en.wikipedia.org/wiki/Mysql">MySQL</a> and <a title="PHP" href="http://en.wikipedia.org/wiki/Php">PHP</a>, all in one nice installable sis package for your phone.<br />
To install it, just go <a title="Pamp 1.0.2" href="http://sourceforge.net/projects/pamp/files/pamp/1_00_02/">here</a> and download the file named <strong>pamp_1_0_2.zip</strong> (not the SDK one).<br />
Extract the files. Notice that there are three <em>.sis</em> files. First install <strong>pips_nokia_1_3_SS.sis</strong>, then install <strong>ssl.sis</strong> and finally install <strong>pamp_1_0_2.sis</strong>.<br />
Now you should have a PAMP application on your phone. Open it. You should see something like this:</p>
<p><a href="http://www.samontab.com/web/wp-content/uploads/2011/08/Scr000004.jpg"><img class="alignnone size-medium wp-image-191" title="Scr000004" src="http://www.samontab.com/web/wp-content/uploads/2011/08/Scr000004-300x225.jpg" alt="" width="300" height="225" /></a></p>
<p>Now, click on <em>Options</em> and then select <em>Start-&gt;Pamp</em>. Answer <em>Yes</em> to the <em>Start WLAN?</em> question and select your home wireless network.</p>
<p><a href="http://www.samontab.com/web/wp-content/uploads/2011/08/Scr000005.jpg"><img class="alignnone size-medium wp-image-192" title="Scr000005" src="http://www.samontab.com/web/wp-content/uploads/2011/08/Scr000005-300x225.jpg" alt="" width="300" height="225" /></a></p>
<p>You should now see that Apache and MySQL services are running, the name of your wireless network and the assigned IP number. That number is the one you need to connect to your phone. Write it down. It should look something like this:</p>
<p><a href="http://www.samontab.com/web/wp-content/uploads/2011/08/Scr000006.jpg"><img class="alignnone size-medium wp-image-193" title="Scr000006" src="http://www.samontab.com/web/wp-content/uploads/2011/08/Scr000006-300x225.jpg" alt="" width="300" height="225" /></a></p>
<p>Let the PAMP application running on the background as is. You can do that by just pressing your <em>Home</em> button. Now let&#8217;s check that everything is working so far. In your laptop open up Firefox (or any other web browser) and type in the IP address from the previous step. You should see something like this:<br />
<a href="http://www.samontab.com/web/wp-content/uploads/2011/08/apache.png"><img class="alignnone size-medium wp-image-189" title="apache" src="http://www.samontab.com/web/wp-content/uploads/2011/08/apache-300x223.png" alt="" width="300" height="223" /></a><br />
If you see the something similar, the Apache server is working. Now follow the <strong>phpinfo.php</strong> link. It should display information about your mobile server (cool, isn&#8217;t it) like this:</p>
<p><a href="http://www.samontab.com/web/wp-content/uploads/2011/08/php.png"><img class="alignnone size-medium wp-image-190" title="php" src="http://www.samontab.com/web/wp-content/uploads/2011/08/php-300x240.png" alt="" width="300" height="240" /></a></p>
<p>The web pages that you are looking at now are stored in the phone at <em>E:/DATA/apache/htdocs</em>. E: represents the memory card. This is the public folder that is being served by PAMP. The <strong>index.html</strong> file is the home page being displayed, and <strong>phpinfo.php</strong> is the link you just visited.</p>
<p>You may edit these web pages if you wish. You can install <a title="Y-Browser" href="http://www.drjukka.com/YBrowser.html">Y-Browser</a> to navigate your documents or create folders in your phone. Also, you can install <a title="ped" href="http://code.google.com/p/ped-s60/">ped</a> for editing text files on your phone (this one requires <a title="PyS60" href="http://sourceforge.net/projects/pys60/files/pys60/1.4.5/">Python for S60</a> to be installed first). You can also edit the files on your PC and then transfer them back to your phone.</p>
<p>The next step is to download <a title="whispercast" href="https://github.com/manastungare/whispercast-php">whispercast</a> which is a lightweight PHP script for music streaming, perfect for our needs (Thanks Manas Tungare for making this cool script!). On your Desktop, create a folder called <strong>music</strong> (it has to be exactly this name to make it work without configuring anything else). Extract all the files from the <em>zip</em> you just downloaded into this folder. Now add all the <em>mp3</em> files that you want into the <strong>music</strong> folder as well. Each directory of <em>mp3</em> files will be a play-list.</p>
<p>Now you need to transfer the entire music folder (not just the contents, the folder itself too) into the phone, inside the <em>E:/DATA/apache/htdocs </em>folder<em>.</em></p>
<p>It is now time to go to your laptop and type in the IP address followed by <em>/music</em>. For example, if your IP is <em>192.168.0.100</em>, then you need to go to <em>192.168.0.100/music</em>. You should now see the text <strong>Manas Tungare&#8217;s Music Library</strong>, with the list of your mp3 files. Navigate to the folder/play-list you want to hear and click on <em>Start Playing</em>. It will create a play-list on the fly and ask you to select the music player that you want to use. If in doubt, just select the default player. After that, you can just save the play-list and double click on it or create a new one visiting the same page.</p>
<p><a href="http://www.samontab.com/web/wp-content/uploads/2011/08/playlist.png"><img class="alignnone size-medium wp-image-194" title="playlist" src="http://www.samontab.com/web/wp-content/uploads/2011/08/playlist-300x185.png" alt="" width="300" height="185" /></a></p>
<p>If you need to tweak some parameters, just edit the <em>config.php</em> file. For changing the format or text displayed, you can edit the other files.</p>
<p>That&#8217;s it, now you can listen to your music from anywhere in your house with a small and noise free music server. It should work for Linux, Windows, Mac, or even other mobile phones or tablets.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.samontab.com/web/2011/08/use-your-old-nokia-symbian-phone-as-a-music-web-server/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Installing OpenCV 2.2 in Ubuntu 11.04</title>
		<link>http://www.samontab.com/web/2011/06/installing-opencv-2-2-in-ubuntu-11-04/</link>
		<comments>http://www.samontab.com/web/2011/06/installing-opencv-2-2-in-ubuntu-11-04/#comments</comments>
		<pubDate>Fri, 17 Jun 2011 22:21:12 +0000</pubDate>
		<dc:creator>samontab</dc:creator>
				<category><![CDATA[Image Processing]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.samontab.com/web/?p=172</guid>
		<description><![CDATA[Many people have used my previous tutorial about installing OpenCV 2.1 in Ubuntu 9.10. In the comments of that post, I noticed great interest for using OpenCV with Python and the Intel Threading Building Blocks (TBB). Since new versions of OpenCV and Ubuntu are available, I decided to create a new post with detailed instructions [...]]]></description>
				<content:encoded><![CDATA[<p>Many people have used my previous tutorial about installing <a href="http://www.samontab.com/web/2010/04/installing-opencv-2-1-in-ubuntu/">OpenCV 2.1 in Ubuntu 9.10</a>. In the comments of that post, I noticed great interest for using OpenCV with Python and the Intel Threading Building Blocks (TBB). Since new versions of OpenCV and Ubuntu are available, I decided to create a new post with detailed instructions for installing the latest version of OpenCV, 2.2, in the latest version of Ubuntu, 11.04, with Python and TBB support.</p>
<p>UPDATE:<br />
Now you can use my <a href="http://www.samontab.com/web/2012/06/installing-opencv-2-4-1-ubuntu-12-04-lts/" title="OpenCV 2.4.1 in Ubuntu 12.04LTS">new guide to install OpenCV 2.4.1 in Ubuntu 12.04 LTS</a>:</p>
<p>First, you need to install many dependencies, such as support for reading and writing image files, drawing on the screen, some needed tools, etc&#8230; This step is very easy, you only need to write the following command in the Terminal</p>
<pre class="brush: bash; title: ; notranslate">

sudo apt-get install build-essential libgtk2.0-dev libjpeg62-dev libtiff4-dev libjasper-dev libopenexr-dev cmake python-dev python-numpy libtbb-dev libeigen2-dev yasm libfaac-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev

</pre>
<p>Now we need to get and compile the ffmpeg source code so that video files work properly with OpenCV. This section is partially based on the method discussed <a href="http://blog.pinglin.idv.tw/20101208031323/">here</a>.</p>
<pre class="brush: plain; title: ; notranslate">
cd ~
wget http://ffmpeg.org/releases/ffmpeg-0.7-rc1.tar.gz
tar -xvzf ffmpeg-0.7-rc1.tar.gz
cd ffmpeg-0.7-rc1
./configure --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libfaac --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libxvid --enable-x11grab --enable-swscale --enable-shared
make
sudo make install
</pre>
<p>The next step is to get the OpenCV 2.2 code:</p>
<pre class="brush: bash; title: ; notranslate">
cd ~
wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.2/OpenCV-2.2.0.tar.bz2
tar -xvf OpenCV-2.2.0.tar.bz2
cd OpenCV-2.2.0/
</pre>
<p>Now we have to generate the Makefile by using cmake. In here we can define which parts of OpenCV we want to compile. Since we want to use Python and TBB with OpenCV, here is where we set that. Just execute the following line at the console to create the appropriate Makefile. Note that there is a dot at the end of the line, it is an argument for the cmake program and it means current directory.</p>
<pre class="brush: bash; title: ; notranslate">
cmake -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=OFF -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON .
</pre>
<p>Check that the above command produces no error and that in particular it reports FFMPEG as 1. If this is not the case you will not be able to read or write videos. Also, check that Python reports ON and Python numpy reports YES. Also, check that under <em>Use TBB</em> it says YES. If anything is wrong, go back, correct the errors by maybe installing extra packages and then run cmake again. You should see something similar to this:</p>
<p><a href="http://www.samontab.com/web/wp-content/uploads/2011/06/cmakeConfig.png"><img src="http://www.samontab.com/web/wp-content/uploads/2011/06/cmakeConfig-300x212.png" alt="" title="cmakeConfig" width="300" height="212" class="alignnone size-medium wp-image-182" /></a></p>
<p>Now, you are ready to compile and install OpenCV 2.2:</p>
<pre class="brush: bash; title: ; notranslate">
make
sudo make install
</pre>
<p>Now you have to configure OpenCV. First, open the opencv.conf file with the following code:</p>
<pre class="brush: bash; title: ; notranslate">
sudo gedit /etc/ld.so.conf.d/opencv.conf
</pre>
<p>Add the following line at the end of the file(it may be an empty file, that is ok) and then save it:</p>
<pre class="brush: bash; title: ; notranslate">
/usr/local/lib
</pre>
<p><a href="http://www.samontab.com/web/wp-content/uploads/2010/03/Screenshot-opencv.conf-etc-ld.so_.conf_.d-gedit.png"><img title="Screenshot-opencv.conf (-etc-ld.so.conf.d) - gedit" src="http://www.samontab.com/web/wp-content/uploads/2010/03/Screenshot-opencv.conf-etc-ld.so_.conf_.d-gedit-300x240.png" alt="" width="300" height="240" /></a></p>
<p>Run the following code to configure the library:</p>
<pre class="brush: bash; title: ; notranslate">
sudo ldconfig
</pre>
<p>Now you have to open another file:</p>
<pre class="brush: bash; title: ; notranslate">
sudo gedit /etc/bash.bashrc
</pre>
<p>Add these two lines at the end of the file and save it:</p>
<pre class="brush: bash; title: ; notranslate">
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH
</pre>
<div><a href="http://www.samontab.com/web/wp-content/uploads/2010/03/Screenshot-bash.bashrc-etc-gedit.png"><img title="Screenshot-bash.bashrc (-etc) - gedit" src="http://www.samontab.com/web/wp-content/uploads/2010/03/Screenshot-bash.bashrc-etc-gedit-300x240.png" alt="" width="300" height="240" /></a></div>
<p>Finally, <strong>close the console and open a new one, restart the computer or logout and then login again</strong>. OpenCV will not work correctly until you do this.</p>
<p>There is a final step to configure Python with OpenCV. You need to copy the file <em>cv.so</em> into the correct place. You can do that by just executing the following command:</p>
<pre class="brush: plain; title: ; notranslate">
sudo cp /usr/local/lib/python2.7/site-packages/cv.so /usr/local/lib/python2.7/dist-packages/cv.so
</pre>
<p>Now you have OpenCV 2.2 installed in your computer with Python and TBB support.</p>
<p>Let&#8217;s check some demos included in OpenCV.<br />
First, let&#8217;s see some C demos:</p>
<pre class="brush: plain; title: ; notranslate">
cd ~/OpenCV-2.2.0/samples/c
chmod +x build_all.sh
./build_all.sh
</pre>
<p>Some of the training data for object detection is stored in /usr/local/share/opencv/haarcascades. You need to tell OpenCV which training data to use. I will use one of the frontal face detectors available. Let&#8217;s find a face:</p>
<pre class="brush: bash; title: ; notranslate">
./facedetect --cascade=&quot;/usr/local/share/opencv/haarcascades/haarcascade_frontalface_alt.xml&quot; --scale=1.5 lena.jpg
</pre>
<p><a href="http://www.samontab.com/web/wp-content/uploads/2010/03/Screenshot-1.png"><img title="Screenshot-1" src="http://www.samontab.com/web/wp-content/uploads/2010/03/Screenshot-1-288x300.png" alt="" width="288" height="300" /></a></p>
<p>Note the scale parameter. It allows you to increase or decrease the size of the smallest object found in the image (faces in this case). Smaller numbers allows OpenCV to find smaller faces, which may lead to increasing the number of false detections. Also, the computation time needed gets larger when searching for smaller objects.</p>
<p>You can also detect smaller objects that are inside larger ones. For example you can search for eyes inside any detected face. You can do that with the nested-cascade parameter:</p>
<pre class="brush: plain; title: ; notranslate">
./facedetect --cascade=&quot;/usr/local/share/opencv/haarcascades/haarcascade_frontalface_alt.xml&quot; --nested-cascade=&quot;/usr/local/share/opencv/haarcascades/haarcascade_eye.xml&quot; --scale=1.5 lena.jpg
</pre>
<p><a href="http://www.samontab.com/web/wp-content/uploads/2011/06/eyes.png"><img src="http://www.samontab.com/web/wp-content/uploads/2011/06/eyes.png" alt="" title="eyes" width="300"  class="alignnone size-full wp-image-176" /></a><br />
Feel free to experiment with other features like mouth or nose for example using the corresponding cascades provided in the haarcascades directory.</p>
<p>Now let&#8217;s check some C++ demos:</p>
<pre class="brush: plain; title: ; notranslate">
cd ~/OpenCV-2.2.0/samples/cpp
make
</pre>
<p>Now all the C++ demos are built in ~/OpenCV-2.2.0/bin. Let&#8217;s see a couple of them. For example, a simulated chessboard calibration:</p>
<pre class="brush: plain; title: ; notranslate">
~/OpenCV-2.2.0/bin/calibration_artificial
</pre>
<p><a href="http://www.samontab.com/web/wp-content/uploads/2011/06/cppchess1.png"><img src="http://www.samontab.com/web/wp-content/uploads/2011/06/cppchess1.png" alt="" title="cppchess" width="300"  class="alignnone size-full wp-image-178" /></a><br />
In OpenCV 2.2, the grabcut algorithm is provided as a C++ sample. This is a very nice segmentation algorithm that needs very little user input to segment  the objects in the image. For using the demo, you need to select a rectangle of the area you want to segment. Then, hold the Control key and left click to select the background (in Blue). After that, hold the Shift key and left click to select the foreground (in Red). Then press the n key to generate the segmentation. You can press n again to continue to the next iteration of the algorithm.</p>
<pre class="brush: plain; title: ; notranslate">
~/OpenCV-2.2.0/bin/grabcut ~/OpenCV-2.2.0/samples/cpp/lena.jpg
</pre>
<p>This image shows the initial rectangle for defining the object that I want to segment.</p>
<p><a href="http://www.samontab.com/web/wp-content/uploads/2010/04/Screenshot-image-2.png"><img class="alignnone size-medium wp-image-43" title="Screenshot-image-2" src="http://www.samontab.com/web/wp-content/uploads/2010/04/Screenshot-image-2-288x300.png" alt="" width="288" height="300" /></a></p>
<p>Now I roughly set the foreground (red) and background (blue).</p>
<p><a href="http://www.samontab.com/web/wp-content/uploads/2010/04/Screenshot-image-3.png"><img class="alignnone size-medium wp-image-44" title="Screenshot-image-3" src="http://www.samontab.com/web/wp-content/uploads/2010/04/Screenshot-image-3-288x300.png" alt="" width="288" height="300" /></a></p>
<p>When you are ready, press the n key to run the grabcut algorithm. This image shows the result of the first iteration of the algorithm.</p>
<p><a href="http://www.samontab.com/web/wp-content/uploads/2010/04/Screenshot-image-4.png"><img class="alignnone size-medium wp-image-45" title="Screenshot-image-4" src="http://www.samontab.com/web/wp-content/uploads/2010/04/Screenshot-image-4-288x300.png" alt="" width="288" height="300" /></a></p>
<p>Now let&#8217;s see some background subtraction from a video. The original video shows a hand moving in front of some trees. OpenCV allows you to separate the foreground (hand) from the background (trees).</p>
<p><a href="http://www.samontab.com/web/wp-content/uploads/2010/03/Screenshot-tree.avi-VLC-media-player.png"><img title="Screenshot-tree.avi - VLC media player" src="http://www.samontab.com/web/wp-content/uploads/2010/03/Screenshot-tree.avi-VLC-media-player-281x300.png" alt="" width="281" height="300" /></a></p>
<pre class="brush: bash; title: ; notranslate">
~/OpenCV-2.2.0/bin/bgfg_segm ~/OpenCV-2.2.0/samples/c/tree.avi
</pre>
<p><a href="http://www.samontab.com/web/wp-content/uploads/2010/03/Screenshot-2.png"><img title="Screenshot-2" src="http://www.samontab.com/web/wp-content/uploads/2010/03/Screenshot-2-300x122.png" alt="" width="300" height="122" /></a></p>
<p>And finally, let&#8217;s see Python working with OpenCV:</p>
<pre class="brush: plain; title: ; notranslate">
cd ~/OpenCV-2.2.0/samples/python/
</pre>
<p>Let&#8217;s run the kmeans.py example. This script starts with randomly generated 2D points and then uses a clustering method called k-means. Each cluster is presented in a different color.</p>
<pre class="brush: plain; title: ; notranslate">
python kmeans.py
</pre>
<p><a href="http://www.samontab.com/web/wp-content/uploads/2011/06/pythonkmeans.png"><img src="http://www.samontab.com/web/wp-content/uploads/2011/06/pythonkmeans.png" alt="" title="pythonkmeans" width="300" class="alignnone size-full wp-image-179" /></a></p>
<p>Now let&#8217;s see the convexhull.py demo. This algorithm basically calculates the smallest convex polygon that encompasses the data points.</p>
<pre class="brush: plain; title: ; notranslate">
python convexhull.py
</pre>
<p><a href="http://www.samontab.com/web/wp-content/uploads/2011/06/convexHullPython.png"><img src="http://www.samontab.com/web/wp-content/uploads/2011/06/convexHullPython-284x300.png" alt="" title="convexHullPython" width="284" height="300" class="alignnone size-medium wp-image-180" /></a></p>
<p>Python scripts can also be executed directly like the following example. This script reads a video file (../c/tree.avi) within pyhton and shows the first frame on screen:</p>
<pre class="brush: plain; title: ; notranslate">
./minidemo.py
</pre>
<p><a href="http://www.samontab.com/web/wp-content/uploads/2011/06/minidemoPython.png"><img src="http://www.samontab.com/web/wp-content/uploads/2011/06/minidemoPython-300x251.png" alt="" title="minidemoPython" width="300" height="251" class="alignnone size-medium wp-image-181" /></a><br />
Have fun with OpenCV in C, C++ or Python&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.samontab.com/web/2011/06/installing-opencv-2-2-in-ubuntu-11-04/feed/</wfw:commentRss>
		<slash:comments>165</slash:comments>
		</item>
	</channel>
</rss>
