diff --git a/client/client.py b/client/client.py index 316f9c3..0ed0de5 100755 --- a/client/client.py +++ b/client/client.py @@ -3,7 +3,7 @@ import socket import getopt import sys import subprocess -#import pyscreenshot +import pyscreenshot #from PIL import Image, ImageDraw, ImageFont #import cv2 import numpy as np @@ -72,7 +72,7 @@ def get_base_color(color): _r,_g,_b = 0,0,0 def vibrant(r,g,b): - intensity = 1 # usabel range 1-100 max:1000 + intensity = 100 # usabel range 1-100 max:1000 intensity = 1+intensity/1000 rgb = [r,g,b] @@ -88,30 +88,31 @@ def vibrant(r,g,b): #rgb[min_idx] = int(rgb[min_idx]*(rgb[min_idx]/d)**2) return rgb +def p_controller(soll, ist, K): + return K*(soll-ist) + def ambient_light_thread(): r,g,b = 0,0,0 brighness = 1 while True: - - if r > _r: - r-=1 - elif r < _r: - r+=1 - - if g > _g: - g-=1 - elif g < _g: - g+=1 - - if b > _b: - b-=1 - elif b < _b: - b+=1 - - print(r,g,b) + # P-Regler + r,g,b = [w+((y-w)*0.05) for y,w in zip((_r,_g,_b),(r,g,b))] + print(int(r), int(g), int(b)) + print(_r,_g,_b) send(rgb_to_hex(int(r*brighness),int(g*brighness),int(b*brighness))) time.sleep(0.01) +ups_counter = 0 +start_time = time.time() +def ups(): + global ups_counter + global start_time + + ups_counter += 1 + time_d = time.time()-start_time + ups = ups_counter/time_d + print(ups) + def ambient_light(): t = Thread(target=ambient_light_thread) @@ -119,22 +120,10 @@ 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) - amp = [1,1,0.8] counter = 0 start_time = time.time() while True: - counter += 1 - time_d = time.time()-start_time - ups = counter/time_d - #print(ups) - # screenshot # Xorg @@ -152,22 +141,8 @@ def ambient_light(): #img = Image.fromarray(frame) #cap.release() - - ''' - img = np.array(img) - pixels = np.float32(img.reshape(-1, 3)) - img = cv2.UMat(img) - n_colors = 1 - criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 200, .1) - flags = cv2.KMEANS_RANDOM_CENTERS - _, labels, palette = cv2.kmeans(img, n_colors, None, criteria, 10, flags) - _, counts = np.unique(labels, return_counts=True) - dominant = palette[np.argmax(counts)] - _r,_g,_b = int(dominant[0]), int(dominant[1]), int(dominant[2]) - ''' - # find dominant color - img.thumbnail((1,1)) + img.thumbnail((2,2)) r,g,b = img.getpixel((0, 0)) _r,_g,_b = vibrant(r,g,b)