Skip to content

vush-man/Computer-Vision-Course

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Computer Vision Course

This repository contains a phase-by-phase OpenCV learning course built in Python. Each script focuses on one concept, from reading images and drawing shapes to webcam capture, image filtering, contour detection, and face/expression detection.

What This Course Covers

  • Loading, displaying, inspecting, and saving images
  • Image transformation and manipulation: resize, crop, rotate, flip
  • Basic drawing on images: lines, rectangles, circles, and text
  • Webcam capture and video recording/playback
  • Image filtering: Gaussian blur, median blur, sharpening
  • Edge detection, thresholding, and bitwise operations
  • Contour detection and shape classification
  • Face, eye, and smile detection with Haar cascades

Requirements

  • Python 3.x
  • opencv-contrib-python

Install dependencies with:

pip install -r requirements.txt

Folder Structure

Computer Vision/
├── Phase 1 - Working with Images/
├── Phase 2 - Image Transformation & Manipulation/
├── Phase 3 - Basic Image Drawing Techniques/
├── Phase 4 - Working with Video & Webcam/
├── Phase 5 - Image Filtering & Blurring/
├── Phase 6 - Edge Detection & Thresholding/
├── Phase 7 - Contours & Shape Detection/
├── Phase 8 - Face & Object Detection/
├── Source/
├── output/
├── requirements.txt
└── README.md

Phase Overview

Phase 1 - Working with Images

These scripts introduce the basics of OpenCV image handling.

  • 1.reading.py loads input_img.png and checks whether the file was read successfully.
  • 2.showing.py displays the loaded image in a window.
  • 3.b&w.py converts the image to grayscale.
  • 4.shape.py prints the image dimensions as height, width, and channels.
  • 5.write.py saves the image as output_img.png.
  • 6.Assignment_1.py is an interactive exercise that loads an image, converts it to grayscale, and lets the user show, save, or do both.

Phase 2 - Image Transformation & Manipulation

These scripts demonstrate how to alter the size and orientation of an image.

  • 1.resizing.py resizes the image to 1300 x 600 and saves the result as resized_img.png.
  • 2.cropping.py crops a rectangular region from the image and saves it as cropped_img.png.
  • 3.rotation.py rotates the image by several angles and also demonstrates scaling.
  • 4.flipping.py flips the image vertically.

Phase 3 - Basic Image Drawing Techniques

These scripts show how to draw on top of an image using OpenCV primitives.

  • 1.line.py draws a blue line.
  • 2.rectangle.py draws a green rectangle.
  • 3.circle.py draws a filled red circle.
  • 4.text.py writes text on the image.
  • 5.Assignment_2.py is an interactive exercise where the user chooses a shape or text, enters coordinates, and then shows or saves the modified image.

Phase 4 - Working with Video & Webcam

This phase introduces webcam capture and video I/O.

  • 1.videoCapture.py opens the webcam and streams live video.
  • 2.saving.py records webcam video to output_feed.avi.
  • 3.Assignment_3.py is an interactive script with three modes: live webcam display, record webcam video to a custom path, or play back a video file.

Phase 5 - Image Filtering & Blurring

These scripts demonstrate common filters used for smoothing and sharpening.

  • 1.gaussian_blur.py applies Gaussian blur.
  • 2.median_blur.py applies median filtering for noise removal.
  • 3.sharpening.py applies a sharpening kernel.

Phase 6 - Edge Detection & Thresholding

These scripts focus on extracting structure from images.

  • 1.canny_edge_detection.py detects edges using the Canny algorithm.
  • 2.thresholding.py converts a grayscale image into a binary image.
  • 3.bitwise_operation.py demonstrates bitwise AND, OR, XOR, and NOT on synthetic shapes.

Phase 7 - Contours & Shape Detection

These scripts work with object outlines and shape classification.

  • 1.finding_contours.py finds and draws contours on a thresholded image.
  • 2.shape_detection.py detects contours, approximates polygon vertices, and labels shapes such as triangle, rectangle, pentagon, and circle.

Phase 8 - Face & Object Detection

This phase uses Haar cascades for real-time object detection.

  • 1.face_detection.py detects faces from the webcam feed.
  • 2.expression_detection.py detects faces, eyes, and smiles and adds labels to the video stream.

Required Input Files

Several scripts expect sample images in the project root:

  • input_img.png for most Phase 1 to Phase 6 scripts
  • triangle.png for Phase 7 - Contours & Shape Detection/1.finding_contours.py
  • circle.png for Phase 7 - Contours & Shape Detection/2.shape_detection.py

If those files are not present, the scripts will print an error or fail to load the image.

Output Files

Generated files are written either to the project root or to the output/ folder, depending on the script.

Common outputs include:

  • output_img.png
  • resized_img.png
  • cropped_img.png
  • output_feed.avi

Haar Cascade Files

The face-detection scripts use the XML classifiers stored in Source/:

  • Source/haarcascade_frontalface_default.xml
  • Source/haarcascade_eye.xml
  • Source/haarcascade_smile.xml

If you run the scripts from the project root, make sure the cascade paths in the code match the file location. If needed, update the script paths to point to the Source/ folder.

How To Run

Run any script directly with Python. For example:

python "Phase 1 - Working with Images/1.reading.py"
python "Phase 4 - Working with Video & Webcam/1.videoCapture.py"

Some scripts are interactive and will ask for input in the terminal, such as:

  • image path
  • output file name
  • coordinates for drawing
  • webcam vs file playback mode

Notes

  • Most scripts are intentionally small and independent so each concept can be tested on its own.
  • Webcam-based scripts require a working camera and may need permission access depending on your system.
  • Video recording uses the XVID codec, which is commonly supported on Windows.

Suggested Learning Order

  1. Phase 1: Learn how OpenCV reads, shows, and saves images.
  2. Phase 2: Practice resizing, cropping, rotating, and flipping.
  3. Phase 3: Draw shapes and text on images.
  4. Phase 4: Move to webcam and video processing.
  5. Phase 5: Apply blurring and sharpening filters.
  6. Phase 6: Detect edges and separate foreground with thresholding.
  7. Phase 7: Detect contours and classify shapes.
  8. Phase 8: Detect faces and facial features in real time.

About

Practice codes for OpenCV

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages