**Heart Eyes**

Screen Shot 2014-04-13 at 2.49.53 PMScreen Shot 2014-04-13 at 2.45.08 PM

For this assignment, I wanted play with something that tracks your eyes and places hearts above them, similar to the popular heart eyes emoticon.persons-0007  I tried using the eye detector codes that were up online.. But I couldn’t get any of them to work. I also tried to somehow manipulate the face detection coding.. But that also wasn’t working..  I was getting very annoyed and defeated so I left it alone for awhile and then came back to it and decided to just fiddle with the tracking color.  This however also gave me some problems.  It didn’t help that my hair color is very similar to my eye color at this point in time.. So I had to resort to covering my hair to some degree.. Work can still be done to it… It doesn’t work amazingly, but it’s decent.

 

PImage heart; 
import processing.video.*;
Capture video;
color trackColor; 

void setup() {
  size(640, 480);
  video = new Capture(this, width, height);
  video.start();
  trackColor = color(255, 0, 0);
  heart = loadImage("heart.png");

}

void draw() {
  if (video.available()) {
    video.read();
  }
  video.loadPixels();
  image(video, 0, 0);

  float worldRecord = 1000; 

  int closestX = 0;
  int closestY = 0;

  for (int x = 0; x < video.width; x ++ ) {
    for (int y = 0; y < video.height; y ++ ) {
      int loc = x + y*video.width;
      color currentColor = video.pixels[loc];
      float r1 = red(currentColor);
      float g1 = green(currentColor);
      float b1 = blue(currentColor);
      float r2 = red(trackColor);
      float g2 = green(trackColor);
      float b2 = blue(trackColor);

      float d = dist(r1, g1, b1, r2, g2, b2); 

      if (d < worldRecord) {
        worldRecord = d;
        closestX = x;
        closestY = y;
      }
    }
  }

  if (worldRecord < 1000) { 
    fill(trackColor);
    image(heart, closestX,closestY, 150, 150);
    image(heart, closestX+200,closestY, 150, 150);

  }
}

void mousePressed() {
  int loc = mouseX + mouseY*video.width;
  trackColor = video.pixels[loc];
}

 

Leave a Reply