add alpha wayland support for ambient mode
This commit is contained in:
parent
c76b3304b3
commit
434b8fc84e
@ -10,6 +10,10 @@ import numpy as np
|
||||
from skimage import io
|
||||
from threading import Thread
|
||||
import time
|
||||
import io
|
||||
import time
|
||||
from gi.repository import GLib
|
||||
from pydbus import SessionBus
|
||||
|
||||
s1 = socket.socket()
|
||||
s2 = socket.socket()
|
||||
@ -46,7 +50,6 @@ def vibrant(r,g,b):
|
||||
|
||||
intensity = 1+intensity/1000
|
||||
rgb = [r,g,b]
|
||||
print(rgb)
|
||||
#min_idx = rgb.index(min(rgb))
|
||||
d = (r+g+b)/3
|
||||
for c in range(3):
|
||||
@ -54,8 +57,9 @@ def vibrant(r,g,b):
|
||||
rgb[c] = int(rgb[c]*(intensity**(rgb[c]-d)))
|
||||
elif rgb[c] > d:
|
||||
rgb[c] = int(rgb[c]*(-intensity**(-rgb[c]+d)+2))
|
||||
if rgb[c] > 255:
|
||||
rgb[c] = 255
|
||||
#rgb[min_idx] = int(rgb[min_idx]*(rgb[min_idx]/d)**2)
|
||||
print(rgb)
|
||||
return rgb
|
||||
|
||||
def ambient_light_thread():
|
||||
@ -89,11 +93,32 @@ def ambient_light():
|
||||
|
||||
global _r,_g,_b
|
||||
|
||||
bus = SessionBus()
|
||||
#RecorderPipeline = "vp8enc min_quantizer=10 max_quantizer=50 cq_level=13 cpu-used=1 deadline=1000000 threads=%T ! queue ! webmmux"
|
||||
GNOMEScreencast = bus.get('org.gnome.Shell.Screencast', '/org/gnome/Shell/Screencast')
|
||||
GNOMEScreencast.Screencast('/tmp/a', {})
|
||||
#GNOMEScreencast.StopScreencast()
|
||||
time.sleep(1)
|
||||
|
||||
while True:
|
||||
# screenshot
|
||||
img = pyscreenshot.grab(backend="mss", childprocess=False, bbox=(1920,0,4480,1440))
|
||||
|
||||
# find dominant color
|
||||
# Xorg
|
||||
#img = pyscreenshot.grab(backend="mss", childprocess=False, bbox=(1920,0,4480,1440))
|
||||
|
||||
#Wayland
|
||||
time.sleep(0.1)
|
||||
cap = cv2.VideoCapture('/tmp/a')
|
||||
count = cap.get(cv2.CAP_PROP_FRAME_COUNT)
|
||||
cap.set(cv2.CAP_PROP_POS_FRAMES, count-1)
|
||||
|
||||
ret, frame = cap.read()
|
||||
|
||||
frame = cv2.cvtColor(frame,cv2.COLOR_BGR2RGB)
|
||||
img = Image.fromarray(frame)
|
||||
cap.release()
|
||||
|
||||
|
||||
'''
|
||||
img = np.array(img)
|
||||
pixels = np.float32(img.reshape(-1, 3))
|
||||
@ -107,6 +132,7 @@ def ambient_light():
|
||||
_r,_g,_b = int(dominant[0]), int(dominant[1]), int(dominant[2])
|
||||
'''
|
||||
|
||||
# find dominant color
|
||||
img.thumbnail((1,1))
|
||||
r,g,b = img.getpixel((0, 0))
|
||||
_r,_g,_b = vibrant(r,g,b)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user