OSDN Git Service

[backup]
authornyatla <nyatla@7cac0a50-4618-4814-88d0-24b83990f816>
Fri, 25 Dec 2009 05:18:18 +0000 (05:18 +0000)
committernyatla <nyatla@7cac0a50-4618-4814-88d0-24b83990f816>
Fri, 25 Dec 2009 05:18:18 +0000 (05:18 +0000)
+NyARSsuareからimvertexの削除
+TransMatのパラメータを変更。基準マーカサイズをOffsetで渡すようにした。

git-svn-id: http://svn.sourceforge.jp/svnroot/nyartoolkit/NyARToolkit@367 7cac0a50-4618-4814-88d0-24b83990f816

12 files changed:
trunk/src/jp/nyatla/nyartoolkit/core/param/NyARPerspectiveProjectionMatrix.java
trunk/src/jp/nyatla/nyartoolkit/core/squaredetect/NyARSquare.java
trunk/src/jp/nyatla/nyartoolkit/core/transmat/INyARTransMat.java
trunk/src/jp/nyatla/nyartoolkit/core/transmat/NyARRectOffset.java [moved from trunk/src/jp/nyatla/nyartoolkit/core/transmat/NyARTransOffset.java with 83% similarity]
trunk/src/jp/nyatla/nyartoolkit/core/transmat/NyARTransMat.java
trunk/src/jp/nyatla/nyartoolkit/core/transmat/NyARTransMatResult.java
trunk/src/jp/nyatla/nyartoolkit/core/transmat/NyARTransMat_ARToolKit.java
trunk/src/jp/nyatla/nyartoolkit/core/types/matrix/NyARDoubleMatrix33.java
trunk/src/jp/nyatla/nyartoolkit/detector/NyARCustomSingleDetectMarker.java
trunk/src/jp/nyatla/nyartoolkit/detector/NyARDetectMarker.java
trunk/src/jp/nyatla/nyartoolkit/processor/SingleARMarkerProcesser.java
trunk/src/jp/nyatla/nyartoolkit/processor/SingleNyIdMarkerProcesser.java

index f4d301c..90e84f5 100644 (file)
@@ -31,7 +31,8 @@
 package jp.nyatla.nyartoolkit.core.param;\r
 \r
 import jp.nyatla.nyartoolkit.core.*;\r
-import jp.nyatla.nyartoolkit.core.types.matrix.NyARDoubleMatrix34;\r
+import jp.nyatla.nyartoolkit.core.types.matrix.*;\r
+import jp.nyatla.nyartoolkit.core.types.*;\r
 \r
 /**\r
  * 透視変換行列を格納します。\r
@@ -173,7 +174,17 @@ final public class NyARPerspectiveProjectionMatrix extends NyARDoubleMatrix34
                //}\r
                return;\r
        }\r
-\r
+       /**\r
+        * 現在の行列で3次元座標を射影変換します。\r
+        * @param i_3dvertex\r
+        * @param o_2d\r
+        */\r
+       public void projectionConvert(NyARDoublePoint3d i_3dvertex,NyARDoublePoint2d o_2d)\r
+       {\r
+               o_2d.x=(i_3dvertex.x*this.m00+i_3dvertex.y*this.m01+i_3dvertex.z*this.m02)/i_3dvertex.z;\r
+               o_2d.y=(i_3dvertex.y*this.m11+i_3dvertex.z*this.m12)/i_3dvertex.z;\r
+               return;\r
+       }\r
        \r
        \r
        \r
index 18fe108..4ac2a8a 100644 (file)
@@ -42,7 +42,7 @@ public class NyARSquare
 {\r
     public NyARLinear[] line = NyARLinear.createArray(4);\r
     public NyARDoublePoint2d[] sqvertex = NyARDoublePoint2d.createArray(4);\r
-    public NyARIntPoint2d[] imvertex = NyARIntPoint2d.createArray(4);\r
+//    public NyARIntPoint2d[] imvertex = NyARIntPoint2d.createArray(4);\r
     public NyARSquare()\r
     {\r
         for (int i = 0; i < 4; i++)\r
index e5c5841..bc6e3cd 100644 (file)
@@ -40,7 +40,6 @@ import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquare;
  */\r
 public interface INyARTransMat\r
 {\r
-       public void setCenter(double i_x, double i_y);\r
-       public void transMat(NyARSquare i_square, double i_width, NyARTransMatResult o_result) throws NyARException;\r
-       public void transMatContinue(NyARSquare i_square, double i_width, NyARTransMatResult io_result_conv) throws NyARException;\r
+       public void transMat(NyARSquare i_square,NyARRectOffset i_offset, NyARTransMatResult o_result) throws NyARException;\r
+       public void transMatContinue(NyARSquare i_square,NyARRectOffset i_offset, NyARTransMatResult io_result_conv) throws NyARException;\r
 }\r
@@ -32,17 +32,26 @@ package jp.nyatla.nyartoolkit.core.transmat;
 \r
 import jp.nyatla.nyartoolkit.core.types.*;\r
 \r
-\r
-final public class NyARTransOffset\r
+/**\r
+ * 矩形の頂点情報を格納します。\r
+ */\r
+final public class NyARRectOffset\r
 {\r
        public final NyARDoublePoint3d[] vertex=NyARDoublePoint3d.createArray(4);\r
-       public final NyARDoublePoint3d point=new NyARDoublePoint3d();   \r
+       public static NyARRectOffset[] createArray(int i_number)\r
+       {\r
+               NyARRectOffset[] ret=new NyARRectOffset[i_number];\r
+               for(int i=0;i<i_number;i++)\r
+               {\r
+                       ret[i]=new NyARRectOffset();\r
+               }\r
+               return ret;\r
+       }       \r
        /**\r
         * 中心位置と辺長から、オフセット情報を作成して設定する。\r
         * @param i_width\r
-        * @param i_center\r
         */\r
-       public void setSquare(double i_width,NyARDoublePoint2d i_center)\r
+       public void setSquare(double i_width)\r
        {\r
                final double w_2 = i_width / 2.0;\r
                \r
@@ -64,9 +73,6 @@ final public class NyARTransOffset
                vertex3d_ptr.y = -w_2;\r
                vertex3d_ptr.z = 0.0;\r
                \r
-               this.point.x=-i_center.x;\r
-               this.point.y=-i_center.y;\r
-               this.point.z=0;\r
                return;\r
        }\r
 }\r
index 4d4998e..b596ae6 100644 (file)
@@ -46,8 +46,6 @@ import jp.nyatla.nyartoolkit.core.types.matrix.*;
  */\r
 public class NyARTransMat implements INyARTransMat\r
 {      \r
-       private final NyARDoublePoint2d _center=new NyARDoublePoint2d(0,0);\r
-       private final NyARTransOffset _offset=new NyARTransOffset();\r
        private NyARPerspectiveProjectionMatrix _projection_mat_ref;\r
        protected NyARRotMatrix _rotmatrix;\r
        protected INyARTransportVectorSolver _transsolver;\r
@@ -79,17 +77,6 @@ public class NyARTransMat implements INyARTransMat
                this._projection_mat_ref=pmat;\r
        }\r
 \r
-       public void setCenter(double i_x, double i_y)\r
-       {\r
-               this._center.x= i_x;\r
-               this._center.y= i_y;\r
-       }\r
-\r
-\r
-\r
-\r
-\r
-\r
        private final NyARDoublePoint2d[] __transMat_vertex_2d = NyARDoublePoint2d.createArray(4);\r
        private final NyARDoublePoint3d[] __transMat_vertex_3d = NyARDoublePoint3d.createArray(4);\r
        private final NyARDoublePoint3d __transMat_trans=new NyARDoublePoint3d();\r
@@ -120,7 +107,7 @@ public class NyARTransMat implements INyARTransMat
         * @return\r
         * @throws NyARException\r
         */\r
-       public void transMat(final NyARSquare i_square, double i_width, NyARTransMatResult o_result_conv) throws NyARException\r
+       public void transMat(final NyARSquare i_square,NyARRectOffset i_offset, NyARTransMatResult o_result_conv) throws NyARException\r
        {\r
                final NyARDoublePoint3d trans=this.__transMat_trans;\r
                \r
@@ -132,21 +119,18 @@ public class NyARTransMat implements INyARTransMat
                this._ref_dist_factor.ideal2ObservBatch(i_square.sqvertex, vertex_2d,4);                \r
                this._transsolver.set2dVertex(vertex_2d,4);\r
                \r
-               //基準矩形の3D座標系を作成\r
-               this._offset.setSquare(i_width,this._center);\r
-\r
                //回転行列を計算\r
                this._rotmatrix.initRotBySquare(i_square.line,i_square.sqvertex);\r
                \r
                //回転後の3D座標系から、平行移動量を計算\r
-               this._rotmatrix.getPoint3dBatch(this._offset.vertex,vertex_3d,4);\r
+               this._rotmatrix.getPoint3dBatch(i_offset.vertex,vertex_3d,4);\r
                this._transsolver.solveTransportVector(vertex_3d,trans);\r
                \r
                //計算結果の最適化(平行移動量と回転行列の最適化)\r
-               o_result_conv.error=this.optimize(this._rotmatrix, trans, this._transsolver,this._offset.vertex, vertex_2d,err_threshold);\r
+               o_result_conv.error=this.optimize(this._rotmatrix, trans, this._transsolver,i_offset.vertex, vertex_2d,err_threshold);\r
                \r
                // マトリクスの保存\r
-               this.updateMatrixValue(this._rotmatrix, this._offset.point, trans,o_result_conv);\r
+               this.updateMatrixValue(this._rotmatrix, trans,o_result_conv);\r
                return;\r
        }\r
 \r
@@ -154,13 +138,13 @@ public class NyARTransMat implements INyARTransMat
         * (non-Javadoc)\r
         * @see jp.nyatla.nyartoolkit.core.transmat.INyARTransMat#transMatContinue(jp.nyatla.nyartoolkit.core.NyARSquare, int, double, jp.nyatla.nyartoolkit.core.transmat.NyARTransMatResult)\r
         */\r
-       public void transMatContinue(NyARSquare i_square, double i_width, NyARTransMatResult o_result_conv) throws NyARException\r
+       public void transMatContinue(NyARSquare i_square,NyARRectOffset i_offset, NyARTransMatResult o_result_conv) throws NyARException\r
        {\r
                final NyARDoublePoint3d trans=this.__transMat_trans;\r
 \r
                // io_result_convが初期値なら、transMatで計算する。\r
                if (!o_result_conv.has_value) {\r
-                       this.transMat(i_square,i_width, o_result_conv);\r
+                       this.transMat(i_square,i_offset, o_result_conv);\r
                        return;\r
                }\r
                \r
@@ -174,18 +158,15 @@ public class NyARTransMat implements INyARTransMat
                this._ref_dist_factor.ideal2ObservBatch(i_square.sqvertex, vertex_2d,4);                \r
                this._transsolver.set2dVertex(vertex_2d,4);\r
                \r
-               //基準矩形の3D座標系を作成\r
-               this._offset.setSquare(i_width,this._center);\r
-\r
                //回転行列を計算\r
                this._rotmatrix.initRotByPrevResult(o_result_conv);\r
                \r
                //回転後の3D座標系から、平行移動量を計算\r
-               this._rotmatrix.getPoint3dBatch(this._offset.vertex,vertex_3d,4);\r
+               this._rotmatrix.getPoint3dBatch(i_offset.vertex,vertex_3d,4);\r
                this._transsolver.solveTransportVector(vertex_3d,trans);\r
 \r
                //現在のエラーレートを計算しておく\r
-               double min_err=errRate(this._rotmatrix,trans, this._offset.vertex, vertex_2d,4,vertex_3d);\r
+               double min_err=errRate(this._rotmatrix,trans,i_offset.vertex, vertex_2d,4,vertex_3d);\r
                NyARDoubleMatrix33 rot=this.__rot;\r
                //エラーレートが前回のエラー値より閾値分大きかったらアゲイン\r
                if(min_err<o_result_conv.error+err_threshold){\r
@@ -193,8 +174,8 @@ public class NyARTransMat implements INyARTransMat
                        //最適化してみる。\r
                        for (int i = 0;i<5; i++) {\r
                                //変換行列の最適化\r
-                               this._mat_optimize.modifyMatrix(rot, trans, this._offset.vertex, vertex_2d, 4);\r
-                               double err=errRate(rot,trans,this._offset.vertex, vertex_2d,4,vertex_3d);\r
+                               this._mat_optimize.modifyMatrix(rot, trans, i_offset.vertex, vertex_2d, 4);\r
+                               double err=errRate(rot,trans,i_offset.vertex, vertex_2d,4,vertex_3d);\r
                                //System.out.println("E:"+err);\r
                                if(min_err-err<err_threshold/2){\r
                                        //System.out.println("BREAK");\r
@@ -204,18 +185,18 @@ public class NyARTransMat implements INyARTransMat
                                this._rotmatrix.setValue(rot);\r
                                min_err=err;\r
                        }\r
-                       this.updateMatrixValue(this._rotmatrix, this._offset.point, trans,o_result_conv);\r
+                       this.updateMatrixValue(this._rotmatrix,  trans,o_result_conv);\r
                }else{\r
                        //回転行列を計算\r
                        this._rotmatrix.initRotBySquare(i_square.line,i_square.sqvertex);\r
                        \r
                        //回転後の3D座標系から、平行移動量を計算\r
-                       this._rotmatrix.getPoint3dBatch(this._offset.vertex,vertex_3d,4);\r
+                       this._rotmatrix.getPoint3dBatch(i_offset.vertex,vertex_3d,4);\r
                        this._transsolver.solveTransportVector(vertex_3d,trans);\r
                        \r
                        //計算結果の最適化(平行移動量と回転行列の最適化)\r
-                       min_err=this.optimize(this._rotmatrix, trans, this._transsolver,this._offset.vertex, vertex_2d,err_threshold);\r
-                       this.updateMatrixValue(this._rotmatrix, this._offset.point, trans,o_result_conv);\r
+                       min_err=this.optimize(this._rotmatrix, trans, this._transsolver,i_offset.vertex, vertex_2d,err_threshold);\r
+                       this.updateMatrixValue(this._rotmatrix, trans,o_result_conv);\r
                }\r
                o_result_conv.error=min_err;\r
                return;\r
@@ -289,22 +270,22 @@ public class NyARTransMat implements INyARTransMat
         * @param i_off\r
         * @param i_trans\r
         */\r
-       public void updateMatrixValue(NyARRotMatrix i_rot, NyARDoublePoint3d i_off, NyARDoublePoint3d i_trans,NyARTransMatResult o_result)\r
+       public void updateMatrixValue(NyARRotMatrix i_rot, NyARDoublePoint3d i_trans,NyARTransMatResult o_result)\r
        {\r
                o_result.m00=i_rot.m00;\r
                o_result.m01=i_rot.m01;\r
                o_result.m02=i_rot.m02;\r
-               o_result.m03=i_rot.m00 * i_off.x + i_rot.m01 * i_off.y + i_rot.m02 * i_off.z + i_trans.x;\r
+               o_result.m03=i_trans.x;\r
 \r
-               o_result.m10 = i_rot.m10;\r
-               o_result.m11 = i_rot.m11;\r
-               o_result.m12 = i_rot.m12;\r
-               o_result.m13 = i_rot.m10 * i_off.x + i_rot.m11 * i_off.y + i_rot.m12 * i_off.z + i_trans.y;\r
+               o_result.m10 =i_rot.m10;\r
+               o_result.m11 =i_rot.m11;\r
+               o_result.m12 =i_rot.m12;\r
+               o_result.m13 =i_trans.y;\r
 \r
                o_result.m20 = i_rot.m20;\r
                o_result.m21 = i_rot.m21;\r
                o_result.m22 = i_rot.m22;\r
-               o_result.m23 = i_rot.m20 * i_off.x + i_rot.m21 * i_off.y + i_rot.m22 * i_off.z + i_trans.z;\r
+               o_result.m23 = i_trans.z;\r
 \r
                o_result.has_value = true;\r
                return;\r
index 4181d95..18838e3 100644 (file)
@@ -73,4 +73,8 @@ public class NyARTransMatResult extends NyARDoubleMatrix34
                o_out.z=this.m20*i_x+this.m21*i_y+this.m22*i_z+this.m23;\r
                return;\r
        }\r
+       public final void transformVertex(NyARDoublePoint3d i_in,NyARDoublePoint3d o_out)\r
+       {\r
+               transformVertex(i_in.x,i_in.y,i_in.z,o_out);\r
+       }\r
 }\r
index 5bfa314..e4be4f9 100644 (file)
@@ -51,8 +51,6 @@ public class NyARTransMat_ARToolKit implements INyARTransMat
        private final static double AR_GET_TRANS_MAT_MAX_FIT_ERROR = 1.0;// #define AR_GET_TRANS_MAT_MAX_FIT_ERROR 1.0\r
        private final static double AR_GET_TRANS_CONT_MAT_MAX_FIT_ERROR = 1.0;\r
 \r
-       private final NyARDoublePoint2d _center=new NyARDoublePoint2d(0,0);\r
-       private final NyARTransOffset _offset=new NyARTransOffset();\r
        protected NyARRotMatrix_ARToolKit _rotmatrix;\r
        protected INyARTransportVectorSolver _transsolver;\r
        protected INyARRotMatrixOptimize _mat_optimize;\r
@@ -80,13 +78,6 @@ public class NyARTransMat_ARToolKit implements INyARTransMat
                this._ref_dist_factor=dist;\r
        }\r
 \r
-       public void setCenter(double i_x, double i_y)\r
-       {\r
-               this._center.x= i_x;\r
-               this._center.y= i_y;\r
-       }\r
-\r
-\r
        private final NyARDoublePoint2d[] __transMat_vertex_2d = NyARDoublePoint2d.createArray(4);\r
        private final NyARDoublePoint3d[] __transMat_vertex_3d = NyARDoublePoint3d.createArray(4);\r
        private final NyARDoublePoint3d __transMat_trans=new NyARDoublePoint3d();\r
@@ -99,7 +90,7 @@ public class NyARTransMat_ARToolKit implements INyARTransMat
         * @return\r
         * @throws NyARException\r
         */\r
-       public void transMat(final NyARSquare i_square, double i_width, NyARTransMatResult o_result_conv) throws NyARException\r
+       public void transMat(final NyARSquare i_square,NyARRectOffset i_offset, NyARTransMatResult o_result_conv) throws NyARException\r
        {\r
                final NyARDoublePoint3d trans=this.__transMat_trans;\r
                \r
@@ -108,22 +99,19 @@ public class NyARTransMat_ARToolKit implements INyARTransMat
                NyARDoublePoint3d[] vertex_3d=this.__transMat_vertex_3d;\r
                this._ref_dist_factor.ideal2ObservBatch(i_square.sqvertex, vertex_2d,4);                \r
                this._transsolver.set2dVertex(vertex_2d,4);\r
-               \r
-               //基準矩形の3D座標系を作成\r
-               this._offset.setSquare(i_width,this._center);\r
 \r
                //回転行列を計算\r
                this._rotmatrix.initRotBySquare(i_square.line,i_square.sqvertex);\r
                \r
                //回転後の3D座標系から、平行移動量を計算\r
-               this._rotmatrix.getPoint3dBatch(this._offset.vertex,vertex_3d,4);\r
+               this._rotmatrix.getPoint3dBatch(i_offset.vertex,vertex_3d,4);\r
                this._transsolver.solveTransportVector(vertex_3d,trans);\r
                \r
                //計算結果の最適化(平行移動量と回転行列の最適化)\r
-               o_result_conv.error=this.optimize(this._rotmatrix, trans, this._transsolver,this._offset.vertex, vertex_2d);\r
+               o_result_conv.error=this.optimize(this._rotmatrix, trans, this._transsolver,i_offset.vertex, vertex_2d);\r
                \r
                // マトリクスの保存\r
-               this.updateMatrixValue(this._rotmatrix, this._offset.point, trans,o_result_conv);\r
+               this.updateMatrixValue(this._rotmatrix,  trans,o_result_conv);\r
                return;\r
        }\r
 \r
@@ -131,13 +119,13 @@ public class NyARTransMat_ARToolKit implements INyARTransMat
         * (non-Javadoc)\r
         * @see jp.nyatla.nyartoolkit.core.transmat.INyARTransMat#transMatContinue(jp.nyatla.nyartoolkit.core.NyARSquare, int, double, jp.nyatla.nyartoolkit.core.transmat.NyARTransMatResult)\r
         */\r
-       public void transMatContinue(NyARSquare i_square, double i_width, NyARTransMatResult o_result_conv) throws NyARException\r
+       public void transMatContinue(NyARSquare i_square,NyARRectOffset i_offset, NyARTransMatResult o_result_conv) throws NyARException\r
        {\r
                final NyARDoublePoint3d trans=this.__transMat_trans;\r
 \r
                // io_result_convが初期値なら、transMatで計算する。\r
                if (!o_result_conv.has_value) {\r
-                       this.transMat(i_square, i_width, o_result_conv);\r
+                       this.transMat(i_square, i_offset, o_result_conv);\r
                        return;\r
                }\r
                \r
@@ -147,35 +135,32 @@ public class NyARTransMat_ARToolKit implements INyARTransMat
                this._ref_dist_factor.ideal2ObservBatch(i_square.sqvertex, vertex_2d,4);                \r
                this._transsolver.set2dVertex(vertex_2d,4);\r
                \r
-               //基準矩形の3D座標系を作成\r
-               this._offset.setSquare(i_width,this._center);\r
-\r
                //回転行列を計算\r
                this._rotmatrix.initRotByPrevResult(o_result_conv);\r
                \r
                //回転後の3D座標系から、平行移動量を計算\r
-               this._rotmatrix.getPoint3dBatch(this._offset.vertex,vertex_3d,4);\r
+               this._rotmatrix.getPoint3dBatch(i_offset.vertex,vertex_3d,4);\r
                this._transsolver.solveTransportVector(vertex_3d,trans);\r
                \r
                //計算結果の最適化(平行移動量と回転行列の最適化)\r
-               double err=this.optimize(this._rotmatrix, trans, this._transsolver, this._offset.vertex, vertex_2d);\r
+               double err=this.optimize(this._rotmatrix, trans, this._transsolver,i_offset.vertex, vertex_2d);\r
                \r
                // マトリクスの保存\r
-               this.updateMatrixValue(this._rotmatrix, this._offset.point, trans,o_result_conv);\r
+               this.updateMatrixValue(this._rotmatrix,  trans,o_result_conv);\r
                \r
                // エラー値が許容範囲でなければTransMatをやり直し\r
                if (err > AR_GET_TRANS_CONT_MAT_MAX_FIT_ERROR) {\r
                        // rotationを矩形情報で初期化\r
                        this._rotmatrix.initRotBySquare(i_square.line,i_square.sqvertex);\r
                        //回転行列の平行移動量の計算\r
-                       this._rotmatrix.getPoint3dBatch(this._offset.vertex,vertex_3d,4);\r
+                       this._rotmatrix.getPoint3dBatch(i_offset.vertex,vertex_3d,4);\r
                        this._transsolver.solveTransportVector(vertex_3d,trans);\r
                        //計算結果の最適化(this._rotmatrix,trans)\r
-                       final double err2=this.optimize(this._rotmatrix, trans, this._transsolver, this._offset.vertex, vertex_2d);\r
+                       final double err2=this.optimize(this._rotmatrix, trans, this._transsolver,i_offset.vertex, vertex_2d);\r
                        //エラー値が低かったら値を差換え\r
                        if (err2 < err) {\r
                                // 良い値が取れたら、差換え\r
-                               this.updateMatrixValue(this._rotmatrix, this._offset.point, trans,o_result_conv);\r
+                               this.updateMatrixValue(this._rotmatrix,  trans,o_result_conv);\r
                        }\r
                        err=err2;\r
                }\r
@@ -214,22 +199,22 @@ public class NyARTransMat_ARToolKit implements INyARTransMat
         * @param i_off\r
         * @param i_trans\r
         */\r
-       public void updateMatrixValue(NyARRotMatrix i_rot, NyARDoublePoint3d i_off, NyARDoublePoint3d i_trans,NyARTransMatResult o_result)\r
+       public void updateMatrixValue(NyARRotMatrix i_rot,NyARDoublePoint3d i_trans,NyARTransMatResult o_result)\r
        {\r
                o_result.m00=i_rot.m00;\r
                o_result.m01=i_rot.m01;\r
                o_result.m02=i_rot.m02;\r
-               o_result.m03=i_rot.m00 * i_off.x + i_rot.m01 * i_off.y + i_rot.m02 * i_off.z + i_trans.x;\r
+               o_result.m03=i_trans.x;\r
 \r
                o_result.m10 = i_rot.m10;\r
                o_result.m11 = i_rot.m11;\r
                o_result.m12 = i_rot.m12;\r
-               o_result.m13 = i_rot.m10 * i_off.x + i_rot.m11 * i_off.y + i_rot.m12 * i_off.z + i_trans.y;\r
+               o_result.m13 = i_trans.y;\r
 \r
                o_result.m20 = i_rot.m20;\r
                o_result.m21 = i_rot.m21;\r
                o_result.m22 = i_rot.m22;\r
-               o_result.m23 = i_rot.m20 * i_off.x + i_rot.m21 * i_off.y + i_rot.m22 * i_off.z + i_trans.z;\r
+               o_result.m23 = i_trans.z;\r
 \r
                o_result.has_value = true;\r
                return;\r
index 714238d..04dfd2a 100644 (file)
@@ -153,6 +153,11 @@ public class NyARDoubleMatrix33 implements INyARDoubleMatrix
                        o_out.y = Math.atan2(-this.m20, this.m22);\r
                }\r
        }\r
+       public final void setZXYAngle(NyARDoublePoint3d i_angle)\r
+       {\r
+               setZXYAngle(i_angle.x,i_angle.y,i_angle.z);\r
+               return;\r
+       }\r
        public final void setZXYAngle(final double i_x, final double i_y, final double i_z)\r
        {\r
                final double sina = Math.sin(i_x);\r
@@ -170,5 +175,24 @@ public class NyARDoubleMatrix33 implements INyARDoubleMatrix
                this.m20 = -cosa * sinb;\r
                this.m21 = sina;\r
                this.m22 = cosb * cosa;\r
-       }       \r
+               return;\r
+       }\r
+       /**\r
+        * 回転行列を適応して座標変換します。\r
+        * @param i_angle\r
+        * @param o_out\r
+        */\r
+       public final void transformVertex(NyARDoublePoint3d i_position,NyARDoublePoint3d o_out)\r
+       {\r
+               transformVertex(i_position.x,i_position.y,i_position.z,o_out);\r
+               return;\r
+       }\r
+       \r
+       public final void transformVertex(double i_x,double i_y,double i_z,NyARDoublePoint3d o_out)\r
+       {\r
+               o_out.x=this.m00*i_x+this.m01*i_y+this.m02*i_z;\r
+               o_out.y=this.m10*i_x+this.m11*i_y+this.m12*i_z;\r
+               o_out.z=this.m20*i_x+this.m21*i_y+this.m22*i_z;\r
+               return;\r
+       }\r
 }\r
index cb26cce..1037f93 100644 (file)
@@ -117,8 +117,6 @@ public class NyARCustomSingleDetectMarker
                        //directionを考慮して、squareを更新する。\r
                        for(int i=0;i<4;i++){\r
                                int idx=(i+4 - mr.direction) % 4;\r
-                               sq.imvertex[i].x=vertex[idx].x;\r
-                               sq.imvertex[i].y=vertex[idx].y;\r
                                this._coordline.coord2Line(i_vertex_index[idx],i_vertex_index[(idx+1)%4],i_coordx,i_coordy,i_coor_num,sq.line[i]);\r
                        }\r
                        for (int i = 0; i < 4; i++) {\r
@@ -139,11 +137,11 @@ public class NyARCustomSingleDetectMarker
        private boolean _is_continue = false;\r
        private INyARSquareContourDetector _square_detect;\r
        protected INyARTransMat _transmat;\r
-       private double _marker_width;\r
        //画処理用\r
        private NyARBinRaster _bin_raster;\r
        protected INyARRasterFilter_RgbToBin _tobin_filter;\r
        private DetectSquareCB _detect_cb;\r
+       private NyARRectOffset _offset; \r
 \r
 \r
        protected NyARCustomSingleDetectMarker()\r
@@ -164,12 +162,13 @@ public class NyARCustomSingleDetectMarker
                this._square_detect = i_sqdetect_inst;\r
                this._transmat = i_transmat_inst;\r
                this._tobin_filter=i_filter;\r
-               // 比較コードを保存\r
-               this._marker_width = i_marker_width;\r
                //2値画像バッファを作る\r
                this._bin_raster=new NyARBinRaster(scr_size.w,scr_size.h);\r
                //_detect_cb\r
                this._detect_cb=new DetectSquareCB(i_patt_inst,i_ref_code,i_ref_param);\r
+               //オフセットを作成\r
+               this._offset=new NyARRectOffset();\r
+               this._offset.setSquare(i_marker_width);\r
                return;\r
                \r
        }\r
@@ -205,7 +204,6 @@ public class NyARCustomSingleDetectMarker
                }\r
                return true;\r
        }\r
-\r
        /**\r
         * 検出したマーカーの変換行列を計算して、o_resultへ値を返します。\r
         * 直前に実行したdetectMarkerLiteが成功していないと使えません。\r
@@ -218,35 +216,13 @@ public class NyARCustomSingleDetectMarker
        {\r
                // 一番一致したマーカーの位置とかその辺を計算\r
                if (this._is_continue) {\r
-                       this._transmat.transMatContinue(this._detect_cb.square,this._marker_width, o_result);\r
+                       this._transmat.transMatContinue(this._detect_cb.square,this._offset, o_result);\r
                } else {\r
-                       this._transmat.transMat(this._detect_cb.square,this._marker_width, o_result);\r
+                       this._transmat.transMat(this._detect_cb.square,this._offset, o_result);\r
                }\r
                return;\r
        }\r
        /**\r
-        * 画面上のマーカ頂点情報を配列へ取得します。\r
-        * @param o_point\r
-        * 4要素以上の配列を指定して下さい。先頭の4要素に値がコピーされます。\r
-        */\r
-       public void getSquarePosition(NyARIntPoint2d[] o_point)\r
-       {\r
-               NyARIntPoint2d.copyArray(this._detect_cb.square.imvertex,o_point);\r
-               return;\r
-       }\r
-       /**\r
-        * 画面上のマーカ頂点情報を配列へのリファレンスを返します。\r
-        * 返されたオブジェクトはクラスに所有し続けられています。クラスのメンバ関数を実行すると内容が書き変わります。\r
-        * 外部でデータをストックする場合は、getSquarePositionで複製して下さい。\r
-        * @return\r
-        */\r
-       public NyARIntPoint2d[] refSquarePosition()\r
-       {\r
-               return this._detect_cb.square.imvertex;\r
-       }\r
-       \r
-\r
-       /**\r
         * 検出したマーカーの一致度を返します。\r
         * \r
         * @return マーカーの一致度を返します。0~1までの値をとります。 一致度が低い場合には、誤認識の可能性が高くなります。\r
index 080c9e6..5acab3d 100644 (file)
@@ -165,8 +165,6 @@ public class NyARDetectMarker
                        //directionを考慮して、squareを更新する。\r
                        for(int i=0;i<4;i++){\r
                                int idx=(i+4 - direction) % 4;\r
-                               sq.imvertex[i].x=vertex[idx].x;\r
-                               sq.imvertex[i].y=vertex[idx].y;\r
                                this._coordline.coord2Line(i_vertex_index[idx],i_vertex_index[(idx+1)%4],i_coordx,i_coordy,i_coor_num,sq.line[i]);\r
                        }\r
                        for (int i = 0; i < 4; i++) {\r
@@ -190,7 +188,7 @@ public class NyARDetectMarker
        private boolean _is_continue = false;\r
        private INyARSquareContourDetector _square_detect;\r
        protected INyARTransMat _transmat;\r
-       private double[] _marker_width; \r
+       private NyARRectOffset[] _offset;       \r
 \r
 \r
        /**\r
@@ -238,7 +236,10 @@ public class NyARDetectMarker
                this._tobin_filter=new NyARRasterFilter_ARToolkitThreshold(100,i_input_raster_type);\r
 \r
                //実サイズ保存\r
-               this._marker_width = i_marker_width;\r
+               this._offset = NyARRectOffset.createArray(i_number_of_code);\r
+               for(int i=0;i<i_number_of_code;i++){\r
+                       this._offset[i].setSquare(i_marker_width[i]);\r
+               }\r
                //2値画像バッファを作る\r
                this._bin_raster=new NyARBinRaster(scr_size.w,scr_size.h);\r
                return;         \r
@@ -291,9 +292,9 @@ public class NyARDetectMarker
                final NyARDetectMarkerResult result = this._detect_cb.result_stack.getItem(i_index);\r
                // 一番一致したマーカーの位置とかその辺を計算\r
                if (_is_continue) {\r
-                       _transmat.transMatContinue(result.square, _marker_width[result.arcode_id], o_result);\r
+                       _transmat.transMatContinue(result.square, this._offset[result.arcode_id], o_result);\r
                } else {\r
-                       _transmat.transMat(result.square, _marker_width[result.arcode_id], o_result);\r
+                       _transmat.transMat(result.square, this._offset[result.arcode_id], o_result);\r
                }\r
                return;\r
        }\r
index fce51f6..26306b3 100644 (file)
@@ -179,8 +179,6 @@ public abstract class SingleARMarkerProcesser
                        //directionを考慮して、squareを更新する。\r
                        for(int i=0;i<4;i++){\r
                                int idx=(i+4 - dir) % 4;\r
-                               sq.imvertex[i].x=vertex[idx].x;\r
-                               sq.imvertex[i].y=vertex[idx].y;\r
                                this._coordline.coord2Line(i_vertex_index[idx],i_vertex_index[(idx+1)%4],i_coordx,i_coordy,i_coor_num,sq.line[i]);\r
                        }\r
                        for (int i = 0; i < 4; i++) {\r
@@ -203,7 +201,7 @@ public abstract class SingleARMarkerProcesser
 \r
        protected INyARTransMat _transmat;\r
 \r
-       private double _marker_width;\r
+       private NyARRectOffset _offset; \r
        private int _threshold = 110;\r
        // [AR]検出結果の保存用\r
        private NyARBinRaster _bin_raster;\r
@@ -238,7 +236,7 @@ public abstract class SingleARMarkerProcesser
                this._initialized=true;\r
                //コールバックハンドラ\r
                this._detectmarker_cb=new DetectSquareCB(i_param);\r
-               \r
+               this._offset=new NyARRectOffset();\r
                return;\r
        }\r
 \r
@@ -260,7 +258,7 @@ public abstract class SingleARMarkerProcesser
                }\r
                //検出するマーカセット、情報、検出器を作り直す。(1ピクセル4ポイントサンプリング,マーカのパターン領域は50%)\r
                this._detectmarker_cb.setNyARCodeTable(i_ref_code_table,i_code_resolution);\r
-               this._marker_width = i_marker_width;\r
+               this._offset.setSquare(i_marker_width);\r
                return;\r
        }\r
 \r
@@ -319,7 +317,7 @@ public abstract class SingleARMarkerProcesser
                                // OnEnter\r
                                this.onEnterHandler(i_code_index);\r
                                // 変換行列を作成\r
-                               this._transmat.transMat(i_square, this._marker_width, result);\r
+                               this._transmat.transMat(i_square, this._offset, result);\r
                                // OnUpdate\r
                                this.onUpdateHandler(i_square, result);\r
                                this._lost_delay_count = 0;\r
@@ -337,7 +335,7 @@ public abstract class SingleARMarkerProcesser
                        } else if (i_code_index == this._current_arcode_index) {// 同じARCodeの再認識\r
                                // イベント生成\r
                                // 変換行列を作成\r
-                               this._transmat.transMat(i_square, this._marker_width, result);\r
+                               this._transmat.transMat(i_square, this._offset, result);\r
                                // OnUpdate\r
                                this.onUpdateHandler(i_square, result);\r
                                this._lost_delay_count = 0;\r
index 0efedfc..1376b56 100644 (file)
@@ -130,8 +130,6 @@ public abstract class SingleNyIdMarkerProcesser
                        //directionを考慮して、squareを更新する。\r
                        for(int i=0;i<4;i++){\r
                                int idx=(i+4 - param.direction) % 4;\r
-                               sq.imvertex[i].x=vertex[idx].x;\r
-                               sq.imvertex[i].y=vertex[idx].y;\r
                                this._coordline.coord2Line(i_vertex_index[idx],i_vertex_index[(idx+1)%4],i_coordx,i_coordy,i_coor_num,sq.line[i]);\r
                        }\r
                        for (int i = 0; i < 4; i++) {\r
@@ -157,7 +155,7 @@ public abstract class SingleNyIdMarkerProcesser
 \r
        private NyARSquareContourDetector_Rle _square_detect;\r
        protected INyARTransMat _transmat;\r
-       private double _marker_width=100;\r
+       private NyARRectOffset _offset; \r
        private boolean _is_active;\r
        private int _current_threshold=110;\r
        // [AR]検出結果の保存用\r
@@ -191,13 +189,14 @@ public abstract class SingleNyIdMarkerProcesser
                this._threshold_detect=new NyARRasterThresholdAnalyzer_SlidePTile(15,i_raster_format,4);\r
                this._initialized=true;\r
                this._is_active=false;\r
+               this._offset=new NyARRectOffset();\r
                return;\r
                \r
        }\r
 \r
        public void setMarkerWidth(int i_width)\r
        {\r
-               this._marker_width=i_width;\r
+               this._offset.setSquare(i_width);\r
                return;\r
        }\r
 \r
@@ -261,7 +260,7 @@ public abstract class SingleNyIdMarkerProcesser
                                // OnEnter\r
                                this.onEnterHandler(this._data_current);\r
                                // 変換行列を作成\r
-                               this._transmat.transMat(i_square, this._marker_width, result);\r
+                               this._transmat.transMat(i_square, this._offset, result);\r
                                // OnUpdate\r
                                this.onUpdateHandler(i_square, result);\r
                                this._lost_delay_count = 0;\r
@@ -279,7 +278,7 @@ public abstract class SingleNyIdMarkerProcesser
                                }\r
                        } else if(this._data_current.isEqual(i_marker_data)) {\r
                                //同じidの再認識\r
-                               this._transmat.transMat(i_square, this._marker_width, result);\r
+                               this._transmat.transMat(i_square, this._offset, result);\r
                                // OnUpdate\r
                                this.onUpdateHandler(i_square, result);\r
                                this._lost_delay_count = 0;\r