Browse Subversion Repository
Contents of /nyar4psg/trunk/examples/markerPlane/markerPlane.pde
Parent Directory
| Revision Log
Revision 1158 -
( show annotations)
( download)
Tue Jan 6 07:38:11 2015 UTC
(9 years, 4 months ago)
by nyatla
File size: 1291 byte(s)
パッケージ構成をProcessing2.0向けに更新
| 1 |
/** |
| 2 |
NyARToolkit for proce55ing/1.0.0 |
| 3 |
(c)2008-2011 nyatla |
| 4 |
airmail(at)ebony.plala.or.jp |
| 5 |
|
| 6 |
このサンプルは、スクリーン座標をマーカ座標に変換します。 |
| 7 |
Hiroマーカを使います。マーカが認識されたら、マウスカーソルを移動させてみて下さい。 |
| 8 |
|
| 9 |
This sample converts to the marker plain position from the screen position. |
| 10 |
Please move the mouse cursor on the screen the marker is recognized. |
| 11 |
The marker is "Patt.hiro" . |
| 12 |
*/ |
| 13 |
import processing.video.*; |
| 14 |
import jp.nyatla.nyar4psg.*; |
| 15 |
|
| 16 |
Capture cam; |
| 17 |
MultiMarker nya; |
| 18 |
|
| 19 |
void setup() { |
| 20 |
size(640,480,P3D); |
| 21 |
colorMode(RGB, 100); |
| 22 |
cam=new Capture(this,640,480); |
| 23 |
nya=new MultiMarker(this,width,height,"camera_para.dat",NyAR4PsgConfig.CONFIG_PSG); |
| 24 |
nya.addARMarker("patt.hiro",80);//id=0 |
| 25 |
cam.start(); |
| 26 |
} |
| 27 |
|
| 28 |
int c=0; |
| 29 |
void draw() |
| 30 |
{ |
| 31 |
c++; |
| 32 |
if (cam.available() !=true) { |
| 33 |
return; |
| 34 |
} |
| 35 |
cam.read(); |
| 36 |
nya.detect(cam); |
| 37 |
background(0); |
| 38 |
nya.drawBackground(cam);//frustumを考慮した背景描画 |
| 39 |
if((!nya.isExistMarker(0))){ |
| 40 |
return; |
| 41 |
} |
| 42 |
PVector p=nya.screen2MarkerCoordSystem(0,mouseX,mouseY); |
| 43 |
nya.beginTransform(0); |
| 44 |
noFill(); |
| 45 |
stroke(100,0,0); |
| 46 |
rect(-40,-40,80,80); |
| 47 |
stroke(100,100,0); |
| 48 |
ellipse((int)p.x,(int)p.y,20-c%20,20-c%20); |
| 49 |
nya.endTransform(); |
| 50 |
} |
| 51 |
|
| 52 |
|
| |