Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /nyar4psg/trunk/examples/test/NyARBoardTest/NyARBoardTest.pde

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1158 - (hide annotations) (download)
Tue Jan 6 07:38:11 2015 UTC (9 years, 3 months ago) by nyatla
File size: 2194 byte(s)
パッケージ構成をProcessing2.0向けに更新

1 nyatla 1158 /*
2     NyARBoard class function test program
3    
4     */
5     import processing.video.*;
6     import jp.nyatla.nyar4psg.*;
7     import processing.opengl.*;
8    
9     PFont font=createFont("FFScala", 32);
10     Capture cam;
11     NyARBoard nya;
12    
13     void setup() {
14     size(640,480,P3D);
15     colorMode(RGB, 100);
16     println(NyARBoard.VERSION);
17     cam=new Capture(this,width,height);
18     nya=new NyARBoard(this,width,height,"camera_para.dat","patt.hiro",80); //SingleMarker検出インスタンス
19     nya.setARClipping(100,1000);
20     nya.gsThreshold=120;//画像2値化の閾値(0<n<255) default=110
21     nya.cfThreshold=0.4;//変換行列計算を行うマーカ一致度(0.0<n<1.0) default=0.4
22     print(nya.VERSION); //バージョンの表示
23     cam.start();
24     }
25     int c=0;
26     void draw() {
27     c++;
28     if (cam.available() !=true) {
29     return;
30     }
31     background(255);
32     cam.read();
33     nya.drawBackground(cam);//frustumを考慮した背景描画
34    
35     if(!nya.detect(cam)) //マーカを検出してる時だけ処理
36     {
37     return;
38     }
39     nya.beginTransform();//マーカ座標系に設定
40     {
41     setMatrix(nya.getMarkerMatrix());//マーカ姿勢をセット
42     drawBox();
43     drawMarkerXYPos();
44     }
45     nya.endTransform(); //マーカ座標系を終了
46     drawMarkerPatt();
47     drawVertex();
48    
49     }
50     void drawBox()
51     {
52     pushMatrix();
53     fill(0);
54     stroke(255,200,0);
55     translate(0,0,20);
56     box(40);
57     noFill();
58     translate(0,0,-20);
59     rect(-40,-40,80,80);
60     popMatrix();
61     }
62    
63     //この関数は、マーカパターンを描画します。
64     void drawMarkerPatt()
65     {
66     PImage p=nya.pickupMarkerImage(40,40,-40,40,-40,-40,40,-40,100,100);
67     image(p,0,0);
68     }
69    
70     //この関数は、マーカ平面上の点を描画します。
71     void drawMarkerXYPos()
72     {
73     pushMatrix();
74     PVector pos=nya.screen2MarkerCoordSystem(mouseX,mouseY);
75     translate(pos.x,pos.y,0);
76     noFill();
77     stroke(0,0,100);
78     ellipse(0,0,20-c%20,20-c%20);
79     popMatrix();
80     }
81    
82     //この関数は、マーカ頂点の情報を描画します。
83     void drawVertex()
84     {
85     PVector[] i_v=nya.getMarkerVertex2D();
86     textFont(font,10.0);
87     stroke(100,0,0);
88     for(int i=0;i<4;i++){
89     fill(100,0,0);
90     ellipse(i_v[i].x,i_v[i].y,6,6);
91     fill(0,0,0);
92     text("("+i_v[i].x+","+i_v[i].y+")",i_v[i].x,i_v[i].y);
93     }
94     }
95    
96    
97    

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26