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.test;
\r
36 import jp.nyatla.nyartoolkit.core.*;
\r
37 import jp.nyatla.nyartoolkit.core.param.NyARParam;
\r
38 import jp.nyatla.nyartoolkit.core.raster.rgb.*;
\r
39 import jp.nyatla.nyartoolkit.core.transmat.*;
\r
40 import jp.nyatla.nyartoolkit.detector.NyARSingleDetectMarker;
\r
41 import jp.nyatla.nyartoolkit.core.types.*;
\r
44 * このサンプルは、{@link NyARSingleDetectMarker}クラスの動作チェック&ベンチマークプログラムです。
\r
45 * 静止画から1個のHiroマーカを認識して、その姿勢変換行列、パターン一致率を得る動作を確認できます。
\r
46 * 同時に、この処理を1000回実行して、処理時間を計測します。この数値は、NyARToolkitの基本性能の
\r
49 public class RawFileTest
\r
51 private final String code_file = "../Data/patt.hiro";
\r
53 private final String data_file = "../Data/320x240ABGR.raw";
\r
55 private final String camera_file = "../Data/camera_para.dat";
\r
57 public RawFileTest()
\r
62 public void Test_arDetectMarkerLite() throws Exception
\r
64 // AR用カメラパラメタファイルをロード
\r
65 NyARParam ap = new NyARParam();
\r
66 ap.loadARParamFromFile(camera_file);
\r
67 ap.changeScreenSize(320, 240);
\r
70 NyARCode code = new NyARCode(16, 16);
\r
71 code.loadARPattFromFile(code_file);
\r
73 // 試験イメージの読み出し(320x240 BGRAのRAWデータ)
\r
74 File f = new File(data_file);
\r
75 FileInputStream fs = new FileInputStream(data_file);
\r
76 byte[] buf = new byte[(int) f.length()];
\r
78 INyARRgbRaster ra = new NyARRgbRaster_BGRA(320, 240,false);
\r
80 // Blank_Raster ra=new Blank_Raster(320, 240);
\r
82 // 1パターンのみを追跡するクラスを作成
\r
83 NyARSingleDetectMarker ar = new NyARSingleDetectMarker(
\r
84 ap, code, 80.0,ra.getBufferType(),NyARSingleDetectMarker.PF_NYARTOOLKIT);
\r
85 NyARTransMatResult result_mat = new NyARTransMatResult();
\r
86 ar.setContinueMode(true);
\r
87 ar.detectMarkerLite(ra, 100);
\r
88 ar.getTransmationMatrix(result_mat);
\r
91 Date d2 = new Date();
\r
92 for (int i = 0; i < 1000; i++) {
\r
94 ar.detectMarkerLite(ra, 100);
\r
95 ar.getTransmationMatrix(result_mat);
\r
97 Date d = new Date();
\r
98 NyARDoublePoint3d ang=new NyARDoublePoint3d();
\r
99 result_mat.getZXYAngle(ang);
\r
100 System.out.println(d.getTime() - d2.getTime());
\r
101 System.out.print( ar.getConfidence());
\r
104 public static void main(String[] args)
\r
108 RawFileTest t = new RawFileTest();
\r
109 // t.Test_arGetVersion();
\r
110 t.Test_arDetectMarkerLite();
\r
111 } catch (Exception e) {
\r
112 e.printStackTrace();
\r