Here, take a common environment as example, is the way to install OpenCV 2.6.4 (or any other latest version) on Ubuntu 12.04. This is simple thanks for the script written by jayrambhia.
- git clone https://github.com/jayrambhia/Install-OpenCV
- cd Install-OpenCV/Ubuntu
- chmod +x opencv_latest.sh
- ./opencv_latest.sh
These steps ask the machine to download the script from jayrambhia's github, then run the script in it. Remember you may be asked to type in your password in order to run the "sudo" commands. After running the four commands, you'll completely installed OpenCV on your Ubuntu machine.