We are about to switch to a new forum software. Until then we have removed the registration on this forum.
// Progetto Segmaister, ERGO SUM FELIX
import processing.video.*; // per la camera
int example = 1;
float recent, old;
float opacNum = 0.0, line1 = 0.0;
Capture cam;
PFont myFont; // ogni PFont serve a richiamare un font gestito nel setup
PFont myFont2;
PFont myFont3;
PFont myFont4;
void setup() { // qui si mettono tutte le impostazioni UNIVERSALI
background(0); // background, gestibile con 3 numeri R G B
size(800, 600); // dimensione dello sketch
old = millis(); // per la camera, al momento non utilizzato
myFont = loadFont("Futura-Medium-52.vlw"); // ogni font viene caricato nel setup
myFont2 = loadFont("Baskerville-72.vlw");
myFont3 = loadFont("Helvetica-Light-72.vlw");
myFont4 = loadFont("SignPainter-HouseScript-80.vlw");
String[] cameras = Capture.list(); // per la camera, al momento non utilizzato
if (cameras.length == 0) { // per la camera, al momento non utilizzato
println("There are no cameras available for capture.");
exit();
}
else { // per la camera, al momento non utilizzato
println("Available cameras:");
for (int i = 0; i < cameras.length; i++) {
println(cameras[i]);
}
cam = new Capture(this, cameras[1]); // per la camera, al momento non utilizzato
cam.start();
}
}
void draw() { // qui si mette ciò che lo sketch deve disegnare, appunto draw
if (example == 1) // qui sto definendo cosa succede se ci si trova in determinati ambiti
{
textAlign(CENTER, CENTER);
background(0);
textFont(myFont);
}
else if (example == 2)
{
background(0);
textFont(myFont2);
}
else if (example == 3)
{
background(0);
textFont(myFont3);
}
else if (example == 4)
{
background(0);
textFont(myFont4);
}
text ( "EGO, FELIS," ,width/2, 200); // carico i testi, il width/2 mi definisce che il testo sarà
text ( "CAMAELEON" ,width/2, 270); // sempre centrato, qualsiasi larghezza abbia lo sketch
text ( "ERGO SUM" ,width/2, 340);
text ( "...FELIX" ,width/2, 410);
}
void keyPressed() // un void che va fuori da draw e setup che mi gestisce la pressione dei tasti
{
if (key == '1') // quando premiamo il tasto definito, richiamiamo quello definito negli "if" nel draw
example = 1;
if (key == '2')
example = 2;
if (key == '3')
example = 3;
if (key == '3')
example = 3;
if (key == '4')
example = 4;
}
hi, i'm an italian student and i created this sketch as you can see, i have a font that writes a phrase in the middle of the sketch and a camera activation command (in fact, my camera activates when i start the sketch), i would like to know how to make possible for me to recognize a certain amount of movement in the scene detected from the camera and make possible that the sketch modifies the position of the phrase randomly based on the camera movement, if detected the sketch moves, if not, stands still or turns back to default
i hope you understand me, thanks
Answers
Have a look at the Video & Vision libraries. I've done this sort of thing in the past with OpenCV: Background substraction is one approach to spot movement... I got as far as doing face recognition and overlaying stuff on viewer's faces: lots of fun! :)
@blindfish how i set up processing on mac @64bits to use openCV on mac?
Did you see the installation guide. I don't do Mac so can't help on that front. IIRC you also have to install OpenCV itself... I would be surprised if there haven't been previous posts on using it ;)