Skip to content

Repository files navigation

AI Vibe Coding for Computer Vision

Course OpenCV Python YOLO Streamlit License

Hands-on labs for building computer vision applications with an AI pair programmer — from reading a single pixel array to running a deployed vision app, with Cursor, GitHub Copilot or Claude writing the OpenCV code alongside you.

📘 Course Page · 📖 Learner Guide · 🧪 All Labs · 🐛 Report Bug · 💡 Request Feature

Real output from the C592 labs — Canny edges, contour counting and shape classification

Note

These are the official hands-on lab materials for the course:

🎓 AI Vibe Coding for Computer Vision

Course Code: C592 · by Tertiary Courses / Tertiary Infotech Course page: https://www.tertiarycourses.com.sg/ai-vibe-coding-for-computer-vision.html 1 day · 7.5 instructional hours · 2 topics · 8 hands-on labs


Lab Activities

Lab 1 — Set Up Your AI Vibe Coding Environment · Isolated Python environment, OpenCV, and your first script written from a prompt rather than from memory.

Lab 2 — Load, Display and Transform Images · Resize, crop, rotate, flip and colour-convert — and deliberately trigger the BGR/RGB bug that turns skin blue.

Lab 3 — Filtering, Thresholding and Edge Detection · A four-panel comparison view with live Canny trackbars, because parameter tuning is where AI assistants are least reliable.

Lab 4 — Contours: Find, Count and Measure Objects · The full pipeline to a labelled count and a CSV export. The first run gives the wrong answer on purpose.

Lab 5 — Detect Shapes and Faces · Shape classification from contour geometry, then Haar-cascade face and eye detection with no training data and no GPU.

Lab 6 — Object Detection with a Pre-Trained Model · YOLOv8 detection with confidence and class filtering, and a per-class summary count.

Lab 7 — Working with Video Streams · Webcam and file capture loops, frame-differencing motion detection, annotated MP4 output, and detection on every Nth frame.

Lab 8 — Build, Test and Run Your Computer Vision App · A Streamlit app with real error handling and a pytest suite over the processing functions.


About

This repository contains the complete lab materials for AI Vibe Coding for Computer Vision (C592) by Tertiary Courses / Tertiary Infotech. Each lab is a self-contained activity that gives you the exact prompt to paste into your AI coding assistant, the code it should produce, and a "Test it" step that tells you what a correct result actually looks like.

The premise of the course is that an assistant which produces runnable code is easy; one that produces correct code needs you to know what the right answer looks like. So every lab has a verifiable outcome — a count that must match, a shape that must be named correctly, a box that must land on the object — rather than "it ran without an error".

What you'll learn

# Lab Concepts
1 Set Up Your AI Vibe Coding Environment venv, OpenCV install, assistant setup, prompt structure, imread returning None
2 Load, Display and Transform Images NumPy image arrays, resize with aspect ratio, ROI crop, rotate/flip, BGR vs RGB
3 Filtering, Thresholding and Edge Detection Gaussian blur, fixed vs Otsu threshold, Canny, trackbars, convolution kernels
4 Contours: Find, Count and Measure Objects findContours, RETR_EXTERNAL, area filtering, moments/centroids, CSV export
5 Detect Shapes and Faces approxPolyDP, circularity, Haar cascades, scaleFactor/minNeighbors, ROI search
6 Object Detection with a Pre-Trained Model YOLOv8, boxes/labels/confidence, class filtering, COCO class limits
7 Working with Video Streams VideoCapture loops, release discipline, frame differencing, VideoWriter, every-Nth-frame inference
8 Build, Test and Run Your Vision App Streamlit UI, pure functions for testability, failure cases, pytest with synthetic images

📖 Full walkthrough: see the Learner Guide for detailed step-by-step instructions for every lab. Slides, the Learner Guide and the Lesson Plan are in courseware/.


Tech Stack

Category Technology
Vision Library OpenCV (opencv-python) — image and video processing
Arrays NumPy — every image is an ndarray
AI Pair Programmer Cursor, GitHub Copilot or Claude
Object Detection Ultralytics YOLOv8 (yolov8n, CPU inference)
Classical Detection Haar cascades bundled with OpenCV (cv2.data.haarcascades)
App Framework Streamlit — upload, process and download in the browser
Testing pytest with synthetic NumPy fixtures
Plotting Matplotlib — used to demonstrate the BGR/RGB trap
Editor VS Code or Cursor
Courseware Slides (python-pptx), Learner Guide + Lesson Plan (python-docx)

Architecture

TOPIC 1 — Getting Started and Image Processing with AI Vibe Coding
  Lab 1  prompt ─▶ assistant ─▶ hello_cv.py ─▶ imread ─▶ imshow      (the vibe coding loop)
  Lab 2  images/ ─▶ resize · crop · rotate · flip ─▶ outputs/
                └─▶ matplotlib preview ─▶ BGR vs RGB
  Lab 3  image ─▶ greyscale ─▶ GaussianBlur ─▶ threshold / Otsu
                                            └─▶ Canny (trackbars) ─▶ edges_best.png
  Lab 4  image ─▶ greyscale ─▶ blur ─▶ Otsu(INV) ─▶ findContours
                            ─▶ area filter ─▶ moments ─▶ counted.jpg + objects.csv

TOPIC 2 — Detection and Building Vision Apps with AI
  Lab 5  contours ─▶ approxPolyDP + circularity ─▶ shape names
         image ─▶ grey ─▶ Haar frontalface ─▶ faces ─▶ ROI ─▶ Haar eye
  Lab 6  image ─▶ YOLOv8n ─▶ boxes + class + confidence
                          ─▶ --conf / --classes filter ─▶ per-class summary
  Lab 7  VideoCapture(0 | file) ─▶ frame loop ─▶ raw | edges | motion
                                ─▶ VideoWriter ─▶ output.mp4
                                └─▶ YOLO every Nth frame ─▶ cached boxes
  Lab 8  upload ─▶ app.py (Streamlit UI) ─▶ vision_ops.py (pure functions) ─▶ result + download
                                          └─▶ test_vision_ops.py (pytest)

Project Structure

C592-AI-Vibe-Coding-for-Computer-Vision/
├── README.md
├── LG-AI Vibe Coding for Computer Vision.md   # Full step-by-step learner guide (start here)
├── screenshot.png                             # Real pipeline output (Labs 3, 4, 5)
│
├── labs/                                      # All hands-on labs (one folder each)
│   ├── README.md                              # Lab index
│   ├── resources/                             # Shared sample images
│   │   ├── shapes.png                         #   5 shapes — known-correct answer
│   │   └── objects.jpg                        #   12 objects + grit — 41 raw contours
│   ├── lab01-set-up-your-ai-vibe-coding-environment/
│   ├── lab02-load-display-and-transform-images/
│   ├── lab03-filtering-thresholding-and-edge-detection/
│   ├── lab04-contours-find-count-and-measure-objects/
│   ├── lab05-detect-shapes-and-faces/
│   ├── lab06-object-detection-with-a-pre-trained-model/
│   ├── lab07-working-with-video-streams/
│   └── lab08-build-test-and-run-your-computer-vision-app/
│
└── courseware/                                # Slides, Lesson Plan + Learner Guide
    ├── AI Vibe Coding for Computer Vision-v1.0.pptx   # 93-slide deck (+ PDF)
    ├── LG-AI Vibe Coding for Computer Vision.docx     # detailed step-by-step (+ PDF)
    └── LP-AI Vibe Coding for Computer Vision.docx     # 1-day lesson plan (+ PDF)

Getting Started

Prerequisites

  • A Windows or Mac laptop with at least 8 GB RAM and permission to install software
  • Python 3.10+ — installed directly or via Anaconda
  • VS Code or Cursor
  • An AI coding assistant: GitHub Copilot in VS Code, Cursor's built-in assistant, or Claude in a browser tab
  • A webcam for Lab 7 (any short MP4 works instead)
  • (Optional) a Google Colab account as a fallback if a local install fails

1. Clone the repo

git clone https://github.com/tertiarycourses/C592-AI-Vibe-Coding-for-Computer-Vision.git
cd C592-AI-Vibe-Coding-for-Computer-Vision

2. Create the workspace and install OpenCV

mkdir cv-vibe
cd cv-vibe
python -m venv .venv
.venv\Scripts\activate          # macOS/Linux: source .venv/bin/activate
pip install opencv-python numpy matplotlib

3. Verify your setup

This prints an OpenCV 4.x version and opens a small black window. Click it and press any key to close.

python -c "import cv2, numpy as np; print('OpenCV', cv2.__version__); cv2.imshow('ok', np.zeros((120,240,3), np.uint8)); cv2.waitKey(0); cv2.destroyAllWindows()"

4. Start Lab 1

Copy the sample images across and open the first lab:

mkdir images
cp ../labs/resources/*.jpg ../labs/resources/*.png images/

Then follow labs/lab01-set-up-your-ai-vibe-coding-environment/README.md.

⚠️ Never close an OpenCV window with the X button — click the window and press any key, or the Python process hangs. Every lab's script ends with cv2.waitKey(0) and cv2.destroyAllWindows() for this reason.

💡 Read the generated code before you run it. The point of this course is that you stay in control of the logic — not that the assistant is always right. Labs 4, 5 and 8 deliberately produce a wrong-but-runnable result so you learn to spot one.

For complete, step-by-step setup, see the Learner Guide.


Contributing

Contributions, fixes, and improvements are welcome:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/my-improvement
  3. Commit your changes: git commit -m "Add my improvement"
  4. Push the branch: git push origin feature/my-improvement
  5. Open a Pull Request

Found a bug or have an idea? Open an issue.


License

This material is provided for educational use as part of the course C592 — AI Vibe Coding for Computer Vision. © Tertiary Infotech Pte. Ltd. All rights reserved.


Developed By

Tertiary Infotech Pte. Ltd.Tertiary Courses Course: AI Vibe Coding for Computer Vision (C592)

Acknowledgements

  • OpenCV — the computer vision library the whole course is built on
  • Ultralytics — YOLOv8 pre-trained detection models
  • Streamlit — turning a Python script into a usable app
  • Cursor, GitHub Copilot and Claude — the AI pair programmers used throughout
  • Course trainers and learners of C592

If this helped you learn computer vision, star the repo!

Powered by Tertiary Infotech Academy Pte Ltd

📘 Course Page · 📖 Learner Guide

About

Hands-on labs for the course 'AI Vibe Coding for Computer Vision' (C592) — building OpenCV image, detection and video apps with an AI pair programmer, from pixel arrays to a deployed Streamlit app.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages