Computer VisionAI & Machine LearningTutorials

Introduction to Computer Vision with OpenCV

Computer vision is the field of teaching computers to "see" — to extract meaningful information from images and video. It powers everything from facial recognition to self-driving cars.

27 May 2026
9 min read
By Head of Applied AI
Introduction to Computer Vision with OpenCV

What Is Computer Vision?

Computer vision is the field of teaching computers to "see" — to extract meaningful information from images and video. It powers everything from facial recognition to self-driving cars.

Setting Up OpenCV

pip install opencv-python numpy matplotlib
import cv2
import numpy as np

# Read an image
img = cv2.imread("photo.jpg")
print(f"Image shape: {img.shape}") # (height, width, channels)

Basic Operations

Reading and Displaying Images

img = cv2.imread("photo.jpg")
cv2.imshow("Window", img)
cv2.waitKey(0)
cv2.destroyAllWindows()

Converting to Grayscale

gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

Resizing

resized = cv2.resize(img, (800, 600))

Edge Detection

The Canny edge detector is a classic algorithm that finds boundaries in images:

edges = cv2.Canny(gray, threshold1=100, threshold2=200)
cv2.imshow("Edges", edges)

It works in three stages:

  • Noise reduction — apply Gaussian blur
  • Gradient calculation — find intensity changes
  • Non-maximum suppression — thin edges to single pixels

Object Tracking with Colour

Here's a simple real-time colour tracker:

cap = cv2.VideoCapture(0) # Webcam

while True:
 ret, frame = cap.read()
 hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)

 # Define range for blue colour
 lower_blue = np.array([100, 150, 50])
 upper_blue = np.array([130, 255, 255])

 mask = cv2.inRange(hsv, lower_blue, upper_blue)
 result = cv2.bitwise_and(frame, frame, mask=mask)

 cv2.imshow("Tracking", result)
 if cv2.waitKey(1) & 0xFF == ord('q'):
 break

cap.release()
cv2.destroyAllWindows()

What's Next?

  • Feature detection — SIFT, ORB, and feature matching
  • Object detection — YOLO and SSD for real-time detection
  • Semantic segmentation — pixel-level classification

Computer vision is a vast field, but starting with OpenCV gives you the foundation to explore any direction.

Written by

Head of Applied AI

Head of Applied AI & Faculty

Designs the applied-AI track around a build-it-yourself philosophy — so graduates can debug and ship, not just call an API.

Read it.Now build it.

Every piece here comes out of real work in the lab. Come do that work yourself — book a visit or find your track.