--- /dev/null
+/* \r
+ * PROJECT: NyARToolkit(Extension)\r
+ * --------------------------------------------------------------------------------\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 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
+ * You should have received a copy of the GNU General Public License\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> or <nyatla(at)nyatla.jp>\r
+ * \r
+ */\r
+package jp.nyatla.nyartoolkit.core.analyzer.histgram;\r
+\r
+\r
+import jp.nyatla.nyartoolkit.core.types.*;\r
+\r
+\r
+/**\r
+ * Pタイル法による閾値検出\r
+ * \r
+ */\r
+public class NyARHistgramAnalyzer_PTile\r
+{\r
+ private int _persentage;\r
+ public NyARHistgramAnalyzer_PTile(int i_persentage)\r
+ {\r
+ assert (0 <= i_persentage && i_persentage <= 50);\r
+ //初期化\r
+ this._persentage=i_persentage;\r
+ } \r
+ public int getThreshold(NyARHistgram i_histgram)\r
+ {\r
+ // 閾値ピクセル数確定\r
+ int th_pixcels = i_histgram.total_of_data * this._persentage / 100;\r
+\r
+ // 閾値判定\r
+ int i;\r
+ if (th_pixcels > 0) {\r
+ // 黒点基準\r
+ for (i = 0; i < 254; i++) {\r
+ th_pixcels -= i_histgram.data[i];\r
+ if (th_pixcels <= 0) {\r
+ break;\r
+ }\r
+ }\r
+ } else {\r
+ // 白点基準\r
+ for (i = 255; i > 1; i--) {\r
+ th_pixcels += i_histgram.data[i];\r
+ if (th_pixcels >= 0) {\r
+ break;\r
+ }\r
+ }\r
+ }\r
+ // 閾値の保存\r
+ return i;\r
+ }\r
+}\r
+\r
--- /dev/null
+/* \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 edition ARToolKit class library.\r
+ * Copyright (C)2008-2009 Ryo Iizuka\r
+ *\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
+ * You should have received a copy of the GNU General Public License\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> or <nyatla(at)nyatla.jp>\r
+ * \r
+ */\r
+package jp.nyatla.nyartoolkit.core.rasteranalyzer;\r
+\r
+import jp.nyatla.nyartoolkit.NyARException;\r
+import jp.nyatla.nyartoolkit.core.raster.*;\r
+import jp.nyatla.nyartoolkit.core.types.stack.*;\r
+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
+\r
+ public NyARRasterDetector_QrCodeEdge(int i_result_max)\r
+ {\r
+ this._result = new NyARIntRectStack(i_result_max);\r
+ return;\r
+ }\r
+\r
+ public NyARIntRectStack geResult()\r
+ {\r
+ return this._result;\r
+ }\r
+\r
+ private boolean check_w1(int i_w1)\r
+ {\r
+ return i_w1>=1; \r
+ }\r
+ private boolean check_b1(int i_b1)\r
+ {\r
+ return i_b1 >= 2; \r
+ }\r
+ private boolean check_w2(int i_b1,int i_w2)\r
+ {\r
+ int v=i_w2*100/i_b1;\r
+ return (30<=v && v<=170);\r
+ }\r
+ private boolean check_b2(int i_b1,int i_b2)\r
+ {\r
+ int v=i_b2*100/i_b1;\r
+ //条件:(b1)/2の2~4倍\r
+ return (200<=v && v<=400);\r
+ }\r
+ private boolean check_w3(int i_w2,int i_w3)\r
+ {\r
+ int v=i_w3*100/i_w2;\r
+ return (50<=v && v<=150);\r
+ }\r
+ private boolean check_b3(int i_b3,int i_b1)\r
+ {\r
+ int v=i_b3*100/i_b1;\r
+ return (50<=v && v<=150);\r
+ } \r
+ public void analyzeRaster(INyARRaster i_input) throws NyARException\r
+ {\r
+ INyARBufferReader buffer_reader=i_input.getBufferReader();\r
+ assert (buffer_reader.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8));\r
+\r
+ // 結果をクリア\r
+ this._result.clear();\r
+\r
+ NyARIntSize size = i_input.getSize();\r
+ int x = 0;\r
+ int w1, b1, w2, b2, w3, b3;\r
+ w1 = b1 = w2 = b2 = w3 = b3 = 0;\r
+\r
+ NyARIntRect item;\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_ptr = y*size.w;\r
+ x = size.w - 1;\r
+ s_pos=0;\r
+ int token_id=0;\r
+ while(x>=0){\r
+ switch(token_id){\r
+ case 0:\r
+ // w1の特定\r
+ w1 = 0;\r
+ for (; x >= 0; x--) {\r
+ if (raster_buf[line_ptr+x] == 0) {\r
+ // 検出条件確認:w1は2以上欲しいな。\r
+ if (!check_w1(w1)) {\r
+ // 条件不十分\r
+ continue;\r
+ }else{\r
+ // 検出→次段処理へ\r
+ token_id=1;\r
+ }\r
+ break;\r
+ }\r
+ w1++;\r
+ }\r
+ break;\r
+ case 1:\r
+ // b1の特定\r
+ b1 = 0;\r
+ s_pos = x;\r
+ for (; x >= 0; x--) {\r
+ if (raster_buf[line_ptr+x] > 0) {\r
+ // 検出条件確認:b1は1以上欲しいな。\r
+ if (!check_b1(b1)){\r
+ //条件不十分→白検出からやり直し\r
+ token_id=0;\r
+ }else{\r
+ // 検出→次段処理へ\r
+ token_id=2;\r
+ }\r
+ break;\r
+ }\r
+ b1++;\r
+ }\r
+ break;\r
+ case 2:\r
+ // w2の特定\r
+ w2 = 0;\r
+ for (; x >= 0; x--) {\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
+ w1=w2;\r
+ token_id=1;\r
+ }else{\r
+ // 検出→次段処理へ\r
+// w1=w2;\r
+// token_id=11;\r
+ token_id=3;\r
+ }\r
+ break;\r
+ }\r
+ w2++;\r
+ }\r
+ break;\r
+ case 3:\r
+ // b2の特定\r
+ b2 = 0;\r
+ b2_spos=x;\r
+ for (; x >= 0; x--) {\r
+ if (raster_buf[line_ptr+x] > 0){\r
+ //条件:(w1+b1)/2の2~4倍\r
+\r
+ if (!check_b2(b1,b2)) {\r
+ // b2->b1と仮定して解析しなおす。\r
+ if(check_w1(w2) && check_b1(b2)){\r
+ w1 = w2;\r
+ b1 = b2;\r
+ s_pos=b2_spos;\r
+ token_id=2;\r
+ }else{\r
+ \r
+ token_id=0;\r
+ }\r
+ }else{\r
+ // 検出→次段処理へ\r
+// token_id=10;\r
+ token_id=4;\r
+ }\r
+ break;\r
+ }\r
+ b2++;\r
+ }\r
+ break;\r
+ case 4:\r
+ // w3の特定\r
+ w3 = 0;\r
+ for (; x >= 0; x--) {\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
+ w1 = w2;\r
+ b1 = b2;\r
+ s_pos=b2_spos;\r
+ token_id=2;\r
+ }else{\r
+ token_id=0;\r
+ }\r
+ }else{\r
+ // 検出→次段処理へ\r
+// w1=w3;\r
+// token_id=10;\r
+ token_id=5;\r
+ }\r
+ break;\r
+ }\r
+ w3++;\r
+ }\r
+ break;\r
+ case 5:\r
+ // b3の特定\r
+ b3 = 0;\r
+ b3_spos=x;\r
+ for (; x >= 0; x--) {\r
+ if (raster_buf[line_ptr+x] > 0) {\r
+ // 検出条件確認\r
+ if (!check_b3(b3,b1)) {\r
+ if(check_w1(w2) && check_b1(b2)){\r
+ //条件不十分→b3->b1,w3->w1として再解析\r
+ w1=w3;\r
+ b1=b3;\r
+ s_pos=b3_spos;\r
+ token_id=2;\r
+ }else{\r
+ token_id=0;\r
+ }\r
+ }else{\r
+ // 検出→次段処理へ\r
+ token_id=10;\r
+ }\r
+ break;\r
+ }\r
+ b3++;\r
+ }\r
+ break;\r
+ case 10:\r
+ /* コード特定→保管 */\r
+ item = this._result.prePush();\r
+ item.x = x;\r
+ item.y = y;\r
+ item.w =s_pos-x;\r
+ item.h=0;\r
+ /* 最大個数? */\r
+ /* 次のコードを探す */\r
+ token_id=0;\r
+ break;\r
+ default:\r
+ throw new NyARException();\r
+ }\r
+ }\r
+ }\r
+ return;\r
+ }\r
+}\r
--- /dev/null
+/* \r
+ * PROJECT: NyARToolkit(Extension)\r
+ * --------------------------------------------------------------------------------\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 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
+ * You should have received a copy of the GNU General Public License\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> or <nyatla(at)nyatla.jp>\r
+ * \r
+ */\r
+package jp.nyatla.nyartoolkit.core.rasteranalyzer.threshold;\r
+\r
+import jp.nyatla.nyartoolkit.NyARException;\r
+import jp.nyatla.nyartoolkit.core.analyzer.raster.threshold.INyARRasterThresholdAnalyzer;\r
+import jp.nyatla.nyartoolkit.core.raster.*;\r
+import jp.nyatla.nyartoolkit.core.rasterreader.INyARBufferReader;\r
+import jp.nyatla.nyartoolkit.core.types.*;\r
+\r
+/**\r
+ * 微分ヒストグラム法による閾値検出\r
+ * \r
+ */\r
+public class NyARRasterThresholdAnalyzer_DiffHistgram implements INyARRasterThresholdAnalyzer\r
+{\r
+ private int _threshold;\r
+\r
+ public NyARRasterThresholdAnalyzer_DiffHistgram()\r
+ {\r
+ }\r
+\r
+ private int createHistgram(int[] in_buf,NyARIntSize i_size, int[] o_histgram) throws NyARException\r
+ {\r
+ int[][] fil1={\r
+ {-1,-2,-1},\r
+ { 0, 0, 0},\r
+ { 1, 2, 1}};\r
+\r
+ // ヒストグラムを作成\r
+ for (int i = 0; i < 256; i++) {\r
+ o_histgram[i] = 0;\r
+ }\r
+ int sam;\r
+ int sam1,sam2;\r
+ for (int y = 1; y < i_size.h-1; y++) {\r
+ for (int x = 1; x < i_size.w-1; x++) {\r
+ int v = in_buf[y* i_size.w+x];\r
+ sam1=sam2=0;\r
+ for(int yy=0;yy<3;yy++){\r
+ for(int xx=0;xx<3;xx++){\r
+ int v2=in_buf[(y+yy-1)* i_size.w+(x+xx-1)];\r
+ sam1+=v2*fil1[xx][yy];\r
+ sam2+=v2*fil1[yy][xx];\r
+ } \r
+ }\r
+ sam=sam1*sam1+sam2*sam2;\r
+ o_histgram[v]+=sam;\r
+ }\r
+ }\r
+ int th=0;\r
+ int max=o_histgram[0];\r
+ for(int i=1;i<256;i++){\r
+ if(max<o_histgram[i]){\r
+ th=i;\r
+ max=o_histgram[i];\r
+ }\r
+ }\r
+ return th;\r
+ }\r
+\r
+ public int analyzeRaster(INyARRaster i_input) throws NyARException\r
+ {\r
+ final INyARBufferReader buffer_reader=i_input.getBufferReader(); \r
+ assert (buffer_reader.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8));\r
+ int[] histgram = new int[256];\r
+ return createHistgram((int[])buffer_reader.getBuffer(),i_input.getSize(), histgram);\r
+ }\r
+\r
+ /**\r
+ * デバック用の関数です。 ヒストグラムをラスタに書き出します。\r
+ * \r
+ * @param i_output\r
+ * 書き出し先のラスタオブジェクト 256ピクセル以上の幅があること。\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_GRAY_8));\r
+ assert (out_buffer_reader.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8));\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((int[])in_buffer_reader.getBuffer(),i_input.getSize(), histgram);\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
+ return;\r
+ }\r
+\r
+ public int getThreshold()\r
+ {\r
+ return this._threshold;\r
+ }\r
+}\r
--- /dev/null
+/* \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 edition ARToolKit class library.\r
+ * Copyright (C)2008-2009 Ryo Iizuka\r
+ *\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
+ * You should have received a copy of the GNU General Public License\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> or <nyatla(at)nyatla.jp>\r
+ * \r
+ */\r
+package jp.nyatla.nyartoolkit.core.rasterfilter;\r
+\r
+import jp.nyatla.nyartoolkit.NyARException;\r
+import jp.nyatla.nyartoolkit.core.raster.*;\r
+import jp.nyatla.nyartoolkit.core.rasterfilter.INyARRasterFilter;\r
+import jp.nyatla.nyartoolkit.core.rasterreader.INyARBufferReader;\r
+import jp.nyatla.nyartoolkit.core.types.NyARIntSize;\r
+\r
+/**\r
+ * エッジ検出フィルタ 入力 BUFFERFORMAT_INT2D 出力 BUFFERFORMAT_INT2D\r
+ */\r
+public class NyARRasterFilter_Edge implements INyARRasterFilter\r
+{\r
+ public void doFilter(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_GRAY_8));\r
+ assert (out_buffer_reader.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8));\r
+ assert (i_input.getSize().isEqualSize(i_output.getSize()) == true);\r
+\r
+ int[] out_buf = (int[]) out_buffer_reader.getBuffer();\r
+ int[] in_buf = (int[]) in_buffer_reader.getBuffer();\r
+\r
+ int bp = 0;\r
+ NyARIntSize size = i_output.getSize();\r
+ for (int y = 1; y < size.h; y++) {\r
+ int prev = 128;\r
+ for (int x = 1; x < size.w; x++) {\r
+ int w = in_buf[y* size.w+x];\r
+ out_buf[y* size.w+x] = (Math.abs(w - prev) + Math.abs(w - in_buf[(y - 1)* size.w+x])) / 2;\r
+ prev = w;\r
+ bp += 3;\r
+ }\r
+ }\r
+ return;\r
+ }\r
+}\r
--- /dev/null
+/* \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 edition ARToolKit class library.\r
+ * Copyright (C)2008-2009 Ryo Iizuka\r
+ *\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
+ * You should have received a copy of the GNU General Public License\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> or <nyatla(at)nyatla.jp>\r
+ * \r
+ */\r
+package jp.nyatla.nyartoolkit.core.rasterfilter;\r
+\r
+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.types.NyARIntSize;\r
+\r
+/**\r
+ * 入力Aと入力Bの積を出力します。\r
+ * \r
+ */\r
+public class NyARRasterOperator_Mul\r
+{\r
+ private IdoFilterImpl _dofilterimpl;\r
+ public NyARRasterOperator_Mul(int i_raster_type) throws NyARException\r
+ {\r
+ switch (i_raster_type) {\r
+ case INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8:\r
+ this._dofilterimpl=new IdoFilterImpl_INT1D_GRAY_8();\r
+ break;\r
+ default:\r
+ throw new NyARException();\r
+ }\r
+ }\r
+ //\r
+ public void doFilter(INyARRaster i_input_a,INyARRaster i_input_b, INyARRaster i_output) throws NyARException\r
+ {\r
+ assert (i_input_a.getSize().isEqualSize(i_output.getSize()) == true);\r
+ assert (i_input_b.getSize().isEqualSize(i_output.getSize()) == true);\r
+ this._dofilterimpl.doFilter(i_input_a.getBufferReader(),i_input_b.getBufferReader(),i_output.getBufferReader(),i_output.getSize());\r
+ }\r
+ \r
+ abstract class IdoFilterImpl\r
+ {\r
+ int[] _window_ref;\r
+ public abstract void doFilter(INyARBufferReader i_input_a,INyARBufferReader i_input_b,INyARBufferReader i_output,NyARIntSize i_size) throws NyARException;\r
+ \r
+ }\r
+ class IdoFilterImpl_INT1D_GRAY_8 extends IdoFilterImpl\r
+ {\r
+ public void doFilter(INyARBufferReader i_input_a,INyARBufferReader i_input_b,INyARBufferReader i_output,NyARIntSize i_size) throws NyARException\r
+ {\r
+ int[] out_buf = (int[]) i_output.getBuffer();\r
+ int[] in_buf1 = (int[]) i_input_a.getBuffer();\r
+ int[] in_buf2 = (int[]) i_input_b.getBuffer();\r
+ for(int i=i_size.h*i_size.w-1;i>=0;i--)\r
+ {\r
+ out_buf[i]=(in_buf1[i]*in_buf2[i])>>8;\r
+ }\r
+ return;\r
+ }\r
+ } \r
+}
\ No newline at end of file
--- /dev/null
+package jp.nyatla.nyartoolkit.core.rasterfilter.rgb2gs;\r
+\r
+import jp.nyatla.nyartoolkit.NyARException;\r
+import jp.nyatla.nyartoolkit.core.raster.NyARGrayscaleRaster;\r
+import jp.nyatla.nyartoolkit.core.raster.rgb.INyARRgbRaster;\r
+import jp.nyatla.nyartoolkit.core.rasterreader.INyARBufferReader;\r
+import jp.nyatla.nyartoolkit.core.types.NyARIntSize;\r
+\r
+/**\r
+ * YCbCr変換したY成分を、RGBカラーベクトルの差が少いほど強度が落ちるようにしてグレースケールに変換します。\r
+ * sには減衰度数を設定します。\r
+ * 強度計算は以下のように行います。\r
+ * f(x):=exp(-x^2/s^2) 窓関数\r
+ * p :=Y*f(cr)*f(cb)\r
+ */\r
+public class NyARRasterFilter_Rgb2Gs_CbCrCut implements INyARRasterFilter_RgbToGs\r
+{\r
+ private IdoFilterImpl _dofilterimpl;\r
+ /**\r
+ * 1024倍した値\r
+ */\r
+ private int _window[]=new int[256];\r
+ public NyARRasterFilter_Rgb2Gs_CbCrCut(int i_raster_type,double i_sigma) throws NyARException\r
+ {\r
+ switch (i_raster_type) {\r
+ case INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8_24:\r
+ this._dofilterimpl=new IdoFilterImpl_BYTE1D_B8G8R8_24();\r
+ break;\r
+ case INyARBufferReader.BUFFERFORMAT_BYTE1D_R8G8B8_24:\r
+ default:\r
+ throw new NyARException();\r
+ }\r
+ this._dofilterimpl._window_ref=this._window;\r
+ //windowの作成\r
+ for(int i=0;i<256;i++){\r
+ double p=((double)i-127.0)/127.0;\r
+ this._window[i]=(int)(1024*Math.exp(-p*p/(i_sigma*i_sigma)));\r
+ }\r
+ }\r
+ public void doFilter(INyARRgbRaster i_input, NyARGrayscaleRaster i_output) throws NyARException\r
+ {\r
+ assert (i_input.getSize().isEqualSize(i_output.getSize()) == true);\r
+ this._dofilterimpl.doFilter(i_input.getBufferReader(),i_output.getBufferReader(),i_input.getSize());\r
+ }\r
+ \r
+ abstract class IdoFilterImpl\r
+ {\r
+ int[] _window_ref;\r
+ public abstract void doFilter(INyARBufferReader i_input, INyARBufferReader i_output,NyARIntSize i_size) throws NyARException;\r
+ \r
+ }\r
+ class IdoFilterImpl_BYTE1D_B8G8R8_24 extends IdoFilterImpl\r
+ {\r
+ public void doFilter(INyARBufferReader i_input, INyARBufferReader i_output,NyARIntSize i_size) throws NyARException\r
+ {\r
+ assert( i_input.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8_24));\r
+ \r
+ int[] out_buf = (int[]) i_output.getBuffer();\r
+ byte[] in_buf = (byte[]) i_input.getBuffer();\r
+ \r
+ int r,g,b;\r
+ int[] win=this._window_ref;\r
+\r
+ int bp = 0;\r
+ for (int y = 0; y < i_size.h; y++){\r
+ for (int x = 0; x < i_size.w; x++){\r
+ b=(in_buf[bp] & 0xff);\r
+ g=(in_buf[bp + 1] & 0xff);\r
+ r=(in_buf[bp + 2] & 0xff);\r
+ bp += 3;\r
+ int yv=(306*r+601*g+117 * b)>>10;//0<yv<255\r
+ int cr=(((-173 * r-339 * g + 512 *b))>>10)+127;//-127.5<=0<=127.5\r
+ int cb=((( 512 * r-429 * g - 83 *b))>>10)+127;//-127.5<=0<=127.5\r
+ out_buf[y*i_size.w+x]=(yv*(int)win[cr]*win[cb])>>20;\r
+ }\r
+ }\r
+ return;\r
+ }\r
+ } \r
+}
\ No newline at end of file
--- /dev/null
+/* \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 edition ARToolKit class library.\r
+ * Copyright (C)2008-2009 Ryo Iizuka\r
+ *\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
+ * You should have received a copy of the GNU General Public License\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> or <nyatla(at)nyatla.jp>\r
+ * \r
+ */\r
+package jp.nyatla.nyartoolkit.core.rasterfilter.rgb2gs;\r
+\r
+import jp.nyatla.nyartoolkit.NyARException;\r
+import jp.nyatla.nyartoolkit.core.raster.*;\r
+import jp.nyatla.nyartoolkit.core.raster.rgb.INyARRgbRaster;\r
+import jp.nyatla.nyartoolkit.core.rasterfilter.rgb2gs.INyARRasterFilter_RgbToGs;\r
+import jp.nyatla.nyartoolkit.core.rasterreader.INyARBufferReader;\r
+import jp.nyatla.nyartoolkit.core.types.NyARIntSize;\r
+\r
+public class NyARRasterFilter_Rgb2Gs_RgbOr implements INyARRasterFilter_RgbToGs\r
+{\r
+ public void doFilter(INyARRgbRaster i_input, NyARGrayscaleRaster i_output) throws NyARException\r
+ {\r
+ INyARBufferReader in_buffer_reader=i_input.getBufferReader(); \r
+ INyARBufferReader out_buffer_reader=i_output.getBufferReader(); \r
+ assert (i_input.getSize().isEqualSize(i_output.getSize()) == true);\r
+\r
+ final int[] out_buf = (int[]) out_buffer_reader.getBuffer();\r
+ final byte[] in_buf = (byte[]) in_buffer_reader.getBuffer();\r
+\r
+ NyARIntSize size = i_output.getSize();\r
+ switch (in_buffer_reader.getBufferType()) {\r
+ case INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8_24:\r
+ case INyARBufferReader.BUFFERFORMAT_BYTE1D_R8G8B8_24:\r
+ convert24BitRgb(in_buf, out_buf, size);\r
+ break;\r
+ default:\r
+ throw new NyARException();\r
+ }\r
+ return;\r
+ }\r
+\r
+ private void convert24BitRgb(byte[] i_in, int[] i_out, NyARIntSize i_size)\r
+ {\r
+ int bp = 0;\r
+ for (int y = 0; y < i_size.h; y++) {\r
+ for (int x = 0; x < i_size.w; x++) {\r
+ i_out[y*i_size.w+x] = ((i_in[bp] & 0xff) | (i_in[bp + 1] & 0xff) | (i_in[bp + 2] & 0xff));\r
+ bp += 3;\r
+ }\r
+ }\r
+ return;\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+/* \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 edition ARToolKit class library.\r
+ * Copyright (C)2008-2009 Ryo Iizuka\r
+ *\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
+ * You should have received a copy of the GNU General Public License\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> or <nyatla(at)nyatla.jp>\r
+ * \r
+ */\r
+\r
+package jp.nyatla.nyartoolkit.core.types;\r
+\r
+import jp.nyatla.nyartoolkit.core.types.NyARFixedFloat16Point2d;\r
+import jp.nyatla.nyartoolkit.core.types.NyARI64Point2d;\r
+\r
+public class NyARFixedFloat16Point2d extends NyARI64Point2d\r
+{\r
+ public static NyARFixedFloat16Point2d[] createArray(int i_number)\r
+ {\r
+ NyARFixedFloat16Point2d[] ret=new NyARFixedFloat16Point2d[i_number];\r
+ for(int i=0;i<i_number;i++)\r
+ {\r
+ ret[i]=new NyARFixedFloat16Point2d();\r
+ }\r
+ return ret;\r
+ }\r
+}\r
--- /dev/null
+/* \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 edition ARToolKit class library.\r
+ * Copyright (C)2008-2009 Ryo Iizuka\r
+ *\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
+ * You should have received a copy of the GNU General Public License\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> or <nyatla(at)nyatla.jp>\r
+ * \r
+ */\r
+package jp.nyatla.nyartoolkit.core.types;\r
+\r
+import jp.nyatla.nyartoolkit.core.types.*;\r
+import jp.nyatla.nyartoolkit.core.types.NyARFixedFloat16Point3d;\r
+import jp.nyatla.nyartoolkit.core.types.NyARI64Point3d;\r
+\r
+public class NyARFixedFloat16Point3d extends NyARI64Point3d\r
+{\r
+ /**\r
+ * 配列ファクトリ\r
+ * @param i_number\r
+ * @return\r
+ */\r
+ public static NyARFixedFloat16Point3d[] createArray(int i_number)\r
+ {\r
+ NyARFixedFloat16Point3d[] ret=new NyARFixedFloat16Point3d[i_number];\r
+ for(int i=0;i<i_number;i++)\r
+ {\r
+ ret[i]=new NyARFixedFloat16Point3d();\r
+ }\r
+ return ret;\r
+ }\r
+ public void copyTo(NyARDoublePoint3d i_to)\r
+ {\r
+ i_to.x=(double)this.x/0x10000;\r
+ i_to.y=(double)this.y/0x10000;\r
+ i_to.z=(double)this.z/0x10000;\r
+ return;\r
+ }\r
+ public void copyFrom(NyARDoublePoint3d i_from)\r
+ {\r
+ this.x=(long)(i_from.x*0x10000);\r
+ this.y=(long)(i_from.y*0x10000);\r
+ this.z=(long)(i_from.z*0x10000);\r
+ return;\r
+ }\r
+\r
+}\r
--- /dev/null
+/* \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 edition ARToolKit class library.\r
+ * Copyright (C)2008-2009 Ryo Iizuka\r
+ *\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
+ * You should have received a copy of the GNU General Public License\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> or <nyatla(at)nyatla.jp>\r
+ * \r
+ */\r
+package jp.nyatla.nyartoolkit.core.types;\r
+\r
+import jp.nyatla.nyartoolkit.core.types.NyARI64Linear;\r
+\r
+public class NyARI64Linear\r
+{\r
+ public long rise;//y軸の増加量\r
+ public long run;//x軸の増加量\r
+ public long intercept;//切片\r
+ public final void copyFrom(NyARI64Linear i_source)\r
+ {\r
+ this.rise=i_source.rise;\r
+ this.run=i_source.run;\r
+ this.intercept=i_source.intercept;\r
+ return;\r
+ }\r
+ public static NyARI64Linear[] createArray(int i_number)\r
+ {\r
+ NyARI64Linear[] ret=new NyARI64Linear[i_number];\r
+ for(int i=0;i<i_number;i++)\r
+ {\r
+ ret[i]=new NyARI64Linear();\r
+ }\r
+ return ret;\r
+ }\r
+}\r
--- /dev/null
+/* \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 edition ARToolKit class library.\r
+ * Copyright (C)2008-2009 Ryo Iizuka\r
+ *\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
+ * You should have received a copy of the GNU General Public License\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> or <nyatla(at)nyatla.jp>\r
+ * \r
+ */\r
+package jp.nyatla.nyartoolkit.core.types;\r
+\r
+import jp.nyatla.nyartoolkit.core.types.NyARI64Point2d;\r
+\r
+public class NyARI64Point2d\r
+{\r
+ public long x;\r
+\r
+ public long y;\r
+ /**\r
+ * 配列ファクトリ\r
+ * @param i_number\r
+ * @return\r
+ */\r
+ public static NyARI64Point2d[] createArray(int i_number)\r
+ {\r
+ NyARI64Point2d[] ret=new NyARI64Point2d[i_number];\r
+ for(int i=0;i<i_number;i++)\r
+ {\r
+ ret[i]=new NyARI64Point2d();\r
+ }\r
+ return ret;\r
+ }\r
+}\r
--- /dev/null
+/* \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 edition ARToolKit class library.\r
+ * Copyright (C)2008-2009 Ryo Iizuka\r
+ *\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
+ * You should have received a copy of the GNU General Public License\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> or <nyatla(at)nyatla.jp>\r
+ * \r
+ */\r
+package jp.nyatla.nyartoolkit.core.types;\r
+\r
+import jp.nyatla.nyartoolkit.core.types.NyARI64Point3d;\r
+\r
+public class NyARI64Point3d\r
+{\r
+ public long x;\r
+ public long y;\r
+ public long z;\r
+ /**\r
+ * 配列ファクトリ\r
+ * @param i_number\r
+ * @return\r
+ */\r
+ public static NyARI64Point3d[] createArray(int i_number)\r
+ {\r
+ NyARI64Point3d[] ret=new NyARI64Point3d[i_number];\r
+ for(int i=0;i<i_number;i++)\r
+ {\r
+ ret[i]=new NyARI64Point3d();\r
+ }\r
+ return ret;\r
+ }\r
+}\r
--- /dev/null
+/* \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 edition ARToolKit class library.\r
+ * Copyright (C)2008-2009 Ryo Iizuka\r
+ *\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
+ * You should have received a copy of the GNU General Public License\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> or <nyatla(at)nyatla.jp>\r
+ * \r
+ */\r
+package jp.nyatla.nyartoolkit.core.types.matrix;\r
+\r
+import jp.nyatla.nyartoolkit.core.types.matrix.NyARDoubleMatrix33;\r
+import jp.nyatla.nyartoolkit.core.types.matrix.NyARFixedFloat16Matrix33;\r
+import jp.nyatla.nyartoolkit.core.types.matrix.NyARI64Matrix33;\r
+\r
+\r
+public class NyARFixedFloat16Matrix33 extends NyARI64Matrix33\r
+{\r
+ public void copyFrom(NyARDoubleMatrix33 i_matrix)\r
+ {\r
+ this.m00=(long)i_matrix.m00*0x10000;\r
+ this.m01=(long)i_matrix.m01*0x10000;\r
+ this.m02=(long)i_matrix.m02*0x10000;\r
+ this.m10=(long)i_matrix.m10*0x10000;\r
+ this.m11=(long)i_matrix.m11*0x10000;\r
+ this.m12=(long)i_matrix.m12*0x10000;\r
+ this.m20=(long)i_matrix.m20*0x10000;\r
+ this.m21=(long)i_matrix.m21*0x10000;\r
+ this.m22=(long)i_matrix.m22*0x10000;\r
+ return;\r
+ }\r
+ public static NyARFixedFloat16Matrix33[] createArray(int i_number)\r
+ {\r
+ NyARFixedFloat16Matrix33[] ret=new NyARFixedFloat16Matrix33[i_number];\r
+ for(int i=0;i<i_number;i++)\r
+ {\r
+ ret[i]=new NyARFixedFloat16Matrix33();\r
+ }\r
+ return ret;\r
+ }\r
+}\r
--- /dev/null
+/* \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 edition ARToolKit class library.\r
+ * Copyright (C)2008-2009 Ryo Iizuka\r
+ *\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
+ * You should have received a copy of the GNU General Public License\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> or <nyatla(at)nyatla.jp>\r
+ * \r
+ */\r
+package jp.nyatla.nyartoolkit.core.types.matrix;\r
+\r
+import jp.nyatla.nyartoolkit.core.types.matrix.*;\r
+import jp.nyatla.nyartoolkit.core.types.matrix.NyARFixedFloat24Matrix33;\r
+import jp.nyatla.nyartoolkit.core.types.matrix.NyARI64Matrix33;\r
+\r
+\r
+public class NyARFixedFloat24Matrix33 extends NyARI64Matrix33\r
+{\r
+ public void copyFrom(NyARDoubleMatrix33 i_matrix)\r
+ {\r
+ this.m00=(long)i_matrix.m00*0x1000000;\r
+ this.m01=(long)i_matrix.m01*0x1000000;\r
+ this.m02=(long)i_matrix.m02*0x1000000;\r
+ this.m10=(long)i_matrix.m10*0x1000000;\r
+ this.m11=(long)i_matrix.m11*0x1000000;\r
+ this.m12=(long)i_matrix.m12*0x1000000;\r
+ this.m20=(long)i_matrix.m20*0x1000000;\r
+ this.m21=(long)i_matrix.m21*0x1000000;\r
+ this.m22=(long)i_matrix.m22*0x1000000;\r
+ return;\r
+ }\r
+ public void copyTo(NyARDoubleMatrix33 i_to)\r
+ {\r
+ i_to.m00=(double)this.m00/0x1000000;\r
+ i_to.m01=(double)this.m01/0x1000000;\r
+ i_to.m02=(double)this.m02/0x1000000;\r
+ i_to.m10=(double)this.m10/0x1000000;\r
+ i_to.m11=(double)this.m11/0x1000000;\r
+ i_to.m12=(double)this.m12/0x1000000;\r
+ i_to.m20=(double)this.m20/0x1000000;\r
+ i_to.m21=(double)this.m21/0x1000000;\r
+ i_to.m22=(double)this.m22/0x1000000;\r
+ return;\r
+ }\r
+ \r
+ public static NyARFixedFloat24Matrix33[] createArray(int i_number)\r
+ {\r
+ NyARFixedFloat24Matrix33[] ret=new NyARFixedFloat24Matrix33[i_number];\r
+ for(int i=0;i<i_number;i++)\r
+ {\r
+ ret[i]=new NyARFixedFloat24Matrix33();\r
+ }\r
+ return ret;\r
+ }\r
+\r
+}\r
--- /dev/null
+/* \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 edition ARToolKit class library.\r
+ * Copyright (C)2008-2009 Ryo Iizuka\r
+ *\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
+ * You should have received a copy of the GNU General Public License\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> or <nyatla(at)nyatla.jp>\r
+ * \r
+ */\r
+package jp.nyatla.nyartoolkit.core.types.matrix;\r
+\r
+public class NyARI64Matrix22\r
+{\r
+ public long m00;\r
+ public long m01;\r
+ public long m10;\r
+ public long m11;\r
+}\r
--- /dev/null
+/* \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 edition ARToolKit class library.\r
+ * Copyright (C)2008-2009 Ryo Iizuka\r
+ *\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
+ * You should have received a copy of the GNU General Public License\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> or <nyatla(at)nyatla.jp>\r
+ * \r
+ */\r
+package jp.nyatla.nyartoolkit.core.types.matrix;\r
+\r
+import jp.nyatla.nyartoolkit.core.types.matrix.NyARI64Matrix33;\r
+\r
+\r
+public class NyARI64Matrix33\r
+{\r
+ public long m00;\r
+ public long m01;\r
+ public long m02;\r
+ public long m10;\r
+ public long m11;\r
+ public long m12;\r
+ public long m20;\r
+ public long m21;\r
+ public long m22;\r
+ public static NyARI64Matrix33[] createArray(int i_number)\r
+ {\r
+ NyARI64Matrix33[] ret=new NyARI64Matrix33[i_number];\r
+ for(int i=0;i<i_number;i++)\r
+ {\r
+ ret[i]=new NyARI64Matrix33();\r
+ }\r
+ return ret;\r
+ }\r
+}\r
for (int i = 0; i < 4; i++) {\r
final NyARLinear l_line_i = l_line[i];\r
final NyARLinear l_line_2 = l_line[(i + 3) % 4];\r
- final double w1 = l_line_2.run * l_line_i.rise - l_line_i.run * l_line_2.rise;\r
+ final double w1 = l_line_2.dy * l_line_i.dx - l_line_i.dy * l_line_2.dx;\r
if (w1 == 0.0) {\r
return;\r
}\r
- l_sqvertex[i].x = (l_line_2.rise * l_line_i.intercept - l_line_i.rise * l_line_2.intercept) / w1;\r
- l_sqvertex[i].y = (l_line_i.run * l_line_2.intercept - l_line_2.run * l_line_i.intercept) / w1;\r
+ l_sqvertex[i].x = (l_line_2.dx * l_line_i.c - l_line_i.dx * l_line_2.c) / w1;\r
+ l_sqvertex[i].y = (l_line_i.dy * l_line_2.c - l_line_2.dy * l_line_i.c) / w1;\r
_distfactor.ideal2Observ(l_sqvertex[i], ideal_vertex);\r
//Ideal→observに変換して、画面上の座標とする。\r
imvertex_ptr[i].x=(int)l_sqvertex[i].x;\r
import jp.nyatla.nyartoolkit.core.param.NyARParam;\r
import jp.nyatla.nyartoolkit.core.raster.rgb.*;\r
import jp.nyatla.nyartoolkit.core.rasterfilter.*;\r
+import jp.nyatla.nyartoolkit.core.rasterfilter.rgb2gs.INyARRasterFilter_RgbToGs;\r
import jp.nyatla.nyartoolkit.core.raster.*;\r
import jp.nyatla.nyartoolkit.core.squaredetect.INyARSquareDetector;\r
import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquare;\r
import java.awt.*;
+import jp.nyatla.nyartoolkit.core.analyzer.raster.threshold.INyARRasterThresholdAnalyzer;
import jp.nyatla.nyartoolkit.core.labeling.artoolkit.NyARLabelingImage;
import jp.nyatla.nyartoolkit.core.labeling.artoolkit.NyARLabeling_ARToolKit;
import jp.nyatla.nyartoolkit.core.param.*;
import jp.nyatla.nyartoolkit.core.raster.*;
+import jp.nyatla.nyartoolkit.core.rasteranalyzer.threshold.NyARRasterThresholdAnalyzer_DiffHistgram;
import jp.nyatla.nyartoolkit.core.rasterfilter.*;
+import jp.nyatla.nyartoolkit.core.rasterfilter.rgb2gs.INyARRasterFilter_RgbToGs;
import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquare;
import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquareStack;
import jp.nyatla.nyartoolkit.core2.rasterfilter.rgb2gs.*;
import jp.nyatla.nyartoolkit.core.raster.rgb.INyARRgbRaster;\r
import jp.nyatla.nyartoolkit.core.rasterreader.INyARBufferReader;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
-import jp.nyatla.nyartoolkit.core.rasterfilter.rgb2bin.*;\r
+import jp.nyatla.nyartoolkit.core.rasterfilter.gs2bin.*;\r
\r
/**\r
* 1/4のサイズの画像に変換しながら閾値判定する関数\r
* \r
*/\r
-public class NyARRasterFilter_ARTTh_Quad implements INyARRasterFilter_RgbToBin\r
+public class NyARRasterFilter_ARTTh_Quad implements INyARRasterFilter_Bin\r
{\r
private int _threshold;\r
\r
\r
import jp.nyatla.nyartoolkit.*;\r
import jp.nyatla.nyartoolkit.core.param.*;\r
-import jp.nyatla.nyartoolkit.core2.types.NyARFixedFloat16Point2d;\r
-import jp.nyatla.nyartoolkit.core2.types.NyARFixedFloat16Point3d;\r
+import jp.nyatla.nyartoolkit.core.types.NyARFixedFloat16Point2d;\r
+import jp.nyatla.nyartoolkit.core.types.NyARFixedFloat16Point3d;\r
import jp.nyatla.nyartoolkit.core.*;\r
\r
class NyARCustomMatrix extends NyARMat\r
\r
import jp.nyatla.nyartoolkit.core.param.*;\r
import jp.nyatla.nyartoolkit.core.types.NyARDoublePoint2d;\r
-import jp.nyatla.nyartoolkit.core2.types.NyARFixedFloat16Point2d;\r
+import jp.nyatla.nyartoolkit.core.types.NyARFixedFloat16Point2d;\r
\r
public class NyARFixedFloatIdeal2Observ\r
{\r
import jp.nyatla.nyartoolkit.core.types.*;\r
import jp.nyatla.nyartoolkit.core.types.matrix.*;\r
import jp.nyatla.nyartoolkit.core.pca2d.*;\r
-import jp.nyatla.nyartoolkit.core2.types.NyARI64Point2d;\r
-import jp.nyatla.nyartoolkit.core2.types.matrix.NyARI64Matrix22;\r
/**\r
* 64bit(小数部16bit)の固定小数点を利用したPCA関数\r
*\r
import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.transmat.NyARTransMatResult;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
+import jp.nyatla.nyartoolkit.core.types.matrix.NyARFixedFloat24Matrix33;\r
import jp.nyatla.nyartoolkit.core.param.*;\r
-import jp.nyatla.nyartoolkit.core2.types.*;\r
-import jp.nyatla.nyartoolkit.core2.types.matrix.NyARFixedFloat24Matrix33;\r
+import jp.nyatla.nyartoolkit.core.types.NyARFixedFloat16Point2d;\r
+import jp.nyatla.nyartoolkit.core.types.NyARFixedFloat16Point3d;\r
\r
\r
\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.param.*;\r
-import jp.nyatla.nyartoolkit.core2.types.NyARFixedFloat16Point2d;\r
-import jp.nyatla.nyartoolkit.core2.types.NyARFixedFloat16Point3d;\r
+import jp.nyatla.nyartoolkit.core.types.NyARFixedFloat16Point2d;\r
+import jp.nyatla.nyartoolkit.core.types.NyARFixedFloat16Point3d;\r
\r
/**\r
* 基本姿勢と実画像を一致するように、角度を微調整→平行移動量を再計算\r
import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.NyARMat;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
+import jp.nyatla.nyartoolkit.core.types.matrix.*;\r
import jp.nyatla.nyartoolkit.core.param.*;\r
-import jp.nyatla.nyartoolkit.core2.types.matrix.*;\r
-import jp.nyatla.nyartoolkit.core2.types.*;\r
+import jp.nyatla.nyartoolkit.core.types.matrix.NyARFixedFloat16Matrix33;\r
+import jp.nyatla.nyartoolkit.core.types.NyARFixedFloat16Point2d;\r
\r
public class NyARFixedFloatRotVector\r
{\r
{\r
//1行目\r
NyARPerspectiveProjectionMatrix cmat = this._projection_mat_ref;\r
- final double w1 = i_linear1.run * i_linear2.rise - i_linear2.run * i_linear1.rise;\r
- final double w2 = i_linear1.rise * i_linear2.intercept - i_linear2.rise * i_linear1.intercept;\r
- final double w3 = i_linear1.intercept * i_linear2.run - i_linear2.intercept * i_linear1.run;\r
+ final double w1 = i_linear1.dy * i_linear2.dx - i_linear2.dy * i_linear1.dx;\r
+ final double w2 = i_linear1.dx * i_linear2.c - i_linear2.dx * i_linear1.c;\r
+ final double w3 = i_linear1.c * i_linear2.dy - i_linear2.c * i_linear1.dy;\r
\r
final double m0 = w1 * (cmat.m01 * cmat.m12 - cmat.m02 * cmat.m11) + w2 * cmat.m11 - w3 * cmat.m01;//w1 * (cpara[0 * 4 + 1] * cpara[1 * 4 + 2] - cpara[0 * 4 + 2] * cpara[1 * 4 + 1]) + w2 * cpara[1 * 4 + 1] - w3 * cpara[0 * 4 + 1];\r
final double m1 = -w1 * cmat.m00 * cmat.m12 + w3 * cmat.m00;//-w1 * cpara[0 * 4 + 0] * cpara[1 * 4 + 2] + w3 * cpara[0 * 4 + 0];\r
*/\r
package jp.nyatla.nyartoolkit.sandbox.x2;\r
\r
-import jp.nyatla.nyartoolkit.core2.types.*;\r
+import jp.nyatla.nyartoolkit.core.types.*;\r
+import jp.nyatla.nyartoolkit.core.types.NyARFixedFloat16Point2d;\r
+import jp.nyatla.nyartoolkit.core.types.NyARFixedFloat16Point3d;\r
\r
\r
final public class NyARFixedFloatTransOffset\r
import jp.nyatla.nyartoolkit.core.raster.*;\r
import jp.nyatla.nyartoolkit.core.transmat.*;\r
import jp.nyatla.nyartoolkit.core.types.NyARIntSize;\r
+import jp.nyatla.nyartoolkit.core.rasterfilter.gs2bin.*;\r
+import jp.nyatla.nyartoolkit.core.rasterfilter.rgb2bin.NyARRasterFilterBuilder_RgbToBin;\r
import jp.nyatla.nyartoolkit.core.rasterfilter.rgb2bin.NyARRasterFilter_ARToolkitThreshold;\r
import jp.nyatla.nyartoolkit.core.squaredetect.INyARSquareDetector;\r
import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquare;\r
this._bin_raster=new NyARBinRaster(scr_size.w,scr_size.h);\r
//差分データインスタンスの作成\r
this._deviation_data=new NyARMatchPattDeviationColorData(cw,ch);\r
- this._tobin_filter=new NyARRasterFilter_ARToolkitThreshold(100,i_raster_type);\r
+ this._tobin_filter=new NyARRasterFilterBuilder_RgbToBin(100,i_raster_type);\r
return;\r
}\r
\r
import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquare;\r
import jp.nyatla.nyartoolkit.core.transmat.*;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
-import jp.nyatla.nyartoolkit.core2.types.*;\r
+import jp.nyatla.nyartoolkit.core.types.NyARFixedFloat16Point2d;\r
+import jp.nyatla.nyartoolkit.core.types.NyARFixedFloat16Point3d;\r
\r
\r
/**\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.*;\r
+import jp.nyatla.nyartoolkit.core.analyzer.threshold.NyARRasterThresholdAnalyzerBuilder_Threshold;\r
import jp.nyatla.nyartoolkit.core.match.*;\r
import jp.nyatla.nyartoolkit.core.param.*;\r
import jp.nyatla.nyartoolkit.core.pickup.*;\r
import jp.nyatla.nyartoolkit.core.raster.*;\r
import jp.nyatla.nyartoolkit.core.raster.rgb.*;\r
import jp.nyatla.nyartoolkit.core.transmat.*;\r
-import jp.nyatla.nyartoolkit.core.rasterfilter.rgb2bin.*;\r
+import jp.nyatla.nyartoolkit.core.rasterfilter.gs2bin.*;\r
+import jp.nyatla.nyartoolkit.core.rasterfilter.rgb2bin.NyARRasterFilterBuilder_RgbToBin;\r
+import jp.nyatla.nyartoolkit.core.rasterfilter.rgb2bin.NyARRasterFilter_ARToolkitThreshold;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
import jp.nyatla.nyartoolkit.core.squaredetect.*;\r
-import jp.nyatla.nyartoolkit.core2.rasteranalyzer.threshold.NyARRasterThresholdAnalyzer_SlidePTile;\r
\r
/**\r
* このクラスは、同時に1個のマーカを処理することのできる、アプリケーションプロセッサです。\r
protected int _current_arcode_index = -1;\r
\r
private NyARMatchPattDeviationColorData _deviation_data;\r
- private NyARRasterThresholdAnalyzer_SlidePTile _threshold_detect;\r
+ private NyARRasterThresholdAnalyzerBuilder_Threshold _threshold_detect;\r
\r
protected SingleARMarkerProcesser_X2()\r
{\r
\r
// 2値画像バッファを作る\r
this._bin_raster = new NyARBinRaster(scr_size.w, scr_size.h);\r
- this._threshold_detect=new NyARRasterThresholdAnalyzer_SlidePTile(15,i_raster_type,4);\r
+ this._threshold_detect=new NyARRasterThresholdAnalyzerBuilder_Threshold(15,i_raster_type,4);\r
return;\r
}\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.param.NyARCameraDistortionFactor;\r
import jp.nyatla.nyartoolkit.core.types.NyARDoublePoint2d;\r
+import jp.nyatla.nyartoolkit.core.types.NyARI64Linear;\r
+import jp.nyatla.nyartoolkit.core.types.NyARI64Point2d;\r
import jp.nyatla.nyartoolkit.core.types.NyARIntPoint2d;\r
import jp.nyatla.nyartoolkit.core.types.NyARIntSize;\r
import jp.nyatla.nyartoolkit.core.types.NyARLinear;\r
+import jp.nyatla.nyartoolkit.core.types.matrix.NyARI64Matrix22;\r
import jp.nyatla.nyartoolkit.core.squaredetect.*;\r
-import jp.nyatla.nyartoolkit.core2.types.NyARI64Linear;\r
-import jp.nyatla.nyartoolkit.core2.types.NyARI64Point2d;\r
-import jp.nyatla.nyartoolkit.core2.types.matrix.NyARI64Matrix22;\r
\r
public class SquareContourDetector_X2\r
{\r
// 頂点インデクスから頂点座標を得て保存\r
l_imvertex[i].x = i_xcoord[i_mkvertex[i]];\r
l_imvertex[i].y = i_ycoord[i_mkvertex[i]];\r
- l_line[i].run=(double)l_line_i.run/65536.0;\r
- l_line[i].rise=(double)l_line_i.rise/65536.0;\r
- l_line[i].intercept=(double)l_line_i.intercept/65536.0;\r
+ l_line[i].dy=(double)l_line_i.run/65536.0;\r
+ l_line[i].dx=(double)l_line_i.rise/65536.0;\r
+ l_line[i].c=(double)l_line_i.intercept/65536.0;\r
}\r
return true;\r
} \r
import java.awt.*;
+import jp.nyatla.nyartoolkit.core.analyzer.raster.threshold.INyARRasterThresholdAnalyzer;
import jp.nyatla.nyartoolkit.core.labeling.*;
import jp.nyatla.nyartoolkit.core.labeling.artoolkit.NyARLabelingImage;
import jp.nyatla.nyartoolkit.core.labeling.artoolkit.NyARLabeling_ARToolKit;
import jp.nyatla.nyartoolkit.core.param.*;
import jp.nyatla.nyartoolkit.core.raster.*;
+import jp.nyatla.nyartoolkit.core.rasteranalyzer.threshold.NyARRasterThresholdAnalyzer_DiffHistgram;
import jp.nyatla.nyartoolkit.core.rasterfilter.*;
+import jp.nyatla.nyartoolkit.core.rasterfilter.rgb2gs.INyARRasterFilter_RgbToGs;
import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquareStack;
import jp.nyatla.nyartoolkit.core2.rasterfilter.rgb2gs.*;
import jp.nyatla.nyartoolkit.core2.rasterfilter.gs2bin.*;