To install OpenCV on Amazon Linux, you can follow these steps:
- Start by updating the system packages using the following command:
sudo yum update -y
- Install the required development tools and dependencies by running the following command:
sudo yum groupinstall -y "Development Tools"
sudo yum install -y cmake gtk2-devel numpy gcc-c++ ffmpeg-devel libjpeg-turbo-devel libpng-devel libtiff-devel libdc1394-devel libv4l-devel gstreamer-plugins-base-devel.x86_64
- Download the OpenCV source code using wget. You can check for the latest release from the OpenCV website and update the URL accordingly. For example:
wget -O opencv.zip https://github.com/opencv/opencv/archive/4.5.3.zip
- Unzip the downloaded file:
- Create a build directory and navigate into it:
mkdir opencv-build && cd opencv-build
- Generate the build files using cmake. Make sure to provide the correct path to the extracted OpenCV source code in the command below:
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_FFMPEG=OFF /path/to/opencv-source/
- Compile the OpenCV library by running:
- Install the compiled OpenCV library:
sudo make install
- Verify the installation by importing cv2 module in Python:
python -c "import cv2; print(cv2.__version__)"
If the installation is successful, it should print the version number of OpenCV.