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
\r
14 * modify it under the terms of the GNU Lesser General Public License
\r
15 * as published by the Free Software Foundation; either version 3
\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 Lesser General Public License for more details
\r
23 * You should have received a copy of the GNU Lesser General Public
\r
24 * License 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_BWと同等のルールで マーカを評価します。
\r
41 public class NyARMatchPatt_BlackWhite implements INyARMatchPatt
\r
43 protected NyARCode _code_patt;
\r
44 protected int _pixels;
\r
46 public NyARMatchPatt_BlackWhite(int i_width, int i_height)
\r
49 this._pixels=i_height*i_width;
\r
52 public NyARMatchPatt_BlackWhite(NyARCode i_code_ref)
\r
55 this._pixels=i_code_ref.getWidth()*i_code_ref.getHeight();
\r
56 this._code_patt=i_code_ref;
\r
60 * 比較対象のARCodeをセットします。
\r
61 * @throws NyARException
\r
63 public void setARCode(NyARCode i_code_ref)
\r
65 this._code_patt=i_code_ref;
\r
69 * 現在セットされているコードとパターンを比較して、結果値o_resultを更新します。
\r
70 * 比較部分はFor文を16倍展開してあります。
\r
72 public boolean evaluate(NyARMatchPattDeviationBlackWhiteData i_patt,NyARMatchPattResult o_result) throws NyARException
\r
74 assert this._code_patt!=null;
\r
76 final int[] linput = i_patt.refData();
\r
79 int res = NyARSquare.DIRECTION_UNKNOWN;
\r
82 for (int j = 0; j < 4; j++) {
\r
85 final NyARMatchPattDeviationBlackWhiteData code_patt=this._code_patt.getBlackWhiteData(j);
\r
86 final int[] pat_j = code_patt.refData();
\r
87 //<全画素について、比較(FORの1/16展開)/>
\r
89 for(i=this._pixels-1;i>=0;i--){
\r
90 sum += linput[i] * pat_j[i];
\r
92 //0.7776737688877927がでればOK
\r
93 final double sum2 = sum / code_patt.getPow() / i_patt.getPow();// sum2 = sum / patpow[k][j]/ datapow;
\r
99 o_result.direction = res;
\r
100 o_result.confidence= max;
\r