OSDN Git Service

[リリース]NyARToolkit 1.0.0
[nyartoolkit-and/nyartoolkit-and.git] / src / jp / nyatla / nyartoolkit / core / NyARDetectSquare.java
1 /* \r
2  * PROJECT: NyARToolkit\r
3  * --------------------------------------------------------------------------------\r
4  * This work is based on the original ARToolKit developed by\r
5  *   Hirokazu Kato\r
6  *   Mark Billinghurst\r
7  *   HITLab, University of Washington, Seattle\r
8  * http://www.hitl.washington.edu/artoolkit/\r
9  *\r
10  * The NyARToolkit is Java version ARToolkit class library.\r
11  * Copyright (C)2008 R.Iizuka\r
12  *\r
13  * This program is free software; you can redistribute it and/or\r
14  * modify it under the terms of the GNU General Public License\r
15  * as published by the Free Software Foundation; either version 2\r
16  * of the License, or (at your option) any later version.\r
17  * \r
18  * This program is distributed in the hope that it will be useful,\r
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
21  * GNU General Public License for more details.\r
22  * \r
23  * You should have received a copy of the GNU General Public License\r
24  * along with this framework; if not, write to the Free Software\r
25  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
26  * \r
27  * For further information please contact.\r
28  *      http://nyatla.jp/nyatoolkit/\r
29  *      <airmail(at)ebony.plala.or.jp>\r
30  * \r
31  */\r
32 package jp.nyatla.nyartoolkit.core;\r
33 \r
34 import jp.nyatla.nyartoolkit.NyARException;\r
35 import jp.nyatla.nyartoolkit.core.raster.*;\r
36 \r
37 \r
38 \r
39 public class NyARDetectSquare\r
40 {\r
41     private final NyARLabeling labeling;\r
42     private final NyARDetectMarker detect;\r
43     private NyARParam param;\r
44 \r
45     /**\r
46      * マーカー抽出インスタンスを作ります。\r
47      * @param i_param\r
48      */\r
49     public NyARDetectSquare(NyARParam i_param)\r
50     {\r
51         param=i_param;\r
52         //解析オブジェクトを作る\r
53         int width=i_param.getX();\r
54         int height=i_param.getY();\r
55 \r
56         labeling=new NyARLabeling_O2(width,height);\r
57         detect=new NyARDetectMarker(width,height);\r
58     }\r
59     /**\r
60      * ラスタイメージから矩形を検出して、結果o_square_holderへ格納します。\r
61      * @param i_marker\r
62      * @param i_number_of_marker\r
63      * @param i_square_holder\r
64      * @throws NyARException\r
65      */\r
66     public void detectSquare(NyARRaster i_image,int i_thresh,NyARSquareList o_square_holder) throws NyARException\r
67     {\r
68 //      number_of_square=0;\r
69         labeling.labeling(i_image, i_thresh);\r
70         if(labeling.getLabelNum()<1){\r
71             return;\r
72         }\r
73         //ここでマーカー配列を作成する。\r
74         detect.detectMarker(labeling,1.0,o_square_holder);\r
75         \r
76         //マーカー情報をフィルタして、スクエア配列を更新する。\r
77         o_square_holder.updateSquareArray(param);\r
78 \r
79 //      NyARSquare square;\r
80 //      int j=0;\r
81 //      for (int i = 0; i <number_of_marker; i++){\r
82 //      double[][]  line        =new double[4][3];\r
83 //      double[][]  vertex      =new double[4][2];\r
84 //      //NyARMarker marker=detect.getMarker(i);\r
85 //      square=square_holder.getSquare(i);\r
86 //      //・・・線の検出??\r
87 //      if (!square.getLine(param))\r
88 //      {\r
89 //          continue;\r
90 //      }\r
91 //      ここで計算するのは良くないと思うんだ  \r
92 //      marker_infoL[j].id  = id.get();\r
93 //      marker_infoL[j].dir = dir.get();\r
94 //      marker_infoL[j].cf  = cf.get(); \r
95 //      j++;\r
96 //      //配列数こえたらドゴォォォンしないようにループを抜ける\r
97 //      if(j>=marker_info.length){\r
98 //          break;\r
99 //      }\r
100 //    }\r
101 //    number_of_square=j;\r
102     }\r
103 }\r