Skip navigation

img_0671
img_0687-eimg_0682img_0681

Above are some images of “Brighten Your Day!” at the Children’s Museum of Pittsburgh.

==============================================================

Description:

Have you ever wondered what it would be like if household products could see you and react to you? By using a machine learning library that detects people, their faces, and other qualities, this lamp is able to turn on and look at you when you look at it. However, the lamp will only respond to people who believe that it can come to life. Are you a believer?

==============================================================

Materials:

The mechanical components and wires were secured in a support structure made of MDF with a vacuum-formed plastic cover that I made for the installation.

Processing 1.0.1

Open CV Library

Webcam (Apple iSight from a MacBook Pro for the installation)

Breadboard (now Perfboard)

Servo

5 Volt Relay

Diode

22-Gauge Solid Wire

12 Volt Power Adapter

Desk Lamp

Extension Cord

USB Cable

Solder

==============================================================

Processing Code:

import processing.serial.*;
import hypermedia.video.*;
OpenCV opencv;
int contrast_value    = 0;
int brightness_value  = 0;
float A = 0;
Serial myPort;
void setup() {
size(1920,1200);
background(0);
opencv = new OpenCV( this );
opencv.capture( 180,135 );
opencv.cascade( OpenCV.CASCADE_FRONTALFACE_ALT );
println(Serial.list());
myPort = new Serial(this, Serial.list()[0], 9600);
}
public void stop() {
opencv.stop();
super.stop();
}
void draw() {
A+=15;
opencv.read();
opencv.convert( GRAY );
opencv.contrast( contrast_value );
opencv.brightness( brightness_value );
Rectangle[] faces = opencv.detect( 1.2, 2, OpenCV.HAAR_DO_CANNY_PRUNING, 40, 40 );
image( opencv.image(), 0, 0 );
noFill();
stroke(255,0,0);
for( int i=0; i<faces.length; i++ ) {
int faceX = (((int)(faces[i].x)));
rect( faces[i].x, faces[i].y, faces[i].width, faces[i].height );
println(faceX);
if((faces[i].y)>25){
if(faceX>=60 && faceX<=100){
myPort.write(faceX);
}
else if(faceX<50){
myPort.write(50);
}
else if(faceX>100){
myPort.write(100);
}
}
}
background(0);
noStroke();
smooth();
fill(random(50,255));
ellipse(width/2,height/2,15,15);
noFill();
noSmooth();
}
void mouseDragged() {
contrast_value   = (int) map( mouseX, 0, width, -128, 128 );
brightness_value = (int) map( mouseY, 0, width, -128, 128 );
}

import processing.serial.*;

import hypermedia.video.*;

OpenCV opencv;

int contrast_value    = 0;

int brightness_value  = 0;

float A = 0;

Serial myPort;

void setup() {

size(1920,1200);

background(0);

opencv = new OpenCV( this );

opencv.capture( 180,135 );

opencv.cascade( OpenCV.CASCADE_FRONTALFACE_ALT );

println(Serial.list());

myPort = new Serial(this, Serial.list()[0], 9600);

}

public void stop() {

opencv.stop();

super.stop();

}

void draw() {

A+=15;

opencv.read();

opencv.convert( GRAY );

opencv.contrast( contrast_value );

opencv.brightness( brightness_value );

Rectangle[] faces = opencv.detect( 1.2, 2, OpenCV.HAAR_DO_CANNY_PRUNING, 40, 40 );

image( opencv.image(), 0, 0 );

noFill();

stroke(255,0,0);

for( int i=0; i<faces.length; i++ ) {

int faceX = (((int)(faces[i].x)));

rect( faces[i].x, faces[i].y, faces[i].width, faces[i].height );

println(faceX);

if((faces[i].y)>25){

if(faceX>=60 && faceX<=100){

myPort.write(faceX);

}

else if(faceX<50){

myPort.write(50);

}

else if(faceX>100){

myPort.write(100);

}

}

}

background(0);

noStroke();

smooth();

fill(random(50,255));

ellipse(width/2,height/2,15,15);

noFill();

noSmooth();

}

void mouseDragged() {

contrast_value   = (int) map( mouseX, 0, width, -128, 128 );

brightness_value = (int) map( mouseY, 0, width, -128, 128 );

}

==============================================================

Arduino Code:

#include <Servo.h>

int incomingByte = 0;

Servo myservo;

int pos = 0;

int ledPin = 11;

int value = LOW;

long previousMillis = 0;

long interval = 1000;

void setup()

{

pinMode(ledPin, OUTPUT);

myservo.attach(9);

Serial.begin(9600);

}

void loop()

{

if (Serial.available() > 0)  {

incomingByte = Serial.read();

if (incomingByte>50 && incomingByte<100){

value = LOW;

digitalWrite(ledPin, value);

}

else{

value = HIGH;

digitalWrite(ledPin, value);

}

}

Serial.println(incomingByte);

myservo.write(incomingByte*.75);

}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: