Use "pip install"
opencv-python
opencv-contrib-python
Getting Python ready:
Download python distribution tool (I recommend Anaconda):
https://www.anaconda.com/products/distribution
We will be working in Python 3.9 in this example.
Getting the environment ready:
After installing Anaconda:
Open the Anaconda command window. If your process in command window gets stuck at any time you can use CTRL + C to force it to stop and try again
We will create first virtual environment (environment that will hold all libraries and python for you to work with). “opencv” will be the name of environment, but can be different.
conda create -n opencv python=3.9
It will install the environment. After, switch to the environment we just created
activate opencv
Now we will install OpenCV library
pip install opencv-python
pip install opencv-contrib-python
Installation might take a while, wait until its finished.
Now we will install the simple IDE for our first code test. Jupyter Notebook is a simple IDE for developing/prototyping. We can also install another IDE (recommended) for development like PyCharm / Visual Studio Code if we want to.
pip install jupyter
ipython kernel install --name "opencv" --user
We can start jupyter notebook. It will open a browser (like google chrome) for you to work in
jupyter notebook
Image below how it looks like. We can now on the right side select “new” -> “opencv” (notebook) and start our code.
Type in the code from the image below to get started -> update the path to your image first. You can run each individual cell by pressing “Run” button
Below is how Jupyter Notebook Looks like:
Create script & Run the code: