It’s time to put everything together! 🎯 In this capstone project, you will build an AI-powered Image Processing App that combines different OpenCV features like filters, sketch effect, ANPR, and face/mask detection. This app will give you real-world, portfolio-ready experience in computer vision.
import cv2
import numpy as np
import pytesseract
from tensorflow.keras.models import load_model
# Load models
face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + "haarcascade_frontalface_default.xml")
mask_model = load_model("mask_detector_model.h5")
def menu():
print("Choose an option:")
print("1. Apply Filters")
print("2. Real-time Sketch")
print("3. Number Plate Detection")
print("4. Face Mask Detection")
print("5. Exit")
Each menu option calls the relevant OpenCV function. Example: applying filters, detecting faces with masks, or detecting number plates.
def sketch_webcam():
cap = cv2.VideoCapture(0)
while True:
ret, frame = cap.read()
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
inv = cv2.bitwise_not(gray)
blur = cv2.GaussianBlur(inv, (21, 21), 0)
sketch = cv2.divide(gray, 255 - blur, scale=256)
cv2.imshow("Sketch Effect", sketch)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
def mask_detection():
cap = cv2.VideoCapture(0)
while True:
ret, frame = cap.read()
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
faces = face_cascade.detectMultiScale(gray, 1.1, 4)
for (x,y,w,h) in faces:
face = cv2.resize(frame[y:y+h, x:x+w], (128,128)) / 255.0
face = np.expand_dims(face, axis=0)
pred = mask_model.predict(face)
label = "Mask" if pred[0][0] > 0.5 else "No Mask"
color = (0,255,0) if label=="Mask" else (0,0,255)
cv2.rectangle(frame,(x,y),(x+w,y+h),color,2)
cv2.putText(frame,label,(x,y-10),cv2.FONT_HERSHEY_SIMPLEX,0.8,color,2)
cv2.imshow("Mask Detection", frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
✅ Congratulations! You’ve completed the Capstone Project for this course.
By building an AI-powered Image Processing App, you have integrated filters, sketching, ANPR, and mask detection.
This is a portfolio-ready project to showcase your OpenCV and AI skills.
👉 Next, we’ll wrap up with Quiz 5 to test your knowledge of advanced applications.
