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

AI Model to change Screen Brightness and Sound! #460

Open
wants to merge 1 commit into
base: master
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
5 changes: 5 additions & 0 deletions kumarbaberwal/0001.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#run pip install screen_brightness_control

import screen_brightness_control as sbc
sbc.set_brightness(100) #set the brightness to 100

93 changes: 93 additions & 0 deletions kumarbaberwal/0002.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Hand recognition to change brightness using index finger and thumb and set them using other fingers!

# (0) in VideoCapture is used to connect to your computer's default camera
import cv2
import mediapipe as mp
import time
capture = cv2.VideoCapture(0)

# Initializing current time and precious time for calculating the FPS
previousTime = 0
currentTime = 0

mp_holistic = mp.solutions.holistic
holistic_model = mp_holistic.Holistic(
min_detection_confidence=0.5,
min_tracking_confidence=0.5
)

# Initializing the drawing utils for drawing the facial landmarks on image
mp_drawing = mp.solutions.drawing_utils

while capture.isOpened():
# capture frame by frame
ret, frame = capture.read()

# resizing the frame for better view
frame = cv2.resize(frame, (800, 600))

# Converting the from BGR to RGB
image = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)

# Making predictions using holistic model
# To improve performance, optionally mark the image as not writeable to
# pass by reference.
image.flags.writeable = False
results = holistic_model.process(image)
image.flags.writeable = True

# Converting back the RGB image to BGR
image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)

# Drawing the Facial Landmarks
mp_drawing.draw_landmarks(
image,
results.face_landmarks,
mp_holistic.FACEMESH_CONTOURS,
mp_drawing.DrawingSpec(
color=(255,0,255),
thickness=1,
circle_radius=1
),
mp_drawing.DrawingSpec(
color=(0,255,255),
thickness=1,
circle_radius=1
)
)

# Drawing Right hand Land Marks
mp_drawing.draw_landmarks(
image,
results.right_hand_landmarks,
mp_holistic.HAND_CONNECTIONS
)

# Drawing Left hand Land Marks
mp_drawing.draw_landmarks(
image,
results.left_hand_landmarks,
mp_holistic.HAND_CONNECTIONS
)

# Calculating the FPS
currentTime = time.time()
fps = 1 / (currentTime-previousTime)
previousTime = currentTime

# Displaying FPS on the image
cv2.putText(image, str(int(fps))+" FPS", (10, 70), cv2.FONT_HERSHEY_COMPLEX, 1, (0,255,0), 2)

# Display the resulting image
cv2.imshow("Facial and Hand Landmarks", image)

# Enter key 'q' to break the loop
if cv2.waitKey(5) & 0xFF == ord('q'):
break

# When all the process is done
# Release the capture and destroy all windows
capture.release()
cv2.destroyAllWindows()


3 changes: 3 additions & 0 deletions kumarbaberwal/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pip install mediapipe
pip install cv2
pip install screen_brighness_control