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.NyARCode;
\r
35 import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquare;
\r
38 * AR_TEMPLATE_MATCHING_COLORかつAR_MATCHING_WITH_PCAと同等のルールで マーカーを評価します。
\r
41 public class NyARMatchPatt_Color_WITH_PCA extends NyARMatchPatt_Color_WITHOUT_PCA
\r
43 private final int EVEC_MAX = 10;// #define EVEC_MAX 10
\r
45 private int evec_dim;// static int evec_dim;
\r
46 private double[][] evec;// static double evec[EVEC_MAX][AR_PATT_SIZE_Y*AR_PATT_SIZE_X*3];
\r
47 private double[][] epat = new double[4][EVEC_MAX];// static double epat[AR_PATT_NUM_MAX][4][EVEC_MAX];
\r
50 public NyARMatchPatt_Color_WITH_PCA(int i_width, int i_height)
\r
52 super(i_width,i_height);
\r
55 public NyARMatchPatt_Color_WITH_PCA(NyARCode i_code_ref)
\r
60 public boolean evaluate(NyARMatchPattDeviationColorData i_patt,NyARMatchPattResult o_result) throws NyARException
\r
62 final int[] linput = i_patt.refData();
\r
65 int res = NyARSquare.DIRECTION_UNKNOWN;
\r
68 "NyARMatchPatt_Color_WITH_PCA\n"+
\r
70 "ARToolKitの移植条件を完全に再現できていないため、evec,epatの計算が無視されています。"+
\r
71 "gen_evec(void)も含めて移植の必要があるはずですが、まだ未解析です。");
\r
72 */ double[] invec = new double[EVEC_MAX];
\r
73 for (int i = 0; i < this.evec_dim; i++) {
\r
75 for(int j=0;j<this._rgbpixels;i++){
\r
76 invec[i] += this.evec[i][j] * linput[j];
\r
78 invec[i] /= i_patt.getPow();
\r
80 double min = 10000.0;
\r
81 for (int j = 0; j < 4; j++) {
\r
83 for (int i = 0; i < this.evec_dim; i++) {
\r
84 sum2 += (invec[i] - this.epat[j][i]) * (invec[i] - this.epat[j][i]);
\r
89 // res2 = k;//kは常にインスタンスを刺すから、省略可能
\r
93 final int[] code_data=this._code_patt.getColorData(res).refData();
\r
94 for (int i = 0; i < this._rgbpixels; i++) {// for(int
\r
95 sum += linput[i] * code_data[i];// sum +=input[i][i2][i3]*pat[res2][res][i][i2][i3];
\r
97 max = sum / this._code_patt.getColorData(res).getPow() / i_patt.getPow();
\r
98 o_result.direction = res;
\r
99 o_result.confidence = max;
\r