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.

Sunday, December 2, 2012

OpenCV tutorials and other resources

The OpenCV tutorial

1. The OpenCV Tutorials Release 2.4.3 - opencv documentation!

This is a very good resource created on 3Nov12 by the opencv team. I was looking for a good C++ tutorial on OpenCV and found this to be very very good. Contains the opencv installation instructions also. And has links to other important resources on the web.

Sunday, November 25, 2012

Important Linux Resources - I keep adding to this

This is a list of very good resources for linux:

1. The Master Book - Contains nearly everything regarding Red Hat and Debian based Linux

More will be added with time

Utilizing your Bash Shell with VIM

Bash shell has a score of features. Mostly they go unused. It has some very nice features that let you save time and be more productive, allowing you to maneuver intricately and imaginatively.

The Best One is:

$ set -o vi

This sets vi as a command line editor in the Bash environment. Press the escape key and you are in the vim mode. You can use all the vim single line commands to edit the command line. Press the 'v' key while in vim mode and you can edit the command straight in a full fledged VIM editor. Isn't it great!


To search a command:
Press esc and then press '/' i.e. slash, and  type some characters to search. To repeat the search in forward and backward directions, guess what.... the 'n' and 'N' keys do the same job here too. Use 'n' for backward searches and 'N' for the opposite direction.

$ /<partial cmd name>

This sequence searches the command history (bottom up) and produces the most recently used cmd matching the <partial cmd name>. Really a good feature. Now when you have the old command line, you can edit it using the features of vim.

Saturday, November 24, 2012

Important yum commands and information you should know

As a linux beginner Yum has irritated me a lot. It hardly works without issues. However some hard work can save you a lot of time in the future.

There are three important things about yum
1. Yum repositories (in the repo directory /etc/yum.repos.d/) e.g fedora.repo
(you can add fedora DVD as a repository when you don't have internet connection to exploit online repositories)
2. Yum proxy settings (refer here)
3. Yum options and capabilities - install packages and rmp file, update, remove, groupinstall, listing the packages, package dependencies etc

Yum finds its packages and their information in the repositories listed in each file in the /etc/yum.repos.d/ directory. There are some very good repositories but the most vital are the two redhat repositories - one is for free software (that comes set default in your system) that hardly meets your appetite, and the other one is a non-free repository. You should add this non-free repository.

Adding a new repository. You have to add a new .repo file in the repositories directory. You can look at the format of this files which is quite simple. To add the non-free repository just copy these files to the /etc/yum.repos.d/ directory:
repos.tar (download this tar file and untar it - add all the files to the repo directory)
Note: When sometimes Yum is not able to download some repository metadata etc.. then try changing the link type from https to http in the repo file of that repository. The links are given in the baseurl and mirrorlist parameter in the repo file.

Yum Commands (most are self-explanatory)
# yum install <package-name> //installs the package but asks you for confirmation - package name could also be a local rpm file.
or
# yum -y install <package-name> //installs the package straightaway
-y will not ask you anything and straight away install the package.
# yum update <package-name>
# yum remove <package-name>
# yum reinstall <package-name>

#yum clean all //cleans up all the yum files left over from previous installations
# yum list available // lists the available package names and descriptions
# yum list installed //lists the installed packages
# yum search <partial package name>
# yum search all <partial package name> // better search results

Group install
# yum grouplist
# yum groupinstall <group-name>
# yum groupremove <group-name>
# yum groupupdate <group-name>
# yum groupinfo <group-name>

Others
# yum deplist <package-name>
# yum info <package-name>
# yum install yumex //gui for yum (idon't use it)
# yum provides <filename> //all packages providing the file (try absolute path)
# rpm -qf <filename> //prints the package to which the files like /bin/bash belong)

Proxy settings in Fedora Bash for yum, wget, curl and any bash program sensibly designed

(Applicable to all the fedora releases ...,Fedora 14, 15, 16 , 17, ...)

Hey, this is a simple setting but has very important role to play in YUM and other internet based software used in the terminal.

If you are behind a proxy (with or without authentication) then this proxy setting in the /etc/bashrc file will help you

$ tail /etc/bashrc
    unset i
    unset pathmunge
fi
# vim:ts=4:sw=4
export http_proxy=http://username:password@172.31.1.6:8080/
export ftp_proxy=http://username:password@172.31.1.6:8080/
export https_proxy=http://username:password@172.31.1.6:8080/


The last three lines set the proxy server address and sends username password to the server for automated authentication. Append the three lines at the end of the /etc/bashrc file. You will need root permission for editing the file.

Once done, viola! Use every internet based bash program easily.