Installing OpenCV in a conda environment

We will carry out the following steps to install OpenCV:

  1. In a Terminal, navigate to the directory where you downloaded the following code:
$ cd Desktop/OpenCV-ML
  1. Then, run the following command to create a conda environment based on Python 3.6, which will also install all the necessary packages listed in the environment.yml file (available in the GitHub repository) in one fell swoop:
$ conda create env -f environment.yml
  1. You can also have a look at the following environment.yml file:
name: OpenCV-ML
channels:
- conda-forge
dependencies:
- python==3.6
- numpy==1.15.4
- scipy==1.1.0
- scikit-learn==0.20.1
- matplotlib
- jupyter==1.0
- notebook==5.7.4
- pandas==0.23.4
- theano
- keras==2.2.4
- mkl-service==1.1.2
- pip
- pip:
- opencv-contrib-python==4.1.0.25
Notice that the environment's name will be OpenCV-ML. This code will use the conda-forge channel to download all the conda based dependencies and use pip to install OpenCV 4.0 (along with opencv_contrib).
  1. To activate the environment, type one of the following, depending on your platform:
$ source activate OpenCV-ML  # on Linux / Mac OS X
$ activate OpenCV-ML # on Windows
  1. When we close the Terminal, the session will be deactivated—so we will have to run this last command again the next time we open a new Terminal. We can also deactivate the environment by hand:
$ source deactivate  # on Linux / Mac OS X
$ deactivate # on Windows

And done! Let's verify whether all this installation was successful or not.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.58.220.83