top of page

Our Recent Posts

Tags

No tags yet.

week 10 pt1: video capture

I originally had the idea of relating the position of the face to react with the code, so that if the face was in one part of the screen it would display one thing, and if it was in another part of the screen it would display another. So the position of the face would react be included in an 'if' function, but i could not work this out.

I tried to change my idea but got stuck at the same point both times. I could not see how to get the code react to the position of the recognised face.

import gab.opencv.*; import processing.video.*; import java.awt.*;

Capture video; OpenCV opencv;

PImage wheredo; PImage city; PImage beach; PImage forest;

PImage tree1Pic; PImage cityPic; PImage fish1Pic;

Float cityS; Float beachS; Float forestS;

FloatList[] xPos; FloatList[] yPos;

int value=0;

void setup() { //size(640, 480); size(960,720); video = new Capture(this, 320, 240); //video = new Capture(this, 160, 120); opencv = new OpenCV(this, 320, 240); opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE);

video.start(); wheredo = loadImage("wheredoyouwanttobe.png"); city = loadImage("citytitle.png"); beach = loadImage("beachtitle.png"); forest = loadImage("foresttitle.png"); tree1Pic = loadImage("tree1.png"); }

void draw() { pushMatrix(); scale(3); opencv.loadImage(video);

image(video, 0, 0 ); noFill(); stroke(255, 255, 255); strokeWeight(2); Rectangle[] faces = opencv.detect(); println(faces.length);

for (int i = 0; i < faces.length; i++) { //ellipse(faces[i].x, faces[i].y, faces[i].width, faces[i].height); ellipse(faces[i].x+25, faces[i].y+30, faces[i].width, faces[i].height); if (faces[i].x<320){ image(tree1Pic,xPos[].get(n),yPos[].get(n)); } if (faces[i].x>320 && faces[i].x<500){ image(cityPic, xPos[].get(n),yPos[].get(n)); } if (faces[i].x>500 && faces[i]<960){ image(fish1Pic, xPos[].get(n),yPos[].get(n));

//if( faces.length == 2 ){ //saveFrame("Asdafsd.jpg"); //println(width/3); popMatrix(); image(wheredo, 180,200); image(forest, 80, 500); image(city, 440,500); image(beach, 700, 500); //if position of face is <320 {trees} else = 0 }

void captureEvent(Capture c) { c.read(); }

//void

void mousePressed(){ if (mouseX<900 && mouseX>650 && mouseY<300 && mouseY>200){ image(tree1Pic,50,50); }else{ value =0; } }

bottom of page