Search code examples
linuxopencvamazon-ec2amazon-elastic-beanstalk

How to install OpenCV on Amazon Linux?


I'm trying to install OpenCV for use with Pastec on an Amazon Linux instance. This is my first time using an Amazon service, and I don't have much experience using linux...

How would I install OpenCV and it's dependencies on Amazon Linux?

I have tried adding the EPEL repository using this command:

$ sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

... which works but it still won't install OpenCV...

$ sudo yum --enablerepo=epel install opencv-core
Loaded plugins: priorities, update-motd, upgrade-helper
948 packages excluded due to repository priority protections
Nothing to do

Solution

  • It seems that default yum repo for Amazon AMI doesn't contain OpenCV packages.

    You can compile it from sources by yourself with the following simple steps:

    • install necessary packages:

    sudo yum install git cmake gcc-c++

    • clone OpenCV from repository:

    git clone https://github.com/opencv/opencv.git

    • (optionally) choose required version, if you do not do it, the master branch will be built:

    git checkout <required version>

    • compile and install - create folder where you want to build it, enter there and type:
    cmake <path to sources>
    make
    sudo make install
    

    It's basic steps - after this you will have OpenCV with some default modules. You can read cmake output and adjust your installation before actual build. Possibly you should install additional packages for your needs (like libpng, libjpg, python etc.).