Saturday, September 26, 2026

OpenCV Operations

import cv2, numpy as np


image = cv2.imread('TT.jpeg')

#cv2.imshow('Image', image)

cv2.waitKey(0)  # Wait indefinitely (0) for key press

cv2.destroyAllWindows()


resized = cv2.resize(image, (400, 400))  # Resize to 400x400 pixels

#cv2.imshow('Resized', resized)

cv2.waitKey(0)

cv2.destroyAllWindows()


gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

#cv2.imshow('Gray Image', gray)

cv2.waitKey(0)

cv2.destroyAllWindows()


edges = cv2.Canny(gray, threshold1=50, threshold2=150)

#cv2.imshow('Edges', edges)

cv2.waitKey(0)

cv2.destroyAllWindows()


kernel = np.ones((5, 5), np.uint8)

eroded = cv2.erode(image, kernel, iterations=1)

dilated = cv2.dilate(image, kernel, iterations=1)

#cv2.imshow('Eroded', eroded);  cv2.moveWindow("Eroded", 0, 0)

#cv2.imshow('Dilated', dilated);  cv2.moveWindow("Dilated", 950, 0)

#cv2.waitKey(0)

#cv2.destroyAllWindows()


opened = cv2.dilate(eroded, kernel, iterations=1)

closed = cv2.erode(dilated, kernel, iterations=1)

#cv2.imshow('Opened', opened);  cv2.moveWindow("Opened", 0, 500)

#cv2.imshow('Closed', closed);  cv2.moveWindow("Closed", 950, 500)

cv2.waitKey(0)

cv2.destroyAllWindows()


equalized = cv2.equalizeHist(gray) # Increases contrast

#cv2.imshow('Equalized', equalized)

cv2.waitKey(0)

cv2.destroyAllWindows()


hsv = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)

#cv2.imshow('HSV', hsv)

cv2.waitKey(0)

cv2.destroyAllWindows()


image1 = cv2.imread('View1.png') # Uploaded to drive

image2 = cv2.imread('View2.png') # Uploaded to drive

#cv2.imshow('Image1', image1)

#cv2.imshow('Image2', image2)

stitcher = cv2.Stitcher.create()

(status, stitched_image) = stitcher.stitch([image1, image2])

if status == cv2.STITCHER_OK:

  #cv2.imshow('Stitched Image', stitched_image)

  cv2.waitKey(0)

  cv2.destroyAllWindows()

else:

  print("Image stitching failed. Status:", status)

    

face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_frontalface_default.xml')

image = cv2.imread('Crowd.jpg') # Uploaded to drive

gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

faces = face_cascade.detectMultiScale(gray_image, scaleFactor=1.1, minNeighbors=5)

for (x, y, w, h) in faces:

  cv2.rectangle(image, (x, y), (x + w, y + h), (0, 255, 0), 2)

#cv2.imshow('Face Detection', image)

cv2.waitKey(0)

cv2.destroyAllWindows()


image = cv2.imread('Traffic signal.jpg')

image = cv2.imread('Traffic.png')

gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

edges = cv2.Canny(gray_image, threshold1=50, threshold2=150)

kernel = np.ones((5, 5), np.uint8)

dilated = cv2.dilate(edges, kernel, iterations=1)

contours, _ = cv2.findContours(dilated, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)

for contour in contours:

  if cv2.contourArea(contour) > 100:

    x, y, w, h = cv2.boundingRect(contour)

    cv2.rectangle(image, (x, y), (x + w, y + h), (0, 255, 0), 2)

cv2.imshow('Traffic Sign Detection', image)

cv2.waitKey(0)

cv2.destroyAllWindows()


from ultralytics import YOLO


model = YOLO("yolo11n.pt")

image = cv2.imread("Traffic.png") # Uploaded to drive

results = model(image)

for result in results:

  for box in result.boxes:

    class_id = int(box.cls[0])

    class_name = model.names[class_id]

    x1, y1, x2, y2 = map(int, box.xyxy[0])

    cv2.rectangle(image, (x1, y1), (x2, y2), (0, 255, 0), 2)

    cv2.putText(image, class_name, (x1, y1 - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.6, (0, 255, 0), 2)

cv2.imshow("Vehicle Detection", image)

cv2.waitKey(0)

cv2.destroyAllWindows()


Thursday, September 3, 2026

Turning GitHub pages as live websites

  • Create the repository on GitHub.
a) Click → New repository
b) Give it a name, e.g. reinforcement-learning-game
c) Choose Public if you're using GitHub Free.
d) Click Create repository.

  • Upload your files in the repository's main folder.
  • Turn on GitHub Pages.

a) In the repository: Settings → Pages

b) Under Build and deployment:

  •    Source: Deploy from a branch
  •    Select Branch: main Folder: / (root)
  •    Click Save.

  • Get your webpage URL.

a) Repository URL: Shows your source files and GitHub repository.

      https://github.com/BinoyThomas1108/ReInforcement-Learning-1

b) Live webpage URL: Runs your index.html as a webpage.

      https://binoythomas1108.github.io/ReInforcement-Learning-1/