Installing OpenCV for Python on Windows Using Anaconda
OpenCV is a cross-platform library for image processing and computer visualization. It can develop real-time computer vision applications. It mainly focuses on image processing, video capture, and analysis including features like face detection and object detection. In this tutorial, we explain how you can use the install OpenCV using Anaconda.
Step 01: Installing Anaconda on Windows
Go to the Anaconda Website and choose the latest Anaconda graphical installer for Windows from Anaconda Website If it’s 64-bit then choose the 64-bit graphical installer or else choose the 32-bit installer. Choose Python 3.7 for working with Python 3. This is the preferred option as python 2.7 is reaching its End-Of-Life by 2020.
Locate your download and double click it. Launch the graphical installer and we will be prompted to choose for which user to install. you can install it by default settings
Step 02: Installing OpenCV
Launch the Anaconda prompt from the Start menu
if you chose “All users” while installing then you have to launch the prompt by Right-clicking and choosing “Run as Administrator” to execute with administrator privileges. This is critical.
To install the OpenCV we need to type the following command at the prompt:
conda install -c conda-forge opencv
important:
internet connection is required to install OpenCV on your computer
after type that command, The prompt will show that it is “solving environment”.
Once the environment is resolved by conda it will list the packages that will be installed, namely: opencv , libopencv , py-OpenCV.
Enter y to proceed with the installation.
after installing OpenCV you can show the installation successful message in the anaconda prompt
you can verify if the installation was successful by launching the python interpreter. OpenCV is referred to as cv2 in python. Type at the prompt:
import cv2
if the prompt is displayed then OpenCV then python has successfully imported the OpenCV library. But we should also verify the version of OpenCV so we need to type:
print(cv2.__version__)
as of March 2019 the version displayed is 3.4.1 which is the officially supported version of OpenCV by anaconda environment. If we want to work with a different version then while installing we can specify the version as “opencv=3.4.1” as shown below
conda install -c conda-forge opencv=3.4.1
Similar steps can be followed to install OpenCV on anaconda for MacOS.