Saturday, 17 January 2015

Design Iterations - Face Tracking Project

Face Tracking Project - 6

Having created the particle system (see blog post Face Tracking - 5) there were three things left for me to do with this project. The first was to place the particle system within the installation, secondly modify the particle system so that it was a lot more random and lastly change the design of the particles. All of these tasks have been completed. 

The first task was completed by adding the code seen within the previous blog post into the code that I had already. At first it was not working, but this is because of the part of the code that actually runs the code was not placed in the correct place. Adding this code with in the circle void, which is as the name suggests the part of the code which deals with the circle, allows the particle system to begin running and also spawn from within the circle. 

The second and third tasks where done very easily. Firstly in terms of the redesign of the particles I wanted them to link to the main object so I have given each particle a random colour so that there is a link. Along with that to give them more life I have given them random sizes and made it so that there size with change throughout the particles life. This I believe adds more to the installation. In terms of the final task which was changing the physics that controls the particles, it was simply as case of trail and error until I found what I believed worked best. There is a much higher level of randomness to each particle unlike in the previous blog post, this has been done to simply breath more life into the installation and make it feel more alive.

A small example of how the installation works 

The Code 

import gab.opencv.*;
import java.awt.Rectangle;

OpenCV opencv;
Capture cam;
Rectangle[] faces;
Particle p;

PVector centreLeft, track;

boolean sketchFullScreen() {
  return true;

ArrayList<Particle> particles;

void setup() {
  //setting up the canvas and cam
  //size(1920, 1080);
  size(displayWidth, displayHeight);
  centreLeft = new PVector(587,191);
  cam = new  Capture(this, 700,500);
  opencv = new OpenCV(this, cam.width, cam.height);
  //declaring the particles arraylist
  particles = new ArrayList<Particle>();  
}//end of VoidSetup

void captureEvent(Capture cam) {;
}//end of void captureEvent

void draw() {
  faces = opencv.detect();
   //below is to with the face tracking  
   if (faces != null) {
    for (int i = 0; i < faces.length; i++) {
        track = new PVector(width-map(faces[i].width/2+faces[i].x,0,cam.width,0,width), map(faces[i].height/2+faces[i].y,0,cam.height,0,height)); 
      }//end of for
   }//end of if
}//end of void draw

class Particle {
  PVector location;
  PVector velocity;
  PVector acceleration;
  float lifespan;

  Particle(PVector l) {
    //the behaviour of the particles
    if (faces.length >=1){
      acceleration = new PVector(0,random(0.05,0.25));
      velocity = new PVector(random(-2.5,2.5),random(-2.5,2.5));
      location = l.get();
      lifespan = random(100,250);
    }//end of IF
   }//end of Particle(PVector)
  void run() {
    //this makes the particles actually run
   }//end of void run

  void update() {
    lifespan -= 3.0;
   }//end of void update

  void display() {
    //the visual aspects of each particle
  }//end of void display

  boolean isDead() {
    //ensuring that when the particles lifespan has finished it goes of the screen
    if (lifespan < 0.0) {
      return true;
    } else {
      return false;
  }//end of boolean
}//end of class Particle

void circle(){
  //tracking for the circle
  PVector newLocLeft = track.get(); 
  //below is the code for the main circle
  ellipse(newLocLeft.x, newLocLeft.y,140,140); 
  for(int i =0; i<50; i++){
    ellipse(newLocLeft.x, newLocLeft.y, 125,125);
    ellipse(newLocLeft.x, newLocLeft.y, 110,110);
    ellipse(newLocLeft.x, newLocLeft.y, 95,95);
  //code so that the particles are working and are being produced from the centre of the circle
  particles.add(new Particle(new PVector(newLocLeft.x + random(1,20), newLocLeft.y +random(1,20))));
  for (int i = 0; i < particles.size(); i++) {
    Particle p = particles.get(i);;
    if (p.isDead()){
    }//end of If
  }//end of for
}//end of void circle

No comments:

Post a Comment