All posts by Abi

About Abi

ヾ(*´∇`)ノ

brightness & tint

is this the right section? i’m not sure. here is one of the things i tried to do with video this week, which is to change the tint of the video depending on the amount of brightness change. i also made a few other programs that all add a video filter type of thing depnding on motion, but haven’t been able to do anything very interesting. what i really want right now is to change the tint of the whole video to different colors depending on location of the movement on the screen. this is really just mr. shiffman’s example of total motion

brightness tint video

import processing.video.*;

Capture video;
PImage prevFrame;
float threshold = 50;

void setup() {
  size(1280,720);
  video = new Capture(this, width, height, 15);
  prevFrame = createImage(video.width,video.height,RGB);
  video.start();
}

void draw() {
  background(0);

  image(video,0,0);

  if (video.available()) {
    prevFrame.copy(video,0,0,video.width,video.height,0,0,video.width,video.height);
    prevFrame.updatePixels();
    video.read();
  }

  loadPixels();
  video.loadPixels();
  prevFrame.loadPixels();

  float totalMotion = 0;

  for (int i = 0; i < video.pixels.length; i ++ ) {
    color current = video.pixels[i];

    color previous = prevFrame.pixels[i];

    float b1 = brightness(current); 
    float b2 = brightness(previous);
    float diff = dist(b1,b1, b2, b2);
    totalMotion += diff; 
  }

 float avgMotion = totalMotion / video.pixels.length; 

//change tint depending on how much motion there is
 tint(avgMotion*4, 0, avgMotion*4);

}

 

plus-plus drip

i recently joined a multimedia artist collective and i’ve been working on visuals for it. it’s called the ++ collective. please watch the sketch at the following link:

https://vimeo.com/89892527

 

Plus1[] p1 = new Plus1[75];
Plus2[] p2 = new Plus2[75];
PImage plus1;
PImage plus2;
PImage plusfill;

void setup() {
  background(255);
  size(1280, 720);

  for (int i = 0; i < p1.length; i++) {
    p1[i] = new Plus1(i *4 );
  }

   for (int i = 0; i < p2.length; i++) {
    p2[i] = new Plus2(i *4 );
  }
}

void draw() {

  for (int i = 0; i < p1.length; i++) {
  p1[i].drawplus1();
  p1[i].move();
  p1[i].bottom();
  }

  for (int i = 0; i < p2.length; i++) {
  p2[i].drawplus2();
  p2[i].move();
  p2[i].bottom(); 
}

PImage plusfill = loadImage("plusfill.png");
image(plusfill, 0, 0, 1280, 720);

}

class Plus1 {

  float x;
  float y;
  float size;
  float yspeed;
  float xspeed;
  PImage plus1 =loadImage("plus1.png");

  Plus1(float tempD) {
    x = random(width);
    y = 0;
    size = tempD;
    yspeed = random(0.5, 2.5);
  }

  void drawplus1() {
    smooth();
    image(plus1, x, y-25, 50, 50);
  }

  void move(){
   y = y + yspeed/2;
   x = x + random(-2, 2);
  }

  void bottom() {
    if (y > height) {
      y = 0;
    }
  }
}

class Plus2 {

  float x;
  float y;
  float size;
  float yspeed;
  float xspeed;
  PImage plus2 = loadImage("plus2.png");

 Plus2(float tempD) {
    x = random(width);
    y = 0;
    size = tempD;
    yspeed = random(0.5, 2.5);
  }

  void drawplus2() {
    smooth();
    image(plus2, x, y-25, 50, 50);
  }

  void move(){
   y = y + yspeed/2;
   x = x + random(-2, 2);
  }

  void bottom() {
    if (y > height) {
      y = 0;
    }
  }
}

 

Animated Eyes

I wanted to make something interactive, so I made eyes that blink with the mouse movement. I dunno, it got a little weird. You can see it here.

 

float rectX;
float xspeed = 10;
float rectY;
float yspeed = 10;

void setup(){
  size(720, 480);
  smooth();
  rectY = 0;
}

void draw(){
  background(255, 230, 240);
  stroke(0);
  fill(255);

 //eyeball
  fill(random(230,255), random(100, 230), random(200, 255));
  rect(200, 125, 100, 200);
  rect(400, 125, 100, 200);

 //pupil
 if (mouseY < 125){
  noStroke();
  fill(mouseY, 230, mouseX);
  ellipse(260, 250, 75, 130);
  ellipse(460, 250, 75, 130);
 }

 else if ((mouseY > 125) && (mouseY < 250)){
  noStroke();
  fill(mouseY, 230, mouseX);
  ellipse(250, 250, 75, 130);
  ellipse(450, 250, 75, 130);
 }

 else if (mouseY > 250){
  noStroke();
  fill(mouseY, 230, mouseX);
  ellipse(240, 250, 75, 130);
  ellipse(440, 250, 75, 130);
 }

 //eyelid
  if ((mouseY > 125) && (mouseY < 325)){
    fill(255, 230, 240);
    noStroke();
    rect(195, mouseY-250, 110, 250);
    rect(395, mouseY-250, 505, 250);
    stroke(0);
    line(180, mouseY, 320, mouseY); 
    line(380, mouseY, 520, mouseY);
  }

  else if (mouseY >= 325){
    noStroke();
    fill(255, 230, 240);
    rect(195, 120, 320, 325);
    rect(395, 120, 520, 325);
    stroke(0);
    line(180, 325, 320, 325);
    line(380, 325, 520, 325);
  }

  else if (mouseY <= 125){
    stroke(0);
    line(180, 125, 320, 125);
    line(380, 125, 520, 125);
  }

  if (keyPressed){
   if (key == 'a'){
    noStroke();
    fill(255, 230, 240);
    rect(180, 120, 150, 325);
    stroke(0);
    line(180, 325, 320, 325);
   }
  }

  //bouncing bar
  fill(random(230,255), random(100, 230), random(200, 255));
  noStroke();
  rect(rectX, random(rectY), 30, 30);
  rect(random(rectX), rectY, 30, 30);
   rectX = rectX + xspeed;
   rectY = rectY + yspeed;

if((rectX > width) || (rectX < 0)){
    xspeed = xspeed * -1;
  }

if((rectY > height) || (rectY < 0)){
    yspeed = yspeed * -1;
  }

}

 

A Salute to Arduino

saluteFor this project I used a flex sensor attached to the inside of my elbow to tell a servo motor where to point. When my arm is down, it commands me to salute. When I salute, it tells me to be at ease.  You can watch the video but it’s essentially the same as the gif.

//control a servo position using a flex sensor

#include <Servo.h> //import servo library

Servo myservo;  //create servo object to control a servo

int flexpin = 0;  //flex sensor connected to analog pin 0
int val; //variable for reading analog pin

void setup() {
  Serial.begin(9600);
  myservo.attach(9); //attaches the servo to pin 9
}

void loop() {
  val = analogRead(flexpin);  //read value of flex sensor (between 0 and 1023)
  val = map(val, 0, 1023, 0, 179);  //scale it to use with servo (0 and 180 degrees)
  Serial.println(val); //print the scaled read from the analog pin
  myservo.write(val);  //set the servo position according to the scaled value
  delay(15);   //wait for the servo to move
}

 

Mother and Baby Sphere in the Playroom

For my design I tried using some animation and some 3D shapes. I don’t have a solid grasp of it yet but I got something working. View it on my website.

float a = 0.0;

void setup() {
  size(720,480, P3D);
}

void draw() {
  background(149,255,224);

  fill(253,216,235);
  noStroke();
  rect(100,90,100,100);

  a += 0.005;
  if(a > TWO_PI) {
    a = 0.0;
  }

  translate(370,250,0);
  rotateY(a);
  stroke(255);
  noFill();
  box(200);

  translate(0, 0, 0);
  rotateY(a * 2);
  noFill();
  sphereDetail(7);
  sphere(100);

  translate(200,0,0);
  rotateY(a * 2);
  noFill();
  sphereDetail(7);
  sphere(50);
}

 

Five Finger Switch

The idea behind my switch is that it is a hand, with each finger switching on a different LED when combined with the thumb. The metal bits are meant to go on the tips of the fingers of one hand. The red wire is the thumb, going down to the pinky with the green wire. When you touch your thumb and pointer finger, the red LED comes on, thumb + middle finger = blue LED, etc. A combination of fingers will turn on a combination of LEDs, but the combination must include the thumb.  I got this idea with the hopes of making it into gestural video art. Instead of LEDs, the combination of fingers would turn on different videos, or layer them in different combinations.

five finger_1

five finger_2

video

the code:

void setup(){
pinMode(7,OUTPUT);
pinMode(6,INPUT);
pinMode(9,OUTPUT);
pinMode(8,INPUT);
pinMode(11,OUTPUT);
pinMode(10,INPUT);
pinMode(13,OUTPUT);
pinMode(12\,INPUT);
}

void loop(){

if (digitalRead(6) == HIGH){
digitalWrite(7,HIGH);
}
else {
digitalWrite(7,LOW);
}

if (digitalRead(8) == HIGH){
digitalWrite(9,HIGH);
}
else {
digitalWrite(9,LOW);
}

if (digitalRead(10) == HIGH){
digitalWrite(11,HIGH);
}
else {
digitalWrite(11,LOW);
}

if (digitalRead(12) == HIGH){
digitalWrite(13,HIGH);
}
else {
digitalWrite(13,LOW);
}
}

 

where the f**k are my keys

When you place your keys on the hook, the LED lights up. The hook is made a bit springy because of the wire inserted behind it, so the weight of the keys hanging weighs it down enough to touch the aluminum foil plate behind it, attached to the “wall.” This sexy box is meant to simulate a wall that the hook and keys would be on. Ideally, this setup would be located near your front door to remind you not to leave your keys behind, as my boyfriend did after class last week and called me to whine about being locked out.

the guts no keys keys guts in a box