From b6c89312e4aca98191ae453c129c8a0c3f319d6f Mon Sep 17 00:00:00 2001 From: nyatla Date: Sun, 6 Dec 2009 16:27:32 +0000 Subject: [PATCH] =?utf8?q?[backup]NyARToolkitCS/2.4.2=202.4.1=E3=81=AE?= =?utf8?q?=E3=83=90=E3=82=B0=E3=83=95=E3=82=A3=E3=82=AF=E3=82=B9,jp.nyatla?= =?utf8?q?.utils=E3=81=AE=E5=89=8A=E9=99=A4=E3=81=A8=E3=80=81NyObjectStack?= =?utf8?q?=E3=81=AE=E7=A7=BB=E5=8B=95=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/jp/nyatla/utils/DoubleValue.java | 30 --- src/jp/nyatla/utils/IntValue.java | 30 --- src/jp/nyatla/utils/NyObjectStack.java | 187 --------------- src/jp/nyatla/utils/j2se/LabelingBufferdImage.java | 251 --------------------- src/jp/nyatla/utils/j2se/NyARRasterImageIO.java | 179 --------------- 5 files changed, 677 deletions(-) delete mode 100644 src/jp/nyatla/utils/DoubleValue.java delete mode 100644 src/jp/nyatla/utils/IntValue.java delete mode 100644 src/jp/nyatla/utils/NyObjectStack.java delete mode 100644 src/jp/nyatla/utils/j2se/LabelingBufferdImage.java delete mode 100644 src/jp/nyatla/utils/j2se/NyARRasterImageIO.java diff --git a/src/jp/nyatla/utils/DoubleValue.java b/src/jp/nyatla/utils/DoubleValue.java deleted file mode 100644 index acdc793..0000000 --- a/src/jp/nyatla/utils/DoubleValue.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * PROJECT: NyARToolkit - * -------------------------------------------------------------------------------- - * The NyARToolkit is Java edition ARToolKit class library. - * Copyright (C)2008-2009 Ryo Iizuka - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * For further information please contact. - * http://nyatla.jp/nyatoolkit/ - * or - * - */ -package jp.nyatla.utils; - -public class DoubleValue -{ - public double value; -} \ No newline at end of file diff --git a/src/jp/nyatla/utils/IntValue.java b/src/jp/nyatla/utils/IntValue.java deleted file mode 100644 index 056cf7a..0000000 --- a/src/jp/nyatla/utils/IntValue.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * PROJECT: NyARToolkit - * -------------------------------------------------------------------------------- - * The NyARToolkit is Java edition ARToolKit class library. - * Copyright (C)2008-2009 Ryo Iizuka - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * For further information please contact. - * http://nyatla.jp/nyatoolkit/ - * or - * - */ -package jp.nyatla.utils; - -public class IntValue -{ - public int value; -} diff --git a/src/jp/nyatla/utils/NyObjectStack.java b/src/jp/nyatla/utils/NyObjectStack.java deleted file mode 100644 index 76f5a1c..0000000 --- a/src/jp/nyatla/utils/NyObjectStack.java +++ /dev/null @@ -1,187 +0,0 @@ -/* - * PROJECT: NyARToolkit - * -------------------------------------------------------------------------------- - * The NyARToolkit is Java edition ARToolKit class library. - * Copyright (C)2008-2009 Ryo Iizuka - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * For further information please contact. - * http://nyatla.jp/nyatoolkit/ - * or - * - */ -package jp.nyatla.utils; -import java.lang.reflect.*; -import jp.nyatla.nyartoolkit.NyARException; - - - - -/** - * オンデマンド割り当てをするオブジェクト配列。 - * 配列には実体を格納します。 - */ -public abstract class NyObjectStack -{ - private final static int ARRAY_APPEND_STEP = 64; - - protected final T[] _items; - - private int _allocated_size; - - protected int _length; - - /** - * 最大ARRAY_MAX個の動的割り当てバッファを準備する。 - * - * @param i_array - * @param i_element_type - * JavaのGenedicsの制限突破 - */ - @SuppressWarnings("unchecked") - protected NyObjectStack(int i_length,Class i_element_type) - { - // ポインタだけははじめに確保しておく - this._items = (T[])Array.newInstance(i_element_type, i_length); - // アロケート済サイズと、使用中個数をリセット - this._allocated_size = 0; - this._length = 0; - return; - } - protected abstract T createElement(); - /** - * ポインタを1進めて、その要素を予約し、その要素へのポインタを返します。 - * 特定型に依存させるときには、継承したクラスでこの関数をオーバーライドしてください。 - */ - public final T prePush() throws NyARException - { - // 必要に応じてアロケート - if (this._length >= this._allocated_size) { - // 要求されたインデクスは範囲外 - if (this._length >= this._items.length) { - throw new NyARException(); - } - // 追加アロケート範囲を計算 - int range = this._length + ARRAY_APPEND_STEP; - if (range >= this._items.length) { - range = this._items.length; - } - // アロケート - this.onReservRequest(this._allocated_size, range, this._items); - this._allocated_size = range; - } - // 使用領域を+1して、予約した領域を返す。 - T ret = this._items[this._length]; - this._length++; - return ret; - } - /** - * 見かけ上の要素数を1減らして、最後尾のアイテムを返します。 - * @return - */ - public final T pop() - { - assert(this._length>=1); - this._length--; - return this._items[this._length]; - } - /** - * 見かけ上の要素数をi_count個減らします。 - * @param i_count - * @return - * NULLを返します。 - */ - public final void pops(int i_count) - { - assert(this._length>=i_count); - this._length-=i_count; - return; - } - - /** - * 0~i_number_of_item-1までの領域を予約します。 - * 予約済の領域よりも小さい場合には、現在の長さを調整します。 - * @param i_number_of_reserv - */ - final public void reserv(int i_number_of_item) throws NyARException - { - // 必要に応じてアロケート - if (i_number_of_item >= this._allocated_size) { - // 要求されたインデクスは範囲外 - if (i_number_of_item >= this._items.length) { - throw new NyARException(); - } - // 追加アロケート範囲を計算 - int range = i_number_of_item+ARRAY_APPEND_STEP; - if (range >= this._items.length) { - range = this._items.length; - } - // アロケート - this.onReservRequest(this._allocated_size, range, this._items); - this._allocated_size = range; - } - //見かけ上の配列サイズを指定 - this._length=i_number_of_item; - return; - } - /** - * 必要に応じて、この関数を継承先クラスで実装して下さい。 - * i_bufferの配列の、i_start番目からi_end-1番目までの要素に、オブジェクトを割り当てて下さい。 - * @param i_start - * @param i_end - * @param i_buffer - */ - final protected void onReservRequest(int i_start, int i_end, Object[] i_buffer) - { - try { - for (int i = i_start; i < i_end; i++){ - i_buffer[i] =createElement(); - } - } catch(Exception e) { - e.printStackTrace(); - } - return; - } - - - /** - * 配列を返します。 - * - * @return - */ - public final T[] getArray() - { - return this._items; - } - public final T getItem(int i_index) - { - return this._items[i_index]; - } - /** - * 配列の見かけ上の要素数を返却します。 - * @return - */ - public final int getLength() - { - return this._length; - } - /** - * 見かけ上の要素数をリセットします。 - */ - public final void clear() - { - this._length = 0; - } -} diff --git a/src/jp/nyatla/utils/j2se/LabelingBufferdImage.java b/src/jp/nyatla/utils/j2se/LabelingBufferdImage.java deleted file mode 100644 index 7f2387a..0000000 --- a/src/jp/nyatla/utils/j2se/LabelingBufferdImage.java +++ /dev/null @@ -1,251 +0,0 @@ -/* - * PROJECT: NyARToolkit - * -------------------------------------------------------------------------------- - * This work is based on the original ARToolKit developed by - * Hirokazu Kato - * Mark Billinghurst - * HITLab, University of Washington, Seattle - * http://www.hitl.washington.edu/artoolkit/ - * - * The NyARToolkit is Java edition ARToolKit class library. - * Copyright (C)2008-2009 Ryo Iizuka - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * For further information please contact. - * http://nyatla.jp/nyatoolkit/ - * or - * - */ -package jp.nyatla.utils.j2se; - -import java.awt.Graphics; -import java.awt.image.*; -import java.awt.color.*; -import java.awt.*; - - -import jp.nyatla.nyartoolkit.NyARException; -import jp.nyatla.nyartoolkit.core.types.*; -import jp.nyatla.nyartoolkit.core.rasterreader.*; -import jp.nyatla.nyartoolkit.core.raster.*; -import jp.nyatla.nyartoolkit.core.types.stack.*; -import jp.nyatla.nyartoolkit.core.labeling.*; -import jp.nyatla.nyartoolkit.core.labeling.artoolkit.NyARLabelingImage; -import jp.nyatla.nyartoolkit.core.labeling.artoolkit.NyARLabelingLabel; - -/** - * bitmapとして利用可能なラベリングイメージです。 - * - * - */ -public class LabelingBufferdImage extends BufferedImage -{ - public final static int COLOR_125_COLOR = 0;// 125色ラベルモード - - public final static int COLOR_256_MONO = 1;// 64階調モノクロモード - - public final static int COLOR_64_MONO = 2;// 64階調モノクロモード - - public final static int COLOR_32_MONO = 3;// 32階調モノクロモード - - public final static int COLOR_16_MONO = 4;// 16階調モノクロモード - - public final static int COLOR_8_MONO = 5;// 16階調モノクロモード - - private int[] _rgb_table_125; - - - /** - * i_width x i_heightの大きさのイメージを作成します。 - * - * @param i_width - * @param i_height - */ - public LabelingBufferdImage(int i_width, int i_height) - { - super(i_width, i_height, ColorSpace.TYPE_RGB); - // RGBテーブルを作成 - this._rgb_table_125 = new int[125]; - for (int i = 0; i < 5; i++) { - for (int i2 = 0; i2 < 5; i2++) { - for (int i3 = 0; i3 < 5; i3++) { - this._rgb_table_125[((i * 5) + i2) * 5 + i3] = ((((i * 63) << 8) | (i2 * 63)) << 8) | (i3 * 63); - } - } - } -/* case COLOR_256_MONO: - this._rgb_table = new int[256]; - this._number_of_color = 256; - for (int i = 0; i < 256; i++) { - this._rgb_table[i] = (i << 16) | (i << 8) | i; - } - break; - case COLOR_64_MONO: - this._rgb_table = new int[64]; - this._number_of_color = 64; - for (int i = 0; i < 64; i++) { - int m = (i * 4); - this._rgb_table[i] = (m << 16) | (m << 8) | m; - } - break; - case COLOR_32_MONO: - this._rgb_table = new int[32]; - this._number_of_color = 32; - for (int i = 0; i < 32; i++) { - int m = (i * 8); - this._rgb_table[i] = (m << 16) | (m << 8) | m; - } - break; - case COLOR_16_MONO: - this._rgb_table = new int[32]; - this._number_of_color = 16; - for (int i = 0; i < 16; i++) { - int m = (i * 8); - this._rgb_table[i] = (m << 16) | (m << 8) | m; - } - break; - }*/ - } - - - - public void drawImage(NyARGrayscaleRaster i_raster) throws NyARException - { - assert (i_raster.getBufferReader().getBufferType() == INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8); - - int w = this.getWidth(); - int h = this.getHeight(); - // サイズをチェック - NyARIntSize size = i_raster.getSize(); - if (size.h > h || size.w > w) { - throw new NyARException(); - } - - int[] limg; - // イメージの描画 - limg = (int[]) i_raster.getBufferReader().getBuffer(); - for (int i = 0; i < h; i++) { - for (int i2 = 0; i2 < w; i2++) { - this.setRGB(i2, i,limg[i*w+i2]); - } - } - return; - } - /** - * バイナリラスタ - * @param i_raster - * @throws NyARException - */ - public void drawImage(NyARBinRaster i_raster) throws NyARException - { - assert (i_raster.getBufferReader().getBufferType() == INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8); - - int w = this.getWidth(); - int h = this.getHeight(); - // サイズをチェック - NyARIntSize size = i_raster.getSize(); - if (size.h > h || size.w > w) { - throw new NyARException(); - } - - int[] limg; - // イメージの描画 - limg = (int[]) i_raster.getBufferReader().getBuffer(); - for (int i = 0; i < h; i++) { - for (int i2 = 0; i2 < w; i2++) { - this.setRGB(i2, i, limg[i*w+i2] > 0 ? 255 : 0); - } - } - return; - } - - /** - * ラベリングイメージを書く - * @param i_raster - * @throws NyARException - */ - public void drawLabel(NyARLabelingImage i_image) throws NyARException - { - int w = this.getWidth(); - int h = this.getHeight(); - // サイズをチェック - NyARIntSize size = i_image.getSize(); - if (size.h > h || size.w > w) { - throw new NyARException(); - } - int[] index_array=i_image.getIndexArray(); - - int[] limg; - // イメージの描画 - limg = (int[]) i_image.getBufferReader().getBuffer(); - for (int i = 0; i < h; i++) { - for (int i2 = 0; i2 < w; i2++) { - int t=limg[i*w+i2]-1; - if(t<0){ - t=0; - }else{ - t=index_array[t]; - } - this.setRGB(i2, i,_rgb_table_125[t% _rgb_table_125.length]); - } - } - return; - } - /** - * - * @param i_stack - */ - - public void overlayData(NyARLabelingLabel i_label) - { - Graphics g = this.getGraphics(); - g.setColor(Color.red); - g.drawRect(i_label.clip_l,i_label.clip_t,i_label.clip_r-i_label.clip_l,i_label.clip_b-i_label.clip_t); - return; - } - /** - * - * @param i_stack - */ - - public void overlayData(NyARIntPointStack i_stack) - { - int count = i_stack.getLength(); - NyARIntPoint2d[] items = i_stack.getArray(); - Graphics g = this.getGraphics(); - for (int i = 0; i < count; i++) { - int x = items[i].x; - int y = items[i].y; - g.setColor(Color.red); - g.drawLine(x - 5, y, x + 5, y); - g.drawLine(x, y + 5, x, y - 5); - } - return; - } - public void overlayData(NyARIntRectStack i_stack) - { - Color[] c=new Color[]{Color.cyan,Color.red,Color.green}; - int count = i_stack.getLength(); - NyARIntRect[] items = i_stack.getArray(); - Graphics g = this.getGraphics(); - for (int i = 0; i < count; i++) { - int x = items[i].x; - int y = items[i].y; - g.setColor(c[i%1]); - g.drawRect(x,y,items[i].w,items[i].h); - } - return; - } -} diff --git a/src/jp/nyatla/utils/j2se/NyARRasterImageIO.java b/src/jp/nyatla/utils/j2se/NyARRasterImageIO.java deleted file mode 100644 index 31af7af..0000000 --- a/src/jp/nyatla/utils/j2se/NyARRasterImageIO.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * PROJECT: NyARToolkit - * -------------------------------------------------------------------------------- - * This work is based on the original ARToolKit developed by - * Hirokazu Kato - * Mark Billinghurst - * HITLab, University of Washington, Seattle - * http://www.hitl.washington.edu/artoolkit/ - * - * The NyARToolkit is Java edition ARToolKit class library. - * Copyright (C)2008-2009 Ryo Iizuka - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * For further information please contact. - * http://nyatla.jp/nyatoolkit/ - * or - * - */ -package jp.nyatla.utils.j2se; - -import java.awt.Graphics.*; -import java.awt.image.*; -import java.awt.*; -import jp.nyatla.nyartoolkit.*; -import jp.nyatla.nyartoolkit.core.raster.rgb.*; -import jp.nyatla.nyartoolkit.core.raster.*; -import jp.nyatla.nyartoolkit.core.rasterreader.*; -import jp.nyatla.nyartoolkit.core.types.*; - -/** - * BufferdImageとRasterイメージ間で、ビットマップをコピーします。 - */ -public class NyARRasterImageIO -{ - /** - * i_inの内容を、このイメージにコピーします。 - * @param i_in - * @throws NyARException - */ - public static void copy(INyARRgbRaster i_in,BufferedImage o_out) throws NyARException - { - assert i_in.getSize().isEqualSize(o_out.getWidth(), o_out.getHeight()); - - //thisへ転写 - INyARRgbPixelReader reader=i_in.getRgbPixelReader(); - int[] rgb=new int[3]; - - for(int y=o_out.getHeight()-1;y>=0;y--){ - for(int x=o_out.getWidth()-1;x>=0;x--){ - reader.getPixel(x,y,rgb); - o_out.setRGB(x,y,(rgb[0]<<16)|(rgb[1]<<8)|rgb[2]); - } - } - return; - } - /** - * GrayScale用 - * @param i_in - * @throws NyARException - */ - public static void copy(NyARGrayscaleRaster i_in,BufferedImage o_out) throws NyARException - { - assert i_in.getSize().isEqualSize(o_out.getWidth(), o_out.getHeight()); - if(i_in.getBufferReader().isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8)) - { - final int[] buf=(int[])i_in.getBufferReader().getBuffer(); - final int w=o_out.getWidth(); - final int h=o_out.getHeight(); - for(int y=h-1;y>=0;y--){ - for(int x=w-1;x>=0;x--){ - int v=buf[x+y*w]; - o_out.setRGB(x, y,v*(1+0x100+0x10000)); - } - } - } - return; - } - /** - * BIN_8用 - * @param i_in - * @throws NyARException - */ - public static void copy(INyARRaster i_in,BufferedImage o_out) throws NyARException - { - assert i_in.getSize().isEqualSize(o_out.getWidth(), o_out.getHeight()); - if(i_in.getBufferReader().isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8)) - { - final int[] buf=(int[])i_in.getBufferReader().getBuffer(); - final int w=o_out.getWidth(); - final int h=o_out.getHeight(); - for(int y=h-1;y>=0;y--){ - for(int x=w-1;x>=0;x--){ - o_out.setRGB(x, y,buf[x+y*w]==0?0:0xffffff); - } - } - } - return; - } - /** - * ヒストグラムを書き出します。 - * @param i_in - * @param o_out - * @throws NyARException - */ - public static void copy(NyARHistgram i_in,int i_l,int i_t,int i_h,Graphics i_g) throws NyARException - { - //正規化のための定数を出す。 - int max=0; - for(int i=0;i=0;y--){ - for(int x=i_in.getWidth()-1;x>=0;x--){ - int pix=i_in.getRGB(x, y); - rgb[0]=(pix>>16)&0xff; - rgb[1]=(pix>>8)&0xff; - rgb[2]=(pix)&0xff; - reader.setPixel(x,y,rgb); - } - } - return; - } - /** - * BIN_8用 - * @param i_in - * @throws NyARException - */ - public static void copy(BufferedImage i_in,INyARRaster o_out) throws NyARException - { - assert o_out.getSize().isEqualSize(i_in.getWidth(), i_in.getHeight()); - if(o_out.getBufferReader().isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8)) - { - final int[] buf=(int[])o_out.getBufferReader().getBuffer(); - final int w=i_in.getWidth(); - final int h=i_in.getHeight(); - for(int y=h-1;y>=0;y--){ - for(int x=w-1;x>=0;x--){ - buf[x+y*w]=(i_in.getRGB(x, y)&0xffffff)>0?1:0; - } - } - } - return; - } - -} -- 2.11.0