チェンジセット 1743
- コミット日時:
- 2008/10/29 02:02:15 (2 ヶ月前)
- ファイル:
-
- as3/FLARToolKit/trunk/samples/org/tarotaro/flash/ar/layers/FLARMultiMarkerLayer.as (更新) (5 diffs)
- as3/FLARToolKit/trunk/src/org/libspark/flartoolkit/detector/CubeMarkerDetector.as (追加)
- as3/FLARToolKit/trunk/src/org/libspark/flartoolkit/detector/FLARMultiMarkerDetector.as (更新) (7 diffs)
- as3/FLARToolKit/trunk/src/org/libspark/flartoolkit/detector/FLARMultiMarkerDetectorResult.as (追加)
- as3/FLARToolKit/trunk/src/org/libspark/flartoolkit/detector/FLARMultiMarkerDetectorResultHolder.as (追加)
凡例:
- 変更無し
- 追加
- 削除
- 更新
- コピー
- 移動
as3/FLARToolKit/trunk/samples/org/tarotaro/flash/ar/layers/FLARMultiMarkerLayer.as
r1739 r1743 38 38 import org.libspark.flartoolkit.core.raster.rgb.IFLARRgbRaster; 39 39 import org.libspark.flartoolkit.core.transmat.FLARTransMatResult; 40 import org.libspark.flartoolkit.detector.FLARMultiMarkerDetector; 40 import org.libspark.flartoolkit.detector.CubeMarkerDetector; 41 import org.libspark.flartoolkit.detector.FLARMultiMarkerDetectorResult; 41 42 42 43 /** … … 46 47 public class FLARMultiMarkerLayer extends FLARLayer 47 48 { 48 protected var _detector: FLARMultiMarkerDetector;49 protected var _detector:CubeMarkerDetector; 49 50 protected var _resultMat:FLARTransMatResult; 50 51 protected var _confidence:Number; … … 61 62 { 62 63 super(src, thresh); 63 this._detector = new FLARMultiMarkerDetector(param, codeList, markerWidthList, codeList.length); 64 this._detector = new CubeMarkerDetector(param, codeList, markerWidthList, codeList.length); 65 this._detector.sizeCheckEnabled = false; 64 66 this._resultMat = new FLARTransMatResult(); 65 67 this._confidence = confidence; … … 71 73 g.clear(); 72 74 73 var numDetected:int = this._detector.detectMarkerLite(this._source, this._thresh); 74 75 if (numDetected > 0) { 76 trace(numDetected); 77 for (var i:uint = 0; i < numDetected; i++) { 78 var r:Object = this._detector.getResult(i); 75 //var numDetected:int = this._detector.detectMarkerLite(this._source, this._thresh); 76 var r:FLARMultiMarkerDetectorResult = this._detector.detectMarkerLite(this._source, this._thresh); 77 if (r != null) { 78 //if (numDetected > 0) { 79 //trace(numDetected); 80 //for (var i:uint = 0; i < numDetected; i++) { 81 //var r:FLARMultiMarkerDetectorResult = this._detector.getResult(i); 79 82 trace(r.codeId,":",r.confidence); 80 if (r.confidence <= this._confidence) {81 continue;82 }83 //if (r.confidence <= this._confidence) { 84 //continue; 85 //} 83 86 var v:Array = r.square.sqvertex; 84 87 g.lineStyle(2, colors[r.codeId]); … … 87 90 g.lineTo(v[vi].x, v[vi].y); 88 91 } 89 }92 //} 90 93 } 91 94 } as3/FLARToolKit/trunk/src/org/libspark/flartoolkit/detector/FLARMultiMarkerDetector.as
r1731 r1743 51 51 52 52 /** 53 * 複数のマーカーを検出し、それぞれに最も一致するARコードを、コンストラクタで登録したARコードから 探すクラスです。最大300個を認識しますが、ゴミラベルを認識したりするので100個程度が限界です。 53 * 複数のマーカーを検出し、それぞれに最も一致するARコードを、コンストラクタで登録したARコードから 探すクラスです。 54 * 最大300個を認識しますが、ゴミラベルを認識したりするので100個程度が限界です。 54 55 * 55 56 */ … … 57 58 58 59 private static const AR_SQUARE_MAX:int = 300; 60 private var _sizeCheckEnabled:Boolean = true; 59 61 60 62 private var _is_continue:Boolean = false; … … 138 140 public function detectMarkerLite(i_raster:IFLARRgbRaster, i_threshold:int):int { 139 141 // サイズチェック 140 //trace(this._bin_raster.getSize().w, i_raster.getSize().w); 141 //if (!this._bin_raster.getSize().isEqualSizeO(i_raster.getSize())) { 142 //throw new FLARException(); 143 //} 142 if(this._sizeCheckEnabled && !this._bin_raster.getSize().isEqualSizeO(i_raster.getSize())) { 143 throw new FLARException(); 144 } 144 145 145 146 // ラスタを2値イメージに変換する. … … 185 186 confidence = _match_patt.getConfidence(); 186 187 direction = _match_patt.getDirection(); 188 trace(i,0, confidence,"(",square.label.area,")"); 187 189 for (i2 = 1;i2 < this._number_of_code; i2++) { 188 190 // コードと比較する 189 191 _match_patt.evaluate(_codes[i2]); 190 192 c2 = _match_patt.getConfidence(); 193 trace(i, i2, c2,"(",square.label.area,")"); 191 194 if (confidence > c2) { 192 195 continue; … … 199 202 // i番目のパターン情報を保存する。 200 203 var result:FLARMultiMarkerDetectorResult = this._result_holder.result_array[i]; 201 result. arcode_id = code_index;202 result. confidence = confidence;203 result. direction = direction;204 result. ref_square = square;204 result._codeId = code_index; 205 result._confidence = confidence; 206 result._direction = direction; 207 result._square = square; 205 208 } 206 209 return number_of_square; … … 220 223 // 一番一致したマーカーの位置とかその辺を計算 221 224 if (_is_continue) { 222 _transmat.transMatContinue(result. ref_square, result.direction, _marker_width[result.arcode_id], o_result);225 _transmat.transMatContinue(result.square, result.direction, _marker_width[result.codeId], o_result); 223 226 } else { 224 _transmat.transMat(result. ref_square, result.direction, _marker_width[result.arcode_id], o_result);227 _transmat.transMat(result.square, result.direction, _marker_width[result.codeId], o_result); 225 228 } 226 229 return; 227 230 } 228 231 229 public function getResult(i_index:int): Object232 public function getResult(i_index:int):FLARMultiMarkerDetectorResult 230 233 { 231 const result:FLARMultiMarkerDetectorResult = this._result_holder.result_array[i_index]; 232 var ret:Object = new Object(); 233 ret.square = result.ref_square; 234 ret.codeId = result.arcode_id; 235 ret.confidence = result.confidence; 236 return ret; 234 return this._result_holder.result_array[i_index]; 237 235 } 238 236 /** … … 279 277 this._is_continue = i_is_continue; 280 278 } 279 280 /** 281 * 入力画像のサイズチェックをする/しない的な。(デフォルトではチェックする) 282 */ 283 public function get sizeCheckEnabled():Boolean { 284 return this._sizeCheckEnabled; 285 } 286 public function set sizeCheckEnabled(value:Boolean):void { 287 this._sizeCheckEnabled = value; 288 } 289 281 290 } 282 291 } 283 292 284 import org.libspark.flartoolkit.core.FLARSquare; 285 286 class FLARMultiMarkerDetectorResult { 287 288 public var arcode_id:int; 289 290 public var direction:int; 291 292 public var confidence:Number; 293 294 public var ref_square:FLARSquare; 295 } 296 297 class FLARMultiMarkerDetectorResultHolder { 298 299 public var result_array:Array = new Array(1); //new FLARMultiMarkerDetectorResult[1]; // FLARMultiMarkerDetectorResult[] 300 301 /** 302 * result_holderを最大i_reserve_size個の要素を格納できるように予約します。 303 * 304 * @param i_reserve_size 305 */ 306 public function reservHolder(i_reserve_size:int):void { 307 if (i_reserve_size >= result_array.length) { 308 var new_size:int = i_reserve_size + 5; 309 result_array = new Array(new_size); //new FLARMultiMarkerDetectorResult[new_size]; 310 for (var i:int = 0; i < new_size; i++) { 311 result_array[i] = new FLARMultiMarkerDetectorResult(); 312 } 313 } 314 } 315 } 293
