CBSE AI Project | Class 10 (Code 417) & Class 12 (Code 843) | Session 2025-26
This AI project covers Image Recognition using Python, OpenCV and MobileNet neural network. Two versions — beginner (Class 10) and advanced (Class 12) — both with full working code and line-by-line explanation.
// concept
What is Image Recognition?
Image recognition is the ability of a computer to identify objects, people, places, or actions in images using Artificial Intelligence. It is one of the most powerful and widely used AI applications in the world today.
In CBSE AI curriculum (Code 417 and 843), image recognition is a key topic in the Computer Vision unit. Building this project demonstrates your understanding of AI Project Cycle, data preprocessing, model usage, and evaluation.
💡 Real-world examples you already use every day
📸 Google Photos — automatically groups photos by person's face using face recognition
🚗 Self-driving cars — detect pedestrians, traffic lights, road signs in real time
🏥 Medical AI — detect tumors and abnormalities in X-ray and MRI scans
📦 Amazon Go stores — detect which products you pick up without any checkout
📱 Face Unlock — your phone's camera recognizes your face in milliseconds
Class 10 Version — Beginner
- Detect colours in an image
- Find dominant colour
- Use OpenCV and NumPy
- No neural network needed
- ~35 lines of code
- Perfect for Code 417
Class 12 Version — Advanced
- Object detection with labels
- Confidence score shown
- MobileNet neural network
- Bounding boxes drawn
- ~65 lines of code
- Perfect for Code 843
// class 10 project
Project 1 — Colour & Shape Detector Beginner
In this project we use Python and OpenCV to detect colours in any image. This covers Computer Vision concepts from the CBSE Class 10 AI syllabus — no machine learning required, perfect for beginners!
// step 1 — install libraries
Open Command Prompt and run these one by one:
pip install opencv-python
pip install numpy
pip install matplotlib
// step 2 — full code
# AI Logic School — Class 10 Image Recognition Project
# Colour Detector using OpenCV | CBSE Code 417
import cv2
import numpy as np
import matplotlib.pyplot as plt
# Step 1: Load image — replace 'photo.jpg' with your file
image = cv2.imread('photo.jpg')
image_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
# Step 2: Convert to HSV colour space for easier detection
hsv = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
# Step 3: Define HSV ranges for Red, Blue, Green
lower_red = np.array([0, 120, 70]); upper_red = np.array([10, 255, 255])
lower_blue = np.array([100, 150, 50]); upper_blue = np.array([130, 255, 255])
lower_green = np.array([40, 70, 70]); upper_green = np.array([80, 255, 255])
# Step 4: Create masks for each colour
mask_red = cv2.inRange(hsv, lower_red, upper_red)
mask_blue = cv2.inRange(hsv, lower_blue, upper_blue)
mask_green = cv2.inRange(hsv, lower_green, upper_green)
# Step 5: Apply masks to show detected colour only
result_red = cv2.bitwise_and(image_rgb, image_rgb, mask=mask_red)
result_blue = cv2.bitwise_and(image_rgb, image_rgb, mask=mask_blue)
result_green = cv2.bitwise_and(image_rgb, image_rgb, mask=mask_green)
# Step 6: Count detected pixels for each colour
red_px = cv2.countNonZero(mask_red)
blue_px = cv2.countNonZero(mask_blue)
green_px = cv2.countNonZero(mask_green)
print(f"Red pixels : {red_px}")
print(f"Blue pixels : {blue_px}")
print(f"Green pixels : {green_px}")
# Step 7: Find the dominant colour
colours = {'Red': red_px, 'Blue': blue_px, 'Green': green_px}
dominant = max(colours, key=colours.get)
print(f"\n✅ Dominant colour: {dominant}")
# Step 8: Display all results
fig, axes = plt.subplots(1, 4, figsize=(16, 4))
axes[0].imshow(image_rgb); axes[0].set_title('Original')
axes[1].imshow(result_red); axes[1].set_title('Red Detected')
axes[2].imshow(result_blue); axes[2].set_title('Blue Detected')
axes[3].imshow(result_green); axes[3].set_title('Green Detected')
for ax in axes: ax.axis('off')
plt.suptitle(f'Dominant Colour: {dominant}', fontsize=14, fontweight='bold')
plt.tight_layout()
plt.show()
▶ EXPECTED OUTPUT
Red pixels : 3420
Blue pixels : 8901
Green pixels : 2150
✅ Dominant colour: Blue
// line-by-line explanation
| Line / Function | What it does |
| cv2.imread() | Loads your image file into Python as a matrix (array) of pixel values |
| cvtColor(BGR2HSV) | Converts image to HSV colour space — easier to detect colours than RGB |
| np.array([...]) | Defines the lower and upper HSV range for each colour to detect |
| cv2.inRange() | Creates a mask — white pixels where colour is found, black everywhere else |
| bitwise_and() | Applies the mask to show only the detected colour on original image |
| countNonZero() | Counts how many pixels of each colour were found in the image |
| max(colours) | Finds which colour appeared the most — that becomes the dominant colour |
| plt.subplots() | Creates a 4-panel figure to display original image + 3 colour results |
🎯 Try It Yourself — Class 10 Challenges
- Add detection for Yellow colour (HSV lower: [20,100,100], upper: [30,255,255])
- Print what percentage of the total image each colour covers
- Save the result image using
cv2.imwrite('result.jpg', image)
- Try on 3 different images — a sunset, a forest, a school photo
// class 12 project
Project 2 — Object Detection with AI Advanced
Now we go deeper. We use a pre-trained neural network called MobileNet SSD to detect and label real objects in any image — like person, car, dog, laptop — with confidence scores shown on screen.
🧠 How the neural network works
MobileNet SSD is trained on 80 different object types (COCO dataset). It was trained by Google on millions of images. We just load the already-trained model — no training needed from scratch!
It outputs three things for each detection: bounding box coordinates (where the object is) + class label (what the object is) + confidence score (how sure the AI is, 0–100%)
This is an example of Transfer Learning — a key CBSE Class 12 AI concept. We use Google's pre-trained model and apply it to our own images.
// step 1 — install libraries
Open Command Prompt and run:
pip install opencv-python
pip install numpy matplotlib
// step 2 — full code
# AI Logic School — Class 12 Image Recognition Project
# Object Detection using MobileNet SSD | CBSE Code 843
import cv2
import numpy as np
import matplotlib.pyplot as plt
import urllib.request
import os
# 80 object labels from COCO dataset
LABELS = [
"background", "person", "bicycle", "car", "motorcycle",
"airplane", "bus", "train", "truck", "boat",
"traffic light", "fire hydrant", "stop sign",
"bench", "bird", "cat", "dog", "horse", "sheep",
"cow", "elephant", "bear", "zebra", "giraffe",
"backpack", "umbrella", "handbag", "suitcase",
"bottle", "cup", "fork", "knife", "spoon", "bowl",
"banana", "apple", "sandwich",
"chair", "couch", "laptop", "cell phone", "book"
]
COLOURS = np.random.uniform(50, 255, size=(len(LABELS), 3))
# Download model files (runs only once, ~25 MB)
MODEL_URL = "https://github.com/chuanqi305/MobileNet-SSD/raw/master/MobileNetSSD_deploy.caffemodel"
PROTO_URL = "https://raw.githubusercontent.com/chuanqi305/MobileNet-SSD/master/MobileNetSSD_deploy.prototxt"
if not os.path.exists("model.caffemodel"):
print("📥 Downloading model... (first time only)")
urllib.request.urlretrieve(MODEL_URL, "model.caffemodel")
urllib.request.urlretrieve(PROTO_URL, "model.prototxt")
print("✅ Model downloaded!")
# Load the pre-trained neural network
print("🧠 Loading neural network...")
net = cv2.dnn.readNetFromCaffe("model.prototxt", "model.caffemodel")
print("✅ Model loaded!")
# Load and prepare image
image = cv2.imread("photo.jpg") # replace with your image
image = cv2.resize(image, (600, 400))
(H, W) = image.shape[:2]
# Convert image to blob format the network understands
blob = cv2.dnn.blobFromImage(
cv2.resize(image, (300, 300)),
0.007843, (300, 300), 127.5
)
# Run image through the neural network
net.setInput(blob)
detections = net.forward() # AI "thinks" here
# Draw bounding boxes on detected objects
found = []
for i in range(detections.shape[2]):
confidence = detections[0, 0, i, 2]
if confidence > 0.50: # only show >50% confident detections
idx = int(detections[0, 0, i, 1])
label = LABELS[idx]
colour = [int(c) for c in COLOURS[idx]]
box = detections[0, 0, i, 3:7] * np.array([W, H, W, H])
(sX, sY, eX, eY) = box.astype("int")
cv2.rectangle(image, (sX, sY), (eX, eY), colour, 2)
text = f"{label}: {confidence*100:.1f}%"
cv2.putText(image, text, (sX, sY-8),
cv2.FONT_HERSHEY_SIMPLEX, 0.5, colour, 2)
found.append(f" • {label} ({confidence*100:.1f}% confidence)")
# Print and display results
print(f"\n🎯 Objects detected: {len(found)}")
for obj in found: print(obj)
result_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
plt.figure(figsize=(10, 6))
plt.imshow(result_rgb)
plt.title(f"Objects Detected: {len(found)}", fontsize=14)
plt.axis('off')
plt.tight_layout()
plt.show()
▶ EXPECTED OUTPUT
📥 Downloading model... (first time only)
✅ Model downloaded!
🧠 Loading neural network...
✅ Model loaded!
🎯 Objects detected: 3
• person (94.2% confidence)
• laptop (87.6% confidence)
• chair (71.3% confidence)
// line-by-line explanation
| Line / Concept | What it does |
| LABELS list | 80 object names the model was trained to recognise — from person to giraffe |
| readNetFromCaffe() | Loads pre-trained MobileNet neural network weights from the downloaded file |
| blobFromImage() | Converts image to exact format (300×300, normalised) the network was designed for |
| net.forward() | The AI "thinks" — image passes through all neural network layers, predictions come out |
| detections[0,0,i,2] | Confidence score for detection i — how sure the AI is (0.0 to 1.0) |
| confidence > 0.50 | Only show results where AI is more than 50% confident — reduces false detections |
| detections[...,3:7] | Bounding box as fractions (0-1) of image size — multiply by W and H for pixel coordinates |
| cv2.rectangle() | Draws the coloured box around each detected object |
| cv2.putText() | Writes the label name and confidence % above each bounding box |
🎯 Try It Yourself — Class 12 Challenges
- Change confidence threshold from 0.50 to 0.70 — what happens to number of detections?
- Count how many people specifically are in the image and print that count
- Save the result image with bounding boxes using
cv2.imwrite('result.jpg', image)
- Try the code on a classroom photo — can it detect students and chairs?
- Extension: Modify code to use webcam using
cv2.VideoCapture(0)
// viva & exam questions
Important Viva & Board Exam Questions
Q1. What is Image Recognition in AI?
Image recognition is the ability of AI to identify objects, people, or actions in images. It uses Computer Vision techniques and neural networks trained on millions of labeled images.
Q2. What is OpenCV? Why is it used?
OpenCV (Open Source Computer Vision) is a Python library for image processing tasks — reading images, colour detection, drawing shapes, applying filters, and running neural networks on images.
Q3. What is HSV colour space? Why use it over RGB?
HSV (Hue, Saturation, Value) separates colour information from brightness. This makes colour detection more reliable under different lighting conditions compared to RGB.
Q4. What is a pre-trained model? Give one example.
A pre-trained model is a neural network already trained on a large dataset. We can directly use it without training from scratch. Example: MobileNet SSD — trained by Google on 80 object types.
Q5. What is a confidence score in object detection?
A confidence score (0 to 1) tells how certain the AI is about its detection. A score of 0.94 means 94% confident. We typically only show detections above 50% confidence to reduce errors.
Q6. How does this project demonstrate the AI Project Cycle?
Problem Scoping: detect objects in images. Data Acquisition: use photo.jpg. Data Exploration: view image pixels. Modeling: run MobileNet neural network. Evaluation: check confidence scores and bounding boxes.
📲 Get More AI Projects — Free!
Join our Telegram channel for free PDF notes, practical files and more AI projects for CBSE Code 417 and 843.
📲 Join Telegram — Free
// more resources
More Free Resources — AI Logic School
AI Logic School · AI Project: Image Recognition · CBSE Class 10 & 12 · Code 417 & 843 · 2025-26