Intelligent Vision Systems
  • Home
  • Syllabus
  • Schedule
  • Labs
  • TAs
  • Tutorials
  • Lectures

Code & Demos

Runnable Python/OpenCV/PyTorch samples for the Raspberry Pi 5, Hailo NPU, and ESP32-CAM

These are working code samples that back the labs — not slideware. Each script is short, self-contained, and meant to be read end-to-end before you adapt it for your own lab or capstone project. Grab requirements.txt and the setup guide first.

LabFileWhat it doesKey APIs
Labs 1–2 01_opencv_basics.py OpenCV bring-up: image/video I/O, drawing, basic pixel & array operations. cv2.imread/imwrite, VideoCapture
Labs 3–6 02_filters_edges.py Point operations, smoothing/sharpening filters, Sobel/Canny edges. cv2.GaussianBlur, Sobel, Canny
Labs 7–8 03_features.py Corner/keypoint detection, ORB/SIFT descriptors and matching, homography + RANSAC, camera calibration. cv2.ORB_create, findHomography, calibrateCamera
Labs 2, 4, 10 04_picamera2_stream.py Pi Camera capture with picamera2/libcamera; live FPS overlay. Picamera2, threaded capture loop
Lab 12 05_yolo_pretrained.py Run a pretrained Ultralytics YOLO model on an image, video, or camera stream. ultralytics.YOLO
Lab 14 06_hailo_picamera2_detect.py Real-time detection on the Hailo NPU fed by the Pi Camera — the deployment target for the edge-vision lecture. HailoRT, .hef models
Lab 14 07_train_export_compile.sh The full deploy chain: train YOLO → export ONNX → Hailo DFC parse/optimise/quantise → compile to .hef. Ultralytics export, Hailo Dataflow Compiler
Labs 2, 11 08_esp32cam_stream_ingest.py Ingest an ESP32-CAM MJPEG stream on the Pi — the ESP32 as a networked camera. cv2.VideoCapture over HTTP/MJPEG
Lab 11 09_tracking_counting.py Detection + tracking (OC-SORT/Strong-SORT style), trajectory, speed estimation, line-crossing counting. ultralytics tracking, custom line-crossing logic
Advanced project bank 10_mediapipe_gesture.py MediaPipe hands/pose for fast, CPU-friendly gesture control. mediapipe.solutions.hands
Lecture 15 11_clip_visual_search.py CLIP-based zero-shot classification / visual search over your own images. CLIP image/text embeddings
Advanced project bank 12_tello_detect.py Drone perception: object detection on a Tello/AI-drone video feed. djitellopy, YOLO inference
Capstone capstone_skeleton.py A perception → logic → action skeleton to fork for the capstone project. Capture → inference → decision → action loop
Lab 12 ml/train_classifier_pytorch.py Custom Dataset/DataLoader + training loop for image classification in PyTorch. PyTorch, transfer learning
Lecture 6 (deploy) apps/gradio_classifier.py Wrap a trained classifier in a Gradio demo for quick sharing. Gradio
Labs 2, 11 esp32cam/README_esp32cam.md Flashing and configuring the ESP32-CAM as a standalone or networked camera. Arduino/ESP-IDF, MJPEG server

These samples are adapted from the companion Applied Intelligent Vision Systems materials. They are teaching examples — read them, understand every line, and adapt them for your own lab/report rather than submitting them unmodified.