/*
* PROJECT: NyARToolkitAS3
* --------------------------------------------------------------------------------
* 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 NyARToolkitAS3 is AS3 edition ARToolKit class library.
* Copyright (C)2010 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.nyartoolkit.as3.detector
{
import jp.nyatla.nyartoolkit.as3.core.param.*;
import jp.nyatla.nyartoolkit.as3.core.*;
import jp.nyatla.nyartoolkit.as3.*;
import jp.nyatla.nyartoolkit.as3.core.transmat.*;
import jp.nyatla.nyartoolkit.as3.core.squaredetect.*;
import jp.nyatla.nyartoolkit.as3.core.rasterfilter.rgb2bin.*;
import jp.nyatla.nyartoolkit.as3.core.raster.*;
import jp.nyatla.nyartoolkit.as3.core.raster.rgb.*;
import jp.nyatla.nyartoolkit.as3.core.types.*;
import jp.nyatla.nyartoolkit.as3.core.pickup.*;
/**
* 複数のマーカーを検出し、それぞれに最も一致するARコードを、コンストラクタで登録したARコードから 探すクラスです。最大300個を認識しますが、ゴミラベルを認識したりするので100個程度が限界です。
*
*/
public class NyARDetectMarker
{
private var _detect_cb:NyARDetectSquareCB;
public static const AR_SQUARE_MAX:int = 300;
private var _is_continue:Boolean = false;
private var _square_detect:NyARSquareContourDetector;
protected var _transmat:INyARTransMat;
private var _offset:Vector.;
/**
* 複数のマーカーを検出し、最も一致するARCodeをi_codeから検索するオブジェクトを作ります。
*
* @param i_param
* カメラパラメータを指定します。
* @param i_code
* 検出するマーカーのARCode配列を指定します。
* 配列要素のインデックス番号が、そのままgetARCodeIndex関数で得られるARCodeインデックスになります。
* 例えば、要素[1]のARCodeに一致したマーカーである場合は、getARCodeIndexは1を返します。
* @param i_marker_width
* i_codeのマーカーサイズをミリメートルで指定した配列を指定します。 先頭からi_number_of_code個の要素には、有効な値を指定する必要があります。
* @param i_number_of_code
* i_codeに含まれる、ARCodeの数を指定します。
* @param i_input_raster_type
* 入力ラスタのピクセルタイプを指定します。この値は、INyARBufferReaderインタフェイスのgetBufferTypeの戻り値を指定します。
* @throws NyARException
*/
public function NyARDetectMarker(i_param:NyARParam, i_code:Vector., i_marker_width:Vector., i_number_of_code:int, i_input_raster_type:int)
{
initInstance(i_param,i_code,i_marker_width,i_number_of_code,i_input_raster_type);
return;
}
protected function initInstance(
i_ref_param:NyARParam,
i_ref_code:Vector.,
i_marker_width:Vector.,
i_number_of_code:int,
i_input_raster_type:int):void
{
var scr_size:NyARIntSize=i_ref_param.getScreenSize();
// 解析オブジェクトを作る
var cw:int = i_ref_code[0].getWidth();
var ch:int = i_ref_code[0].getHeight();
//detectMarkerのコールバック関数
this._detect_cb=new NyARDetectSquareCB(
new NyARColorPatt_Perspective_O2(cw, ch,4,25),
i_ref_code,i_number_of_code,i_ref_param);
this._transmat = new NyARTransMat(i_ref_param);
//NyARToolkitプロファイル
this._square_detect =new NyARSquareContourDetector_Rle(i_ref_param.getScreenSize());
this._tobin_filter=new NyARRasterFilter_ARToolkitThreshold(100,i_input_raster_type);
//実サイズ保存
this._offset = NyARRectOffset.createArray(i_number_of_code);
for(var i:int=0;i