thanks phi.lho,
The random string added to form NyARToolkit works but can not see, maybe I entered something wrong?
/** NyARToolkit for proce55ing/0.3.0
(c)2008-2010 nyatla
airmail(at)ebony.plala.or.jp
*/
import processing.video.*;
import jp.nyatla.nyar4psg.*;
import processing.opengl.*;
import javax.media.opengl.*;
Capture cam;
NyARBoard nya;
NyARBoard nya2;
NyARBoard nya3;
NyARBoard nya4;
NyARBoard nya5;
PFont testo;
String insieme[] = new String[2];
ArrayList charHolder;
ArrayList buffer;
void setup() {
size(800,600,OPENGL);
insieme[0] = "4 - 3 =";
insieme[1] = "5 - 2 =";
charHolder = new ArrayList();
buffer = new ArrayList();
for(int i = 0; i< insieme.length;i++){
charHolder.add(insieme[i]);
}
testo = createFont("FFScala", 32);
textFont (testo,100);
textAlign (CENTER,CENTER);
frameRate(10);
colorMode(RGB, 100);
testo = createFont("FFScala", 32);
cam=new Capture(this,width,height);
// Primo
nya=new NyARBoard(this,width,height,"camera_para.dat","patt.uno",80);
print(nya.VERSION);
nya.gsThreshold=120;//画像2値化の閾値(0<n<255) default=110
nya.cfThreshold=0.4;//変換行列計算を行うマーカ一致度(0.0<n<1.0) default=0.4
}
void draw() {
background(255);
if (cam.available() !=true) {
return;
}
cam.read();
hint(DISABLE_DEPTH_TEST);
image(cam,0,0);
hint(ENABLE_DEPTH_TEST);
fill(0, 102, 153);
//Primo
if(nya.detect(cam)) {
hint(DISABLE_DEPTH_TEST);
//一致度を書く
textFont(testo,25.0);
fill((int)((1.0-nya.confidence)*100),(int)(nya.confidence*100),0);
text((int)(nya.confidence*100)+"%",width-60,height-20);
//マーカの角度、水平位置等
pushMatrix();
textFont(testo,10.0);
// fill(0,100,0,80);
translate((nya.pos2d[0][0]+nya.pos2d[1][0]+nya.pos2d[2][0]+nya.pos2d[3][0])/4+50,(nya.pos2d[0][1]+nya.pos2d[1][1]+nya.pos2d[2][1]+nya.pos2d[3][1])/4+50);
popMatrix();
//マーカの位置を描画
//drawMarkerPos(nya.pos2d);
hint(ENABLE_DEPTH_TEST);
PGraphicsOpenGL pgl = (PGraphicsOpenGL) g;
nya.beginTransform(pgl);//マーカ座標系での描画を開始する。
//ここからマーカ座標系
stroke(255,200,0);
translate(0,0,20);
box(40);
nya.endTransform();//マーカ座標系での描画を終了する。(必ず呼んで!)
}
if (keyPressed == true) {
int index = floor(random(charHolder.size()));
text ((String)charHolder.get(index),200 , 100);
buffer.add(charHolder.remove(index));
}
if(charHolder.size() == 0){
charHolder = (ArrayList)buffer.clone();
buffer.clear();
}
}