Wednesday, April 10, 2013

Good Python resources and Installation Guide


Python is a great scripting language, also capable of building big applications. It is very easy to learn. In fact it is the simplest and at the same time, one of the most powerful languages out there. As one of the major languages of implementation in Google it has a huge repository of libraries that makes it extremely useful for all the applications (for example, you can use OpenCV through Python, and replace Matlab with NumPython, its special integration with java (JPython), and integrate c functions in python easily). This post gives you direct links to the tutorials and installation guides of this great language.

1. Google Python Classes with Nick Parlante

Day 1Part 1
https://www.youtube.com/watch?v=tKTZoB2Vjuk

Day 1 Part 2
https://www.youtube.com/watch?v=EPYupizJYQI

Day 1 Part 3
https://www.youtube.com/watch?v=haycL41dAhg

Day 2 Part 1
https://www.youtube.com/watch?v=kWyoYtvJpe4

Day 2 Part 2
https://www.youtube.com/watch?v=uKZ8GBKmeDM

Day 2 Part 3
https://www.youtube.com/watch?v=Nn2KQmVF5Og

Day 2 Part 4
https://www.youtube.com/watch?v=IcteAbMC1Ok

Each lecture is a short lecture of more or less 20 minutes (one or two reach an hour) and quite easy to follow. All the lectures are supported with an exercise section that is quite good to practice. The links to exercises can be retrieved from the video.

2. Well after you have followed the first then you obviously need some standard place to grow your knowledge. The best place is the official Python tutorials. It is so complete and good that it is followed as it is in MIT python training courses.

http://docs.python.org/2/tutorial/

Installing Python

On fedora :
Type the following command as root and you are done.
# yum install python
(for configuring yum to work with proxy and its repositories se my other posts)
On Ubuntu:
Follow the post given below. You can use this procedure also on fedora.
http://askubuntu.com/questions/101591/how-do-i-install-python-2-7-2-on-10-04

On Windows:
Install Active Python from the link given below, and you are done.
http://www.activestate.com/activepython/downloads

Friday, April 5, 2013

Installing OpenCV 2.4.4 on Ubuntu

Summary of Steps
References  and resources
1. For installation steps (for step 1 and 2)= http://opencv.willowgarage.com/wiki/InstallGuide#Prerequisites
2. For compilation steps (for step 3)= http://opencv.willowgarage.com/wiki/CompileOpenCVUsingLinux
3. For compilation steps (for step 4)= http://docs.opencv.org/doc/tutorials/introduction/linux_gcc_cmake/linux_gcc_cmake.html#linux-gcc-usage
4. http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/

STEP 1: install the packages
$ sudo apt-get install cmake (if the system is fresh - do a sudo apt-get update)
$ sudo apt-get install pkg-config (if not already installed)
$ sudo apt-get install libgtk2.0-dev
sudo apt-get install libavformat-dev libswscale-dev 

STEP 2:
download the opencv-2.4.4a (base link for all the versions is http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/ - at the time of this writing 2.4.5 got released a few hours ago)

Exctract the tar archive this way
$ tar --bzip2 -xvf OpenCV-2.4.4a.tar.bz2
# a folder opencv-2.4.4 is created
$ cd opencv-2.4.4
$ mkdir release
$ cd release
$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON ..

# in my case at this stage the cmake reported no problems - when it does then check if the required packages listed in step 1 are properly installed.

$ sudo make install

STEP 3:

Now set an environment variable in the file /etc/environment
$ sudo echo 'PKG_CONFIG_PATH=/path/to/the/release/folder:$PKG_CONFIG_PATH' >> /etc/environment
(if above statement does't work then go to the file and add the line given in single quotes (and don't put the quotes in the file))

#now logoff and login
#test the pkg-config


$ pkg-config --cflags opencv
-I/where/you/have/installed/opencv/include/opencv  
$ pkg-config --libs opencv
-L/where/you/have/installed/opencv/lib -lcxcore -lcv -lhighgui -lcvaux 
 
If the PKG_CONFIG_PATH is set properly then you output will be quite similar to the above two outputs. (your output may be different, but look for any usual lines reporting error or no output at all)
 
STEP 4:
simply follow the simple tutorial at http://docs.opencv.org/doc/tutorials/introduction/linux_gcc_cmake/linux_gcc_cmake.html#linux-gcc-usage for your first program to run.