Skip to content

Installing OpenCV 2.4.1 in Ubuntu 12.04 LTS

EDIT: I published a new guide using Ubuntu 14.04 LTS and OpenCV 2.4.9 here.

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 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).

OK, so the first step is to make sure that everything in the system is updated and upgraded:

sudo apt-get update
sudo apt-get upgrade

Now, you need to install many dependencies, such as support for reading and writing image files, drawing on the screen, some needed tools, etc… This step is very easy, you only need to write the following command in the Terminal:

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

Time to get the OpenCV 2.4.1 source code:

cd ~
tar -xvf OpenCV-2.4.1.tar.bz2
cd OpenCV-2.4.1

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).

mkdir build
cd build

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.

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:

Now, you are ready to compile and install OpenCV 2.4.1:

sudo make install

Now you have to configure OpenCV. First, open the opencv.conf file with the following code:

sudo gedit /etc/

Add the following line at the end of the file(it may be an empty file, that is ok) and then save it:


Run the following code to configure the library:

sudo ldconfig

Now you have to open another file:

sudo gedit /etc/bash.bashrc

Add these two lines at the end of the file and save it:


Finally, close the console and open a new one, restart the computer or logout and then login again. OpenCV will not work correctly until you do this.

Now you have OpenCV 2.4.1 installed in your computer with Python, TBB, OpenGL, video, and Qt support.

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.

If you zoom in enough, you can see the RGB (or intensity) values for each pixel.

Now let’s build some samples included in OpenCV:

cd ~/OpenCV-2.4.1/samples/c
chmod +x

Now we are ready to run the examples:

./facedetect --cascade="/usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_alt.xml" --scale=1.5 lena.jpg

./facedetect --cascade="/usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_alt.xml" --nested-cascade="/usr/local/share/OpenCV/haarcascades/haarcascade_eye.xml" --scale=1.5 lena.jpg

~/OpenCV-2.4.1/build/bin/grabcut ~/OpenCV-2.4.1/samples/cpp/lena.jpg


python ~/OpenCV-2.4.1/samples/python2/

Posted in Computer Vision, Open Source, OpenCV.

MPD on the N900 or how to use your Nokia N900 as a Wireless Home Music System

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 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.

First of all make sure that you back up all your N900 data. No kidding. We are going to make some changes that could possibly brick your phone. 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.

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 (MPD), which is the program we are going to install on the N900.

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.

To manage your repositories on your N900, go to the App. Manager and click on the menu on top. There, select Application Catalogs.

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.

Now, let’s add some catalogs. Click on the New button and fill in the information provided for the four following catalogs:

Maemo SDK: This catalog provides core system utilities that  we will need to build programs.

Catalog Name: Maemo SDK
Web address:
Distribution: fremantle/sdk
Components: free non-free
Disabled: Unchecked

Maemo tools: This catalog provides tools that are very useful, like nano or wget.

Catalog Name: Maemo tools
Web address:
Distribution: fremantle/tools
Components: free non-free
Disabled: Unchecked

Maemo extras-testing: This catalog provides more applications than the ones in the default Maemo catalog (extras), although they are not as thoroughly tested.

Catalog Name: Maemo extras-testing
Web address:
Distribution: fremantle
Components: free non-free
Disabled: Unchecked

Maemo extras-devel: 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. Make sure that you disable Maemo extras-devel when you add it.

Catalog Name: Maemo extras-devel
Web address:
Distribution: fremantle
Components: free non-free
Disabled: Checked

These catalogs provide different applications that we will need later. Disable Maemo extras-devel and enable the other three.

Now exit the Application Catalogs screen. The N900 will automatically update the list of applications after you changed the repositories. If you didn’t see any update, click on the Update button just to be sure. Now click on Download->All to see the list of applications available to install. You should install the following apps:

openssh client and server
Personal IP Address

When you install OpenSSH, you will be asked for a password. This is the root password, so keep it safe.

Now close the application manager and open the console (X Terminal). In there, you will setup a password for the default user, which is user. Write this:

sudo passwd user

And write a password for the user user, which is the default user (non root privileges). Close the console or write exit to exit.

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 root or user using the passwords you just set for them. If you don’t have Linux installed on your computer, you can use Filezilla for FTP and PuTTy for SSH. Make sure that you can connect to your N900 with the user account.

Now we will be working with the command line only, so I suggest you to connect from your computer via SSH (as user) for easier writing (or copy pasting). Make sure that the App. Manager is closed before continuing.

On the console, write the following:

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

It should install all these packages without a problem. When it is finished, go to the App. Manager, enable Maemo extras-devel and then close the App. Manager. Ignore any updates that are offered by your phone at this point.

Now go back to the console, and write the following (make sure that the App. Manager is closed before you do so):

sudo apt-get install libasound2-dev libmad0-dev libid3tag0-dev libflac-dev libflac++-dev

If  it asks “Install these packages without verification?” Answer yes.

Once it is finished installing the packages, go to the App. Manager and disable all of the four repositories we used (Maemo SDK, Maemo Tools, Maemo extras-testing, Maemo extras-devel).

OK, now your N900 is ready to compile software. We are now going to get and compile Music Player Daemon (MPD).

Open the console (X Terminal) and write the following:

mkdir tempdelme
cd tempdelme
tar -xvzf mpd-0.16.6.tar.gz
cd mpd-0.16.6/
sudo make install

After some time, it should be ready. Now MPD is installed in /usr/local/bin/mpd. Check that everything is OK with this command (Thanks Martin for suggesting the –no-daemon option):

/usr/local/bin/mpd --version --no-daemon

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 ./configure; make; sudo make install again. Most people should be OK with the current settings.

Now that we have MPD installed, we need to configure it. Write this:

nano /home/user/.mpdconf

This will open a text editor. Write the following in there:

port                    "6600"
music_directory         "/home/user/MyDocs/music"
playlist_directory      "/home/user/.mpd/playlists"
db_file                 "/home/user/.mpd/mpd.db"
log_file                "/home/user/.mpd/mpd.log"

user "user"

bind_to_address "any"

audio_output {
        type            "alsa"
        name            "MPD ALSA"
        mixer_type      "software"

Make sure that all your music files and folders are inside the defined music_directory.

Now let’s create those directories

mkdir -p /home/user/.mpd/playlists
mkdir -p /home/user/MyDocs/music

And now put some music files in the music_directory 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:

sudo /usr/local/bin/mpd --create-db

Now we can start MPD with this:

sudo /usr/local/bin/mpd /home/user/.mpdconf

Test that everything is working:

mpc update
mpc add /
mpc play

If you hear music, then everything is great. You can stop the music with:

mpc stop

You can now delete the temporary files we used for the compilation:

rm -r tempdelme

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, mpc, a console client for MPD.

If you are using firefox, you can use Music Player Minion. If you have an IPod/IPhone/IPad/etc… you can use MPoD. There are many clients for MPD, virtually for any device that you may have at your house.

Enjoy playing with your cool new wireless home sound system.

The last (optional) step is to launch MPD automatically when you power up your phone. The N900 uses upstart to control the boot scripts, so let’s create an upstart script for MPD:

sudo nano /etc/event.d/mpd

In that file, write the following:

start on started hildon-desktop

exec /usr/local/bin/mpd /home/user/.mpdconf
end script

stop on starting shutdown

That’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:

ps aux | grep mpd

If it says something like this:

1630 user     46276 S    /usr/local/bin/mpd /home/user/.mpdconf
1642 user      2088 S    grep mpd

It means that MPD is running. If on the other hand only the second line appears, it means it is not running.

You can close MPD by killing the process like this:

killall mpd

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:

sudo ping


Posted in Open Source, Programming.

Use your old Nokia symbian phone as a music web server

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.

OK, the first step is to install PAMP. This is a web server for mobile phones. It contains Apache, MySQL and PHP, all in one nice installable sis package for your phone.
To install it, just go here and download the file named (not the SDK one).
Extract the files. Notice that there are three .sis files. First install pips_nokia_1_3_SS.sis, then install ssl.sis and finally install pamp_1_0_2.sis.
Now you should have a PAMP application on your phone. Open it. You should see something like this:

Now, click on Options and then select Start->Pamp. Answer Yes to the Start WLAN? question and select your home wireless network.

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:

Let the PAMP application running on the background as is. You can do that by just pressing your Home button. Now let’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:

If you see the something similar, the Apache server is working. Now follow the phpinfo.php link. It should display information about your mobile server (cool, isn’t it) like this:

The web pages that you are looking at now are stored in the phone at E:/DATA/apache/htdocs. E: represents the memory card. This is the public folder that is being served by PAMP. The index.html file is the home page being displayed, and phpinfo.php is the link you just visited.

You may edit these web pages if you wish. You can install Y-Browser to navigate your documents or create folders in your phone. Also, you can install ped for editing text files on your phone (this one requires Python for S60 to be installed first). You can also edit the files on your PC and then transfer them back to your phone.

The next step is to download whispercast 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 music (it has to be exactly this name to make it work without configuring anything else). Extract all the files from the zip you just downloaded into this folder. Now add all the mp3 files that you want into the music folder as well. Each directory of mp3 files will be a play-list.

Now you need to transfer the entire music folder (not just the contents, the folder itself too) into the phone, inside the E:/DATA/apache/htdocs folder.

It is now time to go to your laptop and type in the IP address followed by /music. For example, if your IP is, then you need to go to You should now see the text Manas Tungare’s Music Library, with the list of your mp3 files. Navigate to the folder/play-list you want to hear and click on Start Playing. 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.

If you need to tweak some parameters, just edit the config.php file. For changing the format or text displayed, you can edit the other files.

That’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.

Posted in IoT, Open Source, Programming.

Installing OpenCV 2.2 in Ubuntu 11.04

UPDATE: You can also install OpenCV 3.2.0 in Ubuntu 16.04LTS.

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 for installing the latest version of OpenCV, 2.2, in the latest version of Ubuntu, 11.04, with Python and TBB support.

First, you need to install many dependencies, such as support for reading and writing image files, drawing on the screen, some needed tools, etc… This step is very easy, you only need to write the following command in the Terminal

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

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 here.

cd ~
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
sudo make install

The next step is to get the OpenCV 2.2 code:

cd ~
tar -xvf OpenCV-2.2.0.tar.bz2
cd OpenCV-2.2.0/

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.


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 Use TBB 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:

Now, you are ready to compile and install OpenCV 2.2:

sudo make install

Now you have to configure OpenCV. First, open the opencv.conf file with the following code:

sudo gedit /etc/

Add the following line at the end of the file(it may be an empty file, that is ok) and then save it:


Run the following code to configure the library:

sudo ldconfig

Now you have to open another file:

sudo gedit /etc/bash.bashrc

Add these two lines at the end of the file and save it:


Finally, close the console and open a new one, restart the computer or logout and then login again. OpenCV will not work correctly until you do this.

There is a final step to configure Python with OpenCV. You need to copy the file into the correct place. You can do that by just executing the following command:

sudo cp /usr/local/lib/python2.7/site-packages/ /usr/local/lib/python2.7/dist-packages/

Now you have OpenCV 2.2 installed in your computer with Python and TBB support.

Let’s check some demos included in OpenCV.
First, let’s see some C demos:

cd ~/OpenCV-2.2.0/samples/c
chmod +x

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’s find a face:

./facedetect --cascade="/usr/local/share/opencv/haarcascades/haarcascade_frontalface_alt.xml" --scale=1.5 lena.jpg

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.

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:

./facedetect --cascade="/usr/local/share/opencv/haarcascades/haarcascade_frontalface_alt.xml" --nested-cascade="/usr/local/share/opencv/haarcascades/haarcascade_eye.xml" --scale=1.5 lena.jpg

Feel free to experiment with other features like mouth or nose for example using the corresponding cascades provided in the haarcascades directory.

Now let’s check some C++ demos:

cd ~/OpenCV-2.2.0/samples/cpp

Now all the C++ demos are built in ~/OpenCV-2.2.0/bin. Let’s see a couple of them. For example, a simulated chessboard calibration:


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.

~/OpenCV-2.2.0/bin/grabcut ~/OpenCV-2.2.0/samples/cpp/lena.jpg

This image shows the initial rectangle for defining the object that I want to segment.

Now I roughly set the foreground (red) and background (blue).

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.

Now let’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).

~/OpenCV-2.2.0/bin/bgfg_segm ~/OpenCV-2.2.0/samples/c/tree.avi

And finally, let’s see Python working with OpenCV:

cd ~/OpenCV-2.2.0/samples/python/

Let’s run the 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.


Now let’s see the demo. This algorithm basically calculates the smallest convex polygon that encompasses the data points.


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:


Have fun with OpenCV in C, C++ or Python…

Posted in Computer Vision, Open Source, OpenCV.

Create installable applications (.sis files) from your Python scripts for Symbian

Python is great. It makes everything simple. Also, it can be run almost anywhere, even on your Nokia smartphones. In this post I will show you how to create an installable application (.sis file) from your Python scripts.

The first step is to install Python 2.5 on your computer. It has to be 2.5. If you have a newer version of Python installed, either downgrade to 2.5 or create a local folder with Python 2.5 executable on it and make sure you use that version. You can install Python 2.5 from here.

If you are on Ubuntu, probably you have a newer version of Python. Just get the source and compile it locally:

cd ~
mkdir py2sis
cd py2sis
tar -xvzf Python-2.5.4.tgz
rm Python-2.5.4.tgz
cd Python-2.5.4

OK, so now we should have a local copy of Python 2.5.4. To test that everything is fine, run the following command:

~/py2sis/Python-2.5.4/python --version

It should report Python 2.5.4. Windows or Linux users that installed Python 2.5.4 on their entire system can always substitute ~/py2sis/Python-2.5.4/python by just python. For them, the following command should report the same result:

python --version

Now, we need to get the utilities that will allow us to create the sis files. That software is called ensymble. We need exactly this file:

 cd ~/py2sis
~/py2sis/Python-2.5.4/python ~/py2sis/ version

You should get this result: Ensymble v0.27 2008-06-30.

Now let’s get PythonForS60 sis file that will be installed alongside your script. We need the file PythonForS60_1_4_5_3rdEd.sis.

cd ~/py2sis
mv download PythonForS60_1_4_5_3rdEd.sis

All done configuring the tools. Now we are going to create a Python script.

cd ~
mkdir myFirstScript
cd myFirstScript
gedit &

Here you can put any Python code for Symbian S60. Let’s start with something simple. Write this and save the file:

import appuifw
appuifw.note(u"Hello Symbian/Python World", "info")

Time to create your first Python SIS file. Execute the following:

cd ~
~/py2sis/Python-2.5.4/python ~/py2sis/ py2sis myFirstScript

It should generate a file called myFirstScript_v1_0_0.sis. This is the sis file for your script. If you already have PythonForS60 sis installed in your phone, it should work. Most of the time though, users will not have it, so let’s merge the two into just one sis:

cd ~
~/py2sis/Python-2.5.4/python ~/py2sis/ mergesis myFirstScript_v1_0_0.sis ~/py2sis/PythonForS60_1_4_5_3rdEd.sis myFirstScript_v1_0_0_with_Python.sis

Now, you can just install myFirstScript_v1_0_0_with_Python.sis in your Nokia Symbian S60 3rd edition phone (like the E71 for example) and when you open it, you should see something like this:

Great, so now let’s automate this using a script:

sudo touch /usr/local/bin/
sudo chmod +x /usr/local/bin/
sudo gedit /usr/local/bin/ &

Write these commands on the file:

echo "Creating script sis file..."
~/py2sis/Python-2.5.4/python ~/py2sis/ py2sis myFirstScript
echo "Merging script sis file with Python for S60 sis file..."
~/py2sis/Python-2.5.4/python ~/py2sis/ mergesis myFirstScript_v1_0_0.sis ~/py2sis/PythonForS60_1_4_5_3rdEd.sis myFirstScript_v1_0_0_with_Python.sis
echo "Done."

Now let’s test it erasing the files we just created and then generating them with the script:

cd ~
rm myFirstScript_v1_0_0*

It should create the same 2 sis files we just created before manually. Now, let’s edit the script so that we can tell it where is our source code and set other options:

sudo gedit /usr/local/bin/ &

Replace the existing code with this:


#Check that only 1 parameter is passed (the directory of your script)
if [ $# -ne $EXPECTED_ARGS ]
echo "Usage: `basename $0` [ScriptDirectory]"
exit -1

#This is the directory where your Python for S60 Script is

#Application parameters
APP_SHORT_CAPTION="Short description."
APP_CAPTION="Here you can describe your application in more detail."
#Icon path. It should be a Tiny SVG compatible icon.
#To add an app icon, just uncomment the following line and edit the path to point to your icon

#Environment variables

echo "Creating script sis file..."
"${PYTHON_PATH}" "${ENSYMBLE_PATH}" py2sis --appname="${APP_NAME}" --version="${APP_VERSION}" --shortcaption="${APP_SHORT_CAPTION}" --caption="${APP_CAPTION}" ${APP_ICON} "${PYTHON_SCRIPT_DIR}" "${APP_SCRIPT_SIS_NAME}"
echo "Merging script sis file with Python for S60 sis file..."
echo "Done."

There you can set many parameters for your app, like the name, icon, description, and more. Now you should be able to convert your Python scripts to a sis file by just doing this: ScriptDirectory

Remember to name the main script since that is the file that ensymble is looking for inside the script folder.

Let’s test this new script, erasing the sis files and then executing this script to generate new sis files:

cd ~
rm myFirstScript_v1_0_0* myFirstScript

You should see now a myApp.sis and a myApp_with_python.sis files. Note that those were the properties set in the script. Anytime you want to change these settings, just run this and edit them directly:

sudo gedit /usr/local/bin/ &

OK, now go and create some cool Python apps in no time for your Nokia phone. Check out this excellent Symbian for S60 tutorial made by a fellow Nokia Forum Champion, Jurgen Scheible.

Posted in Programming.

Nokia Developers Day in Santiago, Chile

Over one hundred people attended the first Nokia Developers Day in Santiago, Chile. The event was held at the Pontificia Universidad Católica de Chile, which is the university where I have been teaching a course about development of mobile phone applications, at the computer science department.

The first part of the event was a general introduction to the current market strategy and opportunities that Nokia is providing to the local developers. One of the most important topics covered was that Nokia supports global payment via network operators. This means that people around the world can pay for your application without using their credit cards, which makes it easier to sell for the developer. Another important point is that feature phones, of which Nokia still has a large market share, are getting smarter every day. This means that feature phones now support touch UI, have capable CPUs, and new APIs are appearing for them, such as the Nokia Maps API.  On top of this data plans are getting cheaper, so many people are getting always on connectivity with these devices.  At the end of this session, key players from local development companies presented their experience developing for Nokia handsets.

In the second half, I presented the Qt framework for software development on multiple platforms with a focus on Symbian. The idea of the talk was to motivate the use of Qt for mobile phone application development, based on the fact that it is a mature framework, with more than 18 years of development. The mixture of a powerful framework, such as Qt, with integrated sensors,  Sebastian Montabonesuch as GPS, accelerometers, cameras, bluetooth, etc…, gives the developers the ability to create innovative applications easily. Some examples of these applications are mixed or augmented reality type of applications. You can use the GPS to locate yourself broadly, then you can use the accelerometer to know where the device is pointing at. After that, you can use the camera to process what the phone is looking at since the whole world is filtered to just a small area. This is just an example of which type of applications you can develop since with these tools your imagination is the limit. Also, since Qt is a multi platform SDK, you can port your application to Windows, Linux, Mac, and others simply by selecting that platform from a drop down menu and clicking the compile button.

Posted in IoT, Open Source, Programming.

How to install Redmine 1.1.2 on Ubuntu Server 10.04

Redmine is an excellent project management tool written using Ruby on Rails. It provides everything you need to organise your workplace or personal projects. Once you see it working you definitely will want to use it on your own projects. Everything is great until you want to install it since redmine only works with very specific versions of its dependencies. There are many steps that you need to take into consideration, even if you install the outdated version in the repositories. In this guide, I will show you how to install redmine 1.1.2 (the latest version at the time of writing) on Ubuntu Server 10.04 32 bits (latest LTS version at the time of writing).

Make sure that you installed Ubuntu Server 10.04 with SSH (optional) and LAMP support. Both can be selected to be automatically installed at the end of the normal Ubuntu Server 10.04 installation. Once it is installed, remember to update and upgrade your system.

sudo apt-get update
sudo apt-get upgrade

First, let’s install some dependencies:

sudo apt-get install ruby1.8-dev rubygems1.8 libmysql-ruby libmysqlclient-dev rake libopenssl-ruby libapache2-mod-passenger imagemagick libmagickcore-dev libmagickwand-dev

Now we can install the required packages for ruby, or gems. Note that some packages will take a long time to install and provide no output, so just be patient. Also, you will see some warnings like No definition for X. Ignore those, they mean that some documentation was not installed, and we can live with that.

sudo gem install rails -v=2.3.5
sudo gem install mysql
sudo gem install ruby-openid
sudo gem install i18n -v=0.4.2
sudo gem install passenger
sudo gem install rmagick

Now we have to prepare the database. Enter the MySQL console as root:

mysql -uroot -p

Provide the root password. This is the password you set in the early LAMP installation. Now, inside the MySQL console, execute these commands:

create database redmine character set utf8;
create user 'redmine'@'localhost' identified by 'myPassword';
grant all privileges on redmine.* to 'redmine'@'localhost';

Remember to change myPassword with your actual password. This is the one that will be used for the user redmine in the database redmine at localhost.

Now it is time to get the redmine code. Execute the following commands to get redmine 1.1.2.

cd ~
tar -xvzf redmine-1.1.2.tar.gz
cd redmine-1.1.2

Now setup the database configuration file to match our current environment:

cp config/database.yml.example config/database.yml
nano config/database.yml

Put the details of the database on the specific fields, in particular username and password. Username should be redmine and password should be myPassword or the one you provided before. Make sure that you change both, production and development sections. When you are finished, just hold Control and then press X. This is the command for exiting nano. It will ask if you want to save the changes, just press y (as in yes) and hit enter. That’s it, file saved and back to the console.

Now do the same for configuring email:

cp config/email.yml.example config/email.yml
nano config/email.yml

For this example, we are going to use gmail, but you can use any email settings that you need. Make sure that address is, port is changed to 587, domain is set to (or your host if you use google apps) and that the user_name and password are your credentials. Also, make sure that you add a tls: true line. And finally, the most important part, is that you change login with plain in authentication.

 delivery_method: :smtp
 port: 587
 tls: true
 domain: # or your domain
 authentication: :plain
 user_name: # or your domain
 password: secretPassword

For gmail to work, we need to install a script. Let’s get it:

sudo apt-get install git-core
ruby script/plugin install git://

Let’s proceed with the installation:

rake generate_session_store
sudo mkdir /opt/redmine
cd /opt/redmine
sudo cp -r ~/redmine-1.1.2 .
cd redmine-1.1.2
sudo RAILS_ENV=production rake db:migrate
sudo RAILS_ENV=production rake redmine:load_default_data

Press enter to accept the default language (English) and then execute the following:

sudo chown -R www-data:www-data files log tmp public/plugin_assets
sudo chmod -R 755 files log tmp public/plugin_assets
sudo nano /etc/apache2/mods-available/passenger.conf

Add this line inside the <IfModule mod_passenger.c> tag:

PassengerDefaultUser www-data

Now let’s configure apache:

sudo nano /etc/apache2/sites-available/default

Just before the closing tag, </VirtualHost>, add the following:

RailsEnv production
RailsBaseURI /redmine

Now we put a link to our application to be accessible from apache and restart it:

sudo ln -s /opt/redmine/redmine-1.1.2/public /var/www/redmine
sudo /etc/init.d/apache2 restart

Some clean up…

cd ~
rm -r redmine-1.1.2
rm redmine-1.1.2.tar.gz

The installation process is finished. Open a web browser in another computer and go to yourServerIP/redmine and you should see the initial page of redmine. If it does not show, then something is wrong in your installation. Go back and carefully follow the steps from the beginning. If you do not know your IP address, just run ifconfig from the server.

Click on Sign-in. Enter admin for user and password. Now you are logged in as the redmine administrator. Go to Administration and then click on Information. You should see the following:

Note that Redmine 1.1.2 stable is installed correctly with RMagick and the directories that it needs are writeable. The only thing left to do here is to change the details of the administrator account (that is why there is one error sign), and start creating users and projects and manage them with this great tool. Once you change your administrator account, you should see no errors on the information page:

And now you can enjoy all the features of this great project manager: Gantt charts, Roadmaps, wiki, file repositories, multiple project support, forums, and much more…

Posted in Open Source, Programming.

40 great apps for the Nokia E71, or how to do cool things with your symbian phone

I really like my Nokia E71. And I am not the only one saying it. It has many fans around the world, so it is not surprising that it has more than 300 positive reviews on Amazon. It also comes with a nice price tag. The only problem I had was that I spent a lot of time searching for useful applications for this phone. This post is the result of my findings: 40 great applications that cover my needs(and hopefully yours) in many different areas.

The E71 is powered by Symbian OS, specifically S60 3rd edition. This version of the Symbian OS is currently the oldest one that can run most of the software that is out there, including applications developed with the new Nokia Qt SDK. This means that if you have a phone with a newer version of the Symbian OS (S60 5th edition or Symbian^3), you should be able to run all the applications that I am going to list here as well.

OK, here I present you 40 great apps for the Nokia E71:

  1. Y-Browser
    This is a file browser for your phone. The nice thing is that it shows you hidden directories and files, so it is better to use this one instead of the built in browser.
  2. JoikuSpot Light
    Share your phone’s internet connection via WiFi. Connect multiple devices (laptops, other WiFi enabled phones, etc) to your phone and browse the internet everywhere.
  3. SportsTracker
    If you do any type of outdoor exercises like jogging, walking, cycling, etc, download this app. It logs your position using GPS, and then uploads your exercises to an online server that shows your average speed, distance covered, map of the region, etc. It also can be connected to social networking sites such as facebook to encourage your work outs. Highly recommended.
  4. Nokia Maps
    The nice thing about Nokia Maps is that the maps data can be downloaded to the phone’s memory and then you can use it without any connection to the internet. Ideal when travelling abroad and you don’t have a local sim card or when you don’t want to pay for data plans. Also, it comes with turn by turn voice directions in many languages. And all of this for free, for ever.
  5. Google Maps
    Some times you may need extra information that is not available on Nokia Maps. On these rare occasions it is always handy to have the Googls Maps application installed. The good thing is that you can use the places that you saved on Nokia Maps (Favorites) in Google Maps (Starred Items). Note that this app does not come with turn by turn voice directions and it uses internet to get the maps.
  6. Metro
    This application tells you the shortest route from one station to another in your local metro (subway), as well as the one with fewest connections. It uses offline data, so no internet access is necessary. Cities from all over the world are supported. Highly recommended.
  7. cCalcPro
    This is a powerful yet easy to use scientific calculator. It contains many functions such as simple mathematical ones, as well as trigonometric,  financial and base functions. You could actually just use this calculator for every calculation you make, even for the simple ones since it is so easy to use, every key in the keyboard is mapped to a specific function, so it is like using a real calculator.
  8. MobiReader
    This app turns your phone into a nice e-book reader. For managing your e-books, and changing them to the format that this app understands, you can use Calibre, a great software for managing e-books on the PC.
  9. Photo Browser
    This app displays your photos in a nice grid gallery with an easy to use interface. It looks and works better than the built in photo viewer.
  10. Snapper
    If you want to make time-lapse movies, this is the app you should get. It allows you to take a picture every second, minute, hour, or any time interval that you need, up to one picture a day. It is simple to use and it works great. All the images are stored in a single folder. You can transfer that folder to the PC and then just drag and drop the first image into Avidemux and with a couple of clicks you can create a video out of them.
  11. ScreenSnap
    This is for taking screen-shots in your phone. It does the same thing as the Print Screen button on a PC.
  12. SmartCam
    This application allows you to use your phone as a web-cam. It can use Bluetooth or WiFi for connecting to the device.
  13. m3DCam
    Have you ever seen a 3D image using a Red and Cyan lens?, well this app lets you create those images. Take an photo, move the phone and take the second one. This app then creates the image that you can see with your lenses in 3D.
  14. BeatEd
    Do you play any instrument?, if you do, you should check this app out. It is a drum machine. Ideal for accompanying your training sessions. You can create your own rhythms with its 16 channel audio mixer. It is really easy to use and you can download many samples from the website to get you started.
  15. Chromatic Tuner
    If you need to tune your instrument, this is the app that you are looking for. Simply go to a quiet place, start the application and play a note on your guitar (or any other tunable instrument). It will tell you which note is being played.
  16. eBuddy
    Instant messenger. Chat with your friends from msn, yahoo, facebook, and many others in just one application.
  17. Opera Mobile
    A great mobile web browser, with support for tabs and many other features.
  18. Skype
    Call and chat worldwide with your friends, cheaper than using regular phones.
  19. Fring
    This application integrates all your contacts from your phone contacts, msn, yahoo, etc, and allows you to chat, call and video call them using internet as well as cellular calls. It could be used to replace the native contact list, as well as the log of the calls.
  20. Gmail
    Read your email everywhere.
  21. S60SpotOn
    Use your camera flash and the LCD screen to illuminate your surroundings. Nice to have when the lights go out.
  22. Compass
    This application uses the position of the sun and moon to indicate you where the north is. You only need to put the phone facing up, aligned with the shown diagram and you will know where the north is. Also, it gives you extra information such as sunrise, sunset and moon phase.
  23. Sideralis
    If you like to watch the stars, this app is for you. Once you configure it for your location, it will show you the stars that are in your view. You can freely navigate the 3D display of the stars to match the part of the sky you are looking at. Information about the stars is available as well as some astronomic terms explained.
  24. RemoteWitch
    Control your PC with your phone. Specially useful for presentations or media playback.
  25. PyS60
    This is the Python port to the S60 phones. Install it to add the ability to run python scripts on your phone. You need to install both, first PythonForS60_1_4_5_3rdEd.sis and then PythonScriptShell_1_4_5_3rdEd.SIS. Note that there is a newer version of PyS60 here that features Python 2.5, but some applications need the older version installed. Well, you can actually have both versions installed without problems.
  26. Ped
    This is a Python IDE as well as a general text editor. You need to install PyS60 first in order to install it. Also, you need to install it on the same place that you installed PyS60 (phone memory). It has many features, in particular auto completion. You can access the auto completion feature by holding the green button (call) and then pressing the enter button (center of d-pad). This app is also great for text editing in general.
  27. JBakTaskMan
    This is an advanced task manager. It has many nice features, such as launching applications by typing their name, among many others. A must have app for the power user.
  28. FreeTimeBox
    This is an awesome and simple application. It simply displays the current time at the menu bar, always. Now you will never need to go to the Home screen just for knowing the time when you are in the middle of something. You can configure it to disappear when certain applications are running (games for example), as well as the appearance and position. This app is a must.
  29. vHome 4.2
    If you want to change how the Home screen looks, you can install this app. It is a task manager that allows you to change the Home screen with many features. For example, if you need more than the normal 6 apps shortcuts, you can add up to 14 with this app. You can also add weather information or RSS feeds to your home screen. Recommended for the power user.
  30. GPFCe
    Nintendo emulator. This emulator supports sound. Re play your old NES games while you wait for the bus, or anywhere!.
  31. AntSnes
    Super Nintendo emulator. It does not support sound though, but the idea of having the ability to play your old Super NES games in your phone is awesome.
  32. DOSBox
    DOS emulator. This is the port of the DOSBox project to the S60 platform. With this, you can run DOS on your phone, so you can use all your old DOS programs in your phone. You can even run big applications such as Windows 98.
  33. Pamp
    Personal Apache MySQL PHP. Really. You can have a whole web-server on your phone, with databases,  and dynamic pages. You could be hosting a whole CMS or a forum from your pocket. You could for example show a live feed from the camera without needing any external services. The possibilities are endless.
  34. SICFTP
    This is an FTP client. Transfer files back and forth from any server.
  35. Putty
    Good ol’ Putty. Telnet and SSH client on your phone. Thanks to this you could be working on the bus ride to/from work.
  36. CpuMon
    This application displays the usage of CPU and Memory. Good for measuring performance of applications on real devices.
  37. Energy Profiler
    Nokia released this nice application which shows the energy consumed by the device. This can be useful to developers and normal users. Developers can use this app for measuring the energy used by their applications to try to minimize it. Normal users can see the effects of applications and usage of the phone for extending battery life.
  38. Device Status
    This app, developed by Nokia, shows you detailed information about the phone, such as the model, IMEI number, software version, memory available, installed applications, and network information, among other things.
  39. CellTrack
    This application shows you information about the cell that you are connected to, such as the cell id and signal strength, among others.
  40. FreeUnRar
    This application allows you to open rar files.

Please let me know if you think there is a cool application for the E71 that is missing from this list.

Posted in IoT, Open Source, Programming.

How to control the orientation of an application in Qt

By default, S60 applications choose the current orientation automatically based on how the user is holding the device. This is convenient in general, but in some cases the developer needs more control regarding the orientation of the displayed content. In this post I will show you how to override this behavior and set the preferred orientation for your application: portrait, landscape or automatic at run time.

The first thing that we need is to include a couple of libraries: cone, eikcore and avkon. This can be done by editing the Symbian specific part of the .pro file:

symbian {
TARGET.UID3 = 0xe9507491
TARGET.EPOCHEAPSIZE = 0x020000 0x800000
# We need these libs to change the orientation
LIBS += -lcone \
-leikcore \

Now we have to include the specific headers wherever we want to change the orientation of the device:

//These are the headers needed for changing the orientation
#include <eikenv.h>
#include <eikappui.h>
#include <aknenv.h>
#include <aknappui.h>

Now we can just call to this function and the orientation will be changed to portrait, no matter how the user holds the device:

CAknAppUi* appUi = dynamic_cast<CAknAppUi*> (CEikonEnv::Static()->AppUi());
    if (appUi) {

You can do the same for Landscape or Automatic mode. Just change EAppUiOrientationPortrait to EAppUiOrientationLandscape or EAppUiOrientationAutomatic accordingly. Automatic is the default mode, that is, it will change the orientation depending on how the user holds the device.
Make sure that you do not remove the Symbian OS checks (#ifdef Q_OS_SYMBIAN) because these libraries will only be available for the Symbian device, and not for the simulator for example.
Feel free to download the source code of an example that I made for controlling the orientation in Qt.

Posted in Open Source, Programming.

How to easily sign a Nokia S60 unsigned application

Sometimes you try to install a cool application on your Nokia S60 phone but you can’t do it because it is an unsigned application, or the signature has expired. This is to keep your phone and personal information safe from evil software developers that want to harm your phone or steal personal information, among others.

Although, there are some cases where you trust the developer and want to install the unsigned software anyway. In this post I will show you how to sign it very easily (in less than 5 minutes).

The first step is to download and install a very useful software called SISContents.

For this example, I will be using a very nice unsigned application that allows you to disable the camera sound when taking pictures. Once it is installed you only need to disable the warning tones in your profile (or enable and then disable them again) and your camera will be muted. You can download this cool unsigned application from here. Now you need to drag and drop the application you want to sign into SISContents. You will see all the details of the application.

The only thing that we need to do here is to change the Package UID so that it lies inside the Test Range defined by the Symbian Signed guys, which goes from 0xE0000000 to 0xEFFFFFFF. Basically, we want the UID to be an 8-digits hexadecimal number starting with E and the rest does not really matter. In this example, I just changed the original UID 0x10202BE9 to 0xE0202BE9. You can do the same, just change the first number of the UID to E). Then go to File->Save As and write a new file name to save the changes.

Now we need to sign the file you saved. The Symbian Signed guys offer a really easy to use Open Signed online service. You only need to provide the IMEI of your phone, your email and the application that you want to sign (the file you just saved). You can access their online signing service here. You can get your IMEI number easily by just typing *#06# in your phone.

You will then receive a confirmation email where you have to click on a link. Then, just wait and you will receive a second email with a download link for the signed application. Easy.

Posted in Programming.