NyARToolkit+processing/1.0で、お手軽拡張現実デザインができる目処がついたので、SSとかを公開します。
バイナリとかのリリースは明日かなぁ。
その1
まずは基本編
processingのソースコードはこれだけ。ちょー簡単。
import processing.video.*; import jp.nyatla.nyar4psg.*; import processing.opengl.*; import javax.media.opengl.*; Capture cam; NyARBoard nya; PFont font; void setup() { size(640,480,OPENGL); colorMode(RGB, 100); font =createFont("FFScala", 32); // If no device is specified, will just use the default. cam = new Capture(this, 640, 480); nya=new NyARBoard(this,640,480,"camera_para.dat","patt.hiro",80); } 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]); } } void draw() { background(255); if (cam.available() !=true) { return; } cam.read(); image(cam,0,0); PGraphicsOpenGL pgl = (PGraphicsOpenGL) g; // g may change if(nya.detect(cam)){ drawMarkerPos(nya.pos2d); nya.beginTransform(pgl); noFill(); stroke(255,200,0); translate(0,0,20); box(40); nya.endTransform(); } }
nyaが1個のマーカを見つけて変換行列を作るオブジェクトで、NyARToolKitのSingleMarkerDetectorのラッパーになってる。
マーカを見つけたら、その4頂点の座標を表示して、そこに立方体を書いてます。