How to start with Python OpenCV in a JupyterLab Notebook.
If you want see how to install Python and OpenCV on various OS check these videos:
for Windows • Install OpenCV with Python 3 on Windows
for macOS • Install OpenCV for Python on macOS Catalina
for Ubuntu Linux • Install OpenCV 4 for Python on Ubuntu Linux
Create and activate a venv on Windows:
python -m venv work
work\Scripts\activate
Create and activate a venv on Linux and macOS:
python3 -m venv work
source work/bin/activate
Install libraries:
pip install opencv-python-headless
pip install matplotlib
pip install jupyterlab
Start JupyterLab:
jupyter lab
Code used in the video (change the image name to match the image you have on your computer):
import cv2
from matplotlib import pyplot as plt
print(cv2.__version__)
img = cv2.imread("clouds.jpg")
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
plt.imshow(gray, cmap = 'gray')
plt.title("Over the Clouds - gray")
plt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
plt.title("Over the Clouds - original color image")
f = plt.figure(figsize=(15, 15))
f.add_subplot(1, 2, 1)
plt.imshow(gray, cmap = 'gray')
plt.title("Over the Clouds - gray")
f.add_subplot(1, 2, 2)
plt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
plt.title("Over the Clounds - original color image")
On this page of the site you can watch the video online Getting Started with Python OpenCV in a JupyterLab Notebook with a duration of hours minute second in good quality, which was uploaded by the user AtoZ Programming Tutorials 25 March 2020, share the link with friends and acquaintances, this video has already been watched 25,807 times on youtube and it was liked by 200 viewers. Enjoy your viewing!