Category Archives: project-1

Andy

28 Jan 2013

Github: https://github.com/andybiar/SpongeFaceOSC

My FaceOSC project uses Open Sound Control to transmit the parameters of my face via the internet to my Processing sketch. My sketch uses the eyebrow and mouth data to determine the size of the alpha mask over an image of Spongebob Squarepants. Only when I am closest to the camera and my face is ridiculously wide open can I see the image in its entirety, at which point Spongebob’s laughter is triggered. Is he laughing at you, or with you?

faceOSC

P1C – FaceOSC

This is an interesting interface enable you to change your face like a Sichuan Opera Pro. You can also learn more about the story plot and history behind that face. – just use your cell phone scan the QR code below.

Screen Shot 2013-01-28 at 8.06.43 AM

The QR code in the left bottom links to a crowdsourcing knowledge tank that you can learn about or contribute the knowledge about one specific role in the opera. The idea is to provide a simple and instant way to knowledge, but currently it is just my Facebook photo album. : P

Elwin

28 Jan 2013

p1_text
Letters (OOP) will fall down from a random position and stops when it “collides” with an object.
The letters will also trace around an object’s edge through an algorithm that pushes the letter
upwards by checking the brightness of the vertical pixels above it.

Githun link: https://github.com/BlueSpiritbox/p1_textrain

import processing.video.*;

PFont f;

Capture video;
Letter[] letters;


int w = 640;
int h = 480;

String message = "For Part B of this assignment, you are asked to implement “Text Rain” in Processing. Reimplementing a project like this can be highly instructive, and test the limits of your attention to detail.";


color thresholdColor;


void setup() {
  size(w, h);  //window size
  
  f = createFont("Arial", 16, true);
  textFont(f);
  
  letters = new Letter[message.length()];
  for( int i = 0; i < message.length(); i++ ) {
    letters[i] = new Letter( random(0,width), 0, message.charAt(i) );
  }

  //Checks which cameras are available
  //  String[] cameras = Capture.list();
  //  if (cameras.length == 0) {
  //    println("There are no cameras available for capture.");
  //    exit();
  //  } else {
  //    println("Available cameras:");
  //    for (int i = 0; i < cameras.length; i++) {
  //      println(cameras[i]);
  //    }
  //  }  
  
  video = new Capture(this, w, h, 30); //initiates capture
  video.start();  //starts capturing video

  smooth();
}

void draw() {
  if ( video.available() ) {
    video.read();  //reads video input
  }

  image(video, 0, 0);  //displays video image

  for( int i = 0; i < message.length(); i++ ) {
    letters[i].update();
    letters[i].display();
  }
}


class Letter {

  char letter;
  float x, y;
  int velocity;
  int brightnessThreshold = 150; 
  
  long start;
  long delay;
  float life = 255;
  boolean dying = false;
  
  Letter( float _x, float _y, char _letter ) {  //creates Letter instance
    x = _x;
    y = _y;
    letter = _letter;
    velocity = round(random(1,3));
    life = round(random(100,256));
    
    start = millis();
    delay = round(random(500,10000));  //delay when letter falls at the beginning
  }
  
  void display() {  //displays Letter
    fill(100, life);
    text(letter, x, y);
  }
  
  void update() {  //update letter variables

    if( y >= height ) {  //reset if letter at the bottom
      x = random(0,width);  //give random x position
      y = 0;
      
    } else {
      if( brightness(video.pixels[round(x+y*width)]) < brightnessThreshold ) {  //if letter position is dark, stop letter

        //algorithm to push letter up to follow the "edge"
        if( y > 0 && y != 0) {  //only push up if y pos is not at 0
          float _y = y;  //temp y
          
          for( int i = int(y); i > 0; i-- ) {  //look at every single pixel above letter
            if( brightness(video.pixels[round(x+i*width)]) > brightnessThreshold ) {  //if it is bright
              _y = i;  //make that new y position
              break;  //stop looking for next pixel
            }
          }
          y = _y;  //update y position
        }       
      } else {  //move letter down
        if ( (millis() - start) > delay) {  //delay
          y += 1;
        }
      } 
    }
  }
  
}

Elwin

28 Jan 2013

p1_faceosc
Hamburger eating contest using FaceOsc and Processing. It tracks the user’s mouth height until it reaches a threshold. You’ll take a bite out of the hamburger when you close your mouth again. The image sequence is stored in an array and is called according to the counter.

Future work would be to implement head position and show the bite with the corresponding location on the hamburger through image masking.

Github link: https://github.com/BlueSpiritbox/p1_faceosc-hamburgers

import oscP5.*;
OscP5 oscP5;

//our FaceOSC tracked face dat
Face face = new Face();

PFont f;
PImage bg, img, icon, startBtn;

String imgString;
int imgIndex = 0;
int imgLast = 8;
int burgerNumber = 3;  //number of hamburgers
float bgRotate = 0;

int startTime;
int currentTime;  
int maxTime = 60;    //time limit
String counter;

boolean playing = false;
boolean eat = false;
boolean readyToEat = false;
boolean finished = false;


void setup () {
  size(600, 480);
  frameRate(60);

  imgString = "hamburger-"+str(imgIndex)+".png";
  img = loadImage(imgString);
  bg = loadImage("bg.png");
  icon = loadImage("icon.png");
  startBtn = loadImage("start-button.png");

  f = createFont("Arial", 24, true);
  currentTime = maxTime;
  oscP5 = new OscP5(this, 8338);
}

void draw() {

  //background + rotation
  pushMatrix(); 
  translate(width/2, height/2);
  rotate(bgRotate*TWO_PI/360);
  bgRotate += 0.5;
  image(bg, -bg.width/2, -bg.height/2);
  popMatrix();


  img.resize(400, 400);  //resizes image
  image(img, (width/2)-(img.width/2), (height/2)-(img.height/2));  //puts hamburger image in the center

  //draw hamburger icons
  for ( int i=0; i 0) {
      if ( face.mouthHeight > 3 && !readyToEat) {
        println("Mouth Open");
        readyToEat = true;
      }
      if ( face.mouthHeight < 2 && readyToEat) {
        readyToEat = false;
        eatBurger();
      }
    }
  }
}

void eatBurger() {
  imgIndex += 1;  //next hamburger image
  if ( imgIndex == imgLast ) {
    checkBurgers();  //checks how many burgers are leftd
  }

  imgString = "hamburger-"+str(imgIndex)+".png";
  img = loadImage(imgString);
  println("Nom nom nom!");
}
void checkBurgers() {
  if ( burgerNumber != 1) {  //if 1 or more burgers left
    imgIndex = 0;          //reset to full burger
    burgerNumber--;        //minus 1 burger
  } 
  else {
    imgIndex = imgLast;      //blank image
    burgerNumber--;    //no more burgers left
    finished = true;
  }
}

void startButton() {
  cursor(HAND);
  fill(0, 170);
  rect(0, 0, width, height);
  image(startBtn, (width/2)-(startBtn.width/2), (height/2)-(startBtn.height/2));

  if ( mousePressed == true ) { 
    startTime = millis();
    cursor(ARROW);
    playing = true;
  }
}

void score() {
  fill(0);
  textFont(f, 64);
  textAlign(CENTER);
  text("Your score: "+currentTime+"!!", width/2, height/2+12);
}

void keyPressed() {    //hotkeys for testing purposes

  if ( playing ) {
    switch (key) {    //press 'a' to take a bite
    case 'a':
      if ( burgerNumber != 0 ) {
        eatBurger();
      }
      break;  
    default:  
      break;
    }
  }
}


// OSC CALLBACK FUNCTIONS
void oscEvent(OscMessage m) {
  face.parseOSC(m);
}

Elwin

28 Jan 2013

p1_ofx
I think this was the most difficult/annoying part of all the assignments. It was my first time using openFrameworks and I don’t really have experience with C++. I tried more than a dozen addons and most of them didn’t work. Lots of errors, missing links and empty projects. The ones that did work were relatively the same… I tried connecting several addons together but with no success. Finally, I just went for ofxMSAPhysics together with ofxMSACore & ofxMSAObjCPointer.

Elwin

28 Jan 2013

p1_sifteo
A very basic program utilizing the shake function of the Sifteo cubes. An animation is played after the cube has been shaken. The program is based on the Stars example.

This part was also tough because I never worked with the Sifteo SDK AND I don’t have any experience in C++. I took a fair amount of time just trying to understand the syntax and the way things are setup. I had some ideas before I dived into the Sifteo SDK, and I quickly realized that it would be very tough to get something working. Even getting an animation into the cube took quite some time due to the specifications of the sprite itself.

Github link: https://github.com/BlueSpiritbox/p1_sifteo


*Sorry for the sound. Wasn’t aware that it was recording from my mic as well.

Andy

28 Jan 2013

GitHub: https://github.com/andybiar/TextRain


import processing.video.*;

Capture cam;
PFont f;
PImage bg;
final int WIDTH = 640;
final int DARK_THRESHOLD = 120;
Letter[] fallers;
Letter[] droppers;
int dropCount = 0;
final String[] WORDS = {"H","i","m","y","n","a","m","e",
"i","s","A","n","d","y","B","i",
"a","r","a","d","I","l","i","k",
"e","t","o","m","a","k","e","t",
"h","i","n","g","s","f","o","r",
"p","e","o","p","l","e","t","o",
"d","i","s","c","o","v","e","r",
"w","i","t","h","f","u","n","!"};

void setup() {
size(WIDTH, 480);

String[] cameras = Capture.list();
if (cameras.length == 0) println("No cameras");
else cam = new Capture(TextRain.this, cameras[0]);
cam.start();

f = createFont("Verdana", 18, true);
textFont(f);
fill(10);

fallers = new Letter[WIDTH/10];
droppers = new Letter[WIDTH/10];
}

int nextDrop() {
if (dropCount >= WIDTH/10) return -1;

int rand = int(random(WIDTH/10));
while(fallers[rand] != null) {
rand = (rand + 1) % (WIDTH/10);
}

return rand;
}

void draw() {
// Get background from webcam
if (cam.available() == true) cam.read();
image(cam, 0, 0);
loadPixels();

// Drop a letter
if (dropCount < 64 && (millis() / 1000) > dropCount) {
int nextDrop = nextDrop();
if (nextDrop != -1) {
fallers[nextDrop] = new Letter(WORDS[nextDrop%WORDS.length],
nextDrop*10, 0);
}
dropCount++;
}

// Draw letters
for (int i = 0; i < fallers.length; i++) {
Letter n = fallers[i];
if (n != null) text(n.letter, n.x, n.y);
}

// Gravity
for (int i = 0; i < fallers.length; i++) {
if (fallers[i] != null) {
Letter a = fallers[i];
if (a.y >= height || a.y < 0) continue;
color c = pixels[WIDTH * a.y + a.x];
float r, g, b;
r = red(c); g = green(c); b = blue(c);
int brightness = int(.2989*r + .5870*g + .1140*b);
if (brightness > DARK_THRESHOLD) fallers[i].y += 1;
}
}

// Reset falling letters
for(int i = 0; i < fallers.length; i++) {
if (fallers[i] != null && fallers[i].y >= height) {
fallers[i].y = 0;
}
}
}

public class Letter {
public String letter;
public int x;
public int y;

public Letter(String letter, int x, int y) {
this.letter = letter;
this.x = x;
this.y = y;
}
}

I think Text Rain is one of my weaker projects in the upkit intensive, but here it is. I used an object-oriented approach, creating a Letter class which stored it’s x and y position as well as the character to be drawn. Other than that, my implementation is likely pretty vanilla – I used the Capture object to get pixels from the webcam, loaded them into an array, and read points under the letters for darkness above a certain threshold. Definitely a fun starter project! Also, this is the first time in my life I have ever intentionally not shaved my stache, and I think it looks pretty good in this photo:

textrain

Patt

28 Jan 2013

Sifteo_cs

While I think that Pittsburgh is trying to make up for its last ‘winter’, I have been inspired by the white snow everywhere I go this week. I modified the Stars example to make three snow globes for this Sifteo project. I used a photo of a mountain as the first layer background (bg0), and the photos of snow and a skating duck as sprites. The snow keeps falling every time the image is updated, but the duck stays stationary. If I had more time, I would like to either move the duck back and forth from one cube to another. I also want to produce more snow every time I shake the cubes. Oh, and I want to add an audio of the song ‘Let it snow’.

Here’s the code: https://github.com/pattvira/sifteoSnowglobe

John

28 Jan 2013

Screenshot_1_28_13_6_30_AMOh Sifteo, you are too cruel. Seriously, having never worked with any system remotely like this before, I found this project to be completely unapproachable. The documentation for the SDK is lacking and there is significant overhead to get started on these projects. I sort of feel like a solid foundational understanding of C++ is really the only way to travel in Sifteo world.

By the end I figured out the events system pretty well. My demo is a first foray into getting something up and running with (limited) intelligible value. Basically I’m displaying the accelerometer data coming off the cubes graphically. It’s a simple application to be sure, but it took my whole brain several hours to get this far!

Git it: https://github.com/johngruen/myFirstSifteo

Video pending Vimeo: https://vimeo.com/58357777

 

Ziyun

28 Jan 2013

 

TextRain_Processing from kaikai on Vimeo.

 

This was a very fun project for me. It’s the first processing sketch I wrote from scratch that does some relatively more complex things other then just drawing.