OSDN Git Service

[更新]NyARToolkit for Java
[nyartoolkit-and/nyartoolkit-and.git] / src / jp / nyatla / nyartoolkit / core2 / rasteranalyzer / NyARRasterDetector_QrCodeEdge.java
index 4945175..89d908a 100644 (file)
@@ -7,26 +7,25 @@
  *   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
+ * The NyARToolkit is Java edition ARToolKit class library.\r
+ * Copyright (C)2008-2009 Ryo 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
+ * This program is free software: you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation, either version 3 of the License, or\r
+ * (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
+ *\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
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
  * \r
  * For further information please contact.\r
  *     http://nyatla.jp/nyatoolkit/\r
- *     <airmail(at)ebony.plala.or.jp>\r
+ *     <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>\r
  * \r
  */\r
 package jp.nyatla.nyartoolkit.core2.rasteranalyzer;\r
@@ -37,6 +36,11 @@ import jp.nyatla.nyartoolkit.core.types.stack.*;
 import jp.nyatla.nyartoolkit.core.types.*;\r
 import jp.nyatla.nyartoolkit.core.rasterreader.*;\r
 \r
+/**\r
+ * QRコードの4頂点候補を探そうとするクラス。\r
+ * 未完成\r
+ *\r
+ */\r
 public class NyARRasterDetector_QrCodeEdge\r
 {\r
        private NyARIntRectStack _result;\r
@@ -84,7 +88,7 @@ public class NyARRasterDetector_QrCodeEdge
        public void analyzeRaster(INyARRaster i_input) throws NyARException\r
        {\r
                INyARBufferReader buffer_reader=i_input.getBufferReader();\r
-               assert (buffer_reader.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT2D_BIN_8));\r
+               assert (buffer_reader.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8));\r
 \r
                // 結果をクリア\r
                this._result.clear();\r
@@ -95,11 +99,12 @@ public class NyARRasterDetector_QrCodeEdge
                w1 = b1 = w2 = b2 = w3 = b3 = 0;\r
 \r
                NyARIntRect item;\r
-               int[] line;\r
+               int[] raster_buf=(int[])buffer_reader.getBuffer();\r
+               int line_ptr;\r
                int s_pos, b2_spos,b3_spos;\r
                b2_spos=0;\r
                for (int y = size.h - 1-8; y >= 8; y--) {\r
-                       line = ((int[][]) buffer_reader.getBuffer())[y];\r
+                       line_ptr = y*size.w;\r
                        x = size.w - 1;\r
                        s_pos=0;\r
                        int token_id=0;\r
@@ -109,7 +114,7 @@ public class NyARRasterDetector_QrCodeEdge
                                        // w1の特定\r
                                        w1 = 0;\r
                                        for (; x >= 0; x--) {\r
-                                               if (line[x] == 0) {\r
+                                               if (raster_buf[line_ptr+x] == 0) {\r
                                                        // 検出条件確認:w1は2以上欲しいな。\r
                                                        if (!check_w1(w1)) {\r
                                                                // 条件不十分\r
@@ -128,7 +133,7 @@ public class NyARRasterDetector_QrCodeEdge
                                        b1 = 0;\r
                                        s_pos = x;\r
                                        for (; x >= 0; x--) {\r
-                                               if (line[x] > 0) {\r
+                                               if (raster_buf[line_ptr+x] > 0) {\r
                                                        // 検出条件確認:b1は1以上欲しいな。\r
                                                        if (!check_b1(b1)){\r
                                                                //条件不十分→白検出からやり直し\r
@@ -146,7 +151,7 @@ public class NyARRasterDetector_QrCodeEdge
                                        // w2の特定\r
                                        w2 = 0;\r
                                        for (; x >= 0; x--) {\r
-                                               if (line[x] == 0) {\r
+                                               if (raster_buf[line_ptr+x] == 0) {\r
                                                        // 検出条件確認:w2*10/b1は80-120以上欲しいな。\r
                                                        if (!check_w2(b1,w2)) {\r
                                                                //条件不十分→w2→w1として、b1を解析\r
@@ -168,7 +173,7 @@ public class NyARRasterDetector_QrCodeEdge
                                        b2 = 0;\r
                                        b2_spos=x;\r
                                        for (; x >= 0; x--) {\r
-                                               if (line[x] > 0){\r
+                                               if (raster_buf[line_ptr+x] > 0){\r
                                                        //条件:(w1+b1)/2の2~4倍\r
 \r
                                                        if (!check_b2(b1,b2)) {\r
@@ -196,7 +201,7 @@ public class NyARRasterDetector_QrCodeEdge
                                        // w3の特定\r
                                        w3 = 0;\r
                                        for (; x >= 0; x--) {\r
-                                               if (line[x] == 0){\r
+                                               if (raster_buf[line_ptr+x] == 0){\r
                                                        if (!check_w3(w2,w3)) {\r
                                                                //w2→w1,b2->b1として解析しなおす。\r
                                                                if(check_w1(w2) && check_b1(b2)){\r
@@ -223,7 +228,7 @@ public class NyARRasterDetector_QrCodeEdge
                                        b3 = 0;\r
                                        b3_spos=x;\r
                                        for (; x >= 0; x--) {\r
-                                               if (line[x] > 0) {\r
+                                               if (raster_buf[line_ptr+x] > 0) {\r
                                                        // 検出条件確認\r
                                                        if (!check_b3(b3,b1)) {\r
                                                                if(check_w1(w2) && check_b1(b2)){\r