Open santhoshyantraone opened 2 years ago
Can you try my script? Please adjust the opencv $VER and $PYTHON_VERSION to match the target versions.
installOCV.sh
#! /bin/bash
VER=4.6.0
PYTHON_VERSION=3.8
CORES=2
echo "Script for installing the OpenCV $VER on Ubuntu 18.04 LTS"
echo "Updating the OS..."
sudo apt update
sudo apt upgrade -y
echo "Installing dependencies..."
sudo apt install build-essential cmake unzip pkg-config -y
sudo apt install libjpeg-dev libpng-dev libtiff-dev -y
sudo apt install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev -y
sudo apt install libxvidcore-dev libx264-dev -y
sudo apt install libgtk-3-dev -y
sudo apt install libatlas-base-dev gfortran -y
sudo apt install python3-dev libtbb-dev -y
sudo apt install libavcodec-dev libavformat-dev libswscale-dev libavresample-dev -y
sudo apt install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev -y
sudo apt install libxvidcore-dev x264 libx264-dev libfaac-dev libmp3lame-dev libtheora-dev -y
sudo apt install libfaac-dev libmp3lame-dev libvorbis-dev -y
sudo apt install libdc1394-22 libdc1394-22-dev libxine2-dev libv4l-dev v4l-utils -y
sudo apt install libprotobuf-dev protobuf-compiler -y
sudo apt install libgoogle-glog-dev libgflags-dev -y
sudo apt install libgphoto2-dev libeigen3-dev libhdf5-dev doxygen -y
sudo apt install python-is-python3
echo "Fetching and unpacking OpenCV $VER..."
mkdir -p $HOME/repositories
cd $HOME/repositories
wget -O opencv.zip https://github.com/opencv/opencv/archive/${VER}.zip
wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/${VER}.zip
#wget https://bootstrap.pypa.io/get-pip.py
#sudo python3 get-pip.py
sudo -H pip3 install numpy matplotlib imutils -U
unzip opencv.zip
unzip opencv_contrib.zip
rm opencv.zip
rm opencv_contrib.zip
cd opencv-${VER}
mkdir -p build
cd build
echo "Compiling OpenCV $VER... this will take several minutes..."
rm CMakeCache.txt
hostname=$(sudo cat /etc/hostname)
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D INSTALL_C_EXAMPLES=OFF \
-D OPENCV_ENABLE_NONFREE=ON \
-D OPENCV_EXTRA_MODULES_PATH=~/repositories/opencv_contrib-${VER}/modules \
-D BUILD_NEW_PYTHON_SUPPORT=ON \
-D PYTHON3_PACKAGES_PATH=/usr/local/lib/python${PYTHON_VERSION}/dist-packages \
-D BUILD_opencv_python3=ON \
-D PYTHON_DEFAULT_EXECUTABLE=$(which python3) \
-D OPENCV_GENERATE_PKGCONFIG=ON \
-D OPENCV_PC_FILE_NAME=opencv4.pc \
-D WITH_TBB=ON \
-D ENABLE_FAST_MATH=1 \
-D CUDA_FAST_MATH=1 \
-D WITH_CUBLAS=1 \
-D WITH_CUDA=ON \
-D BUILD_opencv_cudacodec=OFF \
-D WITH_CUDNN=ON \
-D OPENCV_DNN_CUDA=ON \
-D CUDA_ARCH_BIN=7.5 \
-D WITH_V4L=ON \
-D WITH_QT=OFF \
-D WITH_OPENGL=ON \
-D WITH_QT=OFF \
-D WITH_GSTREAMER=ON \
-D WITH_FFMPEG=ON \
-D WITH_OPENCL=ON \
-D OPENCV_ENABLE_NONFREE=ON \
-D ENABLE_PRECOMPILED_HEADERS=YES \
-D EIGEN_INCLUDE_PATH=/usr/include/eigen3 \
-D BUILD_EXAMPLES=ON ..
echo "Compilation has started ..."
make -j$CORES
echo "Installing OpenCV $VER ..."
sudo make -j$CORES install
sudo cp unix-install/opencv4.pc /usr/lib/x86_64-linux-gnu/pkgconfig/
sudo cp unix-install/opencv4.pc /usr/local/lib/pkgconfig
sudo ldconfig
source $HOME/.bashrc
echo "Installation complete"
Can you try my script? Please adjust the opencv $VER and $PYTHON_VERSION to match the target versions.
installOCV.sh
#! /bin/bash VER=4.6.0 PYTHON_VERSION=3.8 CORES=2 echo "Script for installing the OpenCV $VER on Ubuntu 18.04 LTS" echo "Updating the OS..." sudo apt update sudo apt upgrade -y echo "Installing dependencies..." sudo apt install build-essential cmake unzip pkg-config -y sudo apt install libjpeg-dev libpng-dev libtiff-dev -y sudo apt install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev -y sudo apt install libxvidcore-dev libx264-dev -y sudo apt install libgtk-3-dev -y sudo apt install libatlas-base-dev gfortran -y sudo apt install python3-dev libtbb-dev -y sudo apt install libavcodec-dev libavformat-dev libswscale-dev libavresample-dev -y sudo apt install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev -y sudo apt install libxvidcore-dev x264 libx264-dev libfaac-dev libmp3lame-dev libtheora-dev -y sudo apt install libfaac-dev libmp3lame-dev libvorbis-dev -y sudo apt install libdc1394-22 libdc1394-22-dev libxine2-dev libv4l-dev v4l-utils -y sudo apt install libprotobuf-dev protobuf-compiler -y sudo apt install libgoogle-glog-dev libgflags-dev -y sudo apt install libgphoto2-dev libeigen3-dev libhdf5-dev doxygen -y sudo apt install python-is-python3 echo "Fetching and unpacking OpenCV $VER..." mkdir -p $HOME/repositories cd $HOME/repositories wget -O opencv.zip https://github.com/opencv/opencv/archive/${VER}.zip wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/${VER}.zip #wget https://bootstrap.pypa.io/get-pip.py #sudo python3 get-pip.py sudo -H pip3 install numpy matplotlib imutils -U unzip opencv.zip unzip opencv_contrib.zip rm opencv.zip rm opencv_contrib.zip cd opencv-${VER} mkdir -p build cd build echo "Compiling OpenCV $VER... this will take several minutes..." rm CMakeCache.txt hostname=$(sudo cat /etc/hostname) cmake -D CMAKE_BUILD_TYPE=RELEASE \ -D CMAKE_INSTALL_PREFIX=/usr/local \ -D INSTALL_PYTHON_EXAMPLES=OFF \ -D INSTALL_C_EXAMPLES=OFF \ -D OPENCV_ENABLE_NONFREE=ON \ -D OPENCV_EXTRA_MODULES_PATH=~/repositories/opencv_contrib-${VER}/modules \ -D BUILD_NEW_PYTHON_SUPPORT=ON \ -D PYTHON3_PACKAGES_PATH=/usr/local/lib/python${PYTHON_VERSION}/dist-packages \ -D BUILD_opencv_python3=ON \ -D PYTHON_DEFAULT_EXECUTABLE=$(which python3) \ -D OPENCV_GENERATE_PKGCONFIG=ON \ -D OPENCV_PC_FILE_NAME=opencv4.pc \ -D WITH_TBB=ON \ -D ENABLE_FAST_MATH=1 \ -D CUDA_FAST_MATH=1 \ -D WITH_CUBLAS=1 \ -D WITH_CUDA=ON \ -D BUILD_opencv_cudacodec=OFF \ -D WITH_CUDNN=ON \ -D OPENCV_DNN_CUDA=ON \ -D CUDA_ARCH_BIN=7.5 \ -D WITH_V4L=ON \ -D WITH_QT=OFF \ -D WITH_OPENGL=ON \ -D WITH_QT=OFF \ -D WITH_GSTREAMER=ON \ -D WITH_FFMPEG=ON \ -D WITH_OPENCL=ON \ -D OPENCV_ENABLE_NONFREE=ON \ -D ENABLE_PRECOMPILED_HEADERS=YES \ -D EIGEN_INCLUDE_PATH=/usr/include/eigen3 \ -D BUILD_EXAMPLES=ON .. echo "Compilation has started ..." make -j$CORES echo "Installing OpenCV $VER ..." sudo make -j$CORES install sudo cp unix-install/opencv4.pc /usr/lib/x86_64-linux-gnu/pkgconfig/ sudo cp unix-install/opencv4.pc /usr/local/lib/pkgconfig sudo ldconfig source $HOME/.bashrc echo "Installation complete"
Which version of gcc/g++ used? gcc throws a lot of internal compiler error. I tested your script with; Ubuntu 20.04 LTS CUDA: 11.7 cuDNN: 8.5.0
The issue is most probably caused by WITH_OPENGL option. OpenGL +GTK is broken in OpenCV: https://github.com/opencv/opencv/issues/20850
System information (version)
4.5.2
Detailed description
following this post to install How to install OpenCV 4.5.2 with CUDA 11.2 and CUDNN 8.2 in Ubuntu 20.04
Steps to reproduce
Followed all the instructions
First of all install update and upgrade your system:
Then, install required libraries:
Generic tools:
Image I/O libs
Video/Audio Libs - FFMPEG, GSTREAMER, x264 and so on.
OpenCore - Adaptive Multi Rate Narrow Band (AMRNB) and Wide Band (AMRWB) speech codec
Cameras programming interface libs
GTK lib for the graphical user functionalites coming from OpenCV highghui module
Python libraries for python3:
Parallelism library C++ for CPU
Optimization libraries for OpenCV
Optional libraries:
We will now proceed with the installation (see the Qt flag that is disabled to do not have conflicts with Qt5.0).
on running
cmake
i get this errorCmakeError.log
What is going wrong?