The Wayback Machine - https://web.archive.org/web/20240723170502/https://www.geeksforgeeks.org/set-opencv-anaconda-environment/
Open In App

Set up Opencv with anaconda environment

Last Updated : 04 Jan, 2023
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report

If you love working on image processing and video analysis using python then you have come to the right place. Python is one of the major languages that can be used to process images or videos. 

Requirements for OpenCV and Anaconda 

  1. – 32- or a 64-bit computer. 
  2. – For Miniconda—400 MB disk space. 
  3. – For Anaconda—A minimum 3 GB disk space to download and install. 
  4. – Windows, macOS or Linux. 
  5. – Python 2.7, 3.4, 3.5 or 3.6. 

ANACONDA

Anaconda is open-source software that contains jupyter, spyder etc that are used for large data processing, data analytics, and heavy scientific computing. Anaconda works for R and python programming languages. Spyder(sub-application of Anaconda) is used for python. Opencv for python will work in spyder. Package versions are managed by the package management system conda.

 

Installing Anaconda : Head over to continuum.io/downloads/ and install the latest version of Anaconda. Make sure to install the “Python 3.6 Version” for the appropriate architecture. Install it with the default settings. 

OPENCV

OpenCV (Open Source Computer Vision) is a computer vision library that contains various functions to perform operations on pictures or videos. It was originally developed by Intel but was later maintained by Willow Garage and is now maintained by Itseez. This library is cross-platform that is it is available in multiple programming languages such as Python, C++ etc. 

 

Steps to import OpenCV on anaconda in windows environmentMinimum

Creating Anaconda Environment : 

Step 1:- Search Anaconda in your taskbar and select ANACONDA NAVIGATOR.

 

Step 2:- Now you will see a menu with various options like Jupiter notebook , Spyder etc. This is Anaconda Environment. 
Step 3:- Select Spyder as it is Anaconda’s IDE for python and OpenCV library will work in it only. 

Install OpenCV 

Step 1:- After installing the anaconda open the Anaconda Prompt. 

Step 2:- Type the given command, press enter, and let it download the whole package. 

Command 

conda install -c menpo opencv

Step 3:- Now simply import OpenCV in your python program in which you want to use image processing functions.

Examples: Some basic functions of the OpenCV library (These functions are performed on Windows flavor of Anaconda but it will work on linux flavor too) 

Reading an image 

img = cv2.imread('LOCATION OF THE IMAGE')

The above function imread stores the image at the given location to the variable img.

Converting an image to grayscale 

img = cv2.imread('watch.jpg',cv2.IMREAD_GRAYSCALE)

The above function converts the image to grayscale and then stores it in the variable img.

Showing the stored image 

cv2.imshow('image',img)

The above function shows the image stored in img variable.

Save an image to a file 

cv2.imwrite(filename, img)

The above function stores the image in the file. The image is stored in the variable of type Mat that is in the form of a matrix.

Reading video directly from the webcam 

cap = cv2.VideoCapture(0)

Stores live video from your webcam in the variable cap.

Reading a video from local storage 

cap = cv2.VideoCapture('LOCATION OF THE VIDEO')

Stores the video located in the given location to the variable.

To check if the video is successfully stored in the variable

cap.isOpened()

cap is the variable that contains the video. The above function returns true if the video is successfully opened else returns false.

Release the stored video after processing is done 

cap.release()

The above function releases the video stored in cap.


Previous Article
Next Article

Similar Reads

Add packages to Anaconda environment in Python
Let's see some methods that can be used to install packages in the Anaconda environment. There are many ways one can add pre-built packages to an anaconda environment. So, let's see how to direct the path in the anaconda and install them. Add packages to the Anaconda environment using the navigator Step 1: Open your Anaconda navigator Step 2: Go to
2 min read
How to Setup Anaconda Path to Environment Variable?
Anaconda is open-source software that contains Jupyter, spyder, etc that are used for large data processing, data analytics, and heavy scientific computing. Anaconda works for R and Python programming languages. Spyder(a sub-application of Anaconda) is used for Python. for Python will work in Spyder. Package versions are managed by the package mana
4 min read
Setup OpenCV With PyCharm Environment
Introduction:If you love working on image processing and video analysis using python then you have come to the right place. Python is one of the key languages which is used to process videos and images. Requirements for OpenCV:32- or a 64-bit computer.Windows, macOS or Linux.Python 2.7, 3.4, 3.5 or 3.6.PyCharmPyCharm is a cross-platform IDE used in
2 min read
How to install packages of Scala, Python and R with Anaconda
In this article, we will see how we can install packages of languages like Scala/Python/R into Anaconda by using the Anaconda Navigator package. Anaconda Navigator is a graphical user interface (GUI) tool included in the Anaconda distribution that makes it simple to set up, install, and use tools like Jupyter Notebook. Steps to install packages of
2 min read
How to Install Anaconda on Windows?
Anaconda is an open-source software that contains Jupyter, spyder, etc that are used for large data processing, data analytics, heavy scientific computing. Anaconda works for R and python programming language. Spyder(sub-application of Anaconda) is used for python. Opencv for python will work in spyder. Package versions are managed by the package m
1 min read
How to install Anaconda on Linux?
Anaconda is an open-source software that contains Jupyter, spyder, etc that are used for large data processing, data analytics, heavy scientific computing. Anaconda works for R and python programming language. Spyder(sub-application of Anaconda) is used for python. Opencv for python will work in spyder. Package versions are managed by the package m
1 min read
How to Install BeautifulSoup in Anaconda
BeautifulSoup is a popular Python library used for web scraping purposes to pull the data out of HTML and XML files. If you're using the Anaconda distribution of Python, installing BeautifulSoup is straightforward. This article will guide you through the steps to install BeautifulSoup in Anaconda. What is BeautifulSoup?BeautifulSoup is a Python lib
3 min read
Install Packages in Conda that are not Available in Anaconda
Conda is a powerful package management system that simplifies managing and deploying packages, especially for scientific computing. However, there are instances when you might need a package that is unavailable in the default Anaconda repository. This article will walk through various methods to install such packages. What is Conda and Anaconda?Con
3 min read
Transition from OpenCV 2 to OpenCV 3.x
OpenCV is one of the most popular and most used Computer vision libraries. It contains tools to carry out image and video processing. When OpenCV 3..4.1 is an improved version of OpenCV 2.4 as it introduced new algorithms and features. Although some of the existing modules were rewritten and moved to sub-modules. In this articles, I will focus on t
2 min read
Top Books for Learning OpenCV: Computer Vision with OpenCV Library
OpenCV or Open Source Computer Vision Library, is an open-source computer vision and machine learning software library. It's extensively used for real-time computer vision tasks such as object detection, face recognition, image processing, etc. Whether you're a beginner or an experienced developer looking to deepen your understanding of OpenCV, her
5 min read
Article Tags :
Practice Tags :
three90RightbarBannerImg