--- /dev/null
+/* \r
+ * PROJECT: NyARToolkit\r
+ * --------------------------------------------------------------------------------\r
+ * This work is based on the original ARToolKit developed by\r
+ * Hirokazu Kato\r
+ * Mark Billinghurst\r
+ * HITLab, University of Washington, Seattle\r
+ * http://www.hitl.washington.edu/artoolkit/\r
+ *\r
+ * The NyARToolkit is Java edition ARToolKit class library.\r
+ * Copyright (C)2008-2009 Ryo Iizuka\r
+ *\r
+ * This program is free software: you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation, either version 3 of the License, or\r
+ * (at your option) any later version.\r
+ * \r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.\r
+ * \r
+ * For further information please contact.\r
+ * http://nyatla.jp/nyatoolkit/\r
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>\r
+ * \r
+ */\r
+package jp.nyatla.nyartoolkit.test;\r
+\r
+import java.io.*;\r
+\r
+\r
+import jp.nyatla.nyartoolkit.NyARException;\r
+import jp.nyatla.nyartoolkit.core.param.NyARParam;\r
+import jp.nyatla.nyartoolkit.core.raster.rgb.*;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquare;\r
+import jp.nyatla.nyartoolkit.core.transmat.*;\r
+import jp.nyatla.nyartoolkit.core.*;\r
+import jp.nyatla.nyartoolkit.processor.*;\r
+\r
+public class SingleARMarkerTest\r
+{\r
+ class MarkerProcessor extends SingleARMarkerProcesser\r
+ { \r
+ private Object _sync_object=new Object();\r
+ public NyARTransMatResult transmat=null;\r
+ public int current_code=-1;\r
+\r
+ public MarkerProcessor(NyARParam i_cparam,int i_raster_format) throws NyARException\r
+ {\r
+ //アプリケーションフレームワークの初期化\r
+ super();\r
+ initInstance(i_cparam,i_raster_format);\r
+ return;\r
+ }\r
+ protected void onEnterHandler(int i_code)\r
+ {\r
+ synchronized(this._sync_object){\r
+ current_code=i_code;\r
+ }\r
+ System.out.println("Marker Number:"+i_code);\r
+ }\r
+ protected void onLeaveHandler()\r
+ {\r
+ synchronized(this._sync_object){\r
+ current_code=-1;\r
+ this.transmat=null;\r
+ }\r
+ return; \r
+ }\r
+\r
+ protected void onUpdateHandler(NyARSquare i_square, NyARTransMatResult result)\r
+ {\r
+ synchronized(this._sync_object){\r
+ this.transmat=result;\r
+ } \r
+ }\r
+ }\r
+ private final static String CARCODE_FILE = "../Data/patt.hiro";\r
+ private final static String PARAM_FILE = "../Data/camera_para.dat"; \r
+ private final String data_file = "../Data/320x240ABGR.raw";\r
+\r
+ public SingleARMarkerTest()\r
+ {\r
+ }\r
+ public void Test() throws Exception\r
+ {\r
+ //AR用カメラパラメタファイルをロード\r
+ NyARParam ap = new NyARParam();\r
+ ap.loadARParamFromFile(PARAM_FILE);\r
+ ap.changeScreenSize(320, 240);\r
+\r
+ // 試験イメージの読み出し(320x240 BGRAのRAWデータ)\r
+ File f = new File(data_file);\r
+ FileInputStream fs = new FileInputStream(data_file);\r
+ byte[] buf = new byte[(int) f.length()];\r
+ fs.read(buf); \r
+\r
+ NyARRgbRaster_BGRA ra = new NyARRgbRaster_BGRA(320, 240,false);\r
+ ra.wrapBuffer(buf);\r
+\r
+ MarkerProcessor pr = new MarkerProcessor(ap, ra.getBufferType());\r
+ NyARCode[] codes=new NyARCode[1];\r
+ codes[0]=new NyARCode(16,16);\r
+ codes[0].loadARPattFromFile(CARCODE_FILE);\r
+ pr.setARCodeTable(codes,16,80.0);\r
+ pr.detectMarker(ra);\r
+ return;\r
+ }\r
+ public static void main(String[] args)\r
+ {\r
+\r
+ try {\r
+ SingleARMarkerTest t = new SingleARMarkerTest();\r
+ // t.Test_arGetVersion();\r
+ t.Test();\r
+ } catch (Exception e) {\r
+ e.printStackTrace();\r
+ }\r
+ } \r
+}\r