Various errors - Augmented Reality from earlier Processing the reason?

edited November 2014 in Questions about Code

Hello hello,

So, I'm trying to get this Augmented Reality sketch working (the first example one). It was written for Procesing 1.5 but should work for the most part in 2.0. However, I can't figure why I'm getting some errors

Syntax error, maybe missing a right parenthesis

[in the console] expecting RPAREN, found ';'

at his line in the Setup:

colors[i] = color( random(255), random(255), random(255), 160); // random color, always at a transparency of 160

AFAIK color(x,y,z,a); is a valid construction for the three hues, and a transparency level.

Note: I was also getting an error on the line before this, but added the == (where originally, it's not there):

for (int i = 0; i == nya.addARMarker(patternPath + "/" + patterns[i],80);

Is this a problem with the general code, or is there just something I'm overlooking?

Answers

  • Lack of open or close braces and semicolons can lead to mysterious errors at unrelated places! :-O
    I advise you to use CTRL+T inside Processing's IDE and look for any discrepancies on indentations! 8-X

  • edited November 2014

    Yeah, I realized the for loop I posted was incorrectly formatted, so I have changed it. I have CTRL+T'd. I will change the topic problem because I think it's something other than a simple error.

    Here's the issue area, I'll post before and after I "fixed" it. Before:

      // for the selected number of markers, add the marker for detection
      // create an individual color and scale for that marker (= box)
      for (int i=0; i nya.addARMarker (patternPath + "/" + patterns[i], 80);
      colors[i] = color( random(255), random(255), random(255), 160); // random color, always at a transparency of 160
      scaler[i] = random(0.5, 1.9); // scaled at half to double size
    }
    

    After:

          // for the selected number of markers, add the marker for detection
          // create an individual color and scale for that marker (= box)
          for (int i=0; i == nya.addARMarker (patternPath + "/" + patterns[i], 80){
          colors[i] = color( random(255), random(255), random(255), 160); // random color, always at a transparency of 160
          scaler[i] = random(0.5, 1.9); // scaled at half to double size
        }
    

    but now I get "unexpected token: {" at the for loop line.

    As mentioned, I added the == because I don't know what it's trying to do without it, don't you need some sort of ==, >=, etc. in a for loop? ...but looking at it, I think I need something other than 'patterns[i]' because logically, I'm setting i to 0, and going until i IS something and I can't use the same variable in the 'IS' part right?

    Edit: Okay I was able to find an old threat about this, and some other issues. I will be reviewing that and come back if I can't figure everything out. Thanks though GoToLoop! (FYI)

  • Answer ✓

    Apparently, the author of the page where you copied the code felt into a common trap, with incorrect formatting of the HTML, so all the isolated < signs are eaten away, interpreted as incorrect HTML. It is even worse when there are no spaces between the < and the text after...

    Anyway, perhaps you can view the source of the page to get a more complete vision of the code.

    Note: the author is a regular of this forum, perhaps he will spot this thread and help.

  • edited November 2014

    Hey PhiLho, I discovered that too the other day. I just viewed source, copied code and removed the errant <*br> and such. Thanks for that tip!

Sign In or Register to comment.