jp.nyatla.nyar4psg
クラス NyARBoard

java.lang.Object
  上位を拡張 jp.nyatla.nyar4psg.NyARBoard

public class NyARBoard
extends java.lang.Object

このクラスは、PImageからARToolKit準拠の変換行列を求めるクラスです。 マーカを1枚の板に見立てて、そこを中心にした座標系を計算します。 同時検出可能なマーカは1種類、1個です。

 NyARBoardは、2つの外部設定ファイル"マーカファイル"と"カメラパラメータ"ファイルを必要とします。
 これらはARToolKitのものと互換性があります。
 これらはスケッチのdataディレクトリ以下に配置をして下さい。(exampleを見てください。)
 

EN: This class calculate a ARToolKit base transformation matrix from PImage. This class handles one marker, and calculates the transformation matrix that displays the object above the marker.
 NyARBoard needs two external configuration file "Marker file" and "Camera parameter" files.
 These are compatible with the original ARToolKit. 
 Place those files to under the data directory of the sketch. (see example.)
 

JP:

作成者:
nyatla

フィールドの概要
 processing.core.PVector angle
          マーカのx,y,zの傾き角度です。
 double cfThreshold
          マーカの座標変換を行う閾値。
 double confidence
          検出したマーカの一致度です。
static int CS_LEFT
          LeftHand座標系であることを示します。
static int CS_RIGHT
          RightHand座標系であることを示します。
 int gsThreshold
          マーカ検出時のグレースケール閾値を指定します。
 int lostCount
          連続でマーカを見失った回数。
 int lostDelay
          消失遅延数。
 int[][] pos2d
          検出したマーカの4隅の2次元画像上の位置です。
 double[] projection
          OpenGLスタイルのProjectionMatrixです。
 processing.core.PVector trans
          マーカのx,y,zの平行移動量です。
 double[] transmat
          検出したマーカの変換行列です。
 java.lang.String VERSION
          バージョン文字列です。
 
コンストラクタの概要
NyARBoard(processing.core.PApplet parent, int i_width, int i_height, java.lang.String i_cparam, java.lang.String i_patt, int i_patt_width)
          この関数はi_projection_coord_systemにCS_LEFTを設定するコンストラクタです。
NyARBoard(processing.core.PApplet parent, int i_width, int i_height, java.lang.String i_cparam, java.lang.String i_patt, int i_patt_width, int i_projection_coord_system)
          この関数はコンストラクタです。
 
メソッドの概要
 void beginTransform(processing.opengl.PGraphicsOpenGL i_pgl)
          座標変換を実行したMatrixを準備します。
 boolean detect(processing.core.PImage i_image)
          i_imageから最も一致度の高いマーカを検出し、cfThreshold以上の一致度であれば、 pos2d,angle,trans,confidence,transmatのプロパティを更新します。
 void endTransform()
          beginTransformによる座標変換を解除して元に戻します。
 
クラス java.lang.Object から継承されたメソッド
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

フィールドの詳細

lostDelay

public int lostDelay
消失遅延数。マーカ消失後、指定回数は過去の情報を維持します。 値は0以上であること。
EN: NyARBoard ignores that it lost the marker while under specified number. Must be "n>=0".


lostCount

public int lostCount
連続でマーカを見失った回数。この値は0EN: It is a number in which it continuously lost the marker. This value range is "0<n<lostDelay"


cfThreshold

public double cfThreshold
マーカの座標変換を行う閾値。0.0<n<1.0の値をとります。 この数値より一致度が大きい場合のみ、マーカを検出したと判定され、座標計算が行われます。
EN: The threshold value of marker pattern confidence. This value range is "0.0<n<1.0". When marker confidence is larger than this value, NyARBoard detects the marker.


confidence

public double confidence
検出したマーカの一致度です。
EN: The confidence value of detected marker.


gsThreshold

public int gsThreshold
マーカ検出時のグレースケール閾値を指定します。この値は、0<=n<=255をります。
EN: The threshold value of labeling process from gray scale image. This value range is "0<=n<=255".


angle

public processing.core.PVector angle
マーカのx,y,zの傾き角度です。
EN: The angle value in radian unit of "x,y,z" .


trans

public processing.core.PVector trans
マーカのx,y,zの平行移動量です。
EN: The translation value in radian unit of "x,y,z".


pos2d

public int[][] pos2d
検出したマーカの4隅の2次元画像上の位置です。
EN: The position of 4 corner of marker.


transmat

public double[] transmat
検出したマーカの変換行列です。
EN: The transform matrix of detected marker.


CS_RIGHT

public static final int CS_RIGHT
RightHand座標系であることを示します。 この値はコンストラクタで使います。
EN: -

関連項目:
定数フィールド値

CS_LEFT

public static final int CS_LEFT
LeftHand座標系であることを示します。 この値はコンストラクタで使います。
EN: -

関連項目:
定数フィールド値

VERSION

public final java.lang.String VERSION
バージョン文字列です。
EN: version string.

関連項目:
定数フィールド値

projection

public final double[] projection
OpenGLスタイルのProjectionMatrixです。
EN: OpenGL form projection matrix.

コンストラクタの詳細

NyARBoard

public NyARBoard(processing.core.PApplet parent,
                 int i_width,
                 int i_height,
                 java.lang.String i_cparam,
                 java.lang.String i_patt,
                 int i_patt_width,
                 int i_projection_coord_system)
この関数はコンストラクタです。
EN: This function is constructor.

パラメータ:
parent - processingのインスタンスをしていします。
EN: Specify processing instance.
i_width - detect()に渡す入力画像の幅を指定します。
EN: Width of source image size for "detect()".
i_htight - detectに渡す入力画像の高さを指定します。
EN: Height of source image size for "detect()".
i_cparam - ARToolKitのパラメータファイル名を指定します。パラメータファイルはdataディレクトリにおいて下さい。
EN: The file name of the camera parameter of ARToolKit format. Place the file to "data" directory at sketch.
i_patt - マーカのパターンファイル名を指定します。パターンファイルは、dataディレクトリにおいて下さい。 マーカの解像度は、16x16である必要があります。
EN: The file name of the marker pattern file of ARToolkit. Place the file to "data" directory at sketch. The marker resolution must be 16x16.
i_patt_width - マーカのサイズを指定します。単位はmmです。
EN: The length of one side of a square marker in millimeter unit.
i_projection_coord_system - Projection Matrixの座標系を指定します。NyARBoard.CS_RIGHT か NyARBoard.Left(規定値)を指定します。
EN: Coordinate system flag of projection Matrix. Should be NyARBoard.CS_RIGHT or NyARBoard.Left(default)

NyARBoard

public NyARBoard(processing.core.PApplet parent,
                 int i_width,
                 int i_height,
                 java.lang.String i_cparam,
                 java.lang.String i_patt,
                 int i_patt_width)
この関数はi_projection_coord_systemにCS_LEFTを設定するコンストラクタです。
EN: This function is constructor same as i_projection_coord_system=CS_LEFT.

パラメータ:
parent - processingのインスタンスを指定します。
EN: Specify processing instance.
i_width - detect()に渡す入力画像の幅を指定します。
EN: Width of source image size for "detect()".
i_htight - detectに渡す入力画像の高さを指定します。
EN: Height of source image size for "detect()".
i_cparam - ARToolKitのパラメータファイル名を指定します。パラメータファイルはdataディレクトリにおいて下さい。
EN: The file name of the camera parameter of ARToolKit format. Place the file to "data" directory at sketch.
i_patt - マーカのパターンファイル名を指定します。パターンファイルは、dataディレクトリにおいて下さい。 マーカの解像度は、16x16である必要があります。
EN: The file name of the marker pattern file of ARToolkit. Place the file to "data" directory at sketch. The marker resolution must be 16x16.
i_patt_width - マーカのサイズを指定します。単位はmmです。
EN: The length of one side of a square marker in millimeter unit.
メソッドの詳細

detect

public boolean detect(processing.core.PImage i_image)
i_imageから最も一致度の高いマーカを検出し、cfThreshold以上の一致度であれば、 pos2d,angle,trans,confidence,transmatのプロパティを更新します。
EN: This function detect a marker which is must higher confidence in i_image. When function detects marker, properties (pos2d,angle,trans,confidence,transmat) are updated.

パラメータ:
i_image - 検出するイメージを設定します。
EN: Specify source image.
戻り値:
マーカが検出され、有効な値が得られればTRUEを返します。 TRUEであれば、プロパティが更新されています。
EN: TRUE if marker found;otherwise FALSE.

beginTransform

public void beginTransform(processing.opengl.PGraphicsOpenGL i_pgl)
座標変換を実行したMatrixを準備します。 この関数を実行すると、processingの座標系がマーカ表面に設定されます。 描画終了後には、必ずendTransform関数を呼び出して座標系を戻してください。
EN: This function sets corresponding transform matrix to the surface of the marker to OpenGL. The coordinate system of processing moves to the surface of the marker when this function is executed. Must return the coordinate system by using endTransform function at the end.

パラメータ:
i_pgl - PGraphicsOpenGLインスタンスを設定します。processingのgメンバをキャストして設定してください。
EN: Specify PGraphicsOpenGL instance. Set cast "g" member of processing graphics object.

endTransform

public void endTransform()
beginTransformによる座標変換を解除して元に戻します。
EN: This function recover coordinate system that was changed by beginTransform function.