2 * PROJECT: NyARToolkit
\r
3 * --------------------------------------------------------------------------------
\r
5 * The NyARToolkit is Java version ARToolkit class library.
\r
6 * Copyright (C)2008 R.Iizuka
\r
8 * This program is free software; you can redistribute it and/or
\r
9 * modify it under the terms of the GNU General Public License
\r
10 * as published by the Free Software Foundation; either version 2
\r
11 * of the License, or (at your option) any later version.
\r
13 * This program is distributed in the hope that it will be useful,
\r
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
16 * GNU General Public License for more details.
\r
18 * You should have received a copy of the GNU General Public License
\r
19 * along with this framework; if not, write to the Free Software
\r
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
\r
22 * For further information please contact.
\r
23 * http://nyatla.jp/nyatoolkit/
\r
24 * <airmail(at)ebony.plala.or.jp>
\r
27 package jp.nyatla.nyartoolkit.sample;
\r
33 import jp.nyatla.nyartoolkit.core.*;
\r
34 import jp.nyatla.nyartoolkit.core.raster.*;
\r
35 import jp.nyatla.nyartoolkit.detector.*;
\r
36 import jp.nyatla.nyartoolkit.core.transmat.*;
\r
39 * 320x240のBGRA32で記録されたRAWイメージから、1種類のパターンを認識し、
\r
40 * その変換行列を1000回求め、それにかかったミリ秒時間を表示します。
\r
43 public class RawFileTest {
\r
44 private final String code_file ="../Data/patt.hiro";
\r
45 private final String data_file ="../Data/320x240ABGR.raw";
\r
46 private final String camera_file="../Data/camera_para.dat";
\r
47 public RawFileTest()
\r
50 public void Test_arDetectMarkerLite() throws Exception
\r
52 //AR用カメラパラメタファイルをロード
\r
53 NyARParam ap =new NyARParam();
\r
54 ap.loadFromARFile(camera_file);
\r
55 ap.changeSize(320,240);
\r
58 NyARCode code=new NyARCode(16,16);
\r
59 code.loadFromARFile(code_file);
\r
61 //試験イメージの読み出し(320x240 BGRAのRAWデータ)
\r
62 File f=new File(data_file);
\r
63 FileInputStream fs=new FileInputStream(data_file);
\r
64 byte[] buf=new byte[(int)f.length()];
\r
66 NyARRaster_BGRA ra=NyARRaster_BGRA.wrap(buf, 320, 240);
\r
67 // Blank_Raster ra=new Blank_Raster(320, 240);
\r
69 //1パターンのみを追跡するクラスを作成
\r
70 NyARSingleDetectMarker ar=new NyARSingleDetectMarker(ap,code,80.0);
\r
71 NyARTransMatResult result_mat=new NyARTransMatResult();
\r
72 ar.setContinueMode(false);
\r
73 ar.detectMarkerLite(ra,100);
\r
74 ar.getTransmationMatrix(result_mat);
\r
78 for(int i=0;i<1000;i++){
\r
80 ar.detectMarkerLite(ra,100);
\r
81 ar.getTransmationMatrix(result_mat);
\r
84 System.out.println(d.getTime()-d2.getTime());
\r
86 public static void main(String[] args)
\r
90 RawFileTest t=new RawFileTest();
\r
91 //t.Test_arGetVersion();
\r
92 t.Test_arDetectMarkerLite();
\r
93 }catch(Exception e){
\r
94 e.printStackTrace();
\r