Set Up Your Environment¶
This page gets you a working vision environment in about 15 minutes. Setting up your vision toolkit explains what each library is for. This page is just the steps.
1. Install Python and uv¶
You need Python 3.12 or newer. We use uv to install Python versions, create environments, and install packages.
2. Create a project and environment¶
mkdir cv-work && cd cv-work
uv venv --python 3.12
source .venv/bin/activate # Windows: .venv\Scripts\activate
3. Install the packages¶
Beginner tier (Levels 0–2):
uv pip install numpy scipy matplotlib pillow opencv-python scikit-image scikit-learn pandas jupyterlab
opencv-python or opencv-python-headless?
opencv-python includes GUI functions such as cv2.imshow windows. opencv-python-headless leaves them out, and is the right choice for servers, Docker, and notebooks, where you display images with matplotlib anyway. Install only one of them: having both installed causes confusing import errors. The handbook's examples work with either.
Intermediate and Expert tiers (Levels 3–8): PyTorch and torchvision. The CPU build is all you need for the handbook:
Use the selector at pytorch.org/get-started to get the command for your CUDA version.
4. Check everything works¶
import cv2
import numpy as np
import skimage
from skimage import data
img = data.astronaut()
print("OpenCV", cv2.__version__, "| scikit-image", skimage.__version__)
print("sample image:", img.shape, img.dtype)
gray = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)
print("gray:", gray.shape, "mean brightness:", round(float(gray.mean()), 1))
OpenCV 5.0.0 | scikit-image 0.26.0
sample image: (512, 512, 3) uint8
gray: (512, 512) mean brightness: 115.4
Your version numbers may differ; any recent version works. scikit-image ships a set of sample photos (data.astronaut(), data.camera(), data.coins(), and others) that the handbook uses throughout, so you don't need to download anything for most chapters.
No setup at all: Google Colab¶
Google Colab gives you free notebooks with OpenCV, scikit-image, and PyTorch preinstalled, plus a time-limited free GPU. It's handy for the deep learning levels. In Colab, display images with matplotlib, not cv2.imshow, which doesn't work in notebooks.
Organizing your work¶
cv-work/
├── .venv/
├── notebooks/ # one per chapter
├── src/ # your reusable code: your own mini vision library
├── data/ # images and datasets (don't commit large files)
├── outputs/ # results and figures
└── mistakes.md # your "mistakes I made" log
Next: start Level 0, or track your progress on the progress checklist.