import jp.nyatla.nyartoolkit.core.transmat.*;\r
import jp.nyatla.nyartoolkit.core.types.NyARIntSize;\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
+import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquareStack;\r
\r
\r
/**\r
\r
private final NyARSquareStack _square_list = new NyARSquareStack(AR_SQUARE_MAX);\r
\r
- private NyARCode _code;\r
-\r
protected INyARTransMat _transmat;\r
\r
private double _marker_width;\r
* ARコードの物理サイズを、ミリメートルで指定します。\r
* @throws NyARException\r
*/\r
- public NyARSingleDetectMarker_X2(NyARParam i_param, NyARCode i_code, double i_marker_width) throws NyARException\r
+ public NyARSingleDetectMarker_X2(NyARParam i_param, NyARCode i_code, double i_marker_width,int i_raster_type) throws NyARException\r
{\r
final NyARIntSize scr_size=i_param.getScreenSize(); \r
- final NyARFixedFloatObserv2IdealMap dist_map = new NyARFixedFloatObserv2IdealMap(i_param.getDistortionFactor(), scr_size);\r
- \r
// 解析オブジェクトを作る\r
- this._square_detect = new NyARSquareDetector_X2(dist_map,scr_size);\r
+ this._square_detect = new NyARSquareDetector_X2(i_param.getDistortionFactor(),scr_size);\r
this._transmat = new NyARTransMat_X2(i_param);\r
- // 比較コードを保存\r
- this._code = i_code;\r
this._marker_width = i_marker_width;\r
+ int cw=i_code.getWidth();\r
+ int ch=i_code.getHeight();\r
// 評価パターンのホルダを作る\r
- this._patt = new NyARColorPatt_O3(_code.getWidth(), _code.getHeight());\r
+ this._patt = new NyARColorPatt_O3(cw,ch);\r
// 評価器を作る。\r
- this._match_patt = new NyARMatchPatt_Color_WITHOUT_PCA();\r
+ this._match_patt = new NyARMatchPatt_Color_WITHOUT_PCA(i_code);\r
//2値画像バッファを作る\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
return;\r
}\r
\r
private NyARBinRaster _bin_raster;\r
- private NyARRasterFilter_ARToolkitThreshold _tobin_filter=new NyARRasterFilter_ARToolkitThreshold(100);\r
+ private NyARRasterFilter_ARToolkitThreshold _tobin_filter;\r
+ private final NyARMatchPattResult __detectMarkerLite_mr=new NyARMatchPattResult();\r
+ private NyARMatchPattDeviationColorData _deviation_data;\r
\r
\r
/**\r
if (number_of_square < 1) {\r
return false;\r
}\r
-\r
- // 評価基準になるパターンをイメージから切り出す\r
- if (!this._patt.pickFromRaster(i_raster, (NyARSquare)l_square_list.getItem(0))) {\r
- // パターンの切り出しに失敗\r
- return false;\r
- }\r
- // パターンを評価器にセット\r
- if (!this._match_patt.setPatt(this._patt)) {\r
- // 計算に失敗した。\r
- throw new NyARException();\r
- }\r
- // コードと比較する\r
- this._match_patt.evaluate(this._code);\r
+ boolean result=false;\r
+ NyARMatchPattResult mr=this.__detectMarkerLite_mr;\r
int square_index = 0;\r
- int direction = this._match_patt.getDirection();\r
- double confidence = this._match_patt.getConfidence();\r
- for (int i = 1; i < number_of_square; i++) {\r
- // 次のパターンを取得\r
- this._patt.pickFromRaster(i_raster, (NyARSquare)l_square_list.getItem(i));\r
- // 評価器にセットする。\r
- this._match_patt.setPatt(this._patt);\r
- // コードと比較する\r
- this._match_patt.evaluate(this._code);\r
- double c2 = this._match_patt.getConfidence();\r
+ int direction = NyARSquare.DIRECTION_UNKNOWN;\r
+ double confidence = 0;\r
+ for(int i=0;i<number_of_square;i++){\r
+ // 評価基準になるパターンをイメージから切り出す\r
+ if (!this._patt.pickFromRaster(i_raster, l_square_list.getItem(i))){\r
+ continue;\r
+ }\r
+ //取得パターンをカラー差分データに変換して評価する。\r
+ this._deviation_data.setRaster(this._patt);\r
+ this._match_patt.evaluate(this._deviation_data,mr);\r
+\r
+ final double c2 = mr.confidence;\r
if (confidence > c2) {\r
continue;\r
}\r
// もっと一致するマーカーがあったぽい\r
square_index = i;\r
- direction = this._match_patt.getDirection();\r
+ direction = mr.direction;\r
confidence = c2;\r
+ result=true;\r
}\r
+ \r
// マーカー情報を保存\r
this._detected_square = (NyARSquare)l_square_list.getItem(square_index);\r
this._detected_direction = direction;\r
this._detected_confidence = confidence;\r
- return true;\r
+ return result;\r
}\r
\r
/**\r