import jp.nyatla.nyartoolkit.core.types.NyARIntSize;\r
import jp.nyatla.nyartoolkit.core.rasterfilter.rgb2bin.*;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.*;\r
\r
/**\r
* 画像からARCodeに最も一致するマーカーを1個検出し、その変換行列を計算するクラスです。\r
* \r
*/\r
public class NyARCustomSingleDetectMarker\r
-{\r
+{ \r
private static final int AR_SQUARE_MAX = 100;\r
\r
private boolean _is_continue = false;\r
protected INyARRasterFilter_RgbToBin _tobin_filter;\r
\r
private NyARMatchPattDeviationColorData _deviation_data;\r
- /**\r
- * 検出するARCodeとカメラパラメータから、1個のARCodeを検出するNyARSingleDetectMarkerインスタンスを作ります。\r
- * \r
- * @param i_param\r
- * カメラパラメータを指定します。\r
- * @param i_code\r
- * 検出するARCodeを指定します。\r
- * @param i_marker_width\r
- * ARコードの物理サイズを、ミリメートルで指定します。\r
- * @param i_filter\r
- * RGB→BIN変換フィルタを指定します。\r
- * @throws NyARException\r
- */\r
- public NyARCustomSingleDetectMarker(NyARParam i_param, NyARCode i_code, double i_marker_width,INyARRasterFilter_RgbToBin i_filter) throws NyARException\r
+\r
+ protected NyARCustomSingleDetectMarker()\r
+ {\r
+ return;\r
+ }\r
+ protected void initInstance(\r
+ INyARColorPatt i_patt_inst,\r
+ INyARSquareDetector i_sqdetect_inst,\r
+ INyARRasterFilter_RgbToBin i_filter,\r
+ NyARParam i_ref_param,\r
+ NyARCode i_ref_code,\r
+ double i_marker_width) throws NyARException\r
{\r
- final NyARIntSize scr_size=i_param.getScreenSize(); \r
+ final NyARIntSize scr_size=i_ref_param.getScreenSize(); \r
// 解析オブジェクトを作る\r
- this._square_detect = new NyARSquareDetector(i_param.getDistortionFactor(),scr_size);\r
- this._transmat = new NyARTransMat(i_param);\r
+ this._square_detect = i_sqdetect_inst;\r
+ this._transmat = new NyARTransMat(i_ref_param);\r
+ this._tobin_filter=i_filter;\r
// 比較コードを保存\r
this._marker_width = i_marker_width;\r
//パターンピックアップを作成\r
-// this._patt = new NyARColorPatt_O1(i_code.getWidth(), i_code.getHeight());\r
- this._patt = new NyARColorPatt_O3(i_code.getWidth(), i_code.getHeight());\r
-// this._patt = new NyARColorPatt_Perspective(i_code.getWidth(), i_code.getHeight(),25);\r
+ this._patt = i_patt_inst;\r
//取得パターンの差分データ器を作成\r
- this._deviation_data=new NyARMatchPattDeviationColorData(i_code.getWidth(),i_code.getHeight());\r
+ this._deviation_data=new NyARMatchPattDeviationColorData(i_ref_code.getWidth(),i_ref_code.getHeight());\r
//i_code用の評価器を作成\r
- this._match_patt = new NyARMatchPatt_Color_WITHOUT_PCA(i_code);\r
- \r
+ this._match_patt = new NyARMatchPatt_Color_WITHOUT_PCA(i_ref_code);\r
//2値画像バッファを作る\r
this._bin_raster=new NyARBinRaster(scr_size.w,scr_size.h);\r
- this._tobin_filter=i_filter;\r
return;\r
+ \r
}\r
\r
private final NyARMatchPattResult __detectMarkerLite_mr=new NyARMatchPattResult();\r
\r
//ラスタを2値イメージに変換する.\r
this._tobin_filter.doFilter(i_raster,this._bin_raster);\r
- \r
- \r
+\r
+ \r
this._detected_square = null;\r
NyARSquareStack l_square_list = this._square_list;\r
// スクエアコードを探す\r
double confidence = 0;\r
for(int i=0;i<number_of_square;i++){\r
// 評価基準になるパターンをイメージから切り出す\r
- if (!this._patt.pickFromRaster(i_raster, (NyARSquare)l_square_list.getItem(i))){\r
+ if (!this._patt.pickFromRaster(i_raster, l_square_list.getItem(i))){\r
continue;\r
}\r
//取得パターンをカラー差分データに変換して評価する。\r
}\r
\r
// マーカー情報を保存\r
- this._detected_square = (NyARSquare)l_square_list.getItem(square_index);\r
+ this._detected_square = l_square_list.getItem(square_index);\r
this._detected_direction = direction;\r
this._detected_confidence = confidence;\r
return result;\r