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.
IndexProgramming Questions & HelpOther Libraries › NYARToolkit for processing
Page Index Toggle Pages: 1
NYARToolkit for processing (Read 1084 times)
NYARToolkit for processing
Jun 16th, 2009, 11:13pm
 
I saw there was a post about NYARToolkit here a little while back.  It looks like there is a version of NYARToolkit for processing now available.

I'm fairly new to processing, but it seemed like it was easier to get hooked into a webcam rather than through JMF as required by NYARToolkit for java.  I ran the example *.pde that comes with the download, and it does detect the marker but for some reason the background comes out blue instead of displaying a video.  

After that, I decided to switch over to eclipse.  I made sure I had WinVDig and QuickTime 7 installed in that order.  Then referenced the NyARToolkit.jar and NyAR2.jar files, as well as video, jogl and core.  Finally I referenced QTJava.zip which was found in the Program Files\Quicktime\QTSystem folder (yep I'm running win xp).  After playing around a bit I got the video to display with the marker.  I also copied the data folder into the project folder, and printed out the Hiro marker.

Here is my code:
Code:
package testVideo;

import processing.video.*;
import jp.nyatla.nyar4psg.*;
import processing.opengl.*;

import processing.core.*;

public class processingVideo extends PApplet{
/**
*
*/
private static final long serialVersionUID = 1L;

private Capture cam;
private NyARBoard nya;
public void setup(){
size(640,480,OPENGL);
colorMode(RGB, 100);

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

nya.gsThreshold = 120;
nya.cfThreshold = 0.4;

}

public void draw(){
background(0);
cam.read();
image(cam, 0 ,0);
if (cam.available() != true){
return;
}


//cam.read();

if (nya.detect(cam)){
pushMatrix();
popMatrix();
PGraphicsOpenGL pgl = (PGraphicsOpenGL)g;
nya.beginTransform(pgl);
//noFill();
stroke(255,200,0);
translate(0,0,20);
box(40);
nya.endTransform();
}

}

public static void main(String args[]){
PApplet.main(new String[] {"testVideo.processingVideo"});

}
}


For some reason when I uncomment noFill();, I get a black screen (I think the background shows up instead).  I thought I would at least share my code for anyone else wanting to play around.  Not sure what is wrong with the noFill.  The other problem, if I understand the doc file for NyARBoard correctly, is it is meant for a single marker detection only.

Cheers,
David
Page Index Toggle Pages: 1