-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathauto.py
31 lines (23 loc) · 831 Bytes
/
auto.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/python3
from gi.repository import Gio
import os
import cv2
import numpy as np
proxy = Gio.DBusProxy.new_sync(
Gio.bus_get_sync(Gio.BusType.SESSION, None),
Gio.DBusProxyFlags.NONE,
None,
"org.cinnamon.SettingsDaemon.Power",
"/org/cinnamon/SettingsDaemon/Power",
"org.cinnamon.SettingsDaemon.Power.Screen",
None)
camera = cv2.VideoCapture(0)
while True:
_, image = camera.read()
cv2.imwrite(os.path.expanduser("~/.face.png"), image)
os.system("mv ~/.face.png ~/.face")
hsv = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
brightness = np.mean(hsv[:, :, 2])
brightness_percent = (brightness / 255) * 100
brightness_percent = 100 - round(brightness_percent, 2)
proxy.SetPercentage("(u)", brightness_percent)