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 edition ARToolKit class library.
\r
11 * Copyright (C)2008-2009 Ryo Iizuka
\r
13 * This program is free software: you can redistribute it and/or modify
\r
14 * it under the terms of the GNU General Public License as published by
\r
15 * the Free Software Foundation, either version 3 of the License, or
\r
16 * (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 program. If not, see <http://www.gnu.org/licenses/>.
\r
26 * For further information please contact.
\r
27 * http://nyatla.jp/nyatoolkit/
\r
28 * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
\r
31 package jp.nyatla.nyartoolkit.core.match;
\r
33 import jp.nyatla.nyartoolkit.NyARException;
\r
34 import jp.nyatla.nyartoolkit.core.*;
\r
35 import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquare;
\r
38 * AR_TEMPLATE_MATCHING_COLORかつAR_MATCHING_WITHOUT_PCAと同等のルールで マーカーを評価します。
\r
41 public class NyARMatchPatt_Color_WITHOUT_PCA implements INyARMatchPatt
\r
43 protected NyARCode _code_patt;
\r
45 protected int _optimize_for_mod;
\r
46 protected int _rgbpixels;
\r
47 public NyARMatchPatt_Color_WITHOUT_PCA(NyARCode i_code_ref)
\r
49 int w=i_code_ref.getWidth();
\r
50 int h=i_code_ref.getHeight();
\r
52 this._rgbpixels=w*h*3;
\r
53 this._optimize_for_mod=this._rgbpixels-(this._rgbpixels%16);
\r
54 this.setARCode(i_code_ref);
\r
57 public NyARMatchPatt_Color_WITHOUT_PCA(int i_width, int i_height)
\r
60 this._rgbpixels=i_height*i_width*3;
\r
61 this._optimize_for_mod=this._rgbpixels-(this._rgbpixels%16);
\r
65 * 比較対象のARCodeをセットします。
\r
66 * @throws NyARException
\r
68 public void setARCode(NyARCode i_code_ref)
\r
70 this._code_patt=i_code_ref;
\r
74 * 現在セットされているARコードとi_pattを比較します。
\r
76 public boolean evaluate(NyARMatchPattDeviationColorData i_patt,NyARMatchPattResult o_result) throws NyARException
\r
78 assert this._code_patt!=null;
\r
80 final int[] linput = i_patt.refData();
\r
82 double max = Double.MIN_VALUE;
\r
83 int res = NyARMatchPattResult.DIRECTION_UNKNOWN;
\r
84 final int for_mod=this._optimize_for_mod;
\r
85 for (int j = 0; j < 4; j++) {
\r
88 final NyARMatchPattDeviationColorData code_patt=this._code_patt.getColorData(j);
\r
89 final int[] pat_j = code_patt.refData();
\r
90 //<全画素について、比較(FORの1/16展開)>
\r
92 for(i=this._rgbpixels-1;i>=for_mod;i--){
\r
93 sum += linput[i] * pat_j[i];
\r
96 sum += linput[i] * pat_j[i];i--;
\r
97 sum += linput[i] * pat_j[i];i--;
\r
98 sum += linput[i] * pat_j[i];i--;
\r
99 sum += linput[i] * pat_j[i];i--;
\r
100 sum += linput[i] * pat_j[i];i--;
\r
101 sum += linput[i] * pat_j[i];i--;
\r
102 sum += linput[i] * pat_j[i];i--;
\r
103 sum += linput[i] * pat_j[i];i--;
\r
104 sum += linput[i] * pat_j[i];i--;
\r
105 sum += linput[i] * pat_j[i];i--;
\r
106 sum += linput[i] * pat_j[i];i--;
\r
107 sum += linput[i] * pat_j[i];i--;
\r
108 sum += linput[i] * pat_j[i];i--;
\r
109 sum += linput[i] * pat_j[i];i--;
\r
110 sum += linput[i] * pat_j[i];i--;
\r
111 sum += linput[i] * pat_j[i];i--;
\r
113 //<全画素について、比較(FORの1/16展開)/>
\r
114 final double sum2 = sum / code_patt.getPow();// sum2 = sum / patpow[k][j]/ datapow;
\r
120 o_result.direction = res;
\r
121 o_result.confidence= max/i_patt.getPow();
\r