We are about to switch to a new forum software. Until then we have removed the registration on this forum.
it is really annoying i couldn't find the error. I can't find any semi colon missed do you have any idea with that ?
void autoMode() {
camCapture.update();
freshBackground = camCapture.retinaImage();
freshImage = camCapture.image();
// invert camera progress
if(invertCam){
for(int i=0 ; i < camWidth*camHeight ; i++){
int y = floor(i/camWidth);
int x = i - (y*camWidth);
x = camWidth - x;
currentFrame[i] = freshImage[(y*camWidth) + x-1];
backGround[i] = freshBackground[(y*camWidth) + x-1];
}
}
else{
currentFrame = freshImage;
background = freshBackground;
}
loadPixels();
int safeColorPixelsCounter = 0;
for(int i = 0; i<camWidth*camHeight; i++){
pixels[i] = currentFrame[i];
// sensing motion, color track and safe color
boolean motion = (((abs(red(currentFrame[i])-red(Background[i])) + abs(green(currentFrame[i])-green(Background[i])) + abs(blue(currentFrame[i])-blue(Background[i]))) > (200-tolerance)) && motionTrack);
boolean trackedColor = (((abs(red(currentFrame[i])-colorTrackRed) + abs(green(currentFrame[i])-colorTrackGreen) + abs(blue(currentFrame[i])-colorTrackBlue)) < colorTrackTolerance) && colorTracking);
boolean isSafeColor = (((abs(red(currentFrame[i])-safeColorRed) + abs(green(currentFrame[i])-safeColorGreen) + abs(blue(currentFrame[i])-safeColorBlue)) < safeColorTolerance) && safeColor);
if(motion || trackedColor){
screenPixels[i] = color(255,255,255);
}
else {
screenPixels[i] = color(0,0,0);
}
if (isSafeColor) {
safeColorpixelsCounter++;
pixels[i] = color(0, 255,0);;
screenPixels[i] = color(0,0,0);
}
}
// pixel array has changed it should update
updatePixels();
int biggestSpotArea = 0;
target.computeBlobs(screenPixels);
for( int i =0; i < target.getBlobNb()-1; i++){
spot = target.getBlob(i);
int spotWidth = int(spot.w*camWidth);
int spotHeight = int(spot.h*camHeight);
// this progres finds the biggest spot on the screen
if(spotWidth*spotHeight >= biggestSpotSize){
biggestSpot = target.getBlob(i);
biggestSpotArea = int(biggestSpot.w*camWidth)*int(biggestSpot.h*camHeight);
}
}
locationX = 0;
locationY = 0;
if(biggestSpotArea >= minTargetSize){
locationX = int(biggestSpot.x*camWidth);
locationY = int(biggestSpot.y*camHeight);
stroke(255,0,0);
strokeWeight(4);
fill(255,10,10,150);
rect(int(biggestSpot.xMin*camWidth),int(biggestSpot.yMin*camHeight),int((biggestSpot.xMax-biggestSpot.xMin)*camWidth),int((biggestSpot.yMax-biggestSpot.yMin)*camHeight));
// anticipation();
viewedX = locationX;
viewedY = locationY;
if (viewedX < 0)
viewedX = 0;
if (viewedX > camWidth)
viewedX = camWidth;
if (viewedY < 0)
viewedY = 0;
if (viewedY > camHeight)
viewedY = 0;
targetX = int((locationX/xRatio)+xMin);
targetY = int(((camHeight-locationY)/yRatio)+yMin);
fire = 1;
}
else{
fire = 0;
}
if (safeColorPixelsCounter > safeColorMinSize && safeColor){
noStroke();
fill(0,0,255,150);
rect(0,0,width,height);
fire = 0;
targetX = int ((xMin+xMax)/2.0);
targetY = int (yMin);
viewedX = camWidth/2;
viewedY = camHeight;
}
}
Answers
Try Ctrl+T to format your code, it often helps in finding these errors. The code fragment you show doesn't seem to have an error, and if we try to run it, we get error about missing variable definitions. So we cannot spot the issue.
Often, this kind of error comes up when you forget to close a brace {}, so a function is defined inside another...