How can i assign my internal camera (iMac) to mouseX and mouseY locations on my screen?

Hello. I've created a sketch that uses a combination of 124 shapes to randomly place 25 of them, onto random positions of my sketch, on to one of 4 random backgrounds... how random, i know! I've chosen to make this sketch into an MS Paint style app so allow people create their own branded imagery. (classic, I know) The shape tools are fun and all, but i was hoping to access the camera with a keyPressed function and let users position it wherever they want. To take the snap, i'm just using an arrow key to saveFrame. and then i'll exit();.

Could anyone recommend an amendment or tell me where i'm going wrong?

Thanks

import processing.video.*;

Capture video;



//declare and initialise variables
static final int PICS = 122, BACKS = 4;
final PImage[] pics = new PImage[PICS], bgs = new PImage[BACKS];



//setting up page
//loading images
void setup () {
  size (842, 595);
  smooth (4);

  for (int i = 0; i < PICS; pics[i] = loadImage("a"  + i++ + ".png"));
  for (int i = 0; i < BACKS; bgs[i] = loadImage("bg" + i++ + ".png"));

  background (255); 

  //The background of the sketch will begin white but then become one of the 
  //4 set backgrounds, randomly changing as the UP and DOWN arrow keys are pressed
}

void draw () {
  if ((keyPressed == true) && (key == ' ')) {//spae bar will allow the page to clear  to white
    background (255);
  }

    if ((keyPressed == true) && (keyCode == UP)) { //THIS IS WHAT CREATES THE FLICKERING THROUGH IMAGERY
      image(bgs[int(random(0, BACKS))], 0, 0, width, height);//set a random background

for(int i = 0; i < 25; i++){
      image(pics[int(random(0, PICS))], random(width), random(height), 30, 30);

  }}

    else  if ((keyPressed == true) && (keyCode == DOWN)) { //THIS IS WHAT CREATES THE FLICKERING THROUGH IMAGERY
      image(bgs[int(random(0, BACKS))], 0, 0, width, height);//set a random background

for(int i = 0; i < 25; i++){ //25 random PICs are placed in random places on to the sketch when the UP & DOWN arrows are pressed 
      image(pics[int(random(0, PICS))], random(width), random(height), 30, 30);
    }
  }
}



void mouseDragged () {

//THIS IS WHERE I WOULD PUT MY kepPressed functions for sketching lines and shapes

}




//save the file as vector - ready
void keyPressed () {

if ((keyPressed == true) && (key == 'z')){
          video = new Capture(this, 70, 70);

  // Start capturing the images from the camera??
  video.start();  
  video.read();
}


  else if (key == CODED) {
    if (keyCode == RIGHT) {
      saveFrame ("YourNameHere-##.tga"); 


      // exit();

    }

  }


}
Tagged:
Sign In or Register to comment.