OSDN Git Service

[backup]NyARToolkit
authornyatla <nyatla@7cac0a50-4618-4814-88d0-24b83990f816>
Mon, 11 Jan 2010 13:58:16 +0000 (13:58 +0000)
committernyatla <nyatla@7cac0a50-4618-4814-88d0-24b83990f816>
Mon, 11 Jan 2010 13:58:16 +0000 (13:58 +0000)
+NyARRasterAnalyzer_Histgram,NyARRasterThresholdAnalyzer_SlidePTileの継承対応
+一部クラスのメンバ変数のスコープ変更
+細かいメンテ

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

trunk/src/jp/nyatla/nyartoolkit/core/analyzer/raster/NyARRasterAnalyzer_Histgram.java
trunk/src/jp/nyatla/nyartoolkit/core/analyzer/raster/threshold/NyARRasterThresholdAnalyzer_SlidePTile.java
trunk/src/jp/nyatla/nyartoolkit/core/labeling/artoolkit/NyARLabelingImage.java
trunk/src/jp/nyatla/nyartoolkit/core/labeling/rlelabeling/NyARLabeling_Rle.java
trunk/src/jp/nyatla/nyartoolkit/core/raster/NyARRaster.java
trunk/src/jp/nyatla/nyartoolkit/core/squaredetect/ContourPickup.java

index 0cd42dd..a012dc4 100644 (file)
@@ -3,6 +3,8 @@ package jp.nyatla.nyartoolkit.core.analyzer.raster;
 import jp.nyatla.nyartoolkit.NyARException;\r
 import jp.nyatla.nyartoolkit.core.raster.INyARRaster;\r
 import jp.nyatla.nyartoolkit.core.rasterreader.INyARBufferReader;\r
+import jp.nyatla.nyartoolkit.core.rasterreader.NyARBufferReader;\r
+import jp.nyatla.nyartoolkit.core.rasterreader.NyARRgbPixelReader_INT1D_X8R8G8B8_32;\r
 import jp.nyatla.nyartoolkit.core.types.NyARHistgram;\r
 import jp.nyatla.nyartoolkit.core.types.NyARIntSize;\r
 import jp.nyatla.nyartoolkit.core.analyzer.histgram.*;\r
@@ -14,7 +16,7 @@ import jp.nyatla.nyartoolkit.core.analyzer.histgram.*;
  */\r
 public class NyARRasterAnalyzer_Histgram\r
 {\r
-       private ICreateHistgramImpl _histImpl;\r
+       protected ICreateHistgramImpl _histImpl;\r
        /**\r
         * ヒストグラム解析の縦方向スキップ数。継承クラスはこのライン数づつ\r
         * スキップしながらヒストグラム計算を行うこと。\r
@@ -24,6 +26,12 @@ public class NyARRasterAnalyzer_Histgram
        \r
        public NyARRasterAnalyzer_Histgram(int i_raster_format,int i_vertical_interval) throws NyARException\r
        {\r
+               if(!initInstance(i_raster_format,i_vertical_interval)){\r
+                       throw new NyARException();\r
+               }\r
+       }\r
+       protected boolean initInstance(int i_raster_format,int i_vertical_interval)\r
+       {\r
                switch (i_raster_format) {\r
                case INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8_24:\r
                case INyARBufferReader.BUFFERFORMAT_BYTE1D_R8G8B8_24:\r
@@ -45,11 +53,14 @@ public class NyARRasterAnalyzer_Histgram
                        this._histImpl = new NyARRasterThresholdAnalyzer_Histgram_INT1D_X8R8G8B8_32();\r
                        break;\r
                default:\r
-                       throw new NyARException();\r
+                       return false;\r
                }\r
                //初期化\r
                this._vertical_skip=i_vertical_interval;\r
+               return true;\r
        }       \r
+       \r
+       \r
        public void setVerticalInterval(int i_step)\r
        {\r
                this._vertical_skip=i_step;\r
index ae6ed46..c1c36d8 100644 (file)
@@ -12,7 +12,7 @@ import jp.nyatla.nyartoolkit.core.types.NyARHistgram;
  */\r
 public class NyARRasterThresholdAnalyzer_SlidePTile implements INyARRasterThresholdAnalyzer\r
 {\r
-       private NyARRasterAnalyzer_Histgram _raster_analyzer;\r
+       protected NyARRasterAnalyzer_Histgram _raster_analyzer;\r
        private NyARHistgramAnalyzer_SlidePTile _sptile;\r
        private NyARHistgram _histgram;\r
        public void setVerticalInterval(int i_step)\r
@@ -24,11 +24,17 @@ public class NyARRasterThresholdAnalyzer_SlidePTile implements INyARRasterThresh
        {\r
                assert (0 <= i_persentage && i_persentage <= 50);\r
                //初期化\r
+               if(!initInstance(i_raster_format,i_vertical_interval)){\r
+                       throw new NyARException();\r
+               }\r
                this._sptile=new NyARHistgramAnalyzer_SlidePTile(i_persentage);\r
                this._histgram=new NyARHistgram(256);\r
+       }\r
+       protected boolean initInstance(int i_raster_format,int i_vertical_interval) throws NyARException\r
+       {\r
                this._raster_analyzer=new NyARRasterAnalyzer_Histgram(i_raster_format,i_vertical_interval);\r
+               return true;\r
        }\r
-       \r
        public int analyzeRaster(INyARRaster i_input) throws NyARException\r
        {\r
                this._raster_analyzer.analyzeRaster(i_input, this._histgram);\r
index 7eb2ae3..02ad8d7 100644 (file)
@@ -111,10 +111,6 @@ public class NyARLabelingImage extends NyARRaster_BasicClass
                this._is_index_table_enable=i_label_index_enable;\r
                return;\r
        }\r
-       //巡回参照できるように、テーブルを二重化\r
-       //                                           0  1  2  3  4  5  6  7   0  1  2  3  4  5  6\r
-       protected final static int[] _getContour_xdir = { 0, 1, 1, 1, 0,-1,-1,-1 , 0, 1, 1, 1, 0,-1,-1};\r
-       protected final static int[] _getContour_ydir = {-1,-1, 0, 1, 1, 1, 0,-1 ,-1,-1, 0, 1, 1, 1, 0};\r
        /**\r
         * i_labelのラベルの、クリップ領域が上辺に接しているx座標を返します。\r
         * @param i_index\r
index c4ee7ed..50a1962 100644 (file)
@@ -205,7 +205,7 @@ public class NyARLabeling_Rle
         */\r
        public int labeling(NyARBinRaster i_bin_raster, int i_top, int i_bottom,RleLabelFragmentInfoStack o_stack) throws NyARException\r
        {\r
-               assert(i_bin_raster.getBufferReader().getBufferType()==INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8);\r
+               assert(i_bin_raster.getBufferReader().isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8));\r
                return this.imple_labeling(i_bin_raster,0,i_top,i_bottom,o_stack);\r
        }\r
        /**\r
@@ -221,7 +221,7 @@ public class NyARLabeling_Rle
         */\r
        public int labeling(NyARGrayscaleRaster i_gs_raster,int i_th, int i_top, int i_bottom,RleLabelFragmentInfoStack o_stack) throws NyARException\r
        {\r
-               assert(i_gs_raster.getBufferReader().getBufferType()==INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8);\r
+               assert(i_gs_raster.getBufferReader().isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8));\r
                return this.imple_labeling(i_gs_raster,i_th,i_top,i_bottom,o_stack);\r
        }\r
        private int imple_labeling(INyARRaster i_raster,int i_th,int i_top, int i_bottom,RleLabelFragmentInfoStack o_stack) throws NyARException\r
index bf8ee12..4aff30c 100644 (file)
@@ -42,10 +42,7 @@ public final class NyARRaster extends NyARRaster_BasicClass
 {\r
        protected NyARBufferReader _reader;\r
        protected Object _buf;\r
-       public INyARBufferReader getBufferReader()\r
-       {\r
-               return this._reader;\r
-       }       \r
+       \r
        public NyARRaster(NyARIntSize i_size,int i_buf_type) throws NyARException\r
        {\r
                super(i_size);\r
@@ -66,5 +63,9 @@ public final class NyARRaster extends NyARRaster_BasicClass
                }\r
                this._reader=new NyARBufferReader(this._buf,i_buf_type);\r
                return true;\r
+       }\r
+       public INyARBufferReader getBufferReader()\r
+       {\r
+               return this._reader;\r
        }       \r
 }
\ No newline at end of file
index bd103e6..1f56368 100644 (file)
@@ -32,6 +32,7 @@ package jp.nyatla.nyartoolkit.core.squaredetect;
 \r
 import jp.nyatla.nyartoolkit.NyARException;\r
 import jp.nyatla.nyartoolkit.core.raster.*;\r
+import jp.nyatla.nyartoolkit.core.rasterreader.INyARBufferReader;\r
 import jp.nyatla.nyartoolkit.core.labeling.artoolkit.*;\r
 \r
 /**\r
@@ -46,6 +47,7 @@ public class ContourPickup
        protected final static int[] _getContour_ydir = {-1,-1, 0, 1, 1, 1, 0,-1 ,-1,-1, 0, 1, 1, 1, 0};\r
        public int getContour(NyARBinRaster i_raster,int i_entry_x,int i_entry_y,int i_array_size,int[] o_coord_x,int[] o_coord_y) throws NyARException\r
        {\r
+               assert(i_raster.getBufferReader().isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8));\r
                return impl_getContour(i_raster,0,i_entry_x,i_entry_y,i_array_size,o_coord_x,o_coord_y);\r
        }\r
        /**\r
@@ -64,6 +66,7 @@ public class ContourPickup
         */\r
        public int getContour(NyARGrayscaleRaster i_raster,int i_th,int i_entry_x,int i_entry_y,int i_array_size,int[] o_coord_x,int[] o_coord_y) throws NyARException\r
        {\r
+               assert(i_raster.getBufferReader().isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8));\r
                return impl_getContour(i_raster,i_th,i_entry_x,i_entry_y,i_array_size,o_coord_x,o_coord_y);\r
        }\r
 \r