Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modification #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added assets/me.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/me2.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/me3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions face-recognition/face-recognition.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import cv2

# Load the pre-trained Haar Cascade face detector
face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_frontalface_default.xml')

# Load the image
image_path = '../assets/me2.jpg'
img = cv2.imread(image_path)
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

# Detect faces in the image
faces = face_cascade.detectMultiScale(gray, scaleFactor=2, minNeighbors=5)

# Draw rectangles around the faces
for (x, y, w, h) in faces:
cv2.rectangle(img, (x, y), (x+w, y+h), (255, 0, 0), 2)

# Display the image with detected faces
cv2.imshow('Detected Faces', img)
cv2.waitKey(0)
cv2.destroyAllWindows()
14 changes: 14 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
opencv-python = "*"
numpy = "*"
screeninfo = "*"

[dev-packages]

[requires]
python_version = "3.11"
Binary file added resize-image/brian.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions resize-image/get_screen_information.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from screeninfo import get_monitors

def get_screen_size():
monitors = get_monitors()
if monitors:
monitor = monitors[0]
width = monitor.width
height = monitor.height
return width, height
else:
return None

screen_size = get_screen_size()
if screen_size:
print("Screen Width: ", screen_size[0])
print("Screen Height: ", screen_size[1])
else:
print("Screen size not available.")

screen_width = screen_size[0]
screen_height = screen_size[1]
29 changes: 29 additions & 0 deletions resize-image/resize-image-final.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Import OpenCV
import cv2
import get_screen_information

screen_height = (get_screen_information.screen_height)
screen_width = (get_screen_information.screen_width)

# Open the image
img = cv2.imread('brian.jpg', 1)
cv2.imshow('image', img)
cv2.waitKey(0)
cv2.destroyAllWindows()

# Get image size
img.shape
height, width, channel = img.shape


# Resize the image: Downscalling
img_down = cv2.resize(img, (width//3, height//3))
cv2.imshow('smaller image', img_down)
cv2.waitKey(0)
cv2.destroyAllWindows()

# Resize the image: Upscalling
img_up = cv2.resize(img_down, (width, height), interpolation = cv2.INTER_LINEAR)
cv2.imshow('bigger image', img_up)
cv2.waitKey(0)
cv2.destroyAllWindows()
24 changes: 24 additions & 0 deletions resize-image/resize-image.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import cv2
import numpy as np
import matplotlib.pyplot as plt

image = cv2.imread(r"../assets/brian.jpg", 1)
# Loading the image

half = cv2.resize(image, (0, 0), fx = 0.1, fy = 0.1)
bigger = cv2.resize(image, (600, 600))

stretch_near = cv2.resize(image, (780, 540),
interpolation = cv2.INTER_LINEAR)


Titles =["Original", "Half", "Bigger", "Interpolation Nearest"]
images =[image, half, bigger, stretch_near]
count = 4

for i in range(count):
plt.subplot(2, 2, i + 1)
plt.title(Titles[i])
plt.imshow(images[i])

plt.show()