Why is not capturing the image from webcam?

edited December 2015 in Library Questions

import processing.video.*;

ArrayList tu = new ArrayList(); PImage imagen; Capture foto; boolean img=false; int num; int norepite=0; int arreglo=5; int posicionfoto=0; int vecespres=0;

void setup(){ size(1366, 768); background(35,81,245); foto=new Capture(this,320,240,30); foto.start(); for ( int i = 0; i< 5; i++ ){ imagen=loadImage(i + ".jpeg"); tu.add(imagen);
} } void captureEvent(Capture foto){ foto.read(); } void draw(){ if (img==true){ if (num==norepite){ if (norepite==tu.size()){ num=num-1; } else{ num=num+1; } } if (vecespres==3){ PImage part = tu.get(posicionfoto); image(part, 43, 24); } else { PImage part = tu.get(num); image(part, 43, 24); /norepite=num; img=false;/ } norepite=num; img=false; } //image(foto,43,24); } void keyPressed(){ if ((keyPressed == true) && ((key == 's') || (key == 'S')) || ((key == 'd') || (key == 'D')) || ((key == 'f') || (key == 'F')) || ((key == 'g') || (key == 'G')) || ((key == 'h') || (key == 'H')) || ((key == 'j') || (key == 'J')) || ((key == 'k') || (key == 'K'))|| ((key == 'l') || (key == 'L'))) { img=true; num = (int)random(tu.size()-1); vecespres=vecespres+1; if (vecespres==1){ saveFrame(arreglo + ".jpg"); imagen=loadImage (arreglo + ".jpg"); image (imagen,43, 24); tu.add(imagen); posicionfoto=arreglo; arreglo=arreglo+1; } background(35, 81, 245); } }

Answers

Sign In or Register to comment.