OSDN Git Service

[リリース]NyARToolkit 0.6
authornyatla <nyatla@7cac0a50-4618-4814-88d0-24b83990f816>
Sat, 7 Jun 2008 01:29:06 +0000 (01:29 +0000)
committernyatla <nyatla@7cac0a50-4618-4814-88d0-24b83990f816>
Sat, 7 Jun 2008 01:29:06 +0000 (01:29 +0000)
16 files changed:
changelog/0.6.20080330.0.txt [new file with mode: 0644]
readme.ja.txt
sample/jmf/NyarToolkitLinkTest.java
sample/jogl/JavaSimpleLite.java
src/jp/nyatla/nyartoolkit/base/Param.java
src/jp/nyatla/nyartoolkit/core/NyARCode.java
src/jp/nyatla/nyartoolkit/core/NyARColorPatt.java
src/jp/nyatla/nyartoolkit/core/NyARDetectMarker.java
src/jp/nyatla/nyartoolkit/core/NyARDetectSquare.java
src/jp/nyatla/nyartoolkit/core/NyARLabeling.java
src/jp/nyatla/nyartoolkit/core/NyARMat.java
src/jp/nyatla/nyartoolkit/core/NyARParam.java
src/jp/nyatla/nyartoolkit/core/NyARTransMat.java
src/jp/nyatla/nyartoolkit/detector/NyARSingleDetectMarker.java
src/jp/nyatla/nyartoolkit/sample/RawFileTest.java
src/jp/nyatla/util/DoubleValue.java

diff --git a/changelog/0.6.20080330.0.txt b/changelog/0.6.20080330.0.txt
new file mode 100644 (file)
index 0000000..0dba4ee
--- /dev/null
@@ -0,0 +1,30 @@
+2008.03.30 version 0.6.20080330.0\r
+\r
+*Title\r
+-メモリ管理の見直し\r
+-速度向上(84%up)\r
+-サンプルの15fps化\r
+\r
+*PublicAPI\r
+\r
+-NyARCode.java\r
+[改名--rename]\r
+ NyARCode::LoadFromARFileをNyARCode::loadFromARFile\r
+\r
+-NyARDetectMarker.java\r
+[廃止--delete]\r
+NyARDetectMarker::getMarkerArray\r
+[追加--add]\r
+NyARDetectMarker::getMarker\r
+\r
+\r
+-NyARMat.java\r
+[更新--update]\r
+NyARMat::matrixSelfInv \r
+NyARMat::matrixDup\r
+\r
+-DoubleValue.java\r
+[廃止--delete]\r
+DoubleValue::set\r
+DoubleValue::get\r
+DoubleValue::add\r
index 7ef27f4..aff2908 100644 (file)
@@ -1,7 +1,7 @@
 ARToolkit Java class library NyARToolkit.\r
 Copyright (C)2008 R.Iizuka\r
 \r
-version Alpha 0.5.20080329.0\r
+version Alpha 0.6.20080330.0\r
 \r
 http://nyatla.jp/\r
 airmail(at)ebony.plala.or.jp\r
@@ -15,25 +15,30 @@ airmail(at)ebony.plala.or.jp
 NyARToolkitは、nativeなコードを一切使用しない、Pure Javaのみで\r
 構成されたARToolkitクラスライブラリです。\r
 \r
-ARToolkit 2.72.0をベースに構築されています。\r
+ARToolkit 2.72.1をベースに構築されています。\r
 \r
 J2SEでのみ動作を確認しました。\r
 J2MEやMIDP2.0にはそのうち対応します。\r
 \r
 \r
+ARToolkitは加藤博一先生とHuman Interface Technology Labにより\r
+開発されたAugmented Reality (AR) ライブラリです。\r
+詳しくはこちらをご覧下さい。\r
+http://www.hitl.washington.edu/artoolkit/\r
+\r
 \r
 \r
 ・基本構成\r
 \r
-+----------------------------\r
-|       Application         |\r
-+-------+-------+-----------+\r
-|NyARJMF| NyJogl|           |\r
-+-------+-------+           |\r
-|  JMF  |  JOGL |NyARToolkit|\r
-+-------+-------+           |\r
-|Camera |  3D   |           |\r
-----------------------------+\r
++-----------------------------+\r
+|         Application         |\r
++-------+-------+-------------+\r
+|NyARJMF| NyARJogl|           |\r
++-------+---------+           |\r
+|  JMF  |  JOGL   |NyARToolkit|\r
++-------+---------+           |\r
+|Camera |  3D     |           |\r
+------------------------------+\r
 \r
 映像キャプチャにはJMFを使用し、3D描画にはJoglを使用しています。\r
 NyARJMFとNyJoglは、これらのエクステンションをApplicationやNyARToolKit\r
@@ -103,7 +108,6 @@ GPLです。詳しくはLICENCE.txtをみてください。
 \r
 \r
 ・お願い\r
-\r
 NyARToolkitを使って面白いものが出来たら、是非教えてください。\r
 \r
 それと強制では有りませんが、NyARToolkitを使った感想などを\r
@@ -111,7 +115,6 @@ NyARToolkitを使って面白いものが出来たら、是非教えてくださ
 \r
 \r
 \r
-\r
 ではでは、楽しく遊んでくださいネ。\r
 \r
-2008.03.29 R.Iizuka@nyatla.jp\r
+2008.03.29 R.Iizuka nyatla.jp\r
index ed667c5..4a6c79a 100644 (file)
@@ -44,7 +44,7 @@ public class NyarToolkitLinkTest extends Frame implements JmfCaptureListener
         ar_param.loadFromARFile(PARAM_FILE);
         ar_param.changeSize(320,240);
         nya=new NyARSingleDetectMarker(ar_param,ar_code,80.0);
-        ar_code.LoadFromARFile(CARCODE_FILE);
+        ar_code.loadFromARFile(CARCODE_FILE);
     }
 
 
index 5b54af6..35733fe 100644 (file)
@@ -121,7 +121,7 @@ public class JavaSimpleLite implements GLEventListener,JmfCaptureListener
         //NyARToolkitの準備\r
         try{\r
             //キャプチャの準備\r
-            capture=new JmfCameraCapture(320,240,30f,JmfCameraCapture.PIXCEL_FORMAT_RGB);\r
+            capture=new JmfCameraCapture(320,240,15f,JmfCameraCapture.PIXCEL_FORMAT_RGB);\r
             capture.setCaptureListener(this);\r
             capture.start();\r
             //NyARToolkitの準備\r
@@ -130,7 +130,7 @@ public class JavaSimpleLite implements GLEventListener,JmfCaptureListener
             ar_param.loadFromARFile(PARAM_FILE);\r
             ar_param.changeSize(320,240);\r
             nya=new GLNyARSingleDetectMarker(ar_param,ar_code,80.0);\r
-            ar_code.LoadFromARFile(CARCODE_FILE);\r
+            ar_code.loadFromARFile(CARCODE_FILE);\r
             //GL対応のRGBラスタオブジェクト\r
             cap_image=new GLNyARRaster_RGB(gl,ar_param,320,240);\r
 \r
index 5079131..42a7368 100644 (file)
@@ -128,7 +128,7 @@ public class Param {
                NyARException.trap("未チェックのパス");\r
                NyARMat.matrixMul( mat_wm1, mat_at, mat_a );//if( arMatrixMul( mat_wm1, mat_at, mat_a ) < 0 ) {\r
                NyARException.trap("未チェックのパス");\r
-               NyARMat.matrixSelfInv(mat_wm1 );//if( arMatrixSelfInv( mat_wm1 ) < 0 ) {\r
+               mat_wm1.matrixSelfInv();//if( arMatrixSelfInv( mat_wm1 ) < 0 ) {\r
 \r
                NyARException.trap("未チェックのパス");\r
                NyARMat.matrixMul( mat_wm2, mat_wm1, mat_at );//if( arMatrixMul( mat_wm2, mat_wm1, mat_at ) < 0 ) {\r
@@ -311,7 +311,7 @@ public class Param {
            t2_array[3][3]=1.0;//t2->m[15] = 1.0;\r
            }\r
            JartkException.trap("未チェックのパス");\r
-           ARMat.matrixSelfInv(t1);//if( arMatrixSelfInv(t1) != 0 ) {\r
+           t1.matrixSelfInv();//if( arMatrixSelfInv(t1) != 0 ) {\r
 \r
            JartkException.trap("未チェックのパス");        \r
            t3 =ARMat.matrixAllocMul(t2, t1);//t3 = arMatrixAllocMul(t2, t1);\r
index acc2596..0a947d8 100644 (file)
@@ -84,7 +84,8 @@ public class NyARCode{
        pat=new int[4][height][width][3];//static int    pat[AR_PATT_NUM_MAX][4][AR_PATT_SIZE_Y*AR_PATT_SIZE_X*3];\r
        patBW=new short[4][height][width];//static int    patBW[AR_PATT_NUM_MAX][4][AR_PATT_SIZE_Y*AR_PATT_SIZE_X*3];\r
     }\r
-    \r
+\r
+\r
     /**\r
      * int arLoadPatt( const char *filename );\r
      * ARToolKitのパターンファイルをロードする。\r
@@ -92,11 +93,11 @@ public class NyARCode{
      * @return\r
      * @throws Exception\r
      */\r
-    public void LoadFromARFile(String filename) throws NyARException\r
+    public void loadFromARFile(String filename) throws NyARException\r
     {\r
        try{\r
             StreamTokenizer st=new StreamTokenizer(new InputStreamReader(new FileInputStream(filename)));\r
-               //パターンデータはGBRAで並んでる。\r
+            //パターンデータはGBRAで並んでる。\r
             for(int h=0; h<4; h++ ) {\r
                 int l = 0;\r
                 for(int i3 = 0; i3 < 3; i3++ ) {\r
index bfb749d..f2f1021 100644 (file)
@@ -93,7 +93,7 @@ public class NyARColorPatt
             b_array[i*2+1][0]=vertex[i][1];//b->m[i*2+1] = vertex[i][1];\r
         }\r
 //         JartkException.trap("未チェックのパス");\r
-        NyARMat.matrixSelfInv(a);\r
+        a.matrixSelfInv();\r
            \r
 //         JartkException.trap("未チェックのパス");\r
         NyARMat.matrixMul( c, a, b );\r
index 2a73545..3d7370d 100644 (file)
@@ -48,7 +48,8 @@ public class NyARDetectMarker {
 \r
     private int area_max=AR_AREA_MAX;\r
     private int area_min=AR_AREA_MIN;\r
-    private NyARMarker[] marker_info2_array;\r
+    private NyARMarker[] marker_holder;        //マーカーデータの保持配列\r
+    private NyARMarker[] marker_info2_array;   //マーカーデータのインデックス配列\r
     private int marker_num;\r
     private int width,height;\r
     /**\r
@@ -61,15 +62,19 @@ public class NyARDetectMarker {
     {\r
        width =i_width;\r
        height=i_height;\r
+       marker_holder=new NyARMarker[i_squre_max];\r
        marker_info2_array=new NyARMarker[i_squre_max];\r
     }\r
     public int getMarkerNum()\r
     {\r
        return marker_num;\r
     }\r
-    public NyARMarker[] getMarkerArray() throws NyARException\r
+    public NyARMarker getMarker(int idx) throws NyARException\r
     {\r
-       return marker_info2_array;\r
+       if(idx>=marker_num){\r
+           throw new NyARException();\r
+       }\r
+       return marker_info2_array[idx];\r
     }\r
     /**\r
      * static int get_vertex( int x_coord[], int y_coord[], int st,  int ed,double thresh, int vertex[], int *vnum)\r
@@ -214,7 +219,9 @@ public class NyARDetectMarker {
        }\r
     /**\r
      * int arGetContour( ARInt16 *limage, int *label_ref,int label, int clip[4], ARMarkerInfo2 *marker_info2 )\r
-     * 関数の代替品      \r
+     * 関数の代替品\r
+     * detectMarker関数から使う関数です。marker_holder[i_holder_num]にオブジェクトが無ければまず新規に作成し、もし\r
+     * 既に存在すればそこにマーカー情報を上書きして記録します。\r
      * @param limage\r
      * @param label_ref\r
      * @param label\r
@@ -223,7 +230,7 @@ public class NyARDetectMarker {
      *         検出したマーカーからマーカーオブジェクトを生成して返す。\r
      * @throws NyARException\r
      */\r
-    private NyARMarker arGetContour(short[][] limage, int[] label_ref,int label, int[] clip) throws NyARException\r
+    private NyARMarker arGetContour(int i_holder_num,short[][] limage, int[] label_ref,int label, int[] clip) throws NyARException\r
     {\r
         final int[] xdir={0,  1, 1, 1, 0,-1,-1,-1}; //static int      xdir[8] = { 0, 1, 1, 1, 0,-1,-1,-1};\r
         final int[] ydir={-1,-1, 0, 1, 1, 1, 0,-1};//static int      ydir[8] = {-1,-1, 0, 1, 1, 1, 0,-1};\r
@@ -232,30 +239,35 @@ public class NyARDetectMarker {
         int             dmax, d, v1=0;\r
         int             i, j;\r
     \r
-//        JartkException.trap("未チェックのパス");\r
         j = clip[2];\r
         //p1=ShortPointer.wrap(limage,j*xsize+clip.get());//p1 = &(limage[j*xsize+clip[0]]);\r
         for( i = clip[0]; i <= clip[1]; i++){//for( i = clip[0]; i <= clip[1]; i++, p1++ ) {\r
-       if(limage[j][i] > 0 && label_ref[(limage[j][i])-1] == label ) {//if( *p1 > 0 && label_ref[(*p1)-1] == label ) {\r
-           sx = i; sy = j;\r
-           break;\r
-       }\r
+            if(limage[j][i] > 0 && label_ref[(limage[j][i])-1] == label ) {//if( *p1 > 0 && label_ref[(*p1)-1] == label ) {\r
+                sx = i; sy = j;\r
+                break;\r
+            }\r
         }\r
         if(i> clip[1]){//if( i > clip[1] ) {\r
-       System.out.println("??? 1");//printf();\r
-       throw new NyARException();//return(-1);\r
+            System.out.println("??? 1");//printf();\r
+            throw new NyARException();//return(-1);\r
         }\r
+        \r
+        //マーカーホルダが既に確保済みかを調べる\r
+        if(marker_holder[i_holder_num]==null){\r
+            //確保していなければ確保\r
+            marker_holder[i_holder_num]=new NyARMarker();\r
+        }\r
+        NyARMarker marker_ref=marker_holder[i_holder_num];\r
+\r
     \r
-        NyARMarker marker_info2=new NyARMarker();\r
-    \r
-        marker_info2.coord_num=1;//marker_info2->coord_num = 1;\r
-        marker_info2.x_coord[0]=sx;//marker_info2->x_coord[0] = sx;\r
-        marker_info2.y_coord[0]=sy;//marker_info2->y_coord[0] = sy;\r
+        marker_ref.coord_num=1;//marker_info2->coord_num = 1;\r
+        marker_ref.x_coord[0]=sx;//marker_info2->x_coord[0] = sx;\r
+        marker_ref.y_coord[0]=sy;//marker_info2->y_coord[0] = sy;\r
         dir = 5;\r
     \r
         for(;;){\r
-            int r=marker_info2.y_coord[marker_info2.coord_num-1];\r
-            int c=marker_info2.x_coord[marker_info2.coord_num-1];\r
+            int r=marker_ref.y_coord[marker_ref.coord_num-1];\r
+            int c=marker_ref.x_coord[marker_ref.coord_num-1];\r
             //p1 = &(limage[marker_info2->y_coord[marker_info2->coord_num-1] * xsize+ marker_info2->x_coord[marker_info2->coord_num-1]]);\r
             dir = (dir+5)%8;\r
             for(i=0;i<8;i++) {\r
@@ -268,21 +280,21 @@ public class NyARDetectMarker {
                 System.out.println("??? 2");//printf("??? 2\n");\r
                 throw new NyARException();//return(-1);\r
             }\r
-            marker_info2.x_coord[marker_info2.coord_num]= marker_info2.x_coord[marker_info2.coord_num-1] + xdir[dir];//marker_info2->x_coord[marker_info2->coord_num]= marker_info2->x_coord[marker_info2->coord_num-1] + xdir[dir];\r
-            marker_info2.y_coord[marker_info2.coord_num]= marker_info2.y_coord[marker_info2.coord_num-1] + ydir[dir];//marker_info2->y_coord[marker_info2->coord_num]= marker_info2->y_coord[marker_info2->coord_num-1] + ydir[dir];\r
-            if( marker_info2.x_coord[marker_info2.coord_num] == sx && marker_info2.y_coord[marker_info2.coord_num] == sy ){\r
+            marker_ref.x_coord[marker_ref.coord_num]= marker_ref.x_coord[marker_ref.coord_num-1] + xdir[dir];//marker_info2->x_coord[marker_info2->coord_num]= marker_info2->x_coord[marker_info2->coord_num-1] + xdir[dir];\r
+            marker_ref.y_coord[marker_ref.coord_num]= marker_ref.y_coord[marker_ref.coord_num-1] + ydir[dir];//marker_info2->y_coord[marker_info2->coord_num]= marker_info2->y_coord[marker_info2->coord_num-1] + ydir[dir];\r
+            if( marker_ref.x_coord[marker_ref.coord_num] == sx && marker_ref.y_coord[marker_ref.coord_num] == sy ){\r
                 break;\r
             }\r
-            marker_info2.coord_num++;\r
-            if( marker_info2.coord_num == marker_info2.x_coord.length-1){//if( marker_info2.coord_num == Config.AR_CHAIN_MAX-1 ){\r
+            marker_ref.coord_num++;\r
+            if( marker_ref.coord_num == marker_ref.x_coord.length-1){//if( marker_info2.coord_num == Config.AR_CHAIN_MAX-1 ){\r
                 System.out.println("??? 3");//printf("??? 3\n");\r
                 throw new NyARException();//return(-1);\r
             }\r
         }\r
     \r
         dmax = 0;\r
-        for(i=1;i<marker_info2.coord_num;i++) {//      for(i=1;i<marker_info2->coord_num;i++) {\r
-            d = (marker_info2.x_coord[i]-sx)*(marker_info2.x_coord[i]-sx)+ (marker_info2.y_coord[i]-sy)*(marker_info2.y_coord[i]-sy);//          d = (marker_info2->x_coord[i]-sx)*(marker_info2->x_coord[i]-sx)+ (marker_info2->y_coord[i]-sy)*(marker_info2->y_coord[i]-sy);\r
+        for(i=1;i<marker_ref.coord_num;i++) {//        for(i=1;i<marker_info2->coord_num;i++) {\r
+            d = (marker_ref.x_coord[i]-sx)*(marker_ref.x_coord[i]-sx)+ (marker_ref.y_coord[i]-sy)*(marker_ref.y_coord[i]-sy);//          d = (marker_info2->x_coord[i]-sx)*(marker_info2->x_coord[i]-sx)+ (marker_info2->y_coord[i]-sy)*(marker_info2->y_coord[i]-sy);\r
             if( d > dmax ) {\r
                dmax = d;\r
                v1 = i;\r
@@ -292,33 +304,30 @@ public class NyARDetectMarker {
         int[]      wx=new int[v1];//new int[Config.AR_CHAIN_MAX];\r
         int[]      wy=new int[v1]; //new int[Config.AR_CHAIN_MAX];   \r
         for(i=0;i<v1;i++) {\r
-            wx[i] = marker_info2.x_coord[i];//wx[i] = marker_info2->x_coord[i];\r
-            wy[i] = marker_info2.y_coord[i];//wy[i] = marker_info2->y_coord[i];\r
+            wx[i] = marker_ref.x_coord[i];//wx[i] = marker_info2->x_coord[i];\r
+            wy[i] = marker_ref.y_coord[i];//wy[i] = marker_info2->y_coord[i];\r
         }\r
-        for(i=v1;i<marker_info2.coord_num;i++) {//for(i=v1;i<marker_info2->coord_num;i++) {\r
-            marker_info2.x_coord[i-v1] = marker_info2.x_coord[i];//marker_info2->x_coord[i-v1] = marker_info2->x_coord[i];\r
-            marker_info2.y_coord[i-v1] = marker_info2.y_coord[i];//marker_info2->y_coord[i-v1] = marker_info2->y_coord[i];\r
+        for(i=v1;i<marker_ref.coord_num;i++) {//for(i=v1;i<marker_info2->coord_num;i++) {\r
+            marker_ref.x_coord[i-v1] = marker_ref.x_coord[i];//marker_info2->x_coord[i-v1] = marker_info2->x_coord[i];\r
+            marker_ref.y_coord[i-v1] = marker_ref.y_coord[i];//marker_info2->y_coord[i-v1] = marker_info2->y_coord[i];\r
         }\r
         for(i=0;i<v1;i++) {\r
-            marker_info2.x_coord[i-v1+marker_info2.coord_num] = wx[i];//marker_info2->x_coord[i-v1+marker_info2->coord_num] = wx[i];\r
-            marker_info2.y_coord[i-v1+marker_info2.coord_num] = wy[i];//marker_info2->y_coord[i-v1+marker_info2->coord_num] = wy[i];\r
+            marker_ref.x_coord[i-v1+marker_ref.coord_num] = wx[i];//marker_info2->x_coord[i-v1+marker_info2->coord_num] = wx[i];\r
+            marker_ref.y_coord[i-v1+marker_ref.coord_num] = wy[i];//marker_info2->y_coord[i-v1+marker_info2->coord_num] = wy[i];\r
         }\r
-        marker_info2.x_coord[marker_info2.coord_num] = marker_info2.x_coord[0];//marker_info2->x_coord[marker_info2->coord_num] = marker_info2->x_coord[0];\r
-        marker_info2.y_coord[marker_info2.coord_num] = marker_info2.y_coord[0];//marker_info2->y_coord[marker_info2->coord_num] = marker_info2->y_coord[0];\r
-        marker_info2.coord_num++;//marker_info2->coord_num++;\r
+        marker_ref.x_coord[marker_ref.coord_num] = marker_ref.x_coord[0];//marker_info2->x_coord[marker_info2->coord_num] = marker_info2->x_coord[0];\r
+        marker_ref.y_coord[marker_ref.coord_num] = marker_ref.y_coord[0];//marker_info2->y_coord[marker_info2->coord_num] = marker_info2->y_coord[0];\r
+        marker_ref.coord_num++;//marker_info2->coord_num++;\r
     \r
-        return marker_info2;\r
+        return marker_ref;\r
     }\r
        /**\r
         * ARMarkerInfo2 *arDetectMarker2( ARInt16 *limage, int label_num, int *label_ref,int *warea, double *wpos, int *wclip,int area_max, int area_min, double factor, int *marker_num )\r
         * 関数の代替品\r
-        * ラベリング情報からマーカー一覧を作成して、保持する。\r
+        * ラベリング情報からマーカー一覧を作成して保持します。\r
+        * この関数を実行すると、前回のdetectMarker関数で計算した保持値は破壊されます。\r
         * @param i_labeling\r
         * ラベリング済みの情報を持つラベリングオブジェクト\r
-        * @param area_max\r
-        * 何かの閾値?\r
-        * @param area_min\r
-        * 何かの閾値?\r
         * @param factor\r
         * 何かの閾値?\r
         * @return\r
@@ -329,7 +338,6 @@ public class NyARDetectMarker {
     {\r
         int               xsize, ysize;\r
         int               marker_num2;\r
-        int               i, j;\r
         double            d;\r
         int[] warea    =i_labeling.getArea();\r
         int label_num  =i_labeling.getLabelNum();\r
@@ -343,7 +351,7 @@ public class NyARDetectMarker {
         ysize =height;\r
         \r
         marker_num2 = 0;\r
-        for(i=0; i<label_num; i++ ) {\r
+        for(int i=0; i<label_num; i++ ) {\r
             if( warea[i] < area_min || warea[i] > area_max ){\r
                 continue;\r
             }\r
@@ -354,49 +362,58 @@ public class NyARDetectMarker {
                 continue;\r
             }\r
             //ret = arGetContour( limage, label_ref, i+1,&(wclip[i*4]), &(marker_info2[marker_num2]));\r
-            marker_info2_array[marker_num2]=arGetContour( limage, label_ref, i+1,wclip[i]);\r
+            arGetContour(marker_num2,limage, label_ref, i+1,wclip[i]);\r
             \r
-            boolean ret = check_square( warea[i], marker_info2_array[marker_num2], factor );//ret = check_square( warea[i], &(marker_info2[marker_num2]), factor );\r
+            boolean ret = check_square( warea[i], marker_holder[marker_num2], factor );//ret = check_square( warea[i], &(marker_info2[marker_num2]), factor );\r
             if(!ret){\r
-                marker_info2_array[marker_num2]=null;\r
+               //後半で整理するからここはいらない。//         marker_holder[marker_num2]=null;\r
                 continue;\r
             }\r
-            marker_info2_array[marker_num2].area   = warea[i];\r
-            marker_info2_array[marker_num2].pos[0] = wpos[i*2+0];\r
-            marker_info2_array[marker_num2].pos[1] = wpos[i*2+1];\r
+            marker_holder[marker_num2].area   = warea[i];\r
+            marker_holder[marker_num2].pos[0] = wpos[i*2+0];\r
+            marker_holder[marker_num2].pos[1] = wpos[i*2+1];\r
             marker_num2++;\r
             //マーカーリストが上限に達した\r
-            if( marker_num2 == marker_info2_array.length){\r
+            if( marker_num2 == marker_holder.length){\r
                 break;\r
             }\r
         }\r
-        for( i=0; i < marker_num2; i++ ) {\r
-            for( j=i+1; j < marker_num2; j++ ) {\r
-                d = (marker_info2_array[i].pos[0] - marker_info2_array[j].pos[0])*\r
-                    (marker_info2_array[i].pos[0] - marker_info2_array[j].pos[0])+\r
-                    (marker_info2_array[i].pos[1] - marker_info2_array[j].pos[1])*\r
-                    (marker_info2_array[i].pos[1] - marker_info2_array[j].pos[1]);\r
-                if(marker_info2_array[i].area >marker_info2_array[j].area ) {\r
-                    if( d <marker_info2_array[i].area / 4 ) {\r
-                        marker_info2_array[j].area = 0;\r
+        for(int i=0; i < marker_num2; i++ ) {\r
+            for(int j=i+1; j < marker_num2; j++ ) {\r
+                d = (marker_holder[i].pos[0] - marker_holder[j].pos[0])*\r
+                    (marker_holder[i].pos[0] - marker_holder[j].pos[0])+\r
+                    (marker_holder[i].pos[1] - marker_holder[j].pos[1])*\r
+                    (marker_holder[i].pos[1] - marker_holder[j].pos[1]);\r
+                if(marker_holder[i].area >marker_holder[j].area ) {\r
+                    if( d <marker_holder[i].area / 4 ) {\r
+                       marker_holder[j].area = 0;\r
                     }\r
                 }else{\r
-                    if( d < marker_info2_array[j].area / 4 ) {\r
-                        marker_info2_array[i].area = 0;\r
+                    if( d < marker_holder[j].area / 4 ) {\r
+                       marker_holder[i].area = 0;\r
                     }\r
                 }\r
             }\r
         }\r
-        for( i=0; i < marker_num2; i++ ) {\r
-            if( marker_info2_array[i].area == 0.0 ) {\r
-                for( j=i+1; j < marker_num2; j++ ) {\r
-               marker_info2_array[j-1] = marker_info2_array[j];\r
-                }\r
-                marker_num2--;\r
+        //みつかったマーカーを整理する。\r
+        //エリアが0のマーカーを外した配列を作って、その数もついでに計算\r
+        for(int i=0;i<marker_num2;i++){\r
+            if(marker_holder[i].area==0.0){\r
+               continue;\r
             }\r
-        }\r
+            marker_info2_array[marker_num]=marker_holder[i];\r
+            marker_num++;\r
+        }        \r
+//        for( i=0; i < marker_num2; i++ ) {\r
+//            if( marker_info2_array[i].area == 0.0 ) {\r
+//                for( j=i+1; j < marker_num2; j++ ){\r
+//                    marker_info2_array[j-1] = marker_info2_array[j];\r
+//                }\r
+//                marker_num2--;\r
+//            }\r
+//        }\r
         //発見したマーカー数をセット\r
-        marker_num=marker_num2;//*marker_num = marker_num2;\r
+//        marker_num=marker_num2;//*marker_num = marker_num2;\r
         //return( &(marker_info2[0]) );\r
     }\r
 \r
index ca3ae4f..c53a678 100644 (file)
@@ -81,7 +81,6 @@ public class NyARDetectSquare{
            return;\r
        }\r
        detect.detectMarker(labeling,1.0);\r
-       NyARMarker[] marker=detect.getMarkerArray();\r
        int number_of_marker=detect.getMarkerNum();\r
 \r
 \r
@@ -90,13 +89,15 @@ public class NyARDetectSquare{
        for (int i = 0; i <number_of_marker; i++){\r
            double[][]  line    =new double[4][3];\r
            double[][]  vertex  =new double[4][2];\r
+           NyARMarker marker=detect.getMarker(i);\r
            \r
            //・・・線の検出??\r
-            if (!getLine(marker[i].x_coord, marker[i].y_coord,marker[i].coord_num, marker[i].vertex,line,vertex))\r
+            if (!getLine(marker.x_coord, marker.y_coord,marker.coord_num, marker.vertex,line,vertex))\r
             {\r
                continue;\r
             }\r
-            marker_info[j]=new NyARSquare(marker[i],line,vertex);\r
+            //markerは参照渡し。実体はdetect内のバッファを共有してるので注意\r
+            marker_info[j]=new NyARSquare(marker,line,vertex);\r
 \r
             \r
 //ここで計算するのは良くないと思うんだ       \r
@@ -152,8 +153,8 @@ public class NyARDetectSquare{
             double [][] in_array=input.getArray();\r
             for( j = 0; j < n; j++ ) {\r
                param.observ2Ideal(x_coord[st+j], y_coord[st+j],dv1,dv2);//arParamObserv2Ideal( dist_factor, x_coord[st+j], y_coord[st+j],&(input->m[j*2+0]), &(input->m[j*2+1]) );\r
-                in_array[j][0]=dv1.get();\r
-                in_array[j][1]=dv2.get();\r
+                in_array[j][0]=dv1.value;\r
+                in_array[j][1]=dv2.value;\r
             }\r
             NyARMat.matrixPCA(input, evec, ev, mean);\r
             \r
index d649977..5c8f048 100644 (file)
@@ -75,7 +75,7 @@ public class NyARLabeling{
        return label_num;\r
     }\r
     /**\r
-     * わからん\r
+     * \r
      * @return\r
      * @throws NyARException\r
      */\r
@@ -87,7 +87,7 @@ public class NyARLabeling{
        return work;\r
     }\r
     /**\r
-     * 検出したエリア配列?よくわからぬ\r
+     * 検出したエリア配列?\r
      * @return\r
      * @throws NyARException\r
      */\r
@@ -99,7 +99,7 @@ public class NyARLabeling{
        return area;\r
     }\r
     /**\r
-     * 検出したクリップ配列?よくわからぬ\r
+     * 検出したクリップ配列?\r
      * @return\r
      * @throws NyARException\r
      */\r
@@ -111,7 +111,7 @@ public class NyARLabeling{
        return clip;\r
     }\r
     /**\r
-     * 検出した位置配列?よくわからぬ\r
+     * 検出した位置配列?\r
      * @return\r
      * @throws NyARException\r
      */\r
index 223637e..8a3819c 100644 (file)
@@ -105,19 +105,20 @@ public class NyARMat{
            }\r
        }\r
     }\r
+    private int[] wk_nos_matrixSelfInv=new int[50];\r
     /**\r
      * i_targetを逆行列に変換する。arMatrixSelfInv()と、arMatrixSelfInv_minv()関数を合成してあります。\r
      * @param i_target\r
      * 逆行列にする行列\r
      * @throws NyARException\r
      */\r
-    public static void matrixSelfInv(NyARMat i_target) throws NyARException\r
+    public void matrixSelfInv() throws NyARException\r
     {\r
-       double[][] ap=i_target.m;\r
+       double[][] ap=m;\r
        int dimen=ap.length;\r
        double[] wcp,wap,wbp;\r
-       int i,j,ip,nwork;\r
-       int[] nos=new int[50];\r
+       int j,ip,nwork;\r
+       int[] nos=wk_nos_matrixSelfInv;//この関数で初期化される。\r
        double epsl;\r
        double p,pbuf,work;\r
 \r
@@ -146,7 +147,7 @@ public class NyARMat{
             wcp =ap[n];//wcp = ap + n * rowa;\r
             p=0.0;\r
             wap_ptr=0;//wap = DoublePointer.wrap(wcp);\r
-            for(i = n; i<dimen ; i++){//for(i = n, wap = wcp, p = 0.0; i < dimen ; i++, wap += rowa)\r
+            for(int i = n; i<dimen ; i++){//for(i = n, wap = wcp, p = 0.0; i < dimen ; i++, wap += rowa)\r
                wap=ap[i];\r
                if( p < ( pbuf = Math.abs(wap[0]))) {\r
                    p = pbuf;\r
@@ -180,7 +181,7 @@ public class NyARMat{
             }\r
             wap[wap_ptr]=1.0/work;//*wap = 1.0 / work;\r
 \r
-            for(i = 0; i < dimen ; i++) {\r
+            for(int i = 0; i < dimen ; i++) {\r
                 if(i != n) {\r
                     wap =ap[i];//wap = ap + i * rowa;\r
                     wbp =wcp;\r
@@ -204,7 +205,7 @@ public class NyARMat{
                }\r
             }\r
             nos[j] = nos[n];\r
-            for(i = 0; i < dimen ;i++){//for(i = 0, wap = ap + j, wbp = ap + n; i < dimen ;i++, wap += rowa, wbp += rowa) {\r
+            for(int i = 0; i < dimen ;i++){//for(i = 0, wap = ap + j, wbp = ap + n; i < dimen ;i++, wap += rowa, wbp += rowa) {\r
                wap=ap[i];\r
                wbp=ap[i];\r
                 work  =wap[j];//work = *wap;\r
@@ -253,28 +254,29 @@ public class NyARMat{
        }\r
     }\r
     /**\r
-     * destにsourceと同じ内容をコピーする。arMatrixDupの代替品\r
+     * sourceの内容を自身にコピーする。\r
      * @param dest\r
      * @param source\r
      * @return\r
      */\r
-    public static void matrixDup(NyARMat dest, NyARMat source) throws NyARException\r
+    public void matrixDup(NyARMat source) throws NyARException\r
     {\r
-       if(dest.row != source.row || dest.clm != source.clm)\r
+       if(row != source.row || clm != source.clm)\r
        {\r
            throw new NyARException();\r
        }\r
-       for(int r = 0; r < source.getRow(); r++) {\r
-           for(int c = 0; c < source.getClm(); c++)\r
+       \r
+       for(int r = 0; r < row; r++){\r
+           for(int c = 0; c < clm; c++)\r
            {\r
-               dest.m[r][c]=source.m[r][c];\r
+               m[r][c]=source.m[r][c];\r
            }\r
        }\r
     }\r
     public NyARMat matrixAllocDup() throws NyARException\r
     {\r
        NyARMat result=new NyARMat(row,clm);\r
-       matrixDup(result,this);\r
+       result.matrixDup(this);\r
        return result;\r
     }    \r
     /**\r
@@ -287,10 +289,10 @@ public class NyARMat{
     public static void matrixInv(NyARMat dest,NyARMat source) throws NyARException\r
     {\r
        NyARException.trap("未チェックのパス");\r
-       matrixDup(dest, source);\r
+       dest.matrixDup(source);\r
 \r
        NyARException.trap("未チェックのパス");\r
-       matrixSelfInv(dest);\r
+       dest.matrixSelfInv();\r
     }\r
     public NyARMat matrixAllocInv() throws NyARException\r
     {\r
@@ -298,7 +300,7 @@ public class NyARMat{
        NyARMat result=matrixAllocDup();\r
 \r
        NyARException.trap("未チェックのパス");\r
-       matrixSelfInv(result);\r
+       result.matrixSelfInv();\r
        return result;\r
     }\r
     /**\r
index a91400a..9fd44b9 100644 (file)
@@ -236,44 +236,48 @@ public class NyARParam{
         x = (ix - dist_factor[0]) * dist_factor[3];\r
         y = (iy - dist_factor[1]) * dist_factor[3];\r
         if( x == 0.0 && y == 0.0 ) {\r
-            ox.set(dist_factor[0]);\r
-            oy.set(dist_factor[1]);\r
+            ox.value=dist_factor[0];\r
+            oy.value=dist_factor[1];\r
         }else{\r
             d = 1.0 - dist_factor[2]/100000000.0 * (x*x+y*y);\r
-            ox.set(x * d + dist_factor[0]);\r
-            oy.set(y * d + dist_factor[1]);\r
+            ox.value=x * d + dist_factor[0];\r
+            oy.value=y * d + dist_factor[1];\r
         }\r
     }\r
     /*int arParamObserv2Ideal( const double dist_factor[4], const double ox, const double oy,double *ix, double *iy );*/\r
     public int observ2Ideal(double ox,double oy,DoubleValue ix,DoubleValue iy)\r
     {\r
-       double  z02, z0, p, q, z, px, py;\r
+       double  z02, z0, p, q, z, px, py,opttmp_1;\r
        \r
        px = ox - dist_factor[0];\r
        py = oy - dist_factor[1];\r
        p = dist_factor[2]/100000000.0;\r
-       z02 = px*px+ py*py;\r
-       q = z0 = Math.sqrt(px*px+ py*py);\r
+       z02 = px*px+py*py;\r
+       q = z0 = Math.sqrt(z02);//Optimize//q = z0 = Math.sqrt(px*px+ py*py);\r
        \r
        for(int i = 1; ; i++ ) {\r
-               if( z0 != 0.0 ) {\r
-                       z = z0 - ((1.0 - p*z02)*z0 - q) / (1.0 - 3.0*p*z02);\r
-                       px = px * z / z0;\r
-                       py = py * z / z0;\r
-               }else {\r
-                       px = 0.0;\r
-                       py = 0.0;\r
-                       break;\r
-               }\r
-               if( i == PD_LOOP ){\r
-                       break;\r
-               }\r
-               z02 = px*px+ py*py;\r
-               z0 = Math.sqrt(px*px+ py*py);\r
+            if( z0 != 0.0 ) {\r
+               //Optimize opttmp_1\r
+               opttmp_1=p*z02;\r
+                z = z0 - ((1.0 - opttmp_1)*z0 - q) / (1.0 - 3.0*opttmp_1);\r
+               //Optimize opttmp_1       \r
+                opttmp_1=z / z0;\r
+                px = px * opttmp_1;\r
+                py = py * opttmp_1;\r
+            }else {\r
+                px = 0.0;\r
+                py = 0.0;\r
+                break;\r
+            }\r
+            if( i == PD_LOOP ){\r
+                break;\r
+            }\r
+            z02 = px*px+ py*py;\r
+            z0 = Math.sqrt(z02);//Optimize//z0 = Math.sqrt(px*px+ py*py);\r
        }\r
        \r
-       ix.set(px / dist_factor[3] + dist_factor[0]);\r
-       iy.set(py / dist_factor[3] + dist_factor[1]);\r
+       ix.value=px / dist_factor[3] + dist_factor[0];\r
+       iy.value=py / dist_factor[3] + dist_factor[1];\r
        return 0;\r
     }\r
     /**\r
index f42a0c4..fe7013a 100644 (file)
@@ -36,6 +36,12 @@ package jp.nyatla.nyartoolkit.core;
 import jp.nyatla.nyartoolkit.NyARException;\r
 import jp.nyatla.util.DoubleValue;\r
 \r
+/**\r
+ * This class calculates ARMatrix from square information and holds it.\r
+ * --\r
+ * 変換行列を計算して、結果を保持するクラス。\r
+ *\r
+ */\r
 public class NyARTransMat{\r
     private static final int AR_FITTING_TO_IDEAL=0;//#define  AR_FITTING_TO_IDEAL          0\r
     private static final int AR_FITTING_TO_INPUT=1;//#define  AR_FITTING_TO_INPUT          1\r
@@ -66,7 +72,17 @@ public class NyARTransMat{
     {\r
        return result_mat;\r
     }\r
-    /*double arGetTransMat( ARMarkerInfo *marker_info,double center[2], double width, double conv[3][4] )*/\r
+    /**\r
+     * double arGetTransMat( ARMarkerInfo *marker_info,double center[2], double width, double conv[3][4] )\r
+     * 関数の置き換え。\r
+     * 保持している変換行列を更新する。\r
+     * @param square\r
+     * 計算対象のNyARSquareオブジェクト\r
+     * @param i_direction\r
+     * @param width\r
+     * @return\r
+     * @throws NyARException\r
+     */\r
     public double transMat( NyARSquare square,int i_direction, double width)throws NyARException\r
     {\r
        double[][]  rot=new double[3][3];\r
@@ -79,7 +95,7 @@ public class NyARTransMat{
 \r
     \r
        if( arGetInitRot( square,i_direction, rot ) < 0 ){\r
-            return -1;\r
+            throw new NyARException();//return -1;\r
        }\r
     \r
        dir = i_direction;\r
@@ -175,8 +191,8 @@ public class NyARTransMat{
            DoubleValue a1=new DoubleValue(),a2=new DoubleValue();\r
            for( i = 0; i < num; i++ ) {\r
                param.ideal2Observ(ppos2d[i][0], ppos2d[i][1],a1,a2);//arParamIdeal2Observ(dist_factor, ppos2d[i][0], ppos2d[i][1],&pos2d[i][0], &pos2d[i][1]);\r
-               pos2d[i][0]=a1.get();\r
-               pos2d[i][1]=a2.get();\r
+               pos2d[i][0]=a1.value;\r
+               pos2d[i][1]=a2.value;\r
            }\r
        }else{\r
            for( i = 0; i < num; i++ ) {\r
@@ -201,7 +217,7 @@ public class NyARTransMat{
 //     JartkException.trap("未チェックのパス");{\r
        NyARMat.matrixMul( mat_d, mat_b, mat_a );\r
        NyARMat.matrixMul( mat_e, mat_b, mat_c );\r
-       NyARMat.matrixSelfInv(mat_d);\r
+       mat_d.matrixSelfInv();\r
        NyARMat.matrixMul( mat_f, mat_d, mat_e );\r
 //     }\r
        trans[0] = f_array[0][0];//trans[0] = mat_f->m[0];\r
@@ -226,7 +242,7 @@ public class NyARTransMat{
 //     JartkException.trap("未チェックのパス");{\r
        NyARMat.matrixMul( mat_d, mat_b, mat_a );\r
        NyARMat.matrixMul( mat_e, mat_b, mat_c );\r
-       NyARMat.matrixSelfInv(mat_d);\r
+       mat_d.matrixSelfInv();\r
        NyARMat.matrixMul( mat_f, mat_d, mat_e );\r
 //     }\r
        trans[0] = f_array[0][0];//trans[0] = mat_f->m[0];\r
@@ -258,9 +274,9 @@ public class NyARTransMat{
         int       i, j;\r
 \r
         arGetAngle( rot, a, b, c);//arGetAngle( rot, &a, &b, &c );\r
-        a2 = a.get();\r
-        b2 = b.get();\r
-        c2 = c.get();\r
+        a2 = a.value;\r
+        b2 = b.value;\r
+        c2 = c.value;\r
         factor = 10.0*Math.PI/180.0;\r
         for( j = 0; j < 10; j++ ) {\r
             minerr = 1000000000.0;\r
@@ -303,37 +319,64 @@ public class NyARTransMat{
         /*  printf("factor = %10.5f\n", factor*180.0/MD_PI); */\r
         return minerr/num;\r
     }\r
+    private double[][] wk_cpara2_arGetNewMatrix=new double[3][4];\r
+    private double[][] wk_rot_arGetNewMatrix   =new double[3][3];\r
+    /**\r
+     * \r
+     * @param a\r
+     * @param b\r
+     * @param c\r
+     * @param trans\r
+     * @param trans2\r
+     * @param ret\r
+     * @return\r
+     */\r
     private int arGetNewMatrix( double a, double b, double c,double trans[], double trans2[][], double ret[][] )\r
     {\r
        double cpara[][]=param.getMat();\r
-        double[][] cpara2=new double[3][4];\r
-        double[][] rot=new double[3][3];\r
+        double[][] cpara2=wk_cpara2_arGetNewMatrix;    //この関数で初期化される。\r
+        double[][] rot   =wk_rot_arGetNewMatrix;       //arGetRotで初期化される。\r
         int      i, j;\r
         \r
         arGetRot( a, b, c, rot );\r
         \r
         if( trans2 != null ) {\r
             for( j = 0; j < 3; j++ ) {\r
-               for( i = 0; i < 4; i++ ) {\r
-                    cpara2[j][i] = cpara[j][0] * trans2[0][i]+ cpara[j][1] * trans2[1][i]+ cpara[j][2] * trans2[2][i];\r
-               }\r
+//             for( i = 0; i < 4; i++ ) {\r
+//                    cpara2[j][i] = cpara[j][0] * trans2[0][i]+ cpara[j][1] * trans2[1][i]+ cpara[j][2] * trans2[2][i];\r
+//             }\r
+//Optimize\r
+                cpara2[j][0] = cpara[j][0] * trans2[0][0]+ cpara[j][1] * trans2[1][0]+ cpara[j][2] * trans2[2][0];\r
+                cpara2[j][1] = cpara[j][0] * trans2[0][1]+ cpara[j][1] * trans2[1][1]+ cpara[j][2] * trans2[2][1];\r
+                cpara2[j][2] = cpara[j][0] * trans2[0][2]+ cpara[j][1] * trans2[1][2]+ cpara[j][2] * trans2[2][2];\r
+                cpara2[j][3] = cpara[j][0] * trans2[0][3]+ cpara[j][1] * trans2[1][3]+ cpara[j][2] * trans2[2][3];\r
             }\r
-        }else{\r
+        }else{            \r
             for( j = 0; j < 3; j++ ) {\r
-               for( i = 0; i < 4; i++ ) {\r
-                    cpara2[j][i] = cpara[j][i];\r
-               }\r
+//             for( i = 0; i < 4; i++ ) {\r
+//                    cpara2[j][i] = cpara[j][i];\r
+//             }\r
+//Optimize             \r
+               cpara2[j][0] = cpara[j][0];\r
+               cpara2[j][1] = cpara[j][1];\r
+               cpara2[j][2] = cpara[j][2];\r
+               cpara2[j][3] = cpara[j][3];\r
             }\r
-        }      \r
+        }\r
         for( j = 0; j < 3; j++ ) {\r
-            for( i = 0; i < 3; i++ ) {\r
-               ret[j][i] = cpara2[j][0] * rot[0][i]+ cpara2[j][1] * rot[1][i]+ cpara2[j][2] * rot[2][i];\r
-            }\r
+//            for( i = 0; i < 3; i++ ) {\r
+//             ret[j][i] = cpara2[j][0] * rot[0][i]+ cpara2[j][1] * rot[1][i]+ cpara2[j][2] * rot[2][i];\r
+//            }\r
+//Optimize            \r
+            ret[j][0] = cpara2[j][0] * rot[0][0]+ cpara2[j][1] * rot[1][0]+ cpara2[j][2] * rot[2][0];\r
+            ret[j][1] = cpara2[j][0] * rot[0][1]+ cpara2[j][1] * rot[1][1]+ cpara2[j][2] * rot[2][1];\r
+            ret[j][2] = cpara2[j][0] * rot[0][2]+ cpara2[j][1] * rot[1][2]+ cpara2[j][2] * rot[2][2];\r
+//\r
             ret[j][3] = cpara2[j][0] * trans[0]+ cpara2[j][1] * trans[1]+ cpara2[j][2] * trans[2]+ cpara2[j][3];\r
         }\r
         return(0);\r
     }\r
-    private int arGetRot( double a, double b, double c, double rot[][] )\r
+    private void arGetRot( double a, double b, double c, double rot[][] )\r
     {\r
         double   sina, sinb, sinc;\r
         double   cosa, cosb, cosc;\r
@@ -344,6 +387,27 @@ public class NyARTransMat{
         cosb = Math.cos(b);\r
         sinc = Math.sin(c);\r
         cosc = Math.cos(c);\r
+        //Optimize\r
+        double A,B,C,D,E,F,G;\r
+        A=sina*cosa;\r
+        B=sina*sina;\r
+        C=cosa*cosa;\r
+        D=cosa*sinb;\r
+        F=cosb*cosc;\r
+        E=cosb*sinc;\r
+        G=sina*sinb;\r
+\r
+        rot[0][0] = C*F + B*cosc + A*(E - sinc);\r
+        rot[0][1] = -C*E-B*sinc+A*(F-cosc);\r
+        rot[0][2] = D;\r
+        rot[1][0] = A*(F-cosc)+B*E+C*sinc;\r
+        rot[1][1] = A*(-E+sinc)+B*F+C*cosc;\r
+        rot[1][2] = G;\r
+        rot[2][0] = -D*cosc-G*sinc;\r
+        rot[2][1] = D*sinc-G*cosc;\r
+        rot[2][2] = cosb;\r
+  /*      \r
+       //49回\r
         rot[0][0] = cosa*cosa*cosb*cosc+sina*sina*cosc+sina*cosa*cosb*sinc-sina*cosa*sinc;\r
         rot[0][1] = -cosa*cosa*cosb*sinc-sina*sina*sinc+sina*cosa*cosb*cosc-sina*cosa*cosc;\r
         rot[0][2] = cosa*sinb;\r
@@ -353,8 +417,7 @@ public class NyARTransMat{
         rot[2][0] = -cosa*sinb*cosc-sina*sinb*sinc;\r
         rot[2][1] = cosa*sinb*sinc-sina*sinb*cosc;\r
         rot[2][2] = cosb;\r
-    \r
-        return 0;\r
+*/\r
     }\r
     /*int arGetAngle( double rot[3][3], double *wa, double *wb, double *wc )*/\r
     private int arGetAngle( double rot[][], DoubleValue wa, DoubleValue wb, DoubleValue wc )\r
@@ -462,9 +525,9 @@ public class NyARTransMat{
             if( sinc < 0 ) c = -c;\r
         }\r
         \r
-        wa.set(a);//*wa = a;\r
-        wb.set(b);//*wb = b;\r
-        wc.set(c);//*wc = c;\r
+        wa.value=a;//*wa = a;\r
+        wb.value=b;//*wb = b;\r
+        wc.value=c;//*wc = c;\r
         \r
         return 0;\r
     }\r
@@ -537,52 +600,52 @@ public class NyARTransMat{
     }\r
 \r
     /*static int check_dir( double dir[3], double st[2], double ed[2],double cpara[3][4] )*/\r
-               private static int check_dir( double dir[], double st[], double ed[],double cpara[][]) throws NyARException\r
-               {\r
-    \r
-                   double[][]  world=new double[2][3];\r
-                   double[][] camera=new double[2][2];\r
-                   double[][] v=new double[2][2];\r
-                   double    h;\r
-                   int       i, j;\r
-    //             JartkException.trap("未チェックパス");\r
-                   NyARMat mat_a = new NyARMat( 3, 3 );\r
-                   double[][] a_array=mat_a.getArray();\r
-                   for(j=0;j<3;j++){\r
-                       for(i=0;i<3;i++){\r
-                           a_array[j][i]=cpara[j][i];//m[j*3+i] = cpara[j][i];\r
-                       }\r
-                   }\r
-    //             JartkException.trap("未チェックのパス");\r
-                   NyARMat.matrixSelfInv(mat_a);\r
-                   world[0][0] = a_array[0][0]*st[0]*10.0+ a_array[0][1]*st[1]*10.0+ a_array[0][2]*10.0;//mat_a->m[0]*st[0]*10.0+ mat_a->m[1]*st[1]*10.0+ mat_a->m[2]*10.0;\r
-                   world[0][1] = a_array[1][0]*st[0]*10.0+ a_array[1][1]*st[1]*10.0+ a_array[1][2]*10.0;//mat_a->m[3]*st[0]*10.0+ mat_a->m[4]*st[1]*10.0+ mat_a->m[5]*10.0;\r
-                   world[0][2] = a_array[2][0]*st[0]*10.0+ a_array[2][1]*st[1]*10.0+ a_array[2][2]*10.0;//mat_a->m[6]*st[0]*10.0+ mat_a->m[7]*st[1]*10.0+ mat_a->m[8]*10.0;\r
-                   world[1][0] = world[0][0] + dir[0];\r
-                   world[1][1] = world[0][1] + dir[1];\r
-                   world[1][2] = world[0][2] + dir[2];\r
-    \r
-                   for( i = 0; i < 2; i++ ) {\r
-                       h = cpara[2][0] * world[i][0]+ cpara[2][1] * world[i][1]+ cpara[2][2] * world[i][2];\r
-                       if( h == 0.0 ){\r
-                           return -1;\r
-                       }\r
-                       camera[i][0] = (cpara[0][0] * world[i][0]+ cpara[0][1] * world[i][1]+ cpara[0][2] * world[i][2]) / h;\r
-                       camera[i][1] = (cpara[1][0] * world[i][0]+ cpara[1][1] * world[i][1]+ cpara[1][2] * world[i][2]) / h;\r
-                   }\r
+    private static int check_dir( double dir[], double st[], double ed[],double cpara[][]) throws NyARException\r
+    {\r
     \r
-                   v[0][0] = ed[0] - st[0];\r
-                   v[0][1] = ed[1] - st[1];\r
-                   v[1][0] = camera[1][0] - camera[0][0];\r
-                   v[1][1] = camera[1][1] - camera[0][1];\r
+        double[][]     world=new double[2][3];\r
+        double[][] camera=new double[2][2];\r
+        double[][] v=new double[2][2];\r
+        double    h;\r
+        int       i, j;\r
+        //                 JartkException.trap("未チェックパス");\r
+        NyARMat mat_a = new NyARMat( 3, 3 );\r
+        double[][] a_array=mat_a.getArray();\r
+        for(j=0;j<3;j++){\r
+            for(i=0;i<3;i++){\r
+                a_array[j][i]=cpara[j][i];//m[j*3+i] = cpara[j][i];\r
+            }\r
+        }\r
+    // JartkException.trap("未チェックのパス");\r
+        mat_a.matrixSelfInv();\r
+        world[0][0] = a_array[0][0]*st[0]*10.0+ a_array[0][1]*st[1]*10.0+ a_array[0][2]*10.0;//mat_a->m[0]*st[0]*10.0+ mat_a->m[1]*st[1]*10.0+ mat_a->m[2]*10.0;\r
+        world[0][1] = a_array[1][0]*st[0]*10.0+ a_array[1][1]*st[1]*10.0+ a_array[1][2]*10.0;//mat_a->m[3]*st[0]*10.0+ mat_a->m[4]*st[1]*10.0+ mat_a->m[5]*10.0;\r
+        world[0][2] = a_array[2][0]*st[0]*10.0+ a_array[2][1]*st[1]*10.0+ a_array[2][2]*10.0;//mat_a->m[6]*st[0]*10.0+ mat_a->m[7]*st[1]*10.0+ mat_a->m[8]*10.0;\r
+        world[1][0] = world[0][0] + dir[0];\r
+        world[1][1] = world[0][1] + dir[1];\r
+        world[1][2] = world[0][2] + dir[2];\r
     \r
-                   if( v[0][0]*v[1][0] + v[0][1]*v[1][1] < 0 ) {\r
-                       dir[0] = -dir[0];\r
-                       dir[1] = -dir[1];\r
-                       dir[2] = -dir[2];\r
-                   }\r
-                   return 0;\r
-               }\r
+        for( i = 0; i < 2; i++ ) {\r
+            h = cpara[2][0] * world[i][0]+ cpara[2][1] * world[i][1]+ cpara[2][2] * world[i][2];\r
+            if( h == 0.0 ){\r
+                return -1;\r
+            }\r
+            camera[i][0] = (cpara[0][0] * world[i][0]+ cpara[0][1] * world[i][1]+ cpara[0][2] * world[i][2]) / h;\r
+            camera[i][1] = (cpara[1][0] * world[i][0]+ cpara[1][1] * world[i][1]+ cpara[1][2] * world[i][2]) / h;\r
+        }\r
+\r
+        v[0][0] = ed[0] - st[0];\r
+        v[0][1] = ed[1] - st[1];\r
+        v[1][0] = camera[1][0] - camera[0][0];\r
+        v[1][1] = camera[1][1] - camera[0][1];\r
+\r
+        if( v[0][0]*v[1][0] + v[0][1]*v[1][1] < 0 ) {\r
+            dir[0] = -dir[0];\r
+            dir[1] = -dir[1];\r
+            dir[2] = -dir[2];\r
+        }\r
+        return 0;\r
+    }\r
 \r
                /*int check_rotation( double rot[2][3] )*/\r
                private static int check_rotation( double rot[][] )\r
index 93104e0..23fe38a 100644 (file)
@@ -50,6 +50,7 @@ public class NyARSingleDetectMarker{
     private int detected_direction;\r
     private double detected_confidence;\r
     private NyARSquare detected_square;\r
+    private NyARColorPatt patt;\r
     public NyARSingleDetectMarker(NyARParam i_param,NyARCode i_code,double i_marker_width)\r
     {\r
        param=i_param;\r
@@ -59,7 +60,8 @@ public class NyARSingleDetectMarker{
        //比較コードを保存\r
        code=i_code;\r
        marker_width=i_marker_width;\r
-\r
+       //評価パターンのホルダを作る\r
+       patt=new NyARColorPatt(code.getWidth(),code.getHeight());\r
        \r
     }\r
     /**\r
@@ -83,8 +85,6 @@ public class NyARSingleDetectMarker{
 \r
        //コードの一致度を調べる準備\r
        NyARSquare[] squares=square.getSquareArray();\r
-       //パターンホルダを作る\r
-       NyARColorPatt patt=new NyARColorPatt(code.getWidth(),code.getHeight());\r
        //評価基準になるパターンをイメージから切り出す\r
        patt.pickFromRaster(i_image,squares[0].getMarker());\r
        \r
index d251e11..d1b84f3 100644 (file)
@@ -57,7 +57,7 @@ public class RawFileTest {
         \r
         //AR用のパターンコードを読み出し \r
         NyARCode code=new NyARCode(16,16);\r
-        code.LoadFromARFile(code_file);\r
+        code.loadFromARFile(code_file);\r
         \r
         //試験イメージの読み出し(320x240 BGRAのRAWデータ)\r
         File f=new File(data_file);\r
index 83a26f1..a42bd14 100644 (file)
@@ -1,14 +1,5 @@
 package jp.nyatla.util;\r
 \r
 public class DoubleValue {\r
-       private double v;\r
-       public void set(double i_v){\r
-               v=i_v;\r
-       }\r
-       public double get(){\r
-               return v;\r
-       }\r
-       public void add(double i_v){\r
-               v+=i_v;\r
-       }\r
+    public double value;\r
 }
\ No newline at end of file