We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Syntax Error on Token
Page Index Toggle Pages: 1
Syntax Error on Token (Read 1096 times)
Syntax Error on Token
May 25th, 2009, 9:29pm
 
I'm getting an error message with my code: Syntax error on token "filename" , identifier expected

A cursory google search let me know that I must have a misplaced '{' somewhere, but even going through the code multiple times didn't let me find anything, all the curly brackets are closed.

Here is my code so far:


Code:
/*
Based on snippets from 'Circle Follow' by Monica Monin
*/

//Import JMyron library

import JMyron.*;

JMyron m; //camera object

//switches
boolean showCamera = true; //Will use this boolean variable to turn the visual of the camera on and off
boolean showBlobs = true;

//threshhold for lighting
int threshold = 255;


void setup(){
 
size (320,240);
m = new Jmyron(); //new instance of camera object
m.start(width,height); //Capture field of view

m.trackColor (255,255,255,threshold);

m.mindensity(100); //min pixels permitted to form a box
m.maxdensity(10000); // max "

println ("Myron " + m.version());
noFill();
}


void draw(){

m.update(); //update (keep updating camera view)

//camera on/off
if (showCamera) {
   drawCamera();//draw the camera to the screen
 } else { //showCamera must be false
   background(0); //draw the background
 }


//glob centers - based on revised Jmyron library by _________

//two arrays

int[][] a; //store the centers of the globs
int[][] b = m.globBoxes();  //will return an array with X,Y position + width+height - rectangles

//store initial area of biggest blob
float biggestBlob = 0;
int d = 0;//this will store the index of our biggest blob in the globBoxes array


//Position 2 and 3 hold the width and height of the glob at index i, times them together to get the area of the blob
float blobSize = b[i][2]*b[i][3];

  //If the current blob is bigger, then make it the biggest blob
   if (blobSize > biggestBlob) {
     biggestBlob = blobSize;
     d = i; //store its position in the array
   }

      //Draw the biggest blob, it will come up red
   if (showBlobs) {
     stroke(255,0,0);
     noFill();
     rect( b[d][0] , b[d][1] , b[d][2] , b[d][3] );
   }


 //fetch the centers of the globs
 a = m.globCenters();
 
 //draw the globs
 stroke(255,128,128);
 fill(128,0,128,128);
 
 //for every blob center  
 print("i see                    " + a.length + " blobs\n");

 //itterate through all blobs in array to find biggest one
// start at i=1
 for(int i=1;i<a.length;i++){
   
   
   //output to the console which blob this is
   print("blob " + i + " : ");
   
 }
   
   //if the blob is not exactly at 0 x 0
   //(jmyron may have this quirk, but it only rarely occurs)
   if(a[i][1] != 0 && a[i][0] != 0){

     //output the x and y coords of the blob to the console
     print(a[i][0] + " X " + a[i][1] + "\n");
   
     //draw the exact point of the blob center
     point(a[i][0],a[i][1]);
   
     //draw an ellipse around the point to make it easyer to see
     //you might also use it as bounds for tracking objects.
     
     ellipse(a[i][0],a[i][1],20,20);  
     
   } else {
     //(if the blob center was at 0x0)
     //output to the console that this blob was skipped
     print ("skipped. (0x0) \n");
   }

}



If anyone can help out, I would really appreciate it Smiley
Re: Syntax Error on Token
Reply #1 - May 26th, 2009, 1:40am
 
I can't run your code at all - getting all kinds of errors.  At first I thought it was because you've missed out capitalisation i.e. in setup: 'Jmyron' instead of 'JMyron'; 'mindensity' instead of 'minDensity'; 'maxdensity' instead of 'maxDensity'... but now I'm wondering whether this is linked to the cryptic comment:

//glob centers - based on revised Jmyron library by _________

Revised by whom?  And what revisions?  Whatever - with the standard library, and I suspect the revised one too, it's not going to work because there are some fundamental errors.  For example the line:

float blobSize = b[i][2]*b[i][3];

You reference 'i' without having defined it yet.  I'm assuming this should be enclosed by the for loop...  And even after fixing that it still doesn't work...

It seems to me you need to get to grips with the basics before trying to adapt someone else's code...
Page Index Toggle Pages: 1