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.detector;
\r
33 import jp.nyatla.nyartoolkit.NyARException;
\r
34 import jp.nyatla.nyartoolkit.core.*;
\r
35 import jp.nyatla.nyartoolkit.core.param.NyARParam;
\r
36 import jp.nyatla.nyartoolkit.core.pickup.INyARColorPatt;
\r
37 import jp.nyatla.nyartoolkit.core.raster.rgb.*;
\r
39 import jp.nyatla.nyartoolkit.core.rasterfilter.rgb2bin.NyARRasterFilter_ARToolkitThreshold;
\r
40 import jp.nyatla.nyartoolkit.core.squaredetect.*;
\r
41 import jp.nyatla.nyartoolkit.core.pickup.*;
\r
42 import jp.nyatla.nyartoolkit.core.transmat.*;
\r
44 * 画像からARCodeに最も一致するマーカーを1個検出し、その変換行列を計算するクラスです。
\r
47 public class NyARSingleDetectMarker extends NyARCustomSingleDetectMarker
\r
49 public final static int PF_ARTOOLKIT_COMPATIBLE=1;
\r
50 public final static int PF_NYARTOOLKIT=2;
\r
51 public final static int PF_NYARTOOLKIT_ARTOOLKIT_FITTING=100;
\r
52 public final static int PF_TEST2=201;
\r
55 * 検出するARCodeとカメラパラメータから、1個のARCodeを検出するNyARSingleDetectMarkerインスタンスを作ります。
\r
61 * @param i_marker_width
\r
62 * ARコードの物理サイズを、ミリメートルで指定します。
\r
63 * @param i_input_raster_type
\r
64 * 入力ラスタのピクセルタイプを指定します。この値は、INyARBufferReaderインタフェイスのgetBufferTypeの戻り値を指定します。
\r
65 * @throws NyARException
\r
67 public NyARSingleDetectMarker(NyARParam i_param, NyARCode i_code, double i_marker_width,int i_input_raster_type,int i_profile_id) throws NyARException
\r
70 initInstance(i_param,i_code,i_marker_width,i_input_raster_type,i_profile_id);
\r
73 public NyARSingleDetectMarker(NyARParam i_param, NyARCode i_code, double i_marker_width,int i_input_raster_type) throws NyARException
\r
76 initInstance(i_param,i_code,i_marker_width,i_input_raster_type,PF_NYARTOOLKIT);
\r
80 * コンストラクタから呼び出す関数です。
\r
81 * @param i_ref_param
\r
83 * @param i_marker_width
\r
84 * @param i_input_raster_type
\r
85 * @param i_profile_id
\r
86 * @throws NyARException
\r
88 protected void initInstance(
\r
89 NyARParam i_ref_param,
\r
90 NyARCode i_ref_code,
\r
91 double i_marker_width,
\r
92 int i_input_raster_type,
\r
93 int i_profile_id) throws NyARException
\r
95 final NyARRasterFilter_ARToolkitThreshold th=new NyARRasterFilter_ARToolkitThreshold(100,i_input_raster_type);
\r
96 INyARColorPatt patt_inst;
\r
97 INyARSquareDetector sqdetect_inst;
\r
98 INyARTransMat transmat_inst;
\r
100 switch(i_profile_id){
\r
101 case PF_ARTOOLKIT_COMPATIBLE:
\r
102 patt_inst=new NyARColorPatt_O3(i_ref_code.getWidth(), i_ref_code.getHeight());
\r
103 sqdetect_inst=new NyARSquareDetector_ARToolKit(i_ref_param.getDistortionFactor(),i_ref_param.getScreenSize());
\r
104 transmat_inst=new NyARTransMat_ARToolKit(i_ref_param);
\r
106 case PF_NYARTOOLKIT_ARTOOLKIT_FITTING:
\r
107 patt_inst=new NyARColorPatt_Perspective_O2(i_ref_code.getWidth(), i_ref_code.getHeight(),4,25);
\r
108 sqdetect_inst=new NyARSquareDetector_Rle(i_ref_param.getDistortionFactor(),i_ref_param.getScreenSize());
\r
109 transmat_inst=new NyARTransMat_ARToolKit(i_ref_param);
\r
111 case PF_NYARTOOLKIT://default
\r
112 patt_inst=new NyARColorPatt_Perspective_O2(i_ref_code.getWidth(), i_ref_code.getHeight(),4,25);
\r
113 sqdetect_inst=new NyARSquareDetector_Rle(i_ref_param.getDistortionFactor(),i_ref_param.getScreenSize());
\r
114 transmat_inst=new NyARTransMat(i_ref_param);
\r
117 throw new NyARException();
\r
119 super.initInstance(patt_inst,sqdetect_inst,transmat_inst,th,i_ref_param,i_ref_code,i_marker_width);
\r
124 * i_imageにマーカー検出処理を実行し、結果を記録します。
\r
127 * マーカーを検出するイメージを指定します。イメージサイズは、コンストラクタで指定i_paramの
\r
128 * スクリーンサイズと一致し、かつi_input_raster_typeに指定した形式でなければいけません。
\r
129 * @return マーカーが検出できたかを真偽値で返します。
\r
130 * @throws NyARException
\r
132 public boolean detectMarkerLite(INyARRgbRaster i_raster,int i_threshold) throws NyARException
\r
134 ((NyARRasterFilter_ARToolkitThreshold)this._tobin_filter).setThreshold(i_threshold);
\r
135 return super.detectMarkerLite(i_raster);
\r