Can't get NyAR4psg examples to work
              in 
             Contributed Library Questions 
              •  
              4 months ago    
            
 
           
             Hello all. I have recently taken interest in AR so, since I had already worked with processing a while back I decided to give this library a try. At first I tried the nyartoolkit 1.3.1 version for processing 2.0 but I always had a "Catch an exception!" error on every example I ran. Since psg 2.0 is so recent I tried version 1.5.1 instead. But on every single example I always get stuck on the line that calls the camera calibration file. That would be line 12 on the example below.
            
            
The error I get is "NullPointerException"
            
Exception in thread "Animation Thread" java.lang.NullPointerException
at jp.nyatla.nyar4psg.SingleNyIdMarker.<init>(SingleNyIdMarker.java:120)
at sketch_130605a.setup(sketch_130605a.java:39)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:662)
            
I have changed the name of the library folder from nyar4psg-1.3.1 to NyAR4psg (I read somewhere it could be a problem). Other than that I have tried every tutorial I could find with no luck so it must be something simple that I'm doing wrong. Any ideas? :S
            
            
 
            
           The error I get is "NullPointerException"
Exception in thread "Animation Thread" java.lang.NullPointerException
at jp.nyatla.nyar4psg.SingleNyIdMarker.<init>(SingleNyIdMarker.java:120)
at sketch_130605a.setup(sketch_130605a.java:39)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:662)
I have changed the name of the library folder from nyar4psg-1.3.1 to NyAR4psg (I read somewhere it could be a problem). Other than that I have tried every tutorial I could find with no luck so it must be something simple that I'm doing wrong. Any ideas? :S
- import processing.video.*;
 import jp.nyatla.nyar4psg.*;
 PFont font=createFont("FFScala", 32);
 Capture cam;
 SingleNyIdMarker nya;
 void setup() {
 size(640,480,P3D);
 colorMode(RGB, 100);
 cam=new Capture(this,width,height);
 nya=new SingleNyIdMarker(this,width,height,"camera_para.dat"); //SingleMarker検出インスタンス
 nya.setIdMarkerSize(80);
 print(nya.VERSION); //バージョンの表示
 }
 int c=0;
 void draw() {
 c++;
 if (cam.available() !=true) {
 return;
 }
 background(255);
 cam.read();
 nya.drawBackground(cam);//frustumを考慮した背景描画
 switch(nya.detect(cam)){
 case SingleNyIdMarker.ST_NOMARKER:
 return;
 case SingleNyIdMarker.ST_NEWMARKER:
 println("Marker found.");
 return;
 case SingleNyIdMarker.ST_UPDATEMARKER:
 break;
 case SingleNyIdMarker.ST_REMOVEMARKER:
 println("Marker removed.");
 return;
 default:
 return;
 }
 nya.beginTransform();//マーカ座標系に設定
 {
 setMatrix(nya.getMarkerMatrix());//マーカ姿勢をセット
 drawBox();
 drawMarkerXYPos();
 }
 nya.endTransform(); //マーカ座標系を終了
 drawMarkerPatt();
 drawVertex();
 
 }
 void drawBox()
 {
 pushMatrix();
 fill(0);
 stroke(255,200,0);
 translate(0,0,20);
 box(40);
 noFill();
 translate(0,0,-20);
 rect(-40,-40,80,80);
 popMatrix();
 }
 //この関数は、マーカパターンを描画します。
 void drawMarkerPatt()
 {
 PImage p=nya.pickupMarkerImage(40,40,-40,40,-40,-40,40,-40,100,100);
 image(p,0,0);
 }
 //この関数は、マーカ平面上の点を描画します。
 void drawMarkerXYPos()
 {
 pushMatrix();
 PVector pos=nya.screen2MarkerCoordSystem(mouseX,mouseY);
 translate(pos.x,pos.y,0);
 noFill();
 stroke(0,0,100);
 ellipse(0,0,20-c%20,20-c%20);
 popMatrix();
 }
 //この関数は、マーカ頂点の情報を描画します。
 void drawVertex()
 {
 PVector[] i_v=nya.getMarkerVertex2D();
 textFont(font,10.0);
 stroke(100,0,0);
 for(int i=0;i<4;i++){
 fill(100,0,0);
 ellipse(i_v[i].x,i_v[i].y,6,6);
 fill(0,0,0);
 text("("+i_v[i].x+","+i_v[i].y+")",i_v[i].x,i_v[i].y);
 }
 }
 
              
              1  
            
 
            
 
 
          