This media is not supported in your browser
VIEW IN TELEGRAM
Gesture-Controlled Volume Adjustment using Python 🎮🔊
Source Code 👇🏻
Source Code 👇🏻
👍7🔥2🫡1
import cv2
import mediapipe as mp
from math import hypot
from ctypes import cast, POINTER
from comtypes import CLSCTX_ALL
from pycaw.pycaw import AudioUtilities, IAudioEndpointVolume
import numpy as np
cap = cv2.VideoCapture(1)
mpHands = mp.solutions.hands
hands = mpHands.Hands()
mpDraw = mp.solutions.drawing_utils
devices = AudioUtilities.GetSpeakers()
interface = devices.Activate(IAudioEndpointVolume._iid_, CLSCTX_ALL, None)
volume = cast(interface, POINTER(IAudioEndpointVolume))
volMin, volMax = volume.GetVolumeRange()[:2]
current_vol = volume.GetMasterVolumeLevel()
# Smoothing parameters
alpha = 0.2 # Adjust this value for smoother changes
while True:
success, img = cap.read()
imgRGB = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
results = hands.process(imgRGB)
lmList = []
if results.multi_hand_landmarks:
for handlandmark in results.multi_hand_landmarks:
for id, lm in enumerate(handlandmark.landmark):
h, w, _ = img.shape
cx, cy = int(lm.x * w), int(lm.y * h)
lmList.append([id, cx, cy])
mpDraw.draw_landmarks(img, handlandmark, mpHands.HAND_CONNECTIONS)
if lmList:
x1, y1 = lmList[4][1], lmList[4][2]
x2, y2 = lmList[8][1], lmList[8][2]
cv2.circle(img, (x1, y1), 4, (255, 0, 0), cv2.FILLED)
cv2.circle(img, (x2, y2), 4, (255, 0, 0), cv2.FILLED)
cv2.line(img, (x1, y1), (x2, y2), (255, 0, 0), 3)
length = hypot(x2 - x1, y2 - y1)
target_vol = np.interp(length, [15, 220], [volMin, volMax])
current_vol = alpha * target_vol + (1 - alpha) * current_vol # Smoothing
volume.SetMasterVolumeLevel(current_vol, None)
# Display rounded volume level on the screen
cv2.putText(img, f"Vol: {int(round(current_vol))}%", (10, 30), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 0, 0), 2)
cv2.imshow('Image', img)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
import mediapipe as mp
from math import hypot
from ctypes import cast, POINTER
from comtypes import CLSCTX_ALL
from pycaw.pycaw import AudioUtilities, IAudioEndpointVolume
import numpy as np
cap = cv2.VideoCapture(1)
mpHands = mp.solutions.hands
hands = mpHands.Hands()
mpDraw = mp.solutions.drawing_utils
devices = AudioUtilities.GetSpeakers()
interface = devices.Activate(IAudioEndpointVolume._iid_, CLSCTX_ALL, None)
volume = cast(interface, POINTER(IAudioEndpointVolume))
volMin, volMax = volume.GetVolumeRange()[:2]
current_vol = volume.GetMasterVolumeLevel()
# Smoothing parameters
alpha = 0.2 # Adjust this value for smoother changes
while True:
success, img = cap.read()
imgRGB = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
results = hands.process(imgRGB)
lmList = []
if results.multi_hand_landmarks:
for handlandmark in results.multi_hand_landmarks:
for id, lm in enumerate(handlandmark.landmark):
h, w, _ = img.shape
cx, cy = int(lm.x * w), int(lm.y * h)
lmList.append([id, cx, cy])
mpDraw.draw_landmarks(img, handlandmark, mpHands.HAND_CONNECTIONS)
if lmList:
x1, y1 = lmList[4][1], lmList[4][2]
x2, y2 = lmList[8][1], lmList[8][2]
cv2.circle(img, (x1, y1), 4, (255, 0, 0), cv2.FILLED)
cv2.circle(img, (x2, y2), 4, (255, 0, 0), cv2.FILLED)
cv2.line(img, (x1, y1), (x2, y2), (255, 0, 0), 3)
length = hypot(x2 - x1, y2 - y1)
target_vol = np.interp(length, [15, 220], [volMin, volMax])
current_vol = alpha * target_vol + (1 - alpha) * current_vol # Smoothing
volume.SetMasterVolumeLevel(current_vol, None)
# Display rounded volume level on the screen
cv2.putText(img, f"Vol: {int(round(current_vol))}%", (10, 30), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 0, 0), 2)
cv2.imshow('Image', img)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
👍14🔥3❤1😱1
Top 10 Github Repositories For Web Developer
1. Web Developer-Roadmap : https://github.com/kamranahmedse/developer-roadmap
2. 30-Seconds-Of-Code : https://github.com/30-seconds/30-seconds-of-code
3. Awesome-Cheatsheets : https://github.com/LeCoupa/awesome-cheatsheets
4. CSS-Protips : https://github.com/AllThingsSmitty/css-protips
5. 33-JS-Concepts : https://github.com/leonardomso/33-js-concepts
6. You-Dont-Know-JS : https://github.com/getify/You-Dont-Know-JS/tree/2nd-ed
7. Front-End-Checklist : https://github.com/thedaviddias/Front-End-Checklist
8. Javascript-Questions : https://github.com/lydiahallie/javascript-questions
9. Clean-Code-Javascript : https://github.com/ryanmcdermott/clean-code-javascript
10. free-programming-books : https://github.com/EbookFoundation/free-programming-books
1. Web Developer-Roadmap : https://github.com/kamranahmedse/developer-roadmap
2. 30-Seconds-Of-Code : https://github.com/30-seconds/30-seconds-of-code
3. Awesome-Cheatsheets : https://github.com/LeCoupa/awesome-cheatsheets
4. CSS-Protips : https://github.com/AllThingsSmitty/css-protips
5. 33-JS-Concepts : https://github.com/leonardomso/33-js-concepts
6. You-Dont-Know-JS : https://github.com/getify/You-Dont-Know-JS/tree/2nd-ed
7. Front-End-Checklist : https://github.com/thedaviddias/Front-End-Checklist
8. Javascript-Questions : https://github.com/lydiahallie/javascript-questions
9. Clean-Code-Javascript : https://github.com/ryanmcdermott/clean-code-javascript
10. free-programming-books : https://github.com/EbookFoundation/free-programming-books
👍13🔥5🥰2👏1🤔1
*YOU WANT 56 PYTHON LECTURE FROM BASIC TO ADVANCE AT 399rs WITH👏
+ FREE 🗓️200 PROJECTS + FREE 🗣️SPOKEN ENGLISH + FREE 📝HANDWRITTEN + FREE 🔖SLIDE + FREE 👨🏻💻INTERVIEW QUESTION AND ANSWER*
+ FREE 🗓️200 PROJECTS + FREE 🗣️SPOKEN ENGLISH + FREE 📝HANDWRITTEN + FREE 🔖SLIDE + FREE 👨🏻💻INTERVIEW QUESTION AND ANSWER*
Anonymous Poll
83%
Yes
9%
No
8%
Later
👍27😍4🔥3🎉3🥰1
10 websites to apply for internships !!
1. Internshala (www.internshala.com)
2. LetsIntern (www.letsintern.com)
3. Twenty19 (www.twenty19.com)
4. Naukri.com (www.naukri.com)
5. Indeed (www.indeed.co.in)
6. Shine.com (www.shine.com)
7. Youth4work (www.youth4work.com)
8. TimesJobs (www.timesjobs.com)
9. LinkedIn (www.linkedin.com)
10. Freshersworld
(www.freshersworld.com)
1. Internshala (www.internshala.com)
2. LetsIntern (www.letsintern.com)
3. Twenty19 (www.twenty19.com)
4. Naukri.com (www.naukri.com)
5. Indeed (www.indeed.co.in)
6. Shine.com (www.shine.com)
7. Youth4work (www.youth4work.com)
8. TimesJobs (www.timesjobs.com)
9. LinkedIn (www.linkedin.com)
10. Freshersworld
(www.freshersworld.com)
👍13❤5🔥2👏1