/* Final Project for Making Things Interactive Carnegie Mellon University Fall 2010 by Paulo Coelho */ import processing.serial.*; import processing.video.*; Capture v; color currColor; int fWidth = 28; boolean communicate = true; Serial myPort; void setup(){ //size(480,420); size(640,800); noStroke(); v = new Capture(this, 53, 40, 30); v.crop(10, 0, 32 , 40); loadPixels(); myPort = new Serial(this, Serial.list()[0], 9600); myPort.write("HI"); } void draw(){ if (v.available()) { v.read(); v.loadPixels(); processPixelatedImage(32,40); } } void processPixelatedImage(int dx, int dy){ int x = 0; int y = 0; for(int i=0;i 0xFF) vColor = 0xFF; fill(vColor); rect(x*20,y*20,20,20); if(x==dx-1){ x = 0; if(y==dy-1) y=0; else y ++; }else x ++; } } int colorizeImage(int currColor){ int currR = (currColor >> 16) & 0xFF; int currG = (currColor >> 8) & 0xFF; int currB = currColor & 0xFF; int BW = (currR+currG+currB)/3; int brighter = BW; return brighter; } void keyPressed() { int keyIndex = -1; if (key == 'a') { printValues(32,40); } if (key == 'b') { /*for(int i=0;i<200;i++){ myPort.write(i); delay(80); }*/ myPort.write(80); //print(hex(80,2)); } } void printValues(int dx, int dy){ int x = 0; int y = 0; //if(communicate) myPort.write(0xFFF); for(int i=0;i 0xFF) mc = 0xFF; print(mc); if(communicate){ myPort.write(mc); delay(1); } print(" "); if(x==dx-1){ x = 0; if(y==dy-1) y=0; else y ++; println(); //if(communicate) myPort.write(0xFF0); }else x ++; } //if(communicate) myPort.write(0x000); }