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
41 import jp.nyatla.nyartoolkit.nymodel.x2.*;
\r
45 * 320x240のBGRA32で記録されたRAWイメージから、1種類のパターンを認識し、
\r
46 * その変換行列を1000回求め、それにかかったミリ秒時間を表示します。
\r
49 public class RawFileTest_X2
\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_X2()
\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 = NyARRgbRaster_BGRA.wrap(buf, 320, 240);
\r
79 // Blank_Raster ra=new Blank_Raster(320, 240);
\r
81 // 1パターンのみを追跡するクラスを作成
\r
82 NyARSingleDetectMarker_X2 ar = new NyARSingleDetectMarker_X2(ap, code, 80.0);
\r
83 NyARTransMatResult result_mat = new NyARTransMatResult();
\r
84 ar.setContinueMode(false);
\r
85 ar.detectMarkerLite(ra, 100);
\r
86 ar.getTransmationMatrix(result_mat);
\r
89 Date d2 = new Date();
\r
90 for (int i = 0; i < 1000; i++) {
\r
92 ar.detectMarkerLite(ra, 100);
\r
93 ar.getTransmationMatrix(result_mat);
\r
95 Date d = new Date();
\r
96 System.out.println(d.getTime() - d2.getTime());
\r
99 public static void main(String[] args)
\r
103 RawFileTest_X2 t = new RawFileTest_X2();
\r
104 // t.Test_arGetVersion();
\r
105 t.Test_arDetectMarkerLite();
\r
106 } catch (Exception e) {
\r
107 e.printStackTrace();
\r