This is my script modified from an AR demo sample :
- /**
- NyARToolkit for proce55ing/1.0.0
- (c)2008-2011 nyatla
- airmail(at)ebony.plala.or.jp
-
- 最も短いARToolKitのコードです。
- Hiroマーカを用意してください。
-
- This sample program is most small sample as simpleLite.
- The marker is "patt.hiro".
- */
- import processing.video.*;
- import jp.nyatla.nyar4psg.*;
- import colladaLoader.*;
- ColladaLoader model;
- float angle = 0.01;
- char axis ='y';
-
- Capture cam;
- MultiMarker nya;
- void setup() {
- size(640,480,P3D);
- //copy duff.kmz manually to processing's "data" folder or choose sketch->add file
- model = ColladaLoader.getInstance("iBook.kmz", this);
- //model = ColladaLoader.getInstance(sketchPath("../data/duff.kmz"), this);
- frameRate(20);
- model.scale(3.0f);
- //colorMode(RGB, 100);
- //println(MultiMarker.VERSION);
- cam=new Capture(this,640,480, Capture.list()[0], 30);
- //myCapture = new Capture(this, width, height, Capture.list()[0], 30);
- nya=new MultiMarker(this,width,height,"camera_para.dat",NyAR4PsgConfig.CONFIG_PSG);
- nya.addARMarker("patt.hiro",80);
- }
- void draw()
- {
- if (cam.available() !=true) {
- return;
- }
- cam.read();
- nya.detect(cam);
- background(0);
- lights();
- nya.drawBackground(cam);//frustumを考慮した背景描画
- if((!nya.isExistMarker(0))){
- return;
- }
- nya.beginTransform(0);
- //fill(0,0,255);
- translate(0,0,0);
- rotateX(30);
- rotateY(90);
- //box(40);
- model.rotate(angle, axis); //rotates Model as an animation
- model.draw();
- nya.endTransform();
- }
- void mouseDragged()
- {
- //scales model bigger or smaller
- model.scale(1+(pmouseY - mouseY) * 0.01f);
- }
- void keyPressed() {
-
- //shifts translates model in all 3D axis
- if (keyCode == LEFT) {angle = 0; model.shift(-5.0f, 'x');}
- if (keyCode == RIGHT) {angle=0; model.shift(5.0f, 'x');}
- if (keyCode == UP) {angle = 0; model.shift(-5.0f, 'y');}
- if (keyCode == DOWN) {angle = 0; model.shift(5.0f, 'y');}
- if (key == 'f') {angle = 0; model.shift(-5.0f, 'z');}
- if (key == 'b') {angle = 0; model.shift(5.0f, 'z');}
- if (key == 'x'||key == 'y'||key == 'z') {axis = key; angle = 0.08f;}
- }
Still, one of my webcam gives me this problem
:
Problem connecting Video output to Quicktime. .
And the other cam is also a problem,
Problem starting streaming...
could not open file mapping object ...
could not unmap view of file .
and only the default one (build-in atop screen ) can be used.
Seems like a conflict using the cams in Processing. In other app or my own Flash script has no such issue .
Cheers
-poserpro