From a0412494fc8c7a2e22f274d5f897929e9725dabd Mon Sep 17 00:00:00 2001 From: nyatla Date: Mon, 28 Dec 2009 18:58:46 +0000 Subject: [PATCH] =?utf8?q?[backup]=20+NyObjectStack=E3=81=AE=E4=BB=95?= =?utf8?q?=E6=A7=98=E5=A4=89=E6=9B=B4=E3=80=82=E3=83=A1=E3=83=A2=E3=83=AA?= =?utf8?q?=E3=82=92=E5=AE=8C=E5=85=A8=E4=BA=8B=E5=89=8D=E7=A2=BA=E4=BF=9D?= =?utf8?q?=E3=81=AB=E5=A4=89=E6=9B=B4=E3=80=82=20+=E7=B4=B0=E3=81=8B?= =?utf8?q?=E3=81=84API=E8=BF=BD=E5=8A=A0=20+dev=E3=81=AB=E3=83=88=E3=83=A9?= =?utf8?q?=E3=83=83=E3=82=AD=E3=83=B3=E3=82=B0=E3=81=AE=E5=AE=9F=E6=A9=9F?= =?utf8?q?=E3=82=A8=E3=83=B3=E3=82=B3=E3=83=BC=E3=83=89=E3=82=92=E8=BF=BD?= =?utf8?q?=E5=8A=A0=E3=80=82(=E4=BA=88=E6=B8=AC=E3=81=AA=E3=81=97=E8=BF=BD?= =?utf8?q?=E8=B7=A1=E3=81=AE=E5=8B=95=E4=BD=9C=E3=81=BE=E3=81=A7=E7=A2=BA?= =?utf8?q?=E8=AA=8D)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: http://svn.sourceforge.jp/svnroot/nyartoolkit/NyARToolkit@368 7cac0a50-4618-4814-88d0-24b83990f816 --- trunk/sample/java3d/.classpath | 20 +- trunk/sample/jmf/.classpath | 12 +- trunk/sample/jogl/.classpath | 18 +- trunk/sample/sandbox/.classpath | 16 +- trunk/src.utils/jmf/.classpath | 10 +- trunk/src.utils/jogl/.classpath | 16 +- .../core/labeling/NyARLabelInfoStack.java | 3 +- .../core/labeling/artoolkit/NyARLabelingImage.java | 2 +- .../labeling/artoolkit/NyARLabelingLabelStack.java | 3 +- .../labeling/artoolkit/NyARLabeling_ARToolKit.java | 2 +- .../labeling/rlelabeling/NyARLabeling_Rle.java | 6 +- .../rlelabeling/RleLabelFragmentInfoStack.java | 3 +- .../param/NyARPerspectiveProjectionMatrix.java | 13 +- .../nyartoolkit/core/squaredetect/NyARSquare.java | 10 +- .../core/squaredetect/NyARSquareStack.java | 3 +- .../nyartoolkit/core/types/NyARDoublePoint2d.java | 6 +- .../nyartoolkit/core/types/NyARDoublePoint3d.java | 12 + .../core/types/stack/NyARIntPointStack.java | 3 +- .../core/types/stack/NyARIntRectStack.java | 3 +- .../core/types/stack/NyObjectStack.java | 107 ++----- .../jp/nyatla/nyartoolkit/core/utils/NyARMath.java | 42 +++ .../nyartoolkit/detector/NyARDetectMarker.java | 2 +- .../nyartoolkit/dev/tracking/IntRectStack.java | 19 ++ .../dev/tracking/MarkerPositionTable.java | 62 ++++ .../dev/tracking/MarkerTableOperator.java | 205 +++++++++++++ .../dev/tracking/MarkerTracking_3dTrans.java | 329 +++++++++++++++++++++ .../dev/tracking/NextFrameMarkerStack.java | 31 ++ .../nyartoolkit/dev/tracking/NyARDataTable.java | 30 ++ .../jp/nyatla/nyartoolkit/dev/tracking/TrTest.java | 223 ++++++++++++++ .../dev/tracking/TransMat2MarkerRect.java | 141 +++++++++ 30 files changed, 1209 insertions(+), 143 deletions(-) create mode 100644 trunk/src/jp/nyatla/nyartoolkit/core/utils/NyARMath.java create mode 100644 trunk/test/jp/nyatla/nyartoolkit/dev/tracking/IntRectStack.java create mode 100644 trunk/test/jp/nyatla/nyartoolkit/dev/tracking/MarkerPositionTable.java create mode 100644 trunk/test/jp/nyatla/nyartoolkit/dev/tracking/MarkerTableOperator.java create mode 100644 trunk/test/jp/nyatla/nyartoolkit/dev/tracking/MarkerTracking_3dTrans.java create mode 100644 trunk/test/jp/nyatla/nyartoolkit/dev/tracking/NextFrameMarkerStack.java create mode 100644 trunk/test/jp/nyatla/nyartoolkit/dev/tracking/NyARDataTable.java create mode 100644 trunk/test/jp/nyatla/nyartoolkit/dev/tracking/TrTest.java create mode 100644 trunk/test/jp/nyatla/nyartoolkit/dev/tracking/TransMat2MarkerRect.java diff --git a/trunk/sample/java3d/.classpath b/trunk/sample/java3d/.classpath index 0a27af9..14ab415 100644 --- a/trunk/sample/java3d/.classpath +++ b/trunk/sample/java3d/.classpath @@ -1,13 +1,13 @@ - - - - - - - - - - + + + + + + + + + + diff --git a/trunk/sample/jmf/.classpath b/trunk/sample/jmf/.classpath index 6ba8b00..d869052 100644 --- a/trunk/sample/jmf/.classpath +++ b/trunk/sample/jmf/.classpath @@ -1,9 +1,9 @@ - - - - - - + + + + + + diff --git a/trunk/sample/jogl/.classpath b/trunk/sample/jogl/.classpath index 966ee53..d8a287d 100644 --- a/trunk/sample/jogl/.classpath +++ b/trunk/sample/jogl/.classpath @@ -1,12 +1,12 @@ - - - - - - - - - + + + + + + + + + diff --git a/trunk/sample/sandbox/.classpath b/trunk/sample/sandbox/.classpath index 0817e89..f58da4c 100644 --- a/trunk/sample/sandbox/.classpath +++ b/trunk/sample/sandbox/.classpath @@ -1,11 +1,11 @@ - - - - - - - - + + + + + + + + diff --git a/trunk/src.utils/jmf/.classpath b/trunk/src.utils/jmf/.classpath index 68860c8..01e0575 100644 --- a/trunk/src.utils/jmf/.classpath +++ b/trunk/src.utils/jmf/.classpath @@ -1,8 +1,8 @@ - - - - - + + + + + diff --git a/trunk/src.utils/jogl/.classpath b/trunk/src.utils/jogl/.classpath index 2b24071..5345587 100644 --- a/trunk/src.utils/jogl/.classpath +++ b/trunk/src.utils/jogl/.classpath @@ -1,11 +1,11 @@ - - - - - - - - + + + + + + + + diff --git a/trunk/src/jp/nyatla/nyartoolkit/core/labeling/NyARLabelInfoStack.java b/trunk/src/jp/nyatla/nyartoolkit/core/labeling/NyARLabelInfoStack.java index 347b51e..23833b4 100644 --- a/trunk/src/jp/nyatla/nyartoolkit/core/labeling/NyARLabelInfoStack.java +++ b/trunk/src/jp/nyatla/nyartoolkit/core/labeling/NyARLabelInfoStack.java @@ -31,6 +31,7 @@ package jp.nyatla.nyartoolkit.core.labeling; +import jp.nyatla.nyartoolkit.NyARException; import jp.nyatla.nyartoolkit.core.types.stack.NyObjectStack; /** @@ -39,7 +40,7 @@ import jp.nyatla.nyartoolkit.core.types.stack.NyObjectStack; */ public abstract class NyARLabelInfoStack extends NyObjectStack { - public NyARLabelInfoStack(int i_length,Class i_element_type) + public NyARLabelInfoStack(int i_length,Class i_element_type) throws NyARException { super(i_length,i_element_type); } diff --git a/trunk/src/jp/nyatla/nyartoolkit/core/labeling/artoolkit/NyARLabelingImage.java b/trunk/src/jp/nyatla/nyartoolkit/core/labeling/artoolkit/NyARLabelingImage.java index 726f79b..7eb2ae3 100644 --- a/trunk/src/jp/nyatla/nyartoolkit/core/labeling/artoolkit/NyARLabelingImage.java +++ b/trunk/src/jp/nyatla/nyartoolkit/core/labeling/artoolkit/NyARLabelingImage.java @@ -47,7 +47,7 @@ public class NyARLabelingImage extends NyARRaster_BasicClass protected NyARLabelingLabelStack _label_list; protected int[] _index_table; protected boolean _is_index_table_enable; - public NyARLabelingImage(int i_width, int i_height) + public NyARLabelingImage(int i_width, int i_height) throws NyARException { super(new NyARIntSize(i_width,i_height)); this._ref_buf =new int[i_height*i_width]; diff --git a/trunk/src/jp/nyatla/nyartoolkit/core/labeling/artoolkit/NyARLabelingLabelStack.java b/trunk/src/jp/nyatla/nyartoolkit/core/labeling/artoolkit/NyARLabelingLabelStack.java index 8405b6a..986669a 100644 --- a/trunk/src/jp/nyatla/nyartoolkit/core/labeling/artoolkit/NyARLabelingLabelStack.java +++ b/trunk/src/jp/nyatla/nyartoolkit/core/labeling/artoolkit/NyARLabelingLabelStack.java @@ -32,6 +32,7 @@ package jp.nyatla.nyartoolkit.core.labeling.artoolkit; +import jp.nyatla.nyartoolkit.NyARException; import jp.nyatla.nyartoolkit.core.labeling.*; /** @@ -40,7 +41,7 @@ import jp.nyatla.nyartoolkit.core.labeling.*; */ public class NyARLabelingLabelStack extends NyARLabelInfoStack { - public NyARLabelingLabelStack(int i_max_array_size) + public NyARLabelingLabelStack(int i_max_array_size) throws NyARException { super(i_max_array_size,NyARLabelingLabel.class); } diff --git a/trunk/src/jp/nyatla/nyartoolkit/core/labeling/artoolkit/NyARLabeling_ARToolKit.java b/trunk/src/jp/nyatla/nyartoolkit/core/labeling/artoolkit/NyARLabeling_ARToolKit.java index c11aa9e..f19d8f6 100644 --- a/trunk/src/jp/nyatla/nyartoolkit/core/labeling/artoolkit/NyARLabeling_ARToolKit.java +++ b/trunk/src/jp/nyatla/nyartoolkit/core/labeling/artoolkit/NyARLabeling_ARToolKit.java @@ -218,7 +218,7 @@ final public class NyARLabeling_ARToolKit NyARLabelingLabelStack label_list = o_destination.getLabelStack(); // ラベルバッファを予約 - label_list.reserv(wlabel_num); + label_list.init(wlabel_num); // エリアと重心、クリップ領域を計算 NyARLabelingLabel label_pt; diff --git a/trunk/src/jp/nyatla/nyartoolkit/core/labeling/rlelabeling/NyARLabeling_Rle.java b/trunk/src/jp/nyatla/nyartoolkit/core/labeling/rlelabeling/NyARLabeling_Rle.java index da52d43..1a8eb7f 100644 --- a/trunk/src/jp/nyatla/nyartoolkit/core/labeling/rlelabeling/NyARLabeling_Rle.java +++ b/trunk/src/jp/nyatla/nyartoolkit/core/labeling/rlelabeling/NyARLabeling_Rle.java @@ -42,7 +42,7 @@ class RleInfoStack extends NyObjectStack public long pos_x; public long pos_y; } - public RleInfoStack(int i_length) + public RleInfoStack(int i_length) throws NyARException { super(i_length, RleInfoStack.RleInfo.class); return; @@ -86,7 +86,7 @@ public class NyARLabeling_Rle private int _max_area; private int _min_area; - public NyARLabeling_Rle(int i_width,int i_height) + public NyARLabeling_Rle(int i_width,int i_height) throws NyARException { this._rlestack=new RleInfoStack(i_width*i_height*2048/(320*240)+32); this._rle1 = RleElement.createArray(i_width/2+1); @@ -374,7 +374,7 @@ public class NyARLabeling_Rle rle_current = tmp; } //対象のラベルだけ転写 - o_stack.reserv(label_count); + o_stack.init(label_count); RleLabelFragmentInfoStack.RleLabelFragmentInfo[] o_dest_array=o_stack.getArray(); final int max=this._max_area; final int min=this._min_area; diff --git a/trunk/src/jp/nyatla/nyartoolkit/core/labeling/rlelabeling/RleLabelFragmentInfoStack.java b/trunk/src/jp/nyatla/nyartoolkit/core/labeling/rlelabeling/RleLabelFragmentInfoStack.java index c11fbad..46aad1e 100644 --- a/trunk/src/jp/nyatla/nyartoolkit/core/labeling/rlelabeling/RleLabelFragmentInfoStack.java +++ b/trunk/src/jp/nyatla/nyartoolkit/core/labeling/rlelabeling/RleLabelFragmentInfoStack.java @@ -25,6 +25,7 @@ package jp.nyatla.nyartoolkit.core.labeling.rlelabeling; +import jp.nyatla.nyartoolkit.NyARException; import jp.nyatla.nyartoolkit.core.labeling.NyARLabelInfo; import jp.nyatla.nyartoolkit.core.labeling.NyARLabelInfoStack; @@ -37,7 +38,7 @@ public class RleLabelFragmentInfoStack extends NyARLabelInfoStack { - public NyARSquareStack(int i_length) + public NyARSquareStack(int i_length) throws NyARException { super(i_length,NyARSquare.class); diff --git a/trunk/src/jp/nyatla/nyartoolkit/core/types/NyARDoublePoint2d.java b/trunk/src/jp/nyatla/nyartoolkit/core/types/NyARDoublePoint2d.java index fe7a22d..128e624 100644 --- a/trunk/src/jp/nyatla/nyartoolkit/core/types/NyARDoublePoint2d.java +++ b/trunk/src/jp/nyatla/nyartoolkit/core/types/NyARDoublePoint2d.java @@ -101,8 +101,12 @@ public class NyARDoublePoint2d * 格納値をベクトルとして、距離を返します。 * @return */ - public double dist() + public final double dist() { return Math.sqrt(this.x*this.x+this.y+this.y); } + public final double sqNorm() + { + return this.x*this.x+this.y+this.y; + } } diff --git a/trunk/src/jp/nyatla/nyartoolkit/core/types/NyARDoublePoint3d.java b/trunk/src/jp/nyatla/nyartoolkit/core/types/NyARDoublePoint3d.java index 33d4579..950b063 100644 --- a/trunk/src/jp/nyatla/nyartoolkit/core/types/NyARDoublePoint3d.java +++ b/trunk/src/jp/nyatla/nyartoolkit/core/types/NyARDoublePoint3d.java @@ -56,4 +56,16 @@ public class NyARDoublePoint3d this.z=i_in.z; return; } + /** + * i_pointとのベクトルから距離を計算します。 + * @return + */ + public double dist(NyARDoublePoint3d i_point) + { + double x,y; + x=this.x-i_point.x; + y=this.y-i_point.y; + z=this.z-i_point.z; + return Math.sqrt(x*x+y*y+z*z); + } } diff --git a/trunk/src/jp/nyatla/nyartoolkit/core/types/stack/NyARIntPointStack.java b/trunk/src/jp/nyatla/nyartoolkit/core/types/stack/NyARIntPointStack.java index a1f1305..421aeaf 100644 --- a/trunk/src/jp/nyatla/nyartoolkit/core/types/stack/NyARIntPointStack.java +++ b/trunk/src/jp/nyatla/nyartoolkit/core/types/stack/NyARIntPointStack.java @@ -31,11 +31,12 @@ package jp.nyatla.nyartoolkit.core.types.stack; +import jp.nyatla.nyartoolkit.NyARException; import jp.nyatla.nyartoolkit.core.types.*; public class NyARIntPointStack extends NyObjectStack { - public NyARIntPointStack(int i_length) + public NyARIntPointStack(int i_length) throws NyARException { super(i_length,NyARIntPoint2d.class); return; diff --git a/trunk/src/jp/nyatla/nyartoolkit/core/types/stack/NyARIntRectStack.java b/trunk/src/jp/nyatla/nyartoolkit/core/types/stack/NyARIntRectStack.java index 4494d0c..db20da2 100644 --- a/trunk/src/jp/nyatla/nyartoolkit/core/types/stack/NyARIntRectStack.java +++ b/trunk/src/jp/nyatla/nyartoolkit/core/types/stack/NyARIntRectStack.java @@ -31,11 +31,12 @@ package jp.nyatla.nyartoolkit.core.types.stack; +import jp.nyatla.nyartoolkit.NyARException; import jp.nyatla.nyartoolkit.core.types.NyARIntRect; public class NyARIntRectStack extends NyObjectStack { - public NyARIntRectStack(int i_length) + public NyARIntRectStack(int i_length) throws NyARException { super(i_length,NyARIntRect.class); } diff --git a/trunk/src/jp/nyatla/nyartoolkit/core/types/stack/NyObjectStack.java b/trunk/src/jp/nyatla/nyartoolkit/core/types/stack/NyObjectStack.java index c3d8cd8..c42625d 100644 --- a/trunk/src/jp/nyatla/nyartoolkit/core/types/stack/NyObjectStack.java +++ b/trunk/src/jp/nyatla/nyartoolkit/core/types/stack/NyObjectStack.java @@ -30,17 +30,12 @@ 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; /** @@ -51,44 +46,54 @@ public abstract class NyObjectStack * JavaのGenedicsの制限突破 */ @SuppressWarnings("unchecked") - protected NyObjectStack(int i_length,Class i_element_type) + protected NyObjectStack(int i_length,Class i_element_type) throws NyARException { - // ポインタだけははじめに確保しておく + //領域確保 this._items = (T[])Array.newInstance(i_element_type, i_length); - // アロケート済サイズと、使用中個数をリセット - this._allocated_size = 0; + for (int i =0; i < i_length; i++){ + this._items[i] =createElement(); + } + //使用中個数をリセット this._length = 0; return; } protected abstract T createElement(); + /** - * ポインタを1進めて、その要素を予約し、その要素へのポインタを返します。 - * 特定型に依存させるときには、継承したクラスでこの関数をオーバーライドしてください。 + * 新しい領域を予約します。 + * @return + * 失敗するとnull + * @throws NyARException */ - public final T prePush() throws NyARException + public final T prePush() { // 必要に応じてアロケート - 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; + if (this._length >= this._items.length){ + return null; } // 使用領域を+1して、予約した領域を返す。 T ret = this._items[this._length]; this._length++; return ret; } + /** + * スタックを初期化します。 + * @param i_reserv_length + * 使用済みにするサイズ + * @return + */ + public final void init(int i_reserv_length) throws NyARException + { + // 必要に応じてアロケート + if (i_reserv_length >= this._items.length){ + throw new NyARException(); + } + this._length=i_reserv_length; + } + /** - * 見かけ上の要素数を1減らして、最後尾のアイテムを返します。 + * 見かけ上の要素数を1減らして、そのオブジェクトを返します。 + * 返却したオブジェクトの内容は、次回のpushまで有効です。 * @return */ public final T pop() @@ -101,7 +106,6 @@ public abstract class NyObjectStack * 見かけ上の要素数をi_count個減らします。 * @param i_count * @return - * NULLを返します。 */ public final void pops(int i_count) { @@ -109,53 +113,6 @@ public abstract class NyObjectStack 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; - } - - /** * 配列を返します。 * diff --git a/trunk/src/jp/nyatla/nyartoolkit/core/utils/NyARMath.java b/trunk/src/jp/nyatla/nyartoolkit/core/utils/NyARMath.java new file mode 100644 index 0000000..4a260dd --- /dev/null +++ b/trunk/src/jp/nyatla/nyartoolkit/core/utils/NyARMath.java @@ -0,0 +1,42 @@ +package jp.nyatla.nyartoolkit.core.utils; + +import jp.nyatla.nyartoolkit.core.types.*; +public class NyARMath +{ + /** + * p2-p1ベクトルのsquare normを計算する。 + * @param i_p1 + * @param i_p2 + * @return + */ + public static final double sqNorm(NyARDoublePoint2d i_p1,NyARDoublePoint2d i_p2) + { + double x,y; + x=i_p2.x-i_p1.x; + y=i_p2.y-i_p1.y; + return x*x+y*y; + } + public static final double sqNorm(double i_p1x,double i_p1y,double i_p2x,double i_p2y) + { + double x,y; + x=i_p2x-i_p1x; + y=i_p2y-i_p1y; + return x*x+y*y; + } + /** + * p2-p1ベクトルのsquare normを計算する。 + * @param i_p1 + * @param i_p2 + * @return + */ + public static final double sqNorm(NyARDoublePoint3d i_p1,NyARDoublePoint3d i_p2) + { + double x,y,z; + x=i_p2.x-i_p1.x; + y=i_p2.y-i_p1.y; + z=i_p2.z-i_p1.z; + return x*x+y*y+z*z; + } + + +} diff --git a/trunk/src/jp/nyatla/nyartoolkit/detector/NyARDetectMarker.java b/trunk/src/jp/nyatla/nyartoolkit/detector/NyARDetectMarker.java index 5acab3d..4aeab43 100644 --- a/trunk/src/jp/nyatla/nyartoolkit/detector/NyARDetectMarker.java +++ b/trunk/src/jp/nyatla/nyartoolkit/detector/NyARDetectMarker.java @@ -57,7 +57,7 @@ class NyARDetectMarkerResult class NyARDetectMarkerResultStack extends NyObjectStack { - public NyARDetectMarkerResultStack(int i_length) + public NyARDetectMarkerResultStack(int i_length) throws NyARException { super(i_length,NyARDetectMarkerResult.class); return; diff --git a/trunk/test/jp/nyatla/nyartoolkit/dev/tracking/IntRectStack.java b/trunk/test/jp/nyatla/nyartoolkit/dev/tracking/IntRectStack.java new file mode 100644 index 0000000..216a04d --- /dev/null +++ b/trunk/test/jp/nyatla/nyartoolkit/dev/tracking/IntRectStack.java @@ -0,0 +1,19 @@ +package jp.nyatla.nyartoolkit.dev.tracking; + +import jp.nyatla.nyartoolkit.NyARException; +import jp.nyatla.nyartoolkit.core.types.*; +import jp.nyatla.nyartoolkit.core.types.stack.NyObjectStack; + +public class IntRectStack extends NyObjectStack +{ + protected NyARIntRect createElement() + { + return new NyARIntRect(); + } + public IntRectStack(int i_length) throws NyARException + { + super(i_length,NyARIntRect.class); + return; + } + +} \ No newline at end of file diff --git a/trunk/test/jp/nyatla/nyartoolkit/dev/tracking/MarkerPositionTable.java b/trunk/test/jp/nyatla/nyartoolkit/dev/tracking/MarkerPositionTable.java new file mode 100644 index 0000000..5533916 --- /dev/null +++ b/trunk/test/jp/nyatla/nyartoolkit/dev/tracking/MarkerPositionTable.java @@ -0,0 +1,62 @@ +package jp.nyatla.nyartoolkit.dev.tracking; + + +import jp.nyatla.nyartoolkit.core.types.*; +import jp.nyatla.nyartoolkit.core.transmat.*; + + + +public class MarkerPositionTable extends NyARDataTable +{ + public static class Item + { + public boolean is_empty=true; + public NyARDoublePoint3d angle=new NyARDoublePoint3d(); + public NyARDoublePoint3d trans=new NyARDoublePoint3d(); + public NyARRectOffset offset=new NyARRectOffset(); + public int life=0; + public NyARDoublePoint3d velocity=new NyARDoublePoint3d(); + public NyARDoublePoint3d acceleration=new NyARDoublePoint3d(); + public int sirial; + + } + public MarkerPositionTable(int i_size) + { + this.initTable(i_size,Item.class); + this.clear(); + return; + } + /** + * 空のアイテムを1個選択します。 + * @return + */ + public Item selectEmptyItem() + { + for(int i=this._items.length-1;i>=0;i--) + { + if(this._items[i].is_empty){ + return this._items[i]; + } + } + return null; + } + protected Item createElement() + { + return new Item(); + } + + public void clear() + { + for(int i=this._items.length-1;i>=0;i--) + { + if(!this._items[i].is_empty){ + this._items[i].is_empty=true; + }else{ + //nothing. + } + } + } + +} + + diff --git a/trunk/test/jp/nyatla/nyartoolkit/dev/tracking/MarkerTableOperator.java b/trunk/test/jp/nyatla/nyartoolkit/dev/tracking/MarkerTableOperator.java new file mode 100644 index 0000000..4cc2b0b --- /dev/null +++ b/trunk/test/jp/nyatla/nyartoolkit/dev/tracking/MarkerTableOperator.java @@ -0,0 +1,205 @@ +package jp.nyatla.nyartoolkit.dev.tracking; + +import jp.nyatla.nyartoolkit.NyARException; +import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquare; +import jp.nyatla.nyartoolkit.core.transmat.*; +import jp.nyatla.nyartoolkit.core.param.*; +import jp.nyatla.nyartoolkit.core.types.*; +import jp.nyatla.nyartoolkit.core.utils.NyARMath; + +/** + * マーカ位置の更新オペレータ。 + * + * + */ +public class MarkerTableOperator +{ + NyARTransMatResult _tmp_trans_result; + INyARTransMat _transmat; + private int _sirial; + + public MarkerTableOperator(NyARParam i_ref_param) throws NyARException + { + this._transmat=new NyARTransMat(i_ref_param); + this._tmp_trans_result=new NyARTransMatResult(); + this._sirial=0; + return; + } + /** + * o_itemのアイテムを更新します。 + * @param i_pkindex + * @param i_marker + */ + public void updateMarker(MarkerPositionTable.Item io_item,NyARSquare i_square) throws NyARException + { + NyARTransMatResult trans_result=this._tmp_trans_result; + this._transmat.transMat(i_square,io_item.offset, trans_result); + trans_result.getZXYAngle(io_item.angle); + //位置を計算(ここでEstimate?) + double x,y,z; + x=trans_result.m03; + y=trans_result.m13; + z=trans_result.m23; + //速度を計算 +/* double vx,vy,vz; + vx=x-io_item.trans.x; + vy=y-io_item.trans.y; + vz=z-io_item.trans.z; + //現在の加速度を計算して保存 + io_item.acceleration.x=vx-io_item.velocity.x; + io_item.acceleration.y=vy-io_item.velocity.y; + io_item.acceleration.z=vz-io_item.velocity.z; + //現在の速度を計算して保存 + io_item.velocity.x=vx; + io_item.velocity.y=vy; + io_item.velocity.z=vz; */ + //現在の位置を計算して保存 + io_item.trans.x=x; + io_item.trans.y=y; + io_item.trans.z=z; + io_item.life=0; +// System.out.println("---"); +// System.out.println(io_item.acceleration.x+","+io_item.acceleration.y+","+io_item.acceleration.z); +// System.out.println(io_item.velocity.x+","+io_item.velocity.y+","+io_item.velocity.z); +// System.out.println(io_item.trans.x+","+io_item.trans.y+","+io_item.trans.z); + return; + } + /** + * 新しいマーカをテーブルに加えます。 + * @param i_table + * @param i_square + * @param i_width + * @return + * @throws NyARException + */ + public boolean insertMarker(MarkerPositionTable i_table,NyARSquare i_square,double i_width) throws NyARException + { + MarkerPositionTable.Item item=i_table.selectEmptyItem(); + if(item==null){ + return false; + } + NyARTransMatResult trans_result=this._tmp_trans_result; + item.offset.setSquare(i_width); + this._transmat.transMat(i_square,item.offset, trans_result); + trans_result.getZXYAngle(item.angle); + item.is_empty=false; + //現在の行列を保存 + item.trans.x=trans_result.m03; + item.trans.y=trans_result.m13; + item.trans.z=trans_result.m23; + item.offset.setSquare(i_width); + item.life=0; + item.sirial=this._sirial; + this._sirial++; + return true; + } + /** + * 3次元空間の指定点の一番近くにあるアイテムを探します。 + * @param i_table + * @param i_pos + * 探索点 + * @param i_limit_max + * 探索範囲の最大値 + * @return + */ + public MarkerPositionTable.Item selectNearItem3d(MarkerPositionTable i_table,NyARDoublePoint3d i_pos,double i_limit_max) + { + MarkerPositionTable.Item[] items=i_table.selectAllItems(); + double d=Double.MAX_VALUE; + int index=-1; + final double limit=3*(i_limit_max*i_limit_max); + + for(int i=items.length-1;i>=0;i--) + { + if(items[i].is_empty){ + continue; + } + + NyARDoublePoint3d trans=items[i].trans; + //distの計算 + double nd=NyARMath.sqNorm(i_pos, trans); + if(nd>limit){ + continue; + } + if(d>nd){ + d=nd; + index=i; + } + } + return index==-1?null:items[index]; + } +// private NyARDoublePoint3d _area_temp=new NyARDoublePoint3d(); + /** + * 2次元空間の指定点の一番近くにあるアイテムを探します。 + * @param i_table + * @param i_pos + * 探索点 + * @param i_limit_max + * 探索範囲の最大値 + * @return + *//* + public MarkerPositionTable.Item selectNearItem2d(MarkerPositionTable i_table,NyARDoublePoint2d i_pos,double i_limit_max,int i_limit_min_life) + { + MarkerPositionTable.Item[] items=i_table.selectAllItems(); + + double d=Double.MAX_VALUE; + NyARPerspectiveProjectionMatrix prjmat=this._prjmat; + NyARDoublePoint2d pos2d=this._pos2d_tmp; + //エリア + NyARDoublePoint3d area=this._area_temp; + area.x=area.y=i_limit_max; + int index=-1; + for(int i=items.length-1;i>=0;i--) + { + if(items[i].is_empty || items[i].lifelimit_d){ + continue; + } + if(d>nd){ + d=nd; + index=i; + } + } + return index==-1?null:items[index]; + }*/ + + /** + * テーブルの全行を1ティック進めます。 + * @param i_table + */ + public void updateTick(MarkerPositionTable i_table) + { + MarkerPositionTable.Item[] items=i_table.selectAllItems(); + for(int i=items.length-1;i>=0;i--) + { + final MarkerPositionTable.Item item=items[i]; + if(item.is_empty){ + continue; + } + if(item.life<10){ + item.life++; + continue; + } + item.is_empty=true; + } + } +} diff --git a/trunk/test/jp/nyatla/nyartoolkit/dev/tracking/MarkerTracking_3dTrans.java b/trunk/test/jp/nyatla/nyartoolkit/dev/tracking/MarkerTracking_3dTrans.java new file mode 100644 index 0000000..bf199a0 --- /dev/null +++ b/trunk/test/jp/nyatla/nyartoolkit/dev/tracking/MarkerTracking_3dTrans.java @@ -0,0 +1,329 @@ +package jp.nyatla.nyartoolkit.dev.tracking; + +import jp.nyatla.nyartoolkit.NyARException; +import jp.nyatla.nyartoolkit.core.NyARCode; +import jp.nyatla.nyartoolkit.core.squaredetect.Coord2Linear; +import jp.nyatla.nyartoolkit.core.squaredetect.INyARSquareContourDetector; +import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquare; +import jp.nyatla.nyartoolkit.core.types.*; +import jp.nyatla.nyartoolkit.core.types.matrix.NyARDoubleMatrix33; +import jp.nyatla.nyartoolkit.core.transmat.*; +import jp.nyatla.nyartoolkit.core.utils.NyARMath; +import jp.nyatla.nyartoolkit.core.match.NyARMatchPattDeviationColorData; +import jp.nyatla.nyartoolkit.core.match.NyARMatchPattResult; +import jp.nyatla.nyartoolkit.core.match.NyARMatchPatt_Color_WITHOUT_PCA; +import jp.nyatla.nyartoolkit.core.param.INyARCameraDistortionFactor; +import jp.nyatla.nyartoolkit.core.param.NyARParam; +import jp.nyatla.nyartoolkit.core.param.NyARPerspectiveProjectionMatrix; +import jp.nyatla.nyartoolkit.core.pickup.INyARColorPatt; +import jp.nyatla.nyartoolkit.core.raster.NyARBinRaster; +import jp.nyatla.nyartoolkit.core.raster.rgb.*; +import jp.nyatla.nyartoolkit.core.rasterfilter.rgb2bin.INyARRasterFilter_RgbToBin; + + + +public class MarkerTracking_3dTrans +{ + /** + * detectMarkerのコールバック関数 + */ + private class DetectSquareCB implements INyARSquareContourDetector.DetectMarkerCallback + { + //公開プロパティ + public NyARSquare square=new NyARSquare(); + public final MarkerPositionTable table; + public final MarkerTableOperator table_operator; + public NextFrameMarkerStack _nextframe; + private double _marker_width; + + //参照インスタンス + private INyARRgbRaster _ref_raster; + //所有インスタンス + private INyARColorPatt _inst_patt; + private NyARMatchPattDeviationColorData _deviation_data; + private NyARMatchPatt_Color_WITHOUT_PCA _match_patt; + private final NyARMatchPattResult __detectMarkerLite_mr=new NyARMatchPattResult(); + private Coord2Linear _coordline; + + private NyARPerspectiveProjectionMatrix _prjmat; + private INyARCameraDistortionFactor _dist; + public DetectSquareCB(INyARColorPatt i_inst_patt,NyARCode i_ref_code,NyARParam i_param,double i_marker_width) throws NyARException + { + this.table_operator=new MarkerTableOperator(i_param); + this.table=new MarkerPositionTable(10); + this._nextframe=new NextFrameMarkerStack(10); + this._marker_width=i_marker_width; + + + this._prjmat=i_param.getPerspectiveProjectionMatrix(); + this._dist=i_param.getDistortionFactor(); + + // + this._inst_patt=i_inst_patt; + this._deviation_data=new NyARMatchPattDeviationColorData(i_ref_code.getWidth(),i_ref_code.getHeight()); + this._coordline=new Coord2Linear(i_param.getScreenSize(),i_param.getDistortionFactor()); + this._match_patt=new NyARMatchPatt_Color_WITHOUT_PCA(i_ref_code); + return; + } + private NyARIntPoint2d[] __tmp_vertex=NyARIntPoint2d.createArray(4); + private NyARDoublePoint2d __tmp_point=new NyARDoublePoint2d(); + /** + * 矩形が見付かるたびに呼び出されます。 + * 発見した矩形のパターンを検査して、方位を考慮した頂点データを確保します。 + */ + public void onSquareDetect(INyARSquareContourDetector i_sender,int[] i_coordx,int[] i_coordy,int i_coor_num,int[] i_vertex_index) throws NyARException + { + //輪郭座標から頂点リストに変換 + NyARIntPoint2d[] vertex=this.__tmp_vertex; + vertex[0].x=i_coordx[i_vertex_index[0]]; + vertex[0].y=i_coordy[i_vertex_index[0]]; + vertex[1].x=i_coordx[i_vertex_index[1]]; + vertex[1].y=i_coordy[i_vertex_index[1]]; + vertex[2].x=i_coordx[i_vertex_index[2]]; + vertex[2].y=i_coordy[i_vertex_index[2]]; + vertex[3].x=i_coordx[i_vertex_index[3]]; + vertex[3].y=i_coordy[i_vertex_index[3]]; + + //マーカ中心を計算 + NyARDoublePoint2d new_center=this.__tmp_point; + new_center.x=(vertex[0].x+vertex[1].x+vertex[2].x+vertex[3].x)/4; + new_center.y=(vertex[0].y+vertex[1].y+vertex[2].y+vertex[3].y)/4; + //近所のマーカを探す。[Optimize:重複計算あり] + NextFrameMarkerStack.Item near_item=this.getNearItem(new_center);//[Optimize]見つけた矩形はリストから削除すべきだよね。 + if(near_item==null){ + //このマーカは未登録 + NyARMatchPattResult mr=this.__detectMarkerLite_mr; + + //画像を取得 + if (!this._inst_patt.pickFromRaster(this._ref_raster,vertex)){ + return; + } + //取得パターンをカラー差分データに変換して評価する。 + this._deviation_data.setRaster(this._inst_patt); + if(!this._match_patt.evaluate(this._deviation_data,mr)){ + return; + } + //現在の一致率より低ければ終了 + if (0.5 > mr.confidence){ + return; + } + //一致率の高い矩形があれば、方位を考慮して頂点情報を作成 + NyARSquare sq=this.square; + //directionを考慮して、squareを更新する。 + for(int i=0;i<4;i++){ + int idx=(i+4 - mr.direction) % 4; + this._coordline.coord2Line(i_vertex_index[idx],i_vertex_index[(idx+1)%4],i_coordx,i_coordy,i_coor_num,sq.line[i]); + } + for (int i = 0; i < 4; i++) { + //直線同士の交点計算 + if(!NyARLinear.crossPos(sq.line[i],sq.line[(i + 3) % 4],sq.sqvertex[i])){ + throw new NyARException();//ここのエラー復帰するならダブルバッファにすればOK + } + } + System.out.println("D:"+mr.direction); + //テーブルにマーカ情報を追加する。 + this.table_operator.insertMarker(this.table,sq,this._marker_width); + + }else{ + //このマーカは登録済。 + MarkerPositionTable.Item item=this.table.selectItem(near_item.oid); + //予想基準頂点に一番近い観測頂点インデクスを得る。 + int dir=getNearVertexIndex(near_item.vertex0,near_item.center,vertex,new_center); + + //一致率の高い矩形があれば、方位を考慮して頂点情報を作成 + NyARSquare sq=this.square; + //directionを考慮して、squareを更新する。 + for(int i=0;i<4;i++){ + int idx=(i+dir) % 4; + this._coordline.coord2Line(i_vertex_index[idx],i_vertex_index[(idx+1)%4],i_coordx,i_coordy,i_coor_num,sq.line[i]); + } + for (int i = 0; i < 4; i++) { + //直線同士の交点計算 + if(!NyARLinear.crossPos(sq.line[i],sq.line[(i + 3) % 4],sq.sqvertex[i])){ + throw new NyARException();//ここのエラー復帰するならダブルバッファにすればOK + } + } + this.table_operator.updateMarker(item,sq); + } + } + private int getNearVertexIndex(NyARDoublePoint2d i_base_vertex,NyARDoublePoint2d i_base_center,NyARIntPoint2d[] i_sq,NyARDoublePoint2d i_sqcenter) + { + double bx,by; + //観察座標の中央位置からのベクトル + bx=i_base_vertex.x-i_sqcenter.x; + by=i_base_vertex.y-i_sqcenter.y; + + //一番近い頂点を探す. + double d=NyARMath.sqNorm(bx,by,i_sq[3].x-i_sqcenter.x,i_sq[3].y-i_sqcenter.y); + int ret=3; + for(int i=2;i>=0;i--) + { + //予測座標の中央位置からのベクトルの長さを計算 + double d2=NyARMath.sqNorm(bx,by,i_sq[i].x-i_sqcenter.x,i_sq[i].y-i_sqcenter.y); + if(d2=0;i--) + { + if(items[i].is_empty){ + continue; + } + final NyARDoublePoint3d trans=items[i].trans; + //pos2dに中心座標を計算 + NextFrameMarkerStack.Item item=stack.prePush(); + item.oid=i; + prjmat.projectionConvert(trans,item.center);//[Optimaize!] + dist.ideal2Observ(item.center, item.center); + //方位決定のためにvertex0の計算[optimize! ここの計算関数すれば早くなる。] + final NyARDoublePoint3d offset=items[i].offset.vertex[0]; + rot.setZXYAngle(items[i].angle); + rot.transformVertex(offset,pos3d); + prjmat.projectionConvert(trans.x+pos3d.x,trans.y+pos3d.y,trans.z+pos3d.z,item.vertex0);//[Optimaize!] + dist.ideal2Observ(item.vertex0, item.vertex0); + //探索範囲の計算 + area.z=trans.z; + prjmat.projectionConvert(area,pos2d);//[Optimaize!] + dist.ideal2Observ(pos2d,pos2d); + item.dist=NyARMath.sqNorm(pos2d.x,pos2d.y,this._prjmat.m02,this._prjmat.m12)/2; + } + return; + } + + + + /** + * 2次元空間の指定点の一番近くにあるアイテムを探します。 + * @param i_table + * @param i_pos + * 探索点 + * @param i_limit_max + * 探索範囲の最大値 + * @return + */ + public NextFrameMarkerStack.Item getNearItem(NyARDoublePoint2d i_pos) + { + NextFrameMarkerStack.Item[] items=this._nextframe.getArray(); + + double d=Double.MAX_VALUE; + //エリア + int index=-1; + for(int i=this._nextframe.getLength()-1;i>=0;i--) + { + NyARDoublePoint2d center=items[i].center; + double nd=NyARMath.sqNorm(i_pos, center); + //有効範囲内? + if(nd>items[i].dist){ + continue; + } + if(d>nd){ + d=nd; + index=i; + } + } + return index==-1?null:items[index]; + } + } + private INyARSquareContourDetector _square_detect; + protected INyARTransMat _transmat; + //画処理用 + private NyARBinRaster _bin_raster; + protected INyARRasterFilter_RgbToBin _tobin_filter; + private DetectSquareCB _detect_cb; + + public IntRectStack _next_marker; + public TransMat2MarkerRect _estimator; + + + protected MarkerTracking_3dTrans() + { + return; + } + protected void initInstance( + INyARColorPatt i_patt_inst, + INyARSquareContourDetector i_sqdetect_inst, + INyARTransMat i_transmat_inst, + INyARRasterFilter_RgbToBin i_filter, + NyARParam i_ref_param, + NyARCode i_ref_code, + double i_marker_width) throws NyARException + { + final NyARIntSize scr_size=i_ref_param.getScreenSize(); + // 解析オブジェクトを作る + this._square_detect = i_sqdetect_inst; + this._transmat = i_transmat_inst; + this._tobin_filter=i_filter; + // 比較コードを保存 + //2値画像バッファを作る + this._bin_raster=new NyARBinRaster(scr_size.w,scr_size.h); + //_detect_cb + this._detect_cb=new DetectSquareCB(i_patt_inst,i_ref_code,i_ref_param,i_marker_width); + this._next_marker=new IntRectStack(10); + this._estimator=new TransMat2MarkerRect(i_ref_param); + return; + } + /** + * i_imageにマーカー検出処理を実行し、結果を記録します。 + * + * @param i_raster + * マーカーを検出するイメージを指定します。イメージサイズは、カメラパラメータ + * と一致していなければなりません。 + * @return マーカーが検出できたかを真偽値で返します。 + * @throws NyARException + */ + public int detectMarkerLite(INyARRgbRaster i_raster) throws NyARException + { + //サイズチェック + if(!this._bin_raster.getSize().isEqualSize(i_raster.getSize())){ + throw new NyARException(); + } + + //ラスタを2値イメージに変換する. + this._tobin_filter.doFilter(i_raster,this._bin_raster); + + //コールバックハンドラの準備 + this._detect_cb.init(i_raster); + //矩形を探す(戻り値はコールバック関数で受け取る。) + this._square_detect.detectMarkerCB(this._bin_raster,_detect_cb); + //時間を進める。 + this._detect_cb.table_operator.updateTick(this._detect_cb.table); + + //矩形位置の予想 + this._next_marker.clear(); + this._estimator.convert(this._detect_cb.table.selectAllItems(), this._next_marker); + return -1; + } + public Object[] _probe() + { + Object[] ret=new Object[10]; + ret[0]=this._detect_cb.table; + ret[1]=this._next_marker; + ret[2]=this._detect_cb._nextframe; + return ret; + } +} \ No newline at end of file diff --git a/trunk/test/jp/nyatla/nyartoolkit/dev/tracking/NextFrameMarkerStack.java b/trunk/test/jp/nyatla/nyartoolkit/dev/tracking/NextFrameMarkerStack.java new file mode 100644 index 0000000..1f19b81 --- /dev/null +++ b/trunk/test/jp/nyatla/nyartoolkit/dev/tracking/NextFrameMarkerStack.java @@ -0,0 +1,31 @@ +package jp.nyatla.nyartoolkit.dev.tracking; + +import jp.nyatla.nyartoolkit.NyARException; +import jp.nyatla.nyartoolkit.core.types.*; +import jp.nyatla.nyartoolkit.core.types.stack.NyObjectStack; + +public class NextFrameMarkerStack extends NyObjectStack +{ + public class Item + { + public int oid; + public NyARDoublePoint2d center=new NyARDoublePoint2d(); + public NyARDoublePoint2d vertex0=new NyARDoublePoint2d(); + /** + * 探索距離 + */ + public double dist; + + + } + protected NextFrameMarkerStack.Item createElement() + { + return new NextFrameMarkerStack.Item(); + } + public NextFrameMarkerStack(int i_length) throws NyARException + { + super(i_length,NextFrameMarkerStack.Item.class); + return; + } + +} \ No newline at end of file diff --git a/trunk/test/jp/nyatla/nyartoolkit/dev/tracking/NyARDataTable.java b/trunk/test/jp/nyatla/nyartoolkit/dev/tracking/NyARDataTable.java new file mode 100644 index 0000000..5e68c24 --- /dev/null +++ b/trunk/test/jp/nyatla/nyartoolkit/dev/tracking/NyARDataTable.java @@ -0,0 +1,30 @@ +package jp.nyatla.nyartoolkit.dev.tracking; + +import java.lang.reflect.Array; + +public abstract class NyARDataTable +{ + protected TItem[] _items; + /** + * アイテムすべてを選択します。 + * @return + */ + public final TItem[] selectAllItems() + { + return this._items; + } + public final TItem selectItem(int i_oid) + { + return this._items[i_oid]; + } + @SuppressWarnings("unchecked") + protected void initTable(int i_size,Class i_elemtype) + { + this._items=(TItem[])Array.newInstance(i_elemtype, i_size); + for(int i=0;i=0;i--) + { + MarkerPositionTable.Item item=i_positions[i]; + //空の項目をパス + if(item.is_empty){ + continue; + } + //変換行列を計算 + rot.setZXYAngle(item.angle); + + //4vertexの2次元座標を計算して、それらを内包する矩形を計算する。 + //[optimize]矩形予測と計算かぶってるよ。 + int n; + int l,t,r,b; + int i2=4-1; + //[3]の座標変換と射影変換、歪み逆補正 + rot.transformVertex(item.offset.vertex[i2], pos); + pos.x+=item.trans.x; + pos.y+=item.trans.y; + pos.z+=item.trans.z; + prjmat.projectionConvert(pos,pos2d); + dist.ideal2Observ(pos2d, pos2d); + l=r=(int)pos2d.x; + t=b=(int)pos2d.y; + i2--; + for(;i2>=0;i2--){ + //[i2]の座標変換と射影変換、歪み逆補正 + rot.transformVertex(item.offset.vertex[i2], pos); + pos.x+=item.trans.x; + pos.y+=item.trans.y; + pos.z+=item.trans.z; + prjmat.projectionConvert(pos,pos2d); + dist.ideal2Observ(pos2d, pos2d); + n=(int)pos2d.x; + if(l>n){ + l=n; + }else if(rn){ + t=n; + }else if(b=0;i2--){ + //[i2]の座標変換と射影変換、歪み逆補正 + rot.transformVertex(i_positions.offset.vertex[i2], pos); + pos.x+=i_positions.trans.x; + pos.y+=i_positions.trans.y; + pos.z+=i_positions.trans.z; + prjmat.projectionConvert(pos,pos2d); + dist.ideal2Observ(pos2d, pos2d); + n=(int)pos2d.x; + if(l>n){ + l=n; + }else if(rn){ + t=n; + }else if(b