You are on page 1of 6

EXPRESSIONS OF CIRCULATION | MELISSA LUI

GLOBAL STRATEGY
TO REGISTER MOVEMENT OF USERS AT STREET LEVEL, UNDER-
GROUND IN THE PATH SYSTEM. THOSE ABOVE GROUND WILL
LEAVE THEIR TRACE BELOW. THOSE BELOW GROUND, ARE
GIVEN AN INDICATION OF THE ACTIVITY THAT OCCURS ABOVE.
1
TYPOLOGIES OF USERS
1. ICE-SKATERS, NATHAN PHILLIPS SQUARE
2. CARS, RICHMOND STREET
3. PEDESTRIANS, COMMERCE COURT
4. PEDESTRIANS, KING STREET

n
1. ICE-SKATERS, NATHAN PHILLIPS SQUARE 2 . CARS, RICHMOND STREET 3 . PEDESTRIANS, COMMERCE COURT
WEB CAM TRACKING MOVEMENT WEB CAM TRACKING MOVEMENT

4 . PEDESTRIANS, KING STREET

+1

-1
PROCESSING CODE import processing.serial.*; background(255); int checkMovementState(int prev, int curr){
int value = 0; for(int i=0; i<cells.length;i++){ if(prev!=-1){
Serial myPort; fill(cells[i]*255); int movementvector=0;
int state; rect((i%4)*width/4,(i/4)*height/4,width/4,height/4); int prevX=prev%4;
int prevNode=-1; } int prevY=prev/4;
int currentNode=-1; for(int i=0;i<b.length;i++){ int currX=curr%4;
int cells[]=new int[16]; ellipse (detectedX[i],detectedY[i],10,10); int currY=curr/4;
checkLocation(detectedX[i],detectedY[i]); if(prevX>currX&&prevY>currY){
int prevX = -30; } movementvector=1; }
int prevY = -30; if(prevX==currX&&prevY>currY){
int cenX=0; if ((cenX!= prevX)&&(cenY!=prevY)){ //if the focus has changed... movementvector=2;
int cenY=0; if ((abs(cenX - prevX)>15)&&(abs(cenY - prevY)>15)){ //...and the }
import JMyron.*; difference in these vaues is bigger than 10 if(prevX<currX&&prevY>currY){
JMyron m;//a camera object if ((cenX==0)&&(cenY==0)){ //if there is nothing on the screen then movementvector=3;
int detectedX[]=new int[20]; the system sends a special signal }
int detectedY[]=new int[20]; prevX = 0; if(prevX>currX&&prevY==currY){
void setup(){ prevY = 0; movementvector=4;
size(320,240); } }
frameRate(5); //used to control the reduce the input of the video } if(prevX<currX&&prevY==currY){
camera } movementvector=5;
m = new JMyron();//make a new instance of the object }
m.start(width,height);//start a capture at 320x240 } if(prevX>currX&&prevY<currY){
m.trackColor(0,0,0,200);//tracking for black with a range of 500 void drawCamera(){ movementvector=6;
m.minDensity(400); //minimum pixels in the glob required to result in a int[] img = m.image(); //get the normal image of the camera }
box loadPixels(); if(prevX==currX&&prevY<currY){
noFill(); for(int i=0;i<width*height;i++){ //loop through all the pixels movementvector=7;
pixels[i] = img[i]; //draw each pixel to the screen }
background(255); } if(prevX<currX&&prevY<currY){
rectMode(CORNER); updatePixels(); movementvector=8;
myPort = new Serial(this, Serial.list()[1], 9600); } }
println(Serial.list()); return movementvector;
for(int i=0; i<cells.length;i++){ void checkLocation(int x, int y){ }
cells[i]=1; for(int i=0; i<cells.length;i++){ else {
} if (x>(i%4)*(width/4) && x<((i%4)*(width/4))+(width/4)&& return 0;
} y>(i/4)*(height/4) && y<((i/4)*(height/4))+(height/4)){ }
void draw(){ if (cells[i]==0){ }
cells[i]=1;
for (int i=0; i<20; i++){ }
detectedX[i]=0; else{
detectedY[i]=0; cells[i]=0;
} currentNode=i; LOCATION DIRECTION
m.update();//update the camera view }
drawCamera();//draw the camera to the screen
int[][] b = m.globBoxes();//get the center points }
}
0 1 2 3 1 2 3
int X=0 ; state=checkMovementState(prevNode,currentNode);

4 5 6 7 4 0 5
int Y=0 ; state=(currentNode*10)+state;
//draw the boxes prevNode=currentNode;
stroke(255,0,0); //This is where we send the state to arduino
for(int i=0;i<b.length;i++){ //goes through each rectangle on a single println(state);
frame
rect( b[i][0] , b[i][1] , b[i][2] , b[i][3] ); // for the given rectangle.... }
myPort.write(state); 8 9 10 11 6 7 8
X = (b[i][0]+((b[i][2])/2)); //...find the X co-ordinate of its centre...
Y = (b[i][1]+((b[i][3])/2)); //... and the y-co-ordinate.
detectedX[i]=X; 12 13 14 15
detectedY[i]=Y;
}
ARDUINO CODE #include <Servo.h> void loop() { if ((j==1)||(j==8)) { if(i==12){
val=Serial.read(); angle=45; myservo12.write(angle);
Servo myservo1; // create servo object to control a servo int i; //servo } timeStamp12=millis();
Servo myservo2; int j; //movementvector if ((j==2)||(j==7)) { }
Servo myservo3; if(val!=-1){ angle=90; if(i==13){
Servo myservo4; i=val/10; } myservo13.write(angle);
Servo myservo5; j=val%10; if ((j==3)||(j==6)) { timeStamp13=millis();
Servo myservo6; Serial.println(val); } angle=135; }
Servo myservo7; if(millis()-timeStamp1>30000){ //check to see if the servos are are } if(i==14){
Servo myservo8; position 0 if ((j==4)||(j==5)) { myservo14.write(angle);
Servo myservo9; myservo1.write(0); //rotate it to angle 0 angle=0; }
Servo myservo10; } } if(i==15){
Servo myservo11; if(millis()-timeStamp2>30000){ if(i==1){ myservo15.write(angle);
Servo myservo12; myservo2.write(0); //rotate it to angle 0 myservo1.write(angle); timeStamp15=millis();
Servo myservo13; } timeStamp1=millis(); }
Servo myservo14; if(millis()-timeStamp3>30000){ } if(i==16){
Servo myservo15; myservo3.write(0); //rotate it to angle 0 if(i==2){ myservo16.write(angle);
Servo myservo16; } myservo2.write(angle); timeStamp16=millis();
//Counters for resetting if(millis()-timeStamp4>30000){ timeStamp2=millis(); }
int timeStamp1; myservo4.write(0); //rotate it to angle 0 } }
int timeStamp2; } if(i==3){
int timeStamp3; if(millis()-timeStamp5>30000){ myservo3.write(angle);
int timeStamp4; myservo5.write(0); //rotate it to angle 0 timeStamp3=millis();
int timeStamp5; } }
int timeStamp6; if(millis()-timeStamp6>30000){ if(i==4){
int timeStamp7; myservo6.write(0); //rotate it to angle 0 myservo4.write(angle);
int timeStamp8; } timeStamp4=millis();
int timeStamp9; if(millis()-timeStamp7>30000){ }
int timeStamp10; myservo7.write(0); //rotate it to angle 0 if(i==5){
int timeStamp11; } myservo5.write(angle);
int timeStamp12; if(millis()-timeStamp8>30000){ timeStamp5=millis();
int timeStamp13; myservo8.write(0); //rotate it to angle 0 }
int timeStamp14; } if(i==6){
int timeStamp15; if(millis()-timeStamp9>30000){ myservo6.write(angle);
int timeStamp16; myservo9.write(0); //rotate it to angle 0 timeStamp6=millis();
} }
int angle; if(millis()-timeStamp10>30000){ if(i==7){
int val = 0; myservo10.write(0); //rotate it to angle 0 myservo7.write(angle);
void setup() } timeStamp7=millis();
{ if(millis()-timeStamp11>30000){ }
myservo1.attach(22); // attaches the servo on pin 22 to the servo object myservo11.write(0); //rotate it to angle 0 if(i==8){
myservo2.attach(24); } myservo8.write(angle);
myservo3.attach(26); if(millis()-timeStamp12>30000){ timeStamp8=millis();
myservo4.attach(28); myservo12.write(0); //rotate it to angle 0 }
myservo5.attach(30); } if(i==9){
myservo6.attach(32); if(millis()-timeStamp13>30000){ myservo9.write(angle);
myservo7.attach(34); myservo13.write(0); //rotate it to angle 0 timeStamp9=millis();
myservo8.attach(36); } }
myservo9.attach(38); if(millis()-timeStamp14>30000){ if(i==10){
myservo10.attach(40); myservo14.write(0); //rotate it to angle 0 myservo10.write(angle);
myservo11.attach(42); } timeStamp10=millis();
myservo12.attach(44); if(millis()-timeStamp15>30000){ }
myservo13.attach(46); myservo15.write(0); //rotate it to angle 0 if(i==11){
myservo14.attach(48); } myservo11.write(angle);
myservo15.attach(50); if(millis()-timeStamp16>30000){ timeStamp11=millis();
myservo16.attach(52); myservo16.write(0); //rotate it to angle 0 }
Serial.begin(9600); } }

You might also like