ITP Class Blog

Final Project #3

Posted: May 5th, 2010 | Author: Candice | Filed under: Phys Comp 10 | No Comments »

During the weekend before the final class, I was on the 34th Street N/Q/R/W platform and saw someone playing with the public art installation. It inspired me to streamline what I was trying to do. It really could be as simple as entering the frame was the trigger and to step out would go back to the static silence.

I spent the last week of working on the project trying to figure out the array. I ended up going to Dan Shiffman for help on that and advice on how to improve my camera detection code. I was happy with the final product and think it could be fun to play with it in a different space further.

Haring Rocker Demo from Candice on Vimeo.

The final code:


//initialize camera reading - with Processing book example 16.2
import processing.video.*;
Capture video;
PImage backgroundImage;
float threshold = 50;

//graphics soundtrack
import ddf.minim.*;
Minim minim;
AudioPlayer song1;
AudioPlayer song2;

//imported graphics
PImage staticimg;
PImage[] images = new PImage[6];
//rows of haring image
int unit = 100;
int num;
Row [] rows;

//SETUP
void setup(){
size (500,500);
//initialize cam
video = new Capture (this, width, height,30);
backgroundImage = createImage (video.width,video.height,RGB);

// this loads song from the data folder
minim = new Minim(this);
//Calvin Harris, Neon Rocks - instrumental version
song1 = minim.loadFile("neonrocks.wav");
//from: http://www.freesound.org/samplesViewSingle.php?id=453
song2 = minim.loadFile("static.wav");

//call images
staticimg = loadImage ("static-poster.jpg");
images[0] = loadImage ("blue_shape.png");
images[1] = loadImage ("green_shape.png");
images[2] = loadImage ("purple_shape.png");
images[3] = loadImage ("magenta_shape.png");
images[4] = loadImage ("red_shape.png");
images[5] = loadImage ("yellow_shape.png");

// //haring rows
num = width/unit * width/unit;
rows = new Row [num];

for (int i = 0; i < height/unit; i++) {
for (int j = 0; j int index = (i * height/unit) + j;
rows[index] = new Row(j*unit, i*unit, unit/2, unit/2);
}
}
}

void draw(){
background(0);

// Capture video
if (video.available()) {
video.read();
}
//loading sets of pixels
loadPixels();
video.loadPixels();
backgroundImage.loadPixels();

int counter = 0;

// Begin loop to walk through every pixel
for (int x = 0; x < video.width; x ++ ) {
for (int y = 0; y < video.height; y ++ ) {
int loc = x + y*video.width; // Step 1, what is the 1D pixel location
color fgColor = video.pixels[loc]; // Step 2, what is the foreground color

//recall the background color
color bgColor = backgroundImage.pixels[loc];

// Step 4, compare the foreground and background color
float r1 = red(fgColor);
float g1 = green(fgColor);
float b1 = blue(fgColor);
float r2 = red(bgColor);
float g2 = green(bgColor);
float b2 = blue(bgColor);
float diff = dist(r1,g1,b1,r2,g2,b2);

// how much is the difference
if (diff > threshold) {
// If so, display the foreground color
counter++;
} }
}
updatePixels();

println(counter);

if (counter > 2500) {
for (int i = 0; i< num; i++){
rows[i].display();
rows[i].move();
song1.play();
song2.pause();
println("haring");
}

} else {
image (staticimg, 0,0);
song2.play();
song1.pause();
song1.rewind();
println("static");
}
}

void mousePressed() {
backgroundImage.copy(video,0,0,video.width,video.height,0,0,video.width,video.height);
backgroundImage.updatePixels();
}
class Row{
float mx, my;
int size = unit;
float x, y = 0;
float ydirection;
float yspeed;

int whichImage;

Row (float imx, float imy, float ix, float iy) {
ydirection = 5;
yspeed = 5;
mx = imy;
my = imx;
x = int(ix);
y = int(iy);

whichImage = int(random(6));
}

void move(){
my = my + yspeed;
if (my > height) {
my = 0;
}
}

void display(){

image (images[whichImage], mx, my);
}
}


Final Project #2

Posted: April 20th, 2010 | Author: Candice | Filed under: Idea Box, Phys Comp 10 | No Comments »

After spending some time thinking about it more, the project has shifted slightly. The sensor started to seem more than a little redundant, so the monitor and camera are the only parts.

The off state will be a silent static screen:

And when someone (or -thing) enters the frame, it will trigger falling objects inspired by this Haring print and scored to this song’s instrumental:

My big challenge right now is importing the objects as different pngs into an array and having them show up in random groupings. I might have to tweak that idea a bit or have them operating under different speeds to achieve what I want.

I was also kicking around the idea of having the objects bounce off of the blob if they meet and a sound accompanying that, but that’s a like to have, not a must have. I’m focusing on making sure I get the main point working.


Final Project Idea

Posted: April 13th, 2010 | Author: Candice | Filed under: Idea Box, Phys Comp 10 | No Comments »

My idea for the final project is something I’ve been kicking around for a long time. Last semester in ICM, I wanted to play around with video, but my skills in Processing never progressed much further than making a lot of balls bounce. Ironically, I feel that P-Comp has made me more comfortable in programming and it doesn’t all seem as foreign as it used to. (Yet another reason why I’m glad I split the two classes into different semesters. I know my head was spinning too hard in the fall to let much sink in at the time.)

When I talked about it in class last week, I wanted to have 2 sensors (one above, one in front) that would play sounds depending on where the user’s placement (i.e. height relative to the one above and closeness to the front sensor) with light playing a decoy controller. As I’ve thought about it since, I’ve become interested in having the project be more visually compelling.

The refined idea is a monitor mounted on the wall, connected to a camera and sensor (and also probably via a Mac mini). The off state is a black and white static animation playing on the monitor. The camera will be set up to detect a blob entering the frame and that will trigger a series of lines (or shapes) that play on screen. As the person moves closer or farther away from the camera/monitor, the sensor mounted below will adjust the direction of the shapes/lines. Alternately, the sensor below could also be the initial trigger (i.e. someone entering the range of the camera) and the camera could detect the size/closeness to change what is seen.

I think a funhouse mirror effect could be fun. I want the colors on all of it to be really bold, perhaps Keith Haring pop art style.

My biggest dilemma is what kind of sensor to use. If I go the below sensor as the initial switch route, a photodiode might do the trick. I was looking on the sensor wiki and thought the GP2D120 might work for me also. I guess that’s something I can work out in class on Wednesday.


Section #2 Project: Bubble Wand

Posted: April 8th, 2010 | Author: Candice | Filed under: Idea Box, Phys Comp 10 | No Comments »

For the serial section, I was interested in creating some sort of game or toy. My initial sketches had me considering a game of pool or skee ball and a maze before I settled on something I figured I could actually program relatively easily: a bubble wand.

I created a sketch in Processing to get a feel for what I wanted to accomplish before adding on the Arduino and analog inputs.

From there, I bought an accelerometer from Radio Shack. That ended up being a big mistake in retrospect because it was about $20 more than I would’ve spent at the NYU computer store and was only a dual-axis one instead of triple. I wired it up to my Arduino and breadboard and programmed the Arduino.

I decided to nestle it in the back of a stuffed duck I bought. That would be the controller of the wand on screen.



From the start, I had problems with getting the readouts from the accelerometer to plug into the x and y positions of the wand. I had to edit the range to correspond with the sketch size more, but it never was quite able to move as well as it did when I had the wand moving with the mouse.

If I had the chance to refine this, I would probably have added the tilt output to the Arduino to see if that helped movement at all. Or switched out the accelerometer to the triple axis one.


Section #1 Project: The Silent Alarm

Posted: March 29th, 2010 | Author: Candice | Filed under: Idea Box, Phys Comp 10 | No Comments »

I was inspired for this project by an episode of this show I watch regularly called White Collar. One of the main characters has a monitoring bracelet and a plot point in the story involved him cutting the circuit to use morse code to communicate a message with it.

I started thinking about ways to send out messages via input and came to the idea of a silent alarm trigger, that would communicated SOS in morse code when triggered. My initial idea involved whisker switches and promixity, but I decided to rein myself in with something simple but as effective. For this build, I started with a push button switch, 3 LEDs, resistors/regulators/wires/etc, and my Arduino hooked up to my laptop.

I ran into a few problems pretty quickly:
1) There wasn’t enough power going to all 3 of the LEDs. I could get the outer ones to glow very brightly but the middle one was very dim.
2) The code itself. Doing the SOS signal was quite beyond me. I was able to program the code I wanted, but not be able to figure out the delay to do like I wanted to without it replaying the sequence and ignoring my inputs all together.

I had to make some compromises to get it all to work. I experimented with wiring to see if I could get more juice to the middle one. And gave it up after blowing out a few LEDs and decided to settle with 2. As for the code, I removed the morse code aspect and decided to settle for having the program acknowledge the 3 inputs to make the lights do a smaller less complicated sequence.

I’ve been considering revisiting this to get it more aligned with my original idea.


Adventures With LEDs and Switches

Posted: February 16th, 2010 | Author: Candice | Filed under: Phys Comp 10 | No Comments »

My first biggest difficulty in class was figuring out how soldering worked. First semester at ITP (plus years and years of staring at screens until I got a headache) basically ruined my vision which didn’t help matters. But, one extremely enlightening help session later (put solder on before heating wires!), I finally got the hang of it. Then it was on to figuring out how to wire things up.

I started with the basic examples from the labs, substituting a 9V battery for a DC power source.

A simple circuit:

Adding a switch to the process:

Two LEDs on one switch:

I found that when I ran into trouble just taking the time to make sure that everything was aligned right would fix it. I ran into a wall trying to get the 2 LEDs working and then I discovered that I had one of the legs on the diode facing the wrong way. Once that was fixed, voila success!
Fun With LEDs and Switches


Intro To Phys Comp

Posted: January 22nd, 2010 | Author: Candice | Filed under: Phys Comp 10 | No Comments »

The questions I had to field about my schedule constantly over the first semester were “they actually let you not take P-Comp the first semester? When are you going to do it?” My answers were: “yeah, why not? You do make your own schedule” and “since never isn’t actual option, spring I guess.” So here I am taking P-Comp at 9:30am on Wednesdays.

I’ll admit that this was the class that terrified me the most as I prepared (or didn’t, as the case might be) for ITP. I’m not especially handy and the horror stories about parts and the cost scared me a little. Still, I’m going into this with an open mind and the hopes I don’t solder myself to a table or something.