2 * PROJECT: NyARToolkit
\r
3 * --------------------------------------------------------------------------------
\r
4 * This work is based on the original ARToolKit developed by
\r
7 * HITLab, University of Washington, Seattle
\r
8 * http://www.hitl.washington.edu/artoolkit/
\r
10 * The NyARToolkit is Java version ARToolkit class library.
\r
11 * Copyright (C)2008 R.Iizuka
\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
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
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
27 * For further information please contact.
\r
28 * http://nyatla.jp/nyatoolkit/
\r
29 * <airmail(at)ebony.plala.or.jp>
\r
32 package jp.nyatla.nyartoolkit.detector;
\r
34 import jp.nyatla.nyartoolkit.NyARException;
\r
35 import jp.nyatla.nyartoolkit.core.*;
\r
36 import jp.nyatla.nyartoolkit.core.match.NyARMatchPatt_Color_WITHOUT_PCA;
\r
37 import jp.nyatla.nyartoolkit.core.raster.*;
\r
39 * 1個のマーカーに対する変換行列を計算するクラスです。
\r
42 public class NyARSingleDetectMarker{
\r
43 private static final int AR_SQUARE_MAX=10;
\r
44 private NyARParam param;
\r
45 private NyARDetectSquare square;
\r
46 private NyARCode code;
\r
47 protected NyARTransMat transmat;
\r
48 private double marker_width;
\r
50 private int detected_direction;
\r
51 private double detected_confidence;
\r
52 private NyARSquare detected_square;
\r
53 private NyARColorPatt patt;
\r
54 public NyARSingleDetectMarker(NyARParam i_param,NyARCode i_code,double i_marker_width)
\r
58 square=new NyARDetectSquare(AR_SQUARE_MAX,i_param);
\r
59 transmat=new NyARTransMat(param);
\r
62 marker_width=i_marker_width;
\r
64 patt=new NyARColorPatt(code.getWidth(),code.getHeight());
\r
68 * i_imageにマーカー検出処理を実行して、結果を保持します。
\r
72 * マーカーが検出できたかを真偽値で返します。
\r
73 * @throws NyARException
\r
75 public boolean detectMarkerLite(NyARRaster i_image,int i_thresh) throws NyARException
\r
77 detected_square=null;
\r
79 square.detectSquare(i_image, i_thresh);
\r
80 int number_of_square=square.getSquareCount();
\r
82 if(number_of_square<1){
\r
87 NyARSquare[] squares=square.getSquareArray();
\r
88 //評価基準になるパターンをイメージから切り出す
\r
89 patt.pickFromRaster(i_image,squares[0].getMarker());
\r
92 NyARMatchPatt_Color_WITHOUT_PCA eva=new NyARMatchPatt_Color_WITHOUT_PCA();
\r
94 if(!eva.setPatt(patt)){
\r
100 int square_index=0;
\r
101 int direction=eva.getDirection();
\r
102 double confidence=eva.getConfidence();
\r
103 for(int i=1;i<number_of_square;i++){
\r
105 patt.pickFromRaster(i_image,squares[i].getMarker());
\r
109 eva.evaluate(code);
\r
110 double c2=eva.getConfidence();
\r
114 //もっと一致するマーカーがあったぽい
\r
116 direction=eva.getDirection();
\r
120 detected_square=squares[square_index];
\r
121 detected_direction=direction;
\r
122 detected_confidence=confidence;
\r
126 * 変換行列を返します。直前に実行したdetectMarkerLiteが成功していないと使えません。
\r
127 * @param i_marker_width
\r
130 * double[3][4]の変換行列を返します。
\r
131 * @throws NyARException
\r
133 public NyARMat getTransmationMatrix() throws NyARException
\r
135 //一番一致したマーカーの位置とかその辺を計算
\r
136 transmat.transMat(detected_square,detected_direction,marker_width);
\r
137 return transmat.getTransformationMatrix();
\r
139 public double getConfidence()
\r
141 return detected_confidence;
\r
143 public int getDirection()
\r
145 return detected_direction;
\r
154 // public static class arUtil_c{
\r
155 // public static final int arFittingMode =Config.DEFAULT_FITTING_MODE;
\r
156 // private static final int arImageProcMode =Config.DEFAULT_IMAGE_PROC_MODE;
\r
157 // public static final int arTemplateMatchingMode =Config.DEFAULT_TEMPLATE_MATCHING_MODE;
\r
158 // public static final int arMatchingPCAMode =Config.DEFAULT_MATCHING_PCA_MODE;
\r
159 /*int arInitCparam( ARParam *param )*/
\r