From c3aff0e659f9f3cd0f5e6b906436fb218ecc1dd9 Mon Sep 17 00:00:00 2001 From: Carmine De Rosa Date: Tue, 24 Sep 2019 17:05:45 +0200 Subject: [PATCH] made modular --- ephimera/ephimera.pde | 23 ++++++++++++++ ephimera/percentage.pde | 68 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 ephimera/ephimera.pde create mode 100644 ephimera/percentage.pde diff --git a/ephimera/ephimera.pde b/ephimera/ephimera.pde new file mode 100644 index 0000000..11870af --- /dev/null +++ b/ephimera/ephimera.pde @@ -0,0 +1,23 @@ +import processing.serial.*; +import processing.video.*; + +Capture video; + +int videoWidth = 640; +int videoHeight = 480; + +void setup() { + size(640, 480); + frameRate(10); + colorMode(HSB, 100, 100, 100); + + + video = new Capture(this, width, height); + video.start(); + + background(0); +} + +void draw() { + ephPercentage(); +} diff --git a/ephimera/percentage.pde b/ephimera/percentage.pde new file mode 100644 index 0000000..aff2290 --- /dev/null +++ b/ephimera/percentage.pde @@ -0,0 +1,68 @@ +int cellSize = 20; +int cols = videoWidth / cellSize; +int rows = videoHeight / cellSize; +int cellN = (cols)*(rows); +int[] colorValues = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + +void ephPercentage() { + + if (video.available()) { + video.read(); + video.loadPixels(); + + for(int i = 0; i 20 && briVal < 80) { + colorValues[int(hueVal/8.3)]++; + } else if(briVal <= 20) { + colorValues[12]++; + } else if(briVal >= 20) { + colorValues[13]++; + } + + pushMatrix(); + translate(x+cellSize/2, y+cellSize/2); + rectMode(CENTER); + fill(c); + noStroke(); + rect(0, 0, cellSize+6, cellSize+6); + popMatrix(); + } + } + + // Print colors percentage values + for(int i = 0; i