Ty. Now it works. I paste the final Script. It was so easy, but I was very tired to understand it. Thanks ^^
ps. I've icreased the threshold. It works better.
import processing.video.*;Movie[] Parte = new Movie[5];int xStart;int yStart;Capture cam;float threshold = 25; // sogliacolor red, yellow, green, blue;void setup(){size(640, 480);tint(255, 20);Parte[1] = new Movie(this, "Parte1.mp4");Parte[2] = new Movie(this, "Parte2.mp4");Parte[3] = new Movie(this, "Parte3.mp4");Parte[4] = new Movie(this, "Parte4.mp4");cam = new Capture(this, 640, 480);cam.start();xStart = width / 2 - 100;yStart = height / 2 - 100;}boolean matchColors(color c1, color c2) //sottrae c1 (c1 è il colore che noi abbiamo definito in partenza con il get color. metto un foglio rosso davanti allo schermo//faccio getcolor, e definisco quel colore come rosso) a c2 ( la seconda volta che passo il foglio il computer memorizza c2 e verifica se il foglio è rosso mi dirà che è rosso true, sennò fause){float diffRed = abs(red(c1) - red(c2));float diffGreen = abs(green(c1) - green(c2));float diffBlue = abs(blue(c1) - blue(c2));if (diffRed < threshold && diffGreen < threshold && diffBlue < threshold) // se la differenza è minore della soglia, considera come se fosse lo stesso colore//se invece anche solo 1 dei 3 colori è maggiore della soglia, lo considera un colore diversoreturn true;elsereturn false;}color getColor(){color current;int totalRed = 0;int totalGreen = 0;int totalBlue = 0;int pixelCount = 0;loadPixels();for (int x = 1; x < 201; x++){for (int y = 1; y < 201; y++){current = pixels[xStart + x + (yStart + y) * width];totalRed += red(current);totalGreen += green(current);totalBlue += blue(current);pixelCount++;// pixels[xStart + x + (yStart + y) * width] = color(255, 255, 255);}}updatePixels();return color(totalRed / pixelCount, totalGreen / pixelCount, totalBlue / pixelCount);}void movieEvent(Movie Parte) {Parte.read();}//calibrazionevoid draw(){if (cam.available() == true)cam.read();set(0, 0, cam);/*noFill();rect(xStart, yStart, 201, 201);strokeWeight(1);stroke(255, 0, 0);*/if (keyPressed) {if (key == 'r') {red = getColor();}else if (key == 'g') {green = getColor();}else if (key == 'y') {yellow = getColor();}else if (key == 'b') {blue = getColor();}}if (keyPressed){if (key == 'R') {if (matchColors(getColor(), red))println("Is red!");}if (key == 'G') {if (matchColors(getColor(), green))println("Is green!");}if (key == 'Y') {if (matchColors(getColor(), yellow))println("Is yellow!");}if (key == 'B') {if (matchColors(getColor(), blue))println("Is blue!");}}//The Saga of Biornif (key == '0') {if (cam.available() == true)cam.read();{if (matchColors(getColor(), red)){println("i'm awesome");Parte[1].play();set(100, 100, Parte[1]);background (0);}}if (matchColors(getColor(), yellow)){println("i'm awesome");Parte[2].play();set(0, 0, Parte[2]);Parte[1].stop();}if (matchColors(getColor(), green)){println("i'm awesome");Parte[3].play();set(0, 0, Parte[3]);Parte[2].stop();}if (matchColors(getColor(), blue)){println("i'm awesome");Parte[4].play();set(0, 0, Parte[4]);Parte[3].stop();}else print("I failed");}}