OSDN Git Service

[更新]NyARToolkit for Java
authornyatla <nyatla@7cac0a50-4618-4814-88d0-24b83990f816>
Tue, 26 May 2009 13:17:14 +0000 (13:17 +0000)
committernyatla <nyatla@7cac0a50-4618-4814-88d0-24b83990f816>
Tue, 26 May 2009 13:17:14 +0000 (13:17 +0000)
バグ修正→NyARColorPatt_O3のパターン抽出エリア不具合
その他雑多な修正

17 files changed:
src/jp/nyatla/nyartoolkit/core/NyARSquare.java
src/jp/nyatla/nyartoolkit/core/match/NyARMatchPattDeviationColorData.java
src/jp/nyatla/nyartoolkit/core/match/NyARMatchPattResult.java
src/jp/nyatla/nyartoolkit/core/pickup/NyARColorPatt_O1.java
src/jp/nyatla/nyartoolkit/core/pickup/NyARColorPatt_O3.java
src/jp/nyatla/nyartoolkit/core/raster/rgb/NyARRgbRaster_BasicClass.java
src/jp/nyatla/nyartoolkit/core/types/NyARLinear.java
src/jp/nyatla/nyartoolkit/core/types/matrix/NyARDoubleMatrix44.java
src/jp/nyatla/nyartoolkit/core/utils/NyARSystemOfLinearEquationsProcessor.java
src/jp/nyatla/nyartoolkit/core2/rasteranalyzer/threshold/NyARRasterThresholdAnalyzer_SlidePTile.java
src/jp/nyatla/nyartoolkit/nyidmarker/NyIdMarkerParam.java
src/jp/nyatla/nyartoolkit/nyidmarker/NyIdMarkerPattern.java
src/jp/nyatla/nyartoolkit/nyidmarker/NyIdMarkerPickup.java
src/jp/nyatla/nyartoolkit/nyidmarker/data/INyIdMarkerData.java
src/jp/nyatla/nyartoolkit/nyidmarker/data/NyIdMarkerDataEncoder_RawBit.java
src/jp/nyatla/nyartoolkit/nyidmarker/data/NyIdMarkerData_RawBit.java
test/jp/nyatla/nyartoolkit/dev/PattPickupTest.java

index 768706f..b74990f 100644 (file)
@@ -43,16 +43,15 @@ public class NyARSquare
 {\r
        public final static int DIRECTION_UNKNOWN=-1;\r
        public int direction;\r
-       public NyARLinear[] line = new NyARLinear[4];\r
-       public NyARDoublePoint2d[] sqvertex = new NyARDoublePoint2d[4];\r
-       public NyARIntPoint2d[] imvertex = new NyARIntPoint2d[4];\r
-       public NyARSquare()\r
-       {\r
-               this.direction=DIRECTION_UNKNOWN;\r
-               for(int i=0;i<4;i++){\r
-                       this.sqvertex[i]=new NyARDoublePoint2d();\r
-                       this.imvertex[i]=new NyARIntPoint2d();\r
-                       this.line[i]=new NyARLinear();\r
-               }\r
-       }\r
+    public NyARLinear[] line = NyARLinear.createArray(4);\r
+    public NyARDoublePoint2d[] sqvertex = NyARDoublePoint2d.createArray(4);\r
+    public NyARIntPoint2d[] imvertex = NyARIntPoint2d.createArray(4);\r
+    public NyARSquare()\r
+    {\r
+        for (int i = 0; i < 4; i++)\r
+        {\r
+            this.line[i] = new NyARLinear();\r
+        }\r
+    }\r
+\r
 }
\ No newline at end of file
index 2b1040c..df2f3d6 100644 (file)
@@ -41,7 +41,7 @@ import jp.nyatla.nyartoolkit.core.rasterreader.*;
  */\r
 public class NyARMatchPattDeviationColorData\r
 {\r
-       private int _data[];\r
+       private int[] _data;\r
        private double _pow;\r
        //\r
        private int _number_of_pixels;\r
index 66852ee..42ca3a1 100644 (file)
  * \r
  */\r
 package jp.nyatla.nyartoolkit.core.match;\r
-\r
+/**\r
+ * [[Strage class]]\r
+ *\r
+ */\r
 public class NyARMatchPattResult\r
 {\r
        public double confidence;\r
index 2b6abcd..a6138ab 100644 (file)
@@ -88,11 +88,11 @@ public class NyARColorPatt_O1 implements INyARColorPatt
 \r
        private final NyARMat __get_cpara_a = new NyARMat(8, 8);\r
        private final NyARMat __get_cpara_b = new NyARMat(8, 1);\r
-       private final double[][] __get__cpara_world = {{ 100.0, 100.0 }, { 100.0 + 10.0, 100.0 }, { 100.0 + 10.0, 100.0 + 10.0 },{ 100.0, 100.0 + 10.0 } };\r
+       private final static double[][] __get__cpara_world = {{ 100.0, 100.0 }, { 100.0 + 10.0, 100.0 }, { 100.0 + 10.0, 100.0 + 10.0 },{ 100.0, 100.0 + 10.0 } };\r
        \r
        final protected boolean get_cpara(final NyARIntPoint2d[] i_vertex, NyARMat o_para)throws NyARException\r
        {\r
-               double[][] world = this.__get__cpara_world;\r
+               double[][] world = __get__cpara_world;\r
                NyARMat a = __get_cpara_a;// 次処理で値を設定するので、初期化不要// new NyARMat( 8, 8 );\r
                double[][] a_array = a.getArray();\r
                NyARMat b = __get_cpara_b;// 次処理で値を設定するので、初期化不要// new NyARMat( 8, 1 );\r
index bef1580..f5030b2 100644 (file)
@@ -50,7 +50,6 @@ public class NyARColorPatt_O3 implements INyARColorPatt
        private NyARBufferReader _buf_reader;\r
        private NyARIntSize _size;\r
        private NyARRgbPixelReader_INT1D_X8R8G8B8_32 _pixelreader;\r
-       private double _edge_percent;\r
        \r
        public NyARColorPatt_O3(int i_width, int i_height)\r
        {\r
@@ -58,7 +57,6 @@ public class NyARColorPatt_O3 implements INyARColorPatt
                this._patdata = new int[i_height*i_width];\r
                this._buf_reader=new NyARBufferReader(this._patdata,NyARBufferReader.BUFFERFORMAT_INT1D_X8R8G8B8_32);\r
                this._pixelreader=new NyARRgbPixelReader_INT1D_X8R8G8B8_32(this._patdata,this._size);\r
-               this._edge_percent=50.0/100;\r
        }\r
        public int getWidth()\r
        {\r
@@ -92,7 +90,7 @@ public class NyARColorPatt_O3 implements INyARColorPatt
         */\r
        private boolean get_cpara(final NyARIntPoint2d[] i_vertex, NyARMat o_para)throws NyARException\r
        {\r
-               int[][] world = this.wk_pickFromRaster_world;\r
+               int[][] world = wk_pickFromRaster_world;\r
                NyARMat a = wk_get_cpara_a;// 次処理で値を設定するので、初期化不要// new NyARMat( 8, 8 );\r
                double[][] a_array = a.getArray();\r
                NyARMat b = wk_get_cpara_b;// 次処理で値を設定するので、初期化不要// new NyARMat( 8, 1 );\r
@@ -133,7 +131,7 @@ public class NyARColorPatt_O3 implements INyARColorPatt
        }\r
 \r
        // private final double[] wk_pickFromRaster_para=new double[9];//[3][3];\r
-       private final int[][] wk_pickFromRaster_world = {// double world[4][2];\r
+       private final static int[][] wk_pickFromRaster_world = {// double world[4][2];\r
        { 100, 100 }, { 100 + 10, 100 }, { 100 + 10, 100 + 10 }, { 100, 100 + 10 } };\r
 \r
 \r
@@ -216,7 +214,9 @@ public class NyARColorPatt_O3 implements INyARColorPatt
                        this.__updateExtpat_rgbset=new int[i_xdiv*i_ydiv*3];\r
                }\r
                return;\r
-       }       \r
+       }\r
+       private static double LT_POS=102.5;\r
+       private static double SQ_SIZE=5.0;\r
        \r
        //分割数16未満になると少し遅くなるかも。\r
        private void updateExtpat(INyARRgbRaster image, NyARMat i_cpara, int i_xdiv2,int i_ydiv2) throws NyARException\r
@@ -246,8 +246,8 @@ public class NyARColorPatt_O3 implements INyARColorPatt
 \r
                //ワークバッファの準備\r
                reservWorkBuffers(xdiv,ydiv);\r
-               final double xw[]=this.__updateExtpat_xw;\r
-               final double yw[]=this.__updateExtpat_yw;\r
+               final double[] xw=this.__updateExtpat_xw;\r
+               final double[] yw=this.__updateExtpat_yw;\r
                final int[] xc=this.__updateExtpat_xc;\r
                final int[] yc=this.__updateExtpat_yc;\r
                int[] rgb_set = this.__updateExtpat_rgbset;\r
@@ -258,11 +258,11 @@ public class NyARColorPatt_O3 implements INyARColorPatt
                                //xw,ywマップを作成\r
                                reciprocal= 1.0 / i_xdiv2;\r
                                for(i=xdiv-1;i>=0;i--){\r
-                                       xw[i]=100 + 10.0 * (ix*xdiv+i + 0.5) * reciprocal;\r
+                                       xw[i]=LT_POS + SQ_SIZE * (ix*xdiv+i + 0.5) * reciprocal;\r
                                }\r
                                reciprocal= 1.0 / i_ydiv2;\r
                                for(i=ydiv-1;i>=0;i--){\r
-                                       yw[i]=100 + 10.0 * (iy*ydiv+i + 0.5) * reciprocal;\r
+                                       yw[i]=LT_POS + SQ_SIZE * (iy*ydiv+i + 0.5) * reciprocal;\r
                                }\r
                                //1ピクセルを構成するピクセル座標の集合をxc,yc配列に取得\r
                                int number_of_pix=0;\r
index a1abbcf..35d6589 100644 (file)
@@ -61,7 +61,7 @@ public abstract class NyARRgbRaster_BasicClass implements INyARRgbRaster
        {\r
                this._size= i_size;\r
        }\r
-       public INyARRgbPixelReader getRgbPixcelReader() throws NyARException\r
+       public INyARRgbPixelReader getRgbPixelReader() throws NyARException\r
        {\r
                NyARException.notImplement();\r
                return null;\r
index df0e062..55bfe79 100644 (file)
@@ -36,6 +36,15 @@ public class NyARLinear
        public double rise;//y軸の増加量\r
        public double run;//x軸の増加量\r
        public double intercept;//切片\r
+       public static NyARLinear[] createArray(int i_number)\r
+       {\r
+               NyARLinear[] ret=new NyARLinear[i_number];\r
+               for(int i=0;i<i_number;i++)\r
+               {\r
+                       ret[i]=new NyARLinear();\r
+               }\r
+               return ret;\r
+       }       \r
        public final void copyFrom(NyARLinear i_source)\r
        {\r
                this.rise=i_source.rise;\r
index 1ef0e15..6a1ca49 100644 (file)
@@ -1,3 +1,34 @@
+/* \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 version ARToolkit class library.\r
+ * Copyright (C)2008 R.Iizuka\r
+ *\r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 2\r
+ * of the License, or (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 framework; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ * \r
+ * For further information please contact.\r
+ *     http://nyatla.jp/nyatoolkit/\r
+ *     <airmail(at)ebony.plala.or.jp>\r
+ * \r
+ */\r
 package jp.nyatla.nyartoolkit.core.types.matrix;\r
 \r
 \r
index 4d05447..747b10f 100644 (file)
@@ -118,8 +118,8 @@ public class NyARSystemOfLinearEquationsProcessor
                                        final double p=i_left[i][i2]*s;\r
                                        dest_l_n[i2]=dest_l_n[i2]-p;\r
                                }\r
-                               final double p=i_right[i]*s;\r
-                               i_right[solve_row]=i_right[solve_row]-p;\r
+                               final double k=i_right[i]*s;\r
+                               i_right[solve_row]=i_right[solve_row]-k;\r
                                \r
                        }\r
                        //消去法の実行(割り算)\r
index 1e5114a..009c3ac 100644 (file)
@@ -150,19 +150,23 @@ public class NyARRasterThresholdAnalyzer_SlidePTile implements INyARRasterThresh
                return;//未実装一号\r
        }\r
 \r
-\r
-       private int createHistgram(INyARBufferReader i_reader,NyARIntSize i_size, int[] o_histgram) throws NyARException\r
+       private int[] _histgram_buf=new int[256];\r
+       public void analyzeRaster(INyARRaster i_input) throws NyARException\r
        {\r
-               //最大画像サイズの制限\r
-               assert i_size.w*i_size.h<0x40000000;\r
+               final INyARBufferReader buffer_reader=i_input.getBufferReader();        \r
+               assert (buffer_reader.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GLAY_8));\r
 \r
-               int[] histgram = o_histgram;\r
+               final int[] histgram = this._histgram_buf;\r
+               final NyARIntSize size=i_input.getSize();\r
                \r
-               //ヒストグラム作成              \r
+               //最大画像サイズの制限\r
+               assert size.w*size.h<0x40000000;\r
+\r
+               //ヒストグラム初期化\r
                for (int i = 0; i < 256; i++) {\r
-                       o_histgram[i] = 0;\r
+                       histgram[i] = 0;\r
                }\r
-               int sum_of_pixel=this._histgram.createHistgramImpl(i_reader, i_size, o_histgram);\r
+               int sum_of_pixel=this._histgram.createHistgramImpl(i_input.getBufferReader(), size, histgram);\r
 \r
                // 閾値ピクセル数確定\r
                final int th_pixcels = sum_of_pixel * this._persentage / 100;\r
@@ -186,72 +190,9 @@ public class NyARRasterThresholdAnalyzer_SlidePTile implements INyARRasterThresh
                        }\r
                }\r
                // 閾値の保存\r
-               return (th_w + th_b) / 2;\r
-       }\r
-\r
-       public void analyzeRaster(INyARRaster i_input) throws NyARException\r
-       {\r
-               final INyARBufferReader buffer_reader=i_input.getBufferReader();        \r
-               assert (buffer_reader.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GLAY_8));\r
-\r
-               int[] histgram = new int[256];\r
-               // 閾値の基準値を出す。\r
-               this._threshold = createHistgram(buffer_reader,i_input.getSize(), histgram);\r
-               return;\r
-       }\r
-\r
-       /**\r
-        * ヒストグラムをラスタに書き出す。\r
-        * \r
-        * @param i_output\r
-        */\r
-       public void debugDrawHistgramMap(INyARRaster i_input, INyARRaster i_output) throws NyARException\r
-       {\r
-               INyARBufferReader in_buffer_reader=i_input.getBufferReader();   \r
-               INyARBufferReader out_buffer_reader=i_output.getBufferReader(); \r
-               assert (in_buffer_reader.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GLAY_8));\r
-               assert (out_buffer_reader.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GLAY_8));\r
-\r
-               NyARIntSize size = i_output.getSize();\r
-\r
-               int[] out_buf = (int[]) out_buffer_reader.getBuffer();\r
-               // 0で塗りつぶし\r
-               for (int y = 0; y < size.h; y++) {\r
-                       for (int x = 0; x < size.w; x++) {\r
-                               out_buf[y* size.w+x] = 0;\r
-                       }\r
-               }\r
-               // ヒストグラムを計算\r
-               int[] histgram = new int[256];\r
-               int threshold = createHistgram(in_buffer_reader,i_input.getSize(), histgram);\r
-               for (int i = 255; i > 0; i--) {\r
-                       histgram[i] = Math.abs(histgram[i]);\r
-               }\r
-\r
-               // ヒストグラムの最大値を出す\r
-               int max_v = 0;\r
-               for (int i = 0; i < 255; i++) {\r
-                       if (max_v < histgram[i]) {\r
-                               max_v = histgram[i];\r
-                       }\r
-               }\r
-               // 目盛り\r
-               for (int i = 0; i < size.h; i++) {\r
-                       out_buf[i* size.w+0] = 128;\r
-                       out_buf[i* size.w+128] = 128;\r
-                       out_buf[i* size.w+255] = 128;\r
-               }\r
-               // スケーリングしながら描画\r
-               for (int i = 0; i < 255; i++) {\r
-                       out_buf[(histgram[i] * (size.h - 1) / max_v)* size.w+i] = 255;\r
-               }\r
-               // 値\r
-               for (int i = 0; i < size.h; i++) {\r
-                       out_buf[i* size.w+threshold] = 255;\r
-               }\r
+               this._threshold = (th_w + th_b) / 2;\r
                return;\r
        }\r
-\r
        public int getThreshold()\r
        {\r
                return this._threshold;\r
index 4e67d10..7cec6e3 100644 (file)
@@ -32,6 +32,7 @@
 package jp.nyatla.nyartoolkit.nyidmarker;\r
 \r
 /**\r
+ * [[Strage class]]\r
  * マーカを抽出した時のパラメータを格納するクラスです。\r
  *\r
  */\r
index f11699f..396ced4 100644 (file)
@@ -31,6 +31,7 @@
  */\r
 package jp.nyatla.nyartoolkit.nyidmarker;\r
 /**\r
+ * [[Strage class]]\r
  * IDマーカパターン値を格納するクラスです。\r
  * クラスは、未整形のマーカデータを格納しています。\r
  *\r
index 3b4ef83..b9996e8 100644 (file)
@@ -303,7 +303,7 @@ class PerspectivePixelReader
                for(int i=0;i<10;i++){\r
                        freq_count_table[i]=0;\r
                }\r
-               final int freq_table[]=this._freq_table;\r
+               final int[] freq_table=this._freq_table;\r
                for(int i=0;i<110;i++){\r
                        freq_table[i]=0;\r
                }\r
@@ -425,8 +425,8 @@ class PerspectivePixelReader
        }       \r
 \r
        class THighAndLow{\r
-               int h;\r
-               int l;\r
+               public int h;\r
+               public int l;\r
        }\r
        /**\r
         * ピクセル配列の上位、下位の4ピクセルのピクセル値平均を求めます。\r
@@ -604,8 +604,8 @@ class PerspectivePixelReader
        private int detectDataBitsIndex(PerspectivePixelReader.TThreshold i_th,double[] o_index_row,double[] o_index_col) throws NyARException\r
        {\r
                //周波数を測定\r
-               final int freq_index1[]=this.__detectDataBitsIndex_freq_index1;\r
-               final int freq_index2[]=this.__detectDataBitsIndex_freq_index2;\r
+               final int[] freq_index1=this.__detectDataBitsIndex_freq_index1;\r
+               final int[] freq_index2=this.__detectDataBitsIndex_freq_index2;\r
                \r
                \r
                int frq_t=getRowFrequency(i_th.lt_y,i_th.th_h,i_th.th_l,freq_index1);\r
@@ -871,7 +871,9 @@ class MarkerPattEncoder
                case 4:\r
                case 5:\r
                case 6:\r
-               case 7:\r
+        case 7:\r
+        default:\r
+            break;\r
                }\r
                return -1;\r
        }\r
@@ -888,7 +890,9 @@ class MarkerPattEncoder
                case 4:\r
                case 5:\r
                case 6:\r
-               case 7:\r
+        case 7:\r
+        default:\r
+            break;\r
                }\r
                return -1;\r
        }\r
index 84ab726..5f101ae 100644 (file)
  */\r
 package jp.nyatla.nyartoolkit.nyidmarker.data;\r
 \r
-\r
+/**\r
+ * \r
+ * [[Strage class]]\r
+ *\r
+ */\r
 public interface INyIdMarkerData\r
 {\r
        /**\r
index 8e8a147..3692599 100644 (file)
@@ -37,7 +37,7 @@ import jp.nyatla.nyartoolkit.nyidmarker.*;
 public class NyIdMarkerDataEncoder_RawBit implements INyIdMarkerDataEncoder\r
 {      \r
        private final static int _DOMAIN_ID=0;\r
-       private final static int _mod_data[]={7,31,127,511,2047,4095};\r
+       private final static int[] _mod_data={7,31,127,511,2047,4095};\r
        public boolean encode(NyIdMarkerPattern i_data,INyIdMarkerData o_dest)\r
        {\r
                final NyIdMarkerData_RawBit dest=(NyIdMarkerData_RawBit)o_dest;\r
index 2e771d0..74ba8b1 100644 (file)
  */\r
 package jp.nyatla.nyartoolkit.nyidmarker.data;\r
 \r
+/**\r
+ * [[Strage class]]\r
+ *\r
+ */\r
 public class NyIdMarkerData_RawBit implements INyIdMarkerData\r
 {\r
        public int[] packet=new int[22];\r
index bbc8022..cb779b6 100644 (file)
@@ -77,7 +77,7 @@ public class PattPickupTest extends Frame implements JmfCaptureListener
                return (int) Math.sqrt((lx1 * lx1) + (ly1 * ly1)) * (int) Math.sqrt(((lx2 * lx2) + (ly2 * ly2)));\r
        }\r
 \r
-       private INyARColorPatt _patt1 = new NyARColorPatt_O3(64, 64);\r
+       private INyARColorPatt _patt1 = new NyARColorPatt_O3(16, 16);\r
 \r
        private INyARColorPatt _patt2 = new NyARColorPatt_Perspective(100,100);\r
 \r
@@ -164,9 +164,6 @@ public class PattPickupTest extends Frame implements JmfCaptureListener
                                                        g2.drawRect(this._patt3.vertex_x[i]-1,this._patt3.vertex_y[i]-1, 2, 2);\r
                                                }\r
 */                                             g2.setColor(Color.red);\r
-                                               for (int i = 0; i <4; i++) {\r
-                                                       g2.drawRect(this._patt3.vertex2_x[i]-1,this._patt3.vertex2_y[i]-1, 2, 2);\r
-                                               }\r
                                        }\r
                                        g.drawImage(sink, ins.left + 320, ins.top, 128, 128, null);\r
                                        g.drawImage(sink2, ins.left + 320, ins.top + 128, 400, 400, null);\r
@@ -178,9 +175,7 @@ public class PattPickupTest extends Frame implements JmfCaptureListener
                                        Image img = b2i.createImage(i_buffer);\r
                                        g.drawImage(img, ins.left, ins.top, this);\r
                                        g.setColor(Color.blue);\r
-                                       for (int i = 0; i < 225*4; i++) {\r
-                                               g.drawRect(ins.left+this._patt3.vertex_x[i]-1,ins.top+this._patt3.vertex_y[i]-1, 2, 2);\r
-                                       }\r
+\r
                                \r
                                }\r
                                /*\r