Hello everyone !
I have a complex question and i can’t find any answer.
I’m trying to make a code that capture a video with webcam when you click on a specific place and create a video in data when you stop the recording. And i want this video to be “loadable” in the same code.
To be more specific :
what i have :
I created a “folder” and when you click on it, a (closable) window pop with the capture.
what i want :
When you close the window i want it to create a new folder which will lead to a second window with the fresh-taken video (or an array of images, i don’t need sound or good motion quality). I would be pleased if it can be done an infinite time (each time you load the capture again it create a new folder) but i would be satisfied if it work for one time already.
THAT’S MY CODE :
import processing.video.*;
boolean saveRecord = false;
int fenCap =0;
int fenCapX ;
int fenCapY;
int fichCapX;
int fichCapY;
Capture capture;
void setup()
{
capture = new Capture(this);
capture.start();
}
void movieEvent(Movie m)
{
m.read();
}
void draw()
{
//folder
rect(fichCapX, fichCapY, 60, 80);
//window
if (fenCap==1)
{
strokeWeight(5);
stroke(0);
fill(255);
rect(fenCapX, fenCapY, 580, 300);
rect(fenCapX, fenCapY, 580, 30);
rect(fenCapX, fenCapY, 30, 30);
line(fenCapX+6, fenCapY+6, fenCapX+24, fenCapY+24);
line(fenCapX+6, fenCapY+24, fenCapX+24, fenCapY+6);
capture.read();
image(capture, fenCapX+2, fenCapY+32, 576, 266);
}
}
void mouseClicked()
{
//open capture
if (mouseX>fichCapX && mouseX<fichCapX+60 && mouseY>fichCapY && mouseY<fichCapY+150)
{
fenCap=1;
saveRecord=true;
}
//close capture(5)
if (fenCap==1 && mouseX>fenCapX && mouseX<fenCapX+30 && mouseY>fenCapY && mouseY<fenCapY+30)
{
fenCap=0;
saveRecord=false;
}
THAT’S WHAT I TRIED WITH IMAGES LIST :
(not working because he expect to find the folder in data)
import processing.video.*;
boolean saveRecord = false;
PImage[] voyeurX ;
int fenCap =0;
int fenPlus =0;
int fenCapX ;
int fenCapY;
int fichCapX;
int fichCapY;
Capture capture;
int Voyeur=0;
int VoyeurCount=0;
float fichPlusX= random(1180);
float fichPlusY= random(600);
float fenPlusX= random(780);
float fenPlusY= random(400);
void setup()
{
capture = new Capture(this);
capture.start();
voyeurX=new PImage[200];
for (int i=0; i<0x200; i++)
{
voyeurX[i]=loadImage("voyeur0/voyeur_"+i+".png");
}
}
void movieEvent(Movie m)
{
m.read();
}
void draw()
{
//folder
rect(fichCapX, fichCapY, 60, 80);
if (Voyeur==1)
{
rect( fichPlusX, fichPlusY , 60, 80);
}
//window
if (fenCap==1)
{
strokeWeight(5);
stroke(0);
fill(255);
rect(fenCapX, fenCapY, 580, 300);
rect(fenCapX, fenCapY, 580, 30);
rect(fenCapX, fenCapY, 30, 30);
line(fenCapX+6, fenCapY+6, fenCapX+24, fenCapY+24);
line(fenCapX+6, fenCapY+24, fenCapX+24, fenCapY+6);
capture.read();
image(capture, fenCapX+2, fenCapY+32, 576, 266);
}
if (fenPlus==1)
{
strokeWeight(5);
stroke(0);
fill(255);
rect(fenPlusX, fenPlusY, 580, 300);
rect(fenPlusX, fenPlusY, 580, 30);
rect(fenPlusX, fenPlusY, 30, 30);
line(fenPlusX+6, fenPlusY+6, fenPlusX+24, fenPlusY+24);
line(fenPlusX+6, fenPlusY+24, fenPlusX+24, fenPlusY+6);
image(voyeurX[0000],fen4X+2, fen4Y+32, 576, 266);
}
if (saveRecord == true)
{
saveFrame("data/voyeur" +VoyeurCount+"/voyeur_###.png");
println(VoyeurCount);
}
}
void mouseClicked()
{
//open capture
if (mouseX>fichCapX && mouseX<fichCapX+60 && mouseY>fichCapY && mouseY<fichCapY+150)
{
fenCap=1;
saveRecord=true;
Voyeur=1;
}
//close capture(5)
if (fenCap==1 && mouseX>fenCapX && mouseX<fenCapX+30 && mouseY>fenCapY && mouseY<fenCapY+30)
{
fenCap=0;
saveRecord=false;
Voyeur=0;
}
I’m new in this forum, english is not my mother language and even if i use processing a bit i’m not very used to programing, so don’t hesitate to give me tips that you find obvious, they won’t necessarely be for me !
Thanks !