I'm writing a code, to track multiple colors after a capture video from my builtin camera. I keep getting the "Unexpected Token : Void" error pointing line 87. I can't figure out why.
Here's the code:
import processing.video.*;
// Capturar Video
Capture video;
// Declaración de Variables
int numcolores=4, t;
color [] trackcolor = new color [numcolores]; // Colores a Buscar
// Setup
void setup() {
size(400,240); // Tamaño Ventana
video = new Capture(this,320,240,30);
//
trackcolor = color(255,0,0); //Comenzar Rojo
smooth();
}
void draw() {
// Capture and display the video
if (video.available()) {
video.read();
}
video.loadPixels();
image(video,0,0,320,240);
float worldRecord = 500;
int closestX = 0; // XY coordinate of closest color
int closestY = 0;
// Begin loop to walk through every pixel
for (int x = 0; x < video.width; x ++ ) {
for (int y = 0; y < video.height; y ++ ) {
int loc = x + y*video.width;
// Color Actual
color currentColor = video.pixels[loc];
float r1 = red(currentColor);
float g1 = green(currentColor);
float b1 = blue(currentColor);
for(t=0;t<numcolores;t++){
if(colores[k]==color(0,0,0)){
} else{
float r2 = red(trackcolor[t]);
float g2 = green(trackcolor[t]);
float b2 = blue(trackcolor[t]);
// Using euclidean distance to compare colors
d[t] = dist(r1,g1,b1,r2,g2,b2); // We are using the dist( ) function to compare the current color with the color we are tracking.
// If current color is more similar to tracked color than
// closest color, save current location and current difference
if (d[t] < worldRecord) {
worldRecord = d;
closestX = x;
closestY = y;
}
}
}
// We only consider the color found if its color distance is less than 10.
// This threshold of 10 is arbitrary and you can adjust this number depending on how accurate you require the tracking to be.
if (worldRecord < 10) {
// Draw a circle at the tracked pixel
fill(trackcolor);
strokeWeight(4.0);
stroke(0);
ellipse(closestX,closestY,16,16);
}
}
//void mousePressed() {
// // Save color where the mouse is clicked in trackcolor variable
// int loc = mouseX + mouseY*video.width;
// trackcolor = video.pixels[loc];
//}
// Al Presionar una tecla, ir guardando colores a buscar