I downloaded the sample files from
http://as.wiley.com/WileyCDA/WileyTitle/productCd-1118036638,miniSiteCd-SYBEX,descCd-DOWNLOAD.html ( chapter 6 is all we need to download )
for this book titled 'Prototyping Augmented Reality' by T. Mullen, but when I run it, it shows some errors and I can't seem to solve this.
Could any Processing guru gives a hint how to fix it.
Thanks in advance.
-poserpro
-
-
/** NyARToolkit for proce55ing/0.3.0
(c)2008-2010 nyatla
airmail(at)ebony.plala.or.jp
MultiMarker + MultiMarkerMarker by
Charl P. Botha < http://cpbotha.net/>
*/
import codeanticode.gsvideo.*;
import jp.nyatla.nyar4psg.*;
import processing.opengl.*;
import saito.objloader.*;
GSCapture cam;
MultiMarker nya;
OBJModel annie ;
PFont font;
PVector move;
PVector xypos;
OBJModel[] anim;
int animFrames = 20;
int animFrame;
boolean animOn= true;
float turn = 0.0;
float prevangle = 0.0;
void setup() {
size(800,600,OPENGL);
colorMode(RGB, 100);
font=createFont("FFScala", 32);
cam=new GSCapture(this,width,height);
String[] patts = {"samarker16.pat", "walkmarker16.pat", "turnmarker16.pat"};
double[] widths = {80,80,80};
nya=new MultiMarker(this,width,height,"camera_para.dat",NyAR4PsgConfig.CONFIG_PSG);
print(nya.VERSION);
nya.gsThreshold=120;//(0<n<255) default=110 ....................error
nya.cfThreshold=0.4;//(0.0<n<1.0) default=0.4 ....................error
int i;
String filename = "";
anim = new OBJModel[animFrames];
for(i = 1; i <= animFrames; i++){
if(i < 10){
filename = "shootinannie-superlowpoly-tri_00000" + i + ".obj";
}else{
filename = "shootinannie-superlowpoly-tri_0000" + i + ".obj";
}
anim[i-1] = new OBJModel(this, filename, "relative", TRIANGLES);
anim[i-1].enableDebug();
anim[i-1].scale(15);
anim[i-1].translateToCenter();
anim[i-1].enableTexture();
}
xypos = new PVector(0, 0);
move = new PVector(0, -1);
}
void drawMarkerPos(int[][] pos2d)
{
textFont(font,10.0);
stroke(100,0,0);
fill(100,0,0);
for(int i=0;i<4;i++){
ellipse(pos2d[i][0], pos2d[i][1],5,5);
}
fill(0,0,0);
for(int i=0;i<4;i++){
text("("+pos2d[i][0]+","+pos2d[i][1]+")",pos2d[i][0],pos2d[i][1]);
}
}
void draw() {
if (cam.available() !=true) {
return;
}
background(255);
cam.read();
hint(DISABLE_DEPTH_TEST);
image(cam,0,0);
if (nya.detect(cam)) //....................error
{
for (int i=0; i < nya.markers.length; i++)
{
if (nya.markers[i].detected)
{
drawMarkerPos(nya.markers[i].pos2d);
}
}
if(nya.markers[1].detected){
animOn = true;
}else{
animOn = false;
}
hint(ENABLE_DEPTH_TEST);
PGraphicsOpenGL pgl = (PGraphicsOpenGL) g;
if (nya.markers[0].detected){
nya.markers[0].beginTransform();
noStroke();
rotateX(radians(-90));
if(nya.markers[2].detected){
turn = nya.markers[2].angle.z;
rotate2D(move, turn-prevangle);
prevangle = turn;
}
translate(xypos.x, xypos.y, 50);
rotateY(turn);
if(animOn){
anim[animFrame].draw();
xypos.add(move);
animFrame++;
if(animFrame == animFrames){
animFrame = 0;
}
}else{
anim[17].draw();
}
nya.markers[0].endTransform();
}
}
}
void rotate2D(PVector v, float theta) {
float xTemp = v.x;
v.x = v.x*cos(theta) - v.y*sin(theta);
v.y = xTemp*sin(theta) + v.y*cos(theta);
}
1