Beispiel #1
0
    def __init__(self, feature_list, std):
        self.matrix_size = (15, 20)
        self.backgrounder = Backgrounder(std, self.matrix_size)
        self.curr_off_pixels = []
        self.curr_object_pixels = []

        self.curr_color = cbf.get_emotion_color_by_angle(60)
        self.hex_array = cbf.to_hex_array(cbf.gaussian_color_matrix(self.curr_color, std=std, size=self.matrix_size))
        self.enabled_features = {}

        self.timer = TimeQuantizer()

        config = configparser.ConfigParser(allow_no_value=True)
        config.optionxform = str
        config.read(config_file)

        self.numpixels = 300
        self.strip = TestStrip(numpixels=self.numpixels)

        self.magnituder = FluxMagnituder(self.strip)
        self.rasta_shower = CoefficientShower(self.strip, len(smile_rastas))
        rec6 = Rectangle(visualizer=self, coordinate=(10, 6), size=(3, 3), led_strip=self.strip, color=yellow)

        self.objects = [rec6]

        for key in config['features']:
            if int(config['features'][key]) == 1 and key in feature_list:
                self.enabled_features[key] = feature_list.index(key)

        print('Enabled Features: ', self.enabled_features)
        self.feature_maxima = np.zeros(len(feature_list))
Beispiel #2
0
    def __init__(self,
                 feature_list,
                 std,
                 led_strip,
                 vis_type=VisualizerTypes.Rasta):
        self.matrix_size = (15, 20)
        self.backgrounder = Backgrounder(std, self.matrix_size)
        self.curr_off_pixels = []
        self.curr_object_pixels = []
        self.type = vis_type

        self.curr_color = cbf.get_emotion_color_by_angle(60)
        self.hex_array = cbf.to_hex_array(
            cbf.gaussian_color_matrix(self.curr_color,
                                      std=std,
                                      size=self.matrix_size))

        self.timer = TimeQuantizer()

        config = configparser.ConfigParser(allow_no_value=True)
        config.optionxform = str
        config.read(config_file)

        self.numpixels = 300
        self.strip = led_strip
        self.rec = Rectangle(visualizer=self,
                             coordinate=(10, 6),
                             size=(3, 3),
                             led_strip=self.strip,
                             color=yellow)
        if self.type == VisualizerTypes.BouncingSquare:
            self.objects = [self.rec]

        self.enabled_features = EnabledFeatures(config, feature_list)
        print('Enabled Features: ', self.enabled_features.list())

        self.feature_maxima = np.zeros(len(feature_list))

        self.rasta_shower = CoefficientShower(self.strip, len(HLDs.rastas))
        if self.type == VisualizerTypes.Rasta:
            self.objects = [self.rasta_shower]

        # if self.type == VisualizerTypes.Magnituder:
        self.magnituder = FluxMagnituder(self.strip)
import visualizer.color.utils as cb
from dotstar import Adafruit_DotStar

black = 0x000000
blue = cb.to_hex_color(cb.get_emotion_color_by_angle(220))


class MoodSlider:
    def __init__(self):
        self.matrix_size = (15,20)
        self.color_array = [black for _ in range(self.matrix_size[0])]
        self.curr_color = black
        self.strip = led_strip(300)

    def slide(self, arousal=None, valence=None):

        self.color_array[1:] = self.color_array[0:-1]
        if (arousal is None) and (valence is None):
            self.color_array[0] = self.curr_color
        else:
            self.curr_color = cb.to_hex_color(cb.get_emotion_color(arousal, valence))
            self.color_array[0] = self.curr_color

        self.refresh()


    def refresh(self):
        for i in range(300):
            self.strip.setPixelColor(i, self.color_array[int(i/self.matrix_size[1])])

        self.strip.show()
Beispiel #4
0
import numpy as np
import time
import random
from threading import Thread
from queue import Queue

import abc

import visualizer.color.utils as cb

red = cb.to_hex_color(cb.get_emotion_color_by_angle(120))
green = cb.to_hex_color(cb.get_emotion_color_by_angle(0))
blue = cb.to_hex_color(cb.get_emotion_color_by_angle(220))


class BaseObject:
    def __init__(self, visualizer, coordinate, led_strip, color=red):
        self.vis = visualizer
        self.x = coordinate[0]
        self.y = coordinate[1]
        self.color = color

        self.strip = led_strip
        self.directions = ['up', 'down', 'left', 'right']

        self.current_pixels = self.object_to_pixels()

        self.energy_mean = 1
        self.decay = 0.95

        self.movements = Queue()
Beispiel #5
0
import configparser
import numpy as np

import visualizer.color.utils as cbf
from utility.time_quantizer import TimeQuantizer
from visualizer.backgrounds.background import Backgrounder
from visualizer.patterns.flux_magnituder import FluxMagnituder
from visualizer.patterns.rectangle_object import Rectangle
from visualizer.patterns.spectrum import CoefficientShower
from visualizer.smile_features import HLDs, EnabledFeatures

black = 0x000000
blue = cbf.to_hex_color(cbf.get_emotion_color_by_angle(220))
yellow = cbf.to_hex_color(cbf.get_emotion_color_by_angle(60))

config_file = "visualizer_conf.ini"


class VisualizerTypes:
    BouncingSquare = "Normal",
    MultiBouncingSquare = "multi"
    Rasta = "rasta"
    Magnituder = "magnituder"


class Visualizer:
    def __init__(self,
                 feature_list,
                 std,
                 led_strip,
                 vis_type=VisualizerTypes.Rasta):