チェンジセット 3312
- コミット日時:
- 2010/01/20 00:40:46 (2 年前)
- ファイル:
凡例:
- 変更無し
- 追加
- 削除
- 更新
- コピー
- 移動
as3/FLARToolKit/trunk/src/org/libspark/flartoolkit/detector/FLARSingleMarkerDetector.as
r2864 r3312 53 53 /** 54 54 * 画像からARCodeに最も一致するマーカーを1個検出し、その変換行列を計算するクラスです。 55 * 55 * <span lang="en">ARCode image markers to find one that best matches 56 * the individual is a class to calculate the transformation matrix.</span> 56 57 */ 57 58 public class FLARSingleMarkerDetector { … … 73 74 74 75 // 検出結果の保存用 76 //Save the results for detection 75 77 private var _detected_direction:int; 76 78 private var _detected_confidence:Number; … … 85 87 86 88 /** 87 * 検出するARCodeとカメラパラメータから、1個のARCodeを検出するFLARSingleDetectMarkerインスタンスを作ります。 88 * 89 * @param i_param 90 * カメラパラメータを指定します。 91 * @param i_code 92 * 検出するARCodeを指定します。 93 * @param i_marker_width 94 * ARコードの物理サイズを、ミリメートルで指定します。 89 * 検出するARCodeとカメラパラメータから、1個のARCodeを検出する 90 * <span lang="en">FLARSingleDetectMarkerインスタンスを作ります。 91 * ARCode from the camera parameters to detect and to detect 92 * a single FLARSingleDetectMarker ARCode create an instance.</span> 93 * 94 * @param i_param カメラパラメータを指定します。 95 * <span lang="en">The camera parameters</span> 96 * @param i_code 検出するARCodeを指定します。 97 * <span lang="en">Specify ARCode detection.</span> 98 * @param i_marker_width ARコードの物理サイズを、ミリメートルで指定します。 99 * <span lang="en">The physical size of the code specified in millimeters.</span> 95 100 * @throws FLARException 96 101 */ … … 98 103 const scr_size:FLARIntSize = i_param.getScreenSize(); 99 104 // 解析オブジェクトを作る 105 //Make the object analysis 100 106 this._square_detect = new FLARSquareDetector(i_param.getDistortionFactor(), scr_size); 101 107 this._transmat = new FLARTransMat(i_param); 102 108 // 比較コードを保存 109 //Save the code comparison 103 110 this._code = i_code; 104 111 this._marker_width = i_marker_width; 105 112 106 113 // 評価パターンのホルダを作る 114 //Make a pattern holder rating 107 115 108 116 //マーカ幅を算出 117 //Calculate the width marker 109 118 var markerWidthByDec:Number = this._code.markerPercentWidth/10; 110 119 //マーカ高を算出 120 //Calculate the height marker 111 121 var markerHeightByDec:Number = this._code.markerPercentHeight / 10; 112 122 113 123 //評価パターンのホルダを作成 124 //Create a pattern holder rating 114 125 this._patt = new FLARDynamicRatioColorPatt_O3(this._code.getWidth(), 115 126 this._code.getHeight(), … … 118 129 119 130 // 評価器を作る。 131 //Make evaluator. 120 132 this._match_patt = new FLARMatchPatt_Color_WITHOUT_PCA(); 121 133 //2値画像バッファを作る 134 //Two images to create a buffer value 122 135 this._bin_raster = new FLARRaster_BitmapData(scr_size.w, scr_size.h); 123 136 //2値画像化フィルタの作成 137 //Create a filter value of 2 images 124 138 this._tobin_filter= new FLARRasterFilter_BitmapDataThreshold(100); 125 139 } … … 127 141 /** 128 142 * i_imageにマーカー検出処理を実行し、結果を記録します。 129 * 130 * @param i_raster131 * マーカーを検出するイメージを指定します。イメージサイズは、カメラパラメータ132 * と一致していなければなりません。143 * <span lang="en">i_image marker to detect and perform and record the results.</span> 144 * 145 * @param i_raster マーカーを検出するイメージを指定します。イメージサイズは、カメラパラメータと一致していなければなりません。 146 * <span lang="en">Specifies the image to detect the marker. The image size must match the camera parameters.</span> 133 147 * @return マーカーが検出できたかを真偽値で返します。 148 * <span lang="en">Returns a boolean value whether the marker was detected.</span> 134 149 * @throws FLARException 135 150 */ 136 151 public function detectMarkerLite(i_raster:IFLARRgbRaster, i_threshold:int):Boolean { 137 152 //サイズチェック 153 //Check size 138 154 if (!this._bin_raster.getSize().isEqualSizeO(i_raster.getSize())) { 139 155 if (this._sizeCheckEnabled ) … … 141 157 else { 142 158 //サイズに合わせて、2値画像バッファを作る 159 //According to the size of two images to create a buffer value 143 160 this._bin_raster = new FLARRaster_BitmapData(i_raster.getSize().w, i_raster.getSize().h); 144 161 } … … 146 163 147 164 //ラスタを2値イメージに変換する. 165 //Value of 2 to convert the raster image. 148 166 this._tobin_filter.setThreshold(i_threshold); 149 167 this._tobin_filter.doFilter(i_raster, this._bin_raster); … … 153 171 var l_square_list:FLARSquareStack = this._square_list; 154 172 // スクエアコードを探す 173 //Square Code Search 155 174 this._square_detect.detectMarker(this._bin_raster, l_square_list); 156 175 … … 158 177 var number_of_square:int = l_square_list.getLength(); 159 178 // コードは見つかった? 179 //Code found? 160 180 if (number_of_square < 1) { 161 181 return false; … … 163 183 164 184 // 評価基準になるパターンをイメージから切り出す 185 //Cut out the pattern from an image which criteria 165 186 if (!this._patt.pickFromRaster(i_raster, l_square_list.getItem(0) as FLARSquare)) { 166 187 // パターンの切り出しに失敗 188 //Failed to cut out the pattern 167 189 return false; 168 190 } 169 191 // パターンを評価器にセット 192 //Pattern set evaluator 170 193 if (!this._match_patt.setPatt(this._patt)) { 171 // 計算に失敗した。 194 // 計算に失敗した。Calculation fails. 172 195 return false; 173 196 } 174 197 // コードと比較する 198 //Code and compare 175 199 this._match_patt.evaluate(this._code); 176 200 var square_index:int = 0; … … 182 206 for (i = 1;i < number_of_square; i++) { 183 207 // 次のパターンを取得 208 //Obtain the following pattern: 184 209 this._patt.pickFromRaster(i_raster, l_square_list.getItem(i) as FLARSquare); 185 210 // 評価器にセットする。 211 //To set the evaluator. 186 212 this._match_patt.setPatt(this._patt); 187 213 // コードと比較する 214 //Code and compare 188 215 this._match_patt.evaluate(this._code); 189 216 c2 = this._match_patt.getConfidence(); … … 192 219 } 193 220 // もっと一致するマーカーがあったぽい 221 //Poi was more consistent marker 194 222 square_index = i; 195 223 direction = this._match_patt.getDirection(); … … 197 225 } 198 226 // マーカー情報を保存 227 //Save marker information 199 228 this._detected_square = l_square_list.getItem(square_index) as FLARSquare; 200 229 this._detected_direction = direction; … … 206 235 * 検出したマーカーの変換行列を計算して、o_resultへ値を返します。 207 236 * 直前に実行したdetectMarkerLiteが成功していないと使えません。 208 * 209 * @param o_result 210 * 変換行列を受け取るオブジェクトを指定します。 237 * <span lang="en">Transformation matrix to calculate the detected markers, o_result to return a value. 238 * DetectMarkerLite not work before you run and have not been successful.</span"> 239 * 240 * @param o_result 変換行列を受け取るオブジェクトを指定します。 241 * <span lang="en">Specifies the object that receives the transformation matrix.</span> 211 242 * @throws FLARException 212 243 */ … … 223 254 /** 224 255 * 検出したマーカーの一致度を返します。 256 * <span lang="en">Returns the coincidence of the marker was detected.</span> 225 257 * 226 258 * @return マーカーの一致度を返します。0~1までの値をとります。 一致度が低い場合には、誤認識の可能性が高くなります。 259 * <span lang="en">Returns the coincidence of the marker. Takes a value between 0 and 1. 260 * If a lesser degree of match, the higher the possibility of false positives.</span> 227 261 * @throws FLARException 228 262 */ … … 234 268 * 検出したマーカーの方位を返します。 235 269 * 236 * @return 0,1,2,3の何れかを返します。 270 * @return Returns whether any of 0,1,2,3. 271 * 0,1,2,3の何れかを返します。 237 272 */ 238 273 public function getDirection():int { … … 245 280 * @param i_is_continue 246 281 * TRUEなら、transMatCont互換の計算をします。 FALSEなら、transMat互換の計算をします。 282 * If TRUE, transMatCont calculate the compatibility. If FALSE, transMat calculate the compatibility. 247 283 */ 248 284 public function setContinueMode(i_is_continue:Boolean):void { … … 251 287 252 288 /** 253 * @return 検出した FLARSquare 1 個返す。検出できなかったら null。 289 * @return Total return detected FLARSquare 1. Detection Dekinakattara null. 290 * 検出した FLARSquare 1 個返す。検出できなかったら null。 254 291 */ 255 292 public function getSquare():FLARSquare { … … 258 295 259 296 /** 260 * @return 検出した全ての四角形を含む FLARSquareStack を返す。 297 * @return FLARSquareStack detected rectangle that contains all the returns. 298 * 検出した全ての四角形を含む FLARSquareStack を返す。 261 299 */ 262 300 public function getSquareList():FLARSquareStack { … … 266 304 /** 267 305 * 入力画像のサイズチェックをする/しない的な。(デフォルトではチェックする) 306 * Check that the input image size / an not. (The default is checked) 268 307 */ 269 308 public function get sizeCheckEnabled():Boolean {

