Install OpenCV2 on Ubuntu:
bash install_opencv2_ubuntu.sh
Install OpenCV3 on Ubuntu:
bash install_opencv3_ubuntu.sh
Alternatively, you can download the install_opencv*_ubuntu.sh
and modify the options to whatever you'd like, then run:
sudo bash install_opencv[2|3]_ubuntu.sh
The scripts are modified from https://raw.githubusercontent.com/arthurbeggs/scripts/master/install_apps/install_opencv2.sh