OSDN Git Service

[backup]NyARToolKit
authornyatla <nyatla@7cac0a50-4618-4814-88d0-24b83990f816>
Sat, 9 Jan 2010 09:30:16 +0000 (09:30 +0000)
committernyatla <nyatla@7cac0a50-4618-4814-88d0-24b83990f816>
Sat, 9 Jan 2010 09:30:16 +0000 (09:30 +0000)
+関数スコープが不足していたものの変更
+NyARRaster仕様変更
+NyARRgbRaster仕様変更
+NyARToolkitAS3からのフィードバック
+SingleNyIdMarkerProcesser.javaの引数変更

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

17 files changed:
trunk/sample/jogl/jp/nyatla/nyartoolkit/jogl/sample/SingleNyIdMarker.java
trunk/src/jp/nyatla/nyartoolkit/core/NyARCode.java
trunk/src/jp/nyatla/nyartoolkit/core/analyzer/raster/NyARRasterAnalyzer_Histgram.java
trunk/src/jp/nyatla/nyartoolkit/core/pickup/NyARColorPatt_Perspective.java
trunk/src/jp/nyatla/nyartoolkit/core/raster/NyARRaster.java
trunk/src/jp/nyatla/nyartoolkit/core/raster/rgb/NyARRgbRaster.java [new file with mode: 0644]
trunk/src/jp/nyatla/nyartoolkit/core/raster/rgb/NyARRgbRaster_BGRA.java
trunk/src/jp/nyatla/nyartoolkit/core/rasterreader/INyARBufferReader.java
trunk/src/jp/nyatla/nyartoolkit/core/rasterreader/NyARBufferReader.java
trunk/src/jp/nyatla/nyartoolkit/core/types/NyARDoublePoint3d.java
trunk/src/jp/nyatla/nyartoolkit/core/utils/NyAREquationSolver.java
trunk/src/jp/nyatla/nyartoolkit/core/utils/NyARPerspectiveParamGenerator_O1.java
trunk/src/jp/nyatla/nyartoolkit/detector/NyARSingleDetectMarker.java
trunk/src/jp/nyatla/nyartoolkit/nyidmarker/NyIdMarkerPickup.java
trunk/src/jp/nyatla/nyartoolkit/processor/SingleNyIdMarkerProcesser.java
trunk/src/jp/nyatla/nyartoolkit/sample/NyIdTest.java
trunk/src/jp/nyatla/nyartoolkit/utils/TransformedBitmapPickup.java

index 69332cf..bf52d87 100644 (file)
@@ -77,11 +77,11 @@ class MarkerProcessor extends SingleNyIdMarkerProcesser
        public NyARTransMatResult transmat=null;\r
        public int current_id=-1;\r
 \r
-       public MarkerProcessor(NyARParam i_cparam,int i_raster_format) throws NyARException\r
+       public MarkerProcessor(NyARParam i_cparam,int i_width,int i_raster_format) throws NyARException\r
        {\r
                //アプリケーションフレームワークの初期化\r
                super();\r
-               initInstance(i_cparam,new NyIdMarkerDataEncoder_RawBit(),i_raster_format);\r
+               initInstance(i_cparam,new NyIdMarkerDataEncoder_RawBit(),100,i_raster_format);\r
                return;\r
        }\r
        /**\r
@@ -160,8 +160,7 @@ public class SingleNyIdMarker implements GLEventListener, JmfCaptureListener
                this._cap_image = new GLNyARRaster_RGB(i_cparam,this._capture.getCaptureFormat());      \r
 \r
                //プロセッサの準備\r
-               this._processor=new MarkerProcessor(i_cparam,this._cap_image.getBufferReader().getBufferType());\r
-               this._processor.setMarkerWidth(100);\r
+               this._processor=new MarkerProcessor(i_cparam,100,this._cap_image.getBufferReader().getBufferType());\r
                \r
                //OpenGLフレームの準備(OpenGLリソースの初期化、カメラの撮影開始は、initコールバック関数内で実行)\r
                Frame frame = new Frame("Java simpleLite with NyARToolkit");\r
index fc92b1d..e71955e 100644 (file)
@@ -77,7 +77,7 @@ class NyARCodeFileReader
        {\r
                int width=o_code.getWidth();\r
                int height=o_code.getHeight();\r
-               NyARRaster tmp_raster=new NyARRaster(new NyARIntSize(width,height),new int[width*height],INyARBufferReader.BUFFERFORMAT_INT1D_X8R8G8B8_32);\r
+               NyARRaster tmp_raster=new NyARRaster(new NyARIntSize(width,height),INyARBufferReader.BUFFERFORMAT_INT1D_X8R8G8B8_32);\r
                //4個の要素をラスタにセットする。\r
                try {\r
                        StreamTokenizer st = new StreamTokenizer(new InputStreamReader(i_stream));\r
index 0e3650e..0cd42dd 100644 (file)
@@ -41,6 +41,9 @@ public class NyARRasterAnalyzer_Histgram
                case INyARBufferReader.BUFFERFORMAT_WORD1D_R5G6B5_16LE:\r
                        this._histImpl = new NyARRasterThresholdAnalyzer_Histgram_WORD1D_R5G6B5_16LE();\r
                        break;\r
+               case INyARBufferReader.BUFFERFORMAT_INT1D_X8R8G8B8_32:\r
+                       this._histImpl = new NyARRasterThresholdAnalyzer_Histgram_INT1D_X8R8G8B8_32();\r
+                       break;\r
                default:\r
                        throw new NyARException();\r
                }\r
@@ -98,7 +101,25 @@ public class NyARRasterAnalyzer_Histgram
                        return i_size.w*i_size.h;\r
                }       \r
        }\r
+       class NyARRasterThresholdAnalyzer_Histgram_INT1D_X8R8G8B8_32 implements ICreateHistgramImpl\r
+       {\r
+               public int createHistgram(INyARBufferReader i_reader,NyARIntSize i_size, int[] o_histgram,int i_skip)\r
+               {\r
+                       assert (i_reader.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_X8R8G8B8_32));\r
+                       final int[] input=(int[]) i_reader.getBuffer();\r
+                       for (int y = i_size.h-1; y >=0 ; y-=i_skip){\r
+                               int pt=y*i_size.w;\r
+                               for (int x = i_size.w-1; x >=0; x--) {\r
+                                       int p=input[pt];\r
+                                       o_histgram[((p& 0xff)+(p& 0xff)+(p& 0xff))/3]++;\r
+                                       pt++;\r
+                               }\r
+                       }\r
+                       return i_size.w*i_size.h;\r
+               }       \r
+       }\r
 \r
+       \r
        class NyARRasterThresholdAnalyzer_Histgram_BYTE1D_RGB_24 implements ICreateHistgramImpl\r
        {\r
                public int createHistgram(INyARBufferReader i_reader,NyARIntSize i_size, int[] o_histgram,int i_skip)\r
index d03c36c..e3f9ae8 100644 (file)
@@ -53,7 +53,7 @@ public class NyARColorPatt_Perspective implements INyARColorPatt
                this._resolution=i_point_per_pix;       \r
                this._size=new NyARIntSize(i_width,i_height);\r
                this._patdata = new int[i_height*i_width];\r
-               this._buf_reader=new NyARBufferReader(this._patdata,NyARBufferReader.BUFFERFORMAT_INT1D_X8R8G8B8_32);\r
+               this._buf_reader=new NyARBufferReader(this._patdata,INyARBufferReader.BUFFERFORMAT_INT1D_X8R8G8B8_32);\r
                this._pixelreader=new NyARRgbPixelReader_INT1D_X8R8G8B8_32(this._patdata,this._size);\r
                return;         \r
        }\r
@@ -81,11 +81,11 @@ public class NyARColorPatt_Perspective implements INyARColorPatt
         * @param i_edge_percentage\r
         * エッジ幅の割合(ARToolKit標準と同じなら、25)\r
         */\r
-       public NyARColorPatt_Perspective(int i_width, int i_height,int i_resolution,int i_edge_percentage)\r
+       public NyARColorPatt_Perspective(int i_width, int i_height,int i_point_per_pix,int i_edge_percentage)\r
        {\r
                //入力制限\r
-               initializeInstance(i_width,i_height,i_resolution);\r
-               setEdgeSizeByPercent(i_edge_percentage,i_edge_percentage,i_resolution);\r
+               initializeInstance(i_width,i_height,i_point_per_pix);\r
+               setEdgeSizeByPercent(i_edge_percentage,i_edge_percentage,i_point_per_pix);\r
                return;\r
        }       \r
        /**\r
index 4fa1f52..57f52ae 100644 (file)
@@ -30,6 +30,7 @@
  */\r
 package jp.nyatla.nyartoolkit.core.raster;\r
 \r
+import jp.nyatla.nyartoolkit.NyARException;\r
 import jp.nyatla.nyartoolkit.core.rasterreader.*;\r
 import jp.nyatla.nyartoolkit.core.types.*;\r
 \r
@@ -43,11 +44,24 @@ public final class NyARRaster extends NyARRaster_BasicClass
        public INyARBufferReader getBufferReader()\r
        {\r
                return this._reader;\r
-       }\r
-       public NyARRaster(NyARIntSize i_size,Object i_ref_buf,int i_buf_type)\r
+       }       \r
+       public NyARRaster(NyARIntSize i_size,int i_buf_type) throws NyARException\r
        {\r
                super(i_size);\r
-               this._reader=new NyARBufferReader(i_ref_buf,i_buf_type);\r
+               init(i_size,i_buf_type);\r
                return;\r
        }\r
+       private void init(NyARIntSize i_size,int i_buf_type) throws NyARException\r
+       {\r
+               Object buf;\r
+               switch(i_buf_type)\r
+               {\r
+                       case INyARBufferReader.BUFFERFORMAT_INT1D_X8R8G8B8_32:\r
+                               buf=new int[i_size.w*i_size.h];\r
+                               break;\r
+                       default:\r
+                               throw new NyARException();\r
+               }\r
+               this._reader=new NyARBufferReader(buf,i_buf_type);\r
+       }       \r
 }
\ No newline at end of file
diff --git a/trunk/src/jp/nyatla/nyartoolkit/core/raster/rgb/NyARRgbRaster.java b/trunk/src/jp/nyatla/nyartoolkit/core/raster/rgb/NyARRgbRaster.java
new file mode 100644 (file)
index 0000000..09e50ab
--- /dev/null
@@ -0,0 +1,40 @@
+package jp.nyatla.nyartoolkit.core.raster.rgb;\r
+\r
+import jp.nyatla.nyartoolkit.core.rasterreader.*;\r
+import jp.nyatla.nyartoolkit.core.types.*;\r
+import jp.nyatla.nyartoolkit.*;\r
+\r
+public class NyARRgbRaster extends NyARRgbRaster_BasicClass\r
+{\r
+       protected Object _ref_buf;\r
+\r
+       private INyARRgbPixelReader _reader;\r
+       private INyARBufferReader _buffer_reader;\r
+       private void init(NyARIntSize i_size,int i_raster_type) throws NyARException\r
+       {\r
+               switch(i_raster_type)\r
+               {\r
+                       case INyARBufferReader.BUFFERFORMAT_INT1D_X8R8G8B8_32:\r
+                               this._ref_buf=new int[i_size.w*i_size.h];\r
+                               this._reader=new NyARRgbPixelReader_INT1D_X8R8G8B8_32((int[])this._ref_buf,i_size);\r
+                               break;\r
+                       default:\r
+                               throw new NyARException();\r
+               }\r
+               this._buffer_reader=new NyARBufferReader(this._ref_buf,i_raster_type);\r
+       }\r
+       public NyARRgbRaster(NyARIntSize i_size,int i_raster_type) throws NyARException\r
+       {\r
+               super(i_size);\r
+               init(i_size,i_raster_type);\r
+               return;\r
+       }\r
+       public INyARRgbPixelReader getRgbPixelReader()\r
+       {\r
+               return this._reader;\r
+       }\r
+       public INyARBufferReader getBufferReader()\r
+       {\r
+               return this._buffer_reader;\r
+       }       \r
+}\r
index 0cf0380..56b1e6c 100644 (file)
@@ -103,7 +103,7 @@ public class NyARRgbRaster_BGRA extends NyARRgbRaster_BasicClass implements INyA
        public NyARRgbRaster_BGRA(int i_width, int i_height)\r
        {\r
                super(new NyARIntSize(i_width,i_height));\r
-               this._ref_buf = new byte[i_width*i_height];\r
+               this._ref_buf = new byte[i_width*i_height*4];\r
                this._rgb_reader = new PixelReader(this);\r
                this._buffer_reader=new NyARBufferReader(this._ref_buf,INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8X8_32);\r
                return;\r
index ca0fddd..05b2e76 100644 (file)
@@ -40,7 +40,7 @@ public interface INyARBufferReader
        public static final int INT2D  =0x00020000;\r
        public static final int SHORT1D=0x00030000;\r
        public static final int INT1D  =0x00040000;\r
-    //  ID規約\r
+       public static final int OBJECT =0x00100000;    //  ID規約\r
        //  24-31(8)予約\r
        //  16-27(8)型ID\r
        //      00:無効/01:byte[]/02:int[][]/03:short[]\r
@@ -121,8 +121,19 @@ public interface INyARBufferReader
         */\r
        public static final int BUFFERFORMAT_INT1D_X7H9S8V8_32=INT1D|0x0103;\r
     \r
+       public static final int BUFFERFORMAT_OBJECT_Javat= OBJECT|0x0100;\r
+       public static final int BUFFERFORMAT_OBJECT_CS= OBJECT|0x0200;\r
+       public static final int BUFFERFORMAT_OBJECT_AS3= OBJECT|0x0300;\r
 \r
        /**\r
+        * ActionScript3のBitmapDataを格納するラスタ\r
+        */\r
+\r
+       public static final int BUFFERFORMAT_OBJECT_AS3_BitmapData= BUFFERFORMAT_OBJECT_AS3|0x01;\r
+\r
+       \r
+       \r
+       /**\r
         * バッファオブジェクトを返します。\r
         * @return\r
         */\r
index a2b8388..5cfa583 100644 (file)
@@ -34,10 +34,6 @@ public final class NyARBufferReader implements INyARBufferReader
 {\r
        private Object _buffer;\r
        private int _buffer_type;\r
-       private NyARBufferReader()\r
-       {\r
-               return;\r
-       }\r
        public NyARBufferReader(Object i_buffer,int i_buffer_type)\r
        {\r
                this._buffer=i_buffer;\r
index 950b063..1c6177e 100644 (file)
@@ -62,7 +62,7 @@ public class NyARDoublePoint3d
         */\r
        public double dist(NyARDoublePoint3d i_point)\r
        {\r
-               double x,y;\r
+               double x,y,z;\r
                x=this.x-i_point.x;\r
                y=this.y-i_point.y;\r
                z=this.z-i_point.z;\r
index 12207f3..232104b 100644 (file)
@@ -261,7 +261,7 @@ public class NyAREquationSolver
         * @param i_in\r
         * @return\r
         */\r
-       private double cuberoot(double i_in) {\r
+       private static double cuberoot(double i_in) {\r
                double res = Math.pow(Math.abs(i_in), 1.0 / 3.0);\r
                return (i_in >= 0) ? res : -res;\r
        }\r
index 7c58442..326a0ee 100644 (file)
@@ -35,10 +35,6 @@ public class NyARPerspectiveParamGenerator_O1 extends NyARPerspectiveParamGenera
        public NyARPerspectiveParamGenerator_O1(int i_local_x,int i_local_y,int i_width, int i_height)\r
        {\r
                super(i_local_x,i_local_y,i_width,i_height);\r
-               this._height=i_height;\r
-               this._width=i_width;\r
-               this._local_x=i_local_x;\r
-               this._local_y=i_local_y;\r
                return;\r
        }\r
        final public boolean getParam(final NyARIntPoint2d[] i_vertex,double[] o_param)throws NyARException\r
index c22907c..3db60a1 100644 (file)
@@ -67,13 +67,13 @@ public class NyARSingleDetectMarker extends NyARCustomSingleDetectMarker
        public NyARSingleDetectMarker(NyARParam i_param, NyARCode i_code, double i_marker_width,int i_input_raster_type,int i_profile_id) throws NyARException\r
        {\r
                super();\r
-               initInstance(i_param,i_code,i_marker_width,i_input_raster_type,i_profile_id);\r
+               initialize(i_param,i_code,i_marker_width,i_input_raster_type,i_profile_id);\r
                return;\r
        }\r
        public NyARSingleDetectMarker(NyARParam i_param, NyARCode i_code, double i_marker_width,int i_input_raster_type) throws NyARException\r
        {\r
                super();\r
-               initInstance(i_param,i_code,i_marker_width,i_input_raster_type,PF_NYARTOOLKIT);\r
+               initialize(i_param,i_code,i_marker_width,i_input_raster_type,PF_NYARTOOLKIT);\r
                return;\r
        }\r
        /**\r
@@ -85,7 +85,7 @@ public class NyARSingleDetectMarker extends NyARCustomSingleDetectMarker
         * @param i_profile_id\r
         * @throws NyARException\r
         */\r
-       protected void initInstance(\r
+       private void initialize(\r
                NyARParam       i_ref_param,\r
                NyARCode        i_ref_code,\r
                double          i_marker_width,\r
index af85d7a..ca5e3bc 100644 (file)
@@ -799,10 +799,10 @@ class MarkerPattEncoder
         * RECT(2):[2]=(9-16),[3]=(17-24)\r
         * RECT(3):[4]=(25-32),[5]=(33-40),[6]=(41-48)\r
         */\r
-       int[] _bit_table;\r
-       int[] _bits=new int[16];\r
-       int[] _work=new int[16];\r
-       int _model;\r
+       private int[] _bit_table;\r
+       private int[] _bits=new int[16];\r
+       private int[] _work=new int[16];\r
+       private int _model;\r
        public void setBitByBitIndex(int i_index_no,int i_value)\r
        {\r
                assert i_value==0 || i_value==1;\r
index 1376b56..11dbc90 100644 (file)
@@ -170,7 +170,7 @@ public abstract class SingleNyIdMarkerProcesser
                return;\r
        }\r
        private boolean _initialized=false;\r
-       protected void initInstance(NyARParam i_param,INyIdMarkerDataEncoder i_encoder,int i_raster_format) throws NyARException\r
+       protected void initInstance(NyARParam i_param,INyIdMarkerDataEncoder i_encoder,int i_marker_width,int i_raster_format) throws NyARException\r
        {\r
                //初期化済?\r
                assert this._initialized==false;\r
@@ -190,6 +190,7 @@ public abstract class SingleNyIdMarkerProcesser
                this._initialized=true;\r
                this._is_active=false;\r
                this._offset=new NyARRectOffset();\r
+               this._offset.setSquare(i_marker_width);\r
                return;\r
                \r
        }\r
index f14fa7f..7d3a55a 100644 (file)
@@ -56,7 +56,7 @@ public class NyIdTest
         public MarkerProcessor(NyARParam i_cparam, int i_raster_format) throws Exception\r
         {\r
                super();//\r
-            initInstance(i_cparam, new NyIdMarkerDataEncoder_RawBit(), i_raster_format);\r
+            initInstance(i_cparam, new NyIdMarkerDataEncoder_RawBit(),100, i_raster_format);\r
             //アプリケーションフレームワークの初期化\r
             return;\r
         }\r
index c7d4154..e96a259 100644 (file)
@@ -27,7 +27,7 @@ class TransformedBitmapPickup extends NyARColorPatt_Perspective_O2
         * @param i_resolution\r
         * resolution of reading pixel per point. ---- 取得時の解像度。高解像度のときは1を指定してください。低解像度のときは2以上を指定します。\r
         */\r
-       TransformedBitmapPickup(NyARPerspectiveProjectionMatrix i_ref_cparam, int i_width, int i_height, int i_resolution)\r
+       public TransformedBitmapPickup(NyARPerspectiveProjectionMatrix i_ref_cparam, int i_width, int i_height, int i_resolution)\r
        {\r
                super(i_width, i_height, i_resolution, 0);\r
                this._ref_perspective = i_ref_cparam;\r