We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
audio in NyARToolkit (Read 911 times)
audio in NyARToolkit
May 12th, 2010, 7:27am
 


Hello everyone,
I wish that the markers are "loads" a video and audio track, I have this problem:
with player.play (); repeats indefinitely when it is loaded by the marker
as I can hear the whole audio track when  load the marker?

regards


/**      NyARToolkit for proce55ing/0.2.2
     (c)2008 nyatla
     airmail(at)ebony.plala.or.jp
*/

import processing.video.*;
import jp.nyatla.nyar4psg.*;
import processing.opengl.*;
import javax.media.opengl.*;
import ddf.minim.*;



Capture cam;
NyARBoard nya;
PFont font;
Movie myMovie;
AudioPlayer player;
Minim minim;



void setup() {
 size(1024,768,OPENGL);
 myMovie = new Movie(this, "test.avi");
 myMovie.loop();

minim = new Minim(this);
player = minim.loadFile("test.wav", 2048);
player.loop();



 colorMode(RGB, 100);
 font=createFont("FFScala", 32);

 cam=new Capture(this,width,height);
 nya=new NyARBoard(this,width,height,"camera_para.dat","patt.prova", 80);
 print(nya.VERSION);
(this,width,height,"camera_para.dat","patt.hiro",80,NyARBoard.CS_RIGHT);

 nya.gsThreshold=130;//画像2値化の閾値(0<n<255) default=110
 nya.cfThreshold=0.2;//変換行列計算を行うマーカ一致度(0.0<n<1.0) default=0.4
 //nya.lostDelay=10;//マーカ消失を無視する回数(0<n) default=10


}
void drawMarkerPos(int[][] points)
{
 textFont(font,10.0);
 stroke(100,0,0);
 fill(100,0,0);
 for(int i=0;i<4;i++){
   ellipse(nya.pos2d[i][0], nya.pos2d[i][1],5,5);
 }
 fill(0,0,0);
 for(int i=0;i<4;i++){
   text("("+nya.pos2d[i][0]+","+nya.pos2d[i][1]+")",nya.pos2d[i][0],nya.pos2d[i][1]);
 }
}

String angle2text(float a)
{
 int i=(int)degrees(a);
 i=(i>0?i:i+360);
 return (i<100?"  ":i<10?" ":"")+Integer.toString(i);
}
String trans2text(float i)
{
 return (i<100?"  ":i<10?" ":"")+Integer.toString((int)i);
}

void draw() {


 background(255);
 if (cam.available() !=true) {
   return;
 }
 cam.read();

 image(cam,0,0);

   if(nya.detect(cam)){
   
   textFont(font,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(font,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-90,(nya.pos2d[0][1]+nya.pos2d[1][1]+nya.pos2d[2][1]+nya.pos2d[3][1])/4-50);
   text("TRANS "+trans2text(nya.trans.x)+","+trans2text(nya.trans.y)+","+trans2text(nya.trans.z
),0,0);
   text("ANGLE "+angle2text(nya.angle.x)+","+angle2text(nya.angle.y)+","+angle2text(nya.angle.z
),0,15);
   popMatrix();    
   //マーカの位置を描画
   drawMarkerPos(nya.pos2d);
   
   PGraphicsOpenGL pgl = (PGraphicsOpenGL) g;
   nya.beginTransform(pgl);//マーカ座標系での描画を開始する。
   //ここからマーカ座標系
  stroke(255,200,0);
   translate(-40,-40,0);
   scale(0.3);
 //tint(255, 20);
 image(myMovie, 0, 0);
 
player.play();


   nya.endTransform();//マーカ座標系での描画を終了する。(必ず呼んで!)
 }
}
// Called every time a new frame is available to read
void movieEvent(Movie m) {
 m.read();
}
void stop()
{
 
player.close();
 minim.stop();
 
 super.stop();
}
Page Index Toggle Pages: 1