git clone https://github.com/MayurDeshmukh10/opencv-installation-scripts.git
cd opencv-installation-scripts
sudo chmod +x *.sh
Change OPENCV_VERSION=
value to required version in download_opencv.sh
and then
./download_opencv.sh
./install_dependencies.sh
./build_opencv.sh