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 version ARToolkit class library.
\r
11 * Copyright (C)2008 R.Iizuka
\r
13 * This program is free software; you can redistribute it and/or
\r
14 * modify it under the terms of the GNU General Public License
\r
15 * as published by the Free Software Foundation; either version 2
\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 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 framework; if not, write to the Free Software
\r
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
\r
27 * For further information please contact.
\r
28 * http://nyatla.jp/nyatoolkit/
\r
29 * <airmail(at)ebony.plala.or.jp>
\r
32 package jp.nyatla.nyartoolkit.toys.x2;
\r
37 import jp.nyatla.nyartoolkit.core.*;
\r
38 import jp.nyatla.nyartoolkit.core.param.NyARParam;
\r
39 import jp.nyatla.nyartoolkit.core.raster.rgb.*;
\r
40 import jp.nyatla.nyartoolkit.core.transmat.*;
\r
44 * 320x240のBGRA32で記録されたRAWイメージから、1種類のパターンを認識し、
\r
45 * その変換行列を1000回求め、それにかかったミリ秒時間を表示します。
\r
48 public class RawFileTest_X2
\r
50 private final String code_file = "../../Data/patt.hiro";
\r
52 private final String data_file = "../../Data/320x240ABGR.raw";
\r
54 private final String camera_file = "../../Data/camera_para.dat";
\r
56 public RawFileTest_X2()
\r
61 public void Test_arDetectMarkerLite() throws Exception
\r
63 // AR用カメラパラメタファイルをロード
\r
64 NyARParam ap = new NyARParam();
\r
65 ap.loadARParamFromFile(camera_file);
\r
66 ap.changeScreenSize(320, 240);
\r
69 NyARCode code = new NyARCode(16, 16);
\r
70 code.loadARPattFromFile(code_file);
\r
72 // 試験イメージの読み出し(320x240 BGRAのRAWデータ)
\r
73 File f = new File(data_file);
\r
74 FileInputStream fs = new FileInputStream(data_file);
\r
75 byte[] buf = new byte[(int) f.length()];
\r
77 INyARRgbRaster ra = NyARRgbRaster_BGRA.wrap(buf, 320, 240);
\r
78 // Blank_Raster ra=new Blank_Raster(320, 240);
\r
80 // 1パターンのみを追跡するクラスを作成
\r
81 NyARSingleDetectMarker_X2 ar = new NyARSingleDetectMarker_X2(ap, code, 80.0);
\r
82 NyARTransMatResult result_mat = new NyARTransMatResult();
\r
83 ar.setContinueMode(false);
\r
84 ar.detectMarkerLite(ra, 100);
\r
85 ar.getTransmationMatrix(result_mat);
\r
88 Date d2 = new Date();
\r
89 for (int i = 0; i < 1000; i++) {
\r
91 ar.detectMarkerLite(ra, 100);
\r
92 ar.getTransmationMatrix(result_mat);
\r
94 Date d = new Date();
\r
95 System.out.println(d.getTime() - d2.getTime());
\r
98 public static void main(String[] args)
\r
102 RawFileTest_X2 t = new RawFileTest_X2();
\r
103 // t.Test_arGetVersion();
\r
104 t.Test_arDetectMarkerLite();
\r
105 } catch (Exception e) {
\r
106 e.printStackTrace();
\r