I don't know. Why occure missing semicolon

edited March 2014 in Questions about Code

I have some problem

I try to AR example using processing

and I found tutorial

but this tutorial code have some error

I strange "for" sentence

but I don't know how to fix it

this code is example code

import java.io.*; // for the loadPatternFilenames() function
import processing.opengl.*;
import jp.nyatla.nyar4psg.*;


String camPara = "camera_para.dat";
String patternPath = "ARToolKit_Patterns";
int arWidth = 1280;
int arHeight = 720;
int numMarkers = 10;

MultiMarker nya;
float displayScale;
color[] colors = new color[numMarkers];
float[] scaler = new float[numMarkers];
PImage input, inputSmall;

void setup() {
size(1280, 720, OPENGL);
textFont(createFont("Arial", 80));
input = loadImage("input.jpg");
inputSmall = input.get();
inputSmall.resize(arWidth, arHeight);
displayScale = (float) width / arWidth;
nya = new MultiMarker(this, arWidth, arHeight, camPara, NyAR4PsgConfig.CONFIG_DEFAULT);
nya.setLostDelay(1);
String[] patterns = loadPatternFilenames(patternPath);
// 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); i++){
  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);
  }
}

void draw() {
background(0);
image(input, 0, 0, width, height);
nya.detect(inputSmall);
drawMarkers();
drawBoxes();
}


void drawMarkers() {
textAlign(LEFT, TOP);
textSize(10);
noStroke();
scale(displayScale);
for (int i=0; i PVector[] pos2d = nya.getMarkerVertex2D(i);){
  for (int j=0; j String s = "(" + int(pos2d[j].x) + "," + int(pos2d[j].y) + ")";){
    fill(255);
    rect(pos2d[j].x, pos2d[j].y, textWidth(s) + 3, textAscent() + textDescent() + 3);
    fill(0);
    text(s, pos2d[j].x + 2, pos2d[j].y + 2);
    fill(255, 0, 0);
    ellipse(pos2d[j].x, pos2d[j].y, 5, 5);
    }
  }
}
void drawBoxes() {
  nya.setARPerspective();
  textAlign(CENTER, CENTER);
  textSize(20);
  for (int i=0; i++){
    if ((!nya.isExistMarker(i))) { continue; }
    setMatrix(nya.getMarkerMatrix(i));
    scale(1, -1);
    scale(scaler[i]);
    translate(0, 0, 20);
    lights();
    stroke(0);
    fill(colors[i]);
    box(40);
    noLights();
    translate(0, 0, 20.1);
    noStroke();
    fill(255, 50);
    rect(-20, -20, 40, 40);
    translate(0, 0, 0.1);
    fill(0);
    text("" + i, -20, -20, 40, 40);
    }
  perspective();
}

String[] loadPatternFilenames(String path) {
  File folder = new File(path);
  FilenameFilter pattFilter = new FilenameFilter() {
    public boolean accept(File dir, String name) {
      return name.toLowerCase().endsWith(".patt");
    }
  };
  return folder.list(pattFilter);
}

Answers

  • edited March 2014 Answer ✓

    line 30

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

    I would write

    for (int i=0; i < numMarkers; i++){
    
    nya.addARMarker(patternPath + "/" + patterns[i], 80); 
    
  • Answer ✓

    line 50 and 51

    for (int i=0; i PVector[] pos2d = nya.getMarkerVertex2D(i);){
      for (int j=0; j String s = "(" + int(pos2d[j].x) + "," + int(pos2d[j].y) + ")";){
    

    I would write as

    for (int i=0; i < numMarkers; i++ ) { 
        PVector[] pos2d = nya.getMarkerVertex2D(i);
        for (int j=0; j < pos2d.length; j++ ){
          String s = "(" + int(pos2d[j].x) + "," + int(pos2d[j].y) + ")";
    
  • edited February 2015

    Thank you very much!!! :-)

  • edited March 2014 Answer ✓

    line 65

    for (int i=0; i++){

    should be

    for (int i=0; i < numMarkers; i++ ) {

Sign In or Register to comment.