チェンジセット 3312

差分発生行の前後
無視リスト:
コミット日時:
2010/01/20 00:40:46 (2 年前)
コミッタ:
rokubou
ログメッセージ:

Add comment

ファイル:

凡例:

変更無し
追加
削除
更新
コピー
移動
  • as3/FLARToolKit/trunk/src/org/libspark/flartoolkit/detector/FLARSingleMarkerDetector.as

    r2864 r3312  
    5353        /** 
    5454         * 画像から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> 
    5657         */ 
    5758        public class FLARSingleMarkerDetector { 
     
    7374 
    7475                // 検出結果の保存用 
     76                //Save the results for detection 
    7577                private var _detected_direction:int; 
    7678                private var _detected_confidence:Number; 
     
    8587 
    8688                /** 
    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> 
    95100                 * @throws FLARException 
    96101                 */ 
     
    98103                        const scr_size:FLARIntSize = i_param.getScreenSize();            
    99104                        // 解析オブジェクトを作る 
     105                        //Make the object analysis 
    100106                        this._square_detect = new FLARSquareDetector(i_param.getDistortionFactor(), scr_size); 
    101107                        this._transmat = new FLARTransMat(i_param); 
    102108                        // 比較コードを保存 
     109                        //Save the code comparison 
    103110                        this._code = i_code; 
    104111                        this._marker_width = i_marker_width; 
    105112 
    106113                        // 評価パターンのホルダを作る 
     114                        //Make a pattern holder rating 
    107115 
    108116                        //マーカ幅を算出 
     117                        //Calculate the width marker 
    109118                        var markerWidthByDec:Number = this._code.markerPercentWidth/10; 
    110119                        //マーカ高を算出 
     120                        //Calculate the height marker 
    111121                        var markerHeightByDec:Number = this._code.markerPercentHeight / 10; 
    112122 
    113123                        //評価パターンのホルダを作成 
     124                        //Create a pattern holder rating 
    114125                        this._patt = new FLARDynamicRatioColorPatt_O3(this._code.getWidth(),  
    115126                                                                                                                  this._code.getHeight(), 
     
    118129 
    119130                        // 評価器を作る。 
     131                        //Make evaluator. 
    120132                        this._match_patt = new FLARMatchPatt_Color_WITHOUT_PCA(); 
    121133                        //2値画像バッファを作る 
     134                        //Two images to create a buffer value 
    122135                        this._bin_raster = new FLARRaster_BitmapData(scr_size.w, scr_size.h); 
    123136                        //2値画像化フィルタの作成 
     137                        //Create a filter value of 2 images 
    124138                        this._tobin_filter= new FLARRasterFilter_BitmapDataThreshold(100); 
    125139                } 
     
    127141                /** 
    128142                 * i_imageにマーカー検出処理を実行し、結果を記録します。 
    129                  *  
    130                  * @param i_raster 
    131                  * マーカーを検出するイメージを指定します。イメージサイズは、カメラパラメータ 
    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> 
    133147                 * @return マーカーが検出できたかを真偽値で返します。 
     148                 * <span lang="en">Returns a boolean value whether the marker was detected.</span> 
    134149                 * @throws FLARException 
    135150                 */ 
    136151                public function detectMarkerLite(i_raster:IFLARRgbRaster, i_threshold:int):Boolean { 
    137152                        //サイズチェック 
     153                        //Check size 
    138154                        if (!this._bin_raster.getSize().isEqualSizeO(i_raster.getSize())) { 
    139155                                if (this._sizeCheckEnabled )  
     
    141157                                else { 
    142158                                        //サイズに合わせて、2値画像バッファを作る 
     159                                        //According to the size of two images to create a buffer value 
    143160                                        this._bin_raster = new FLARRaster_BitmapData(i_raster.getSize().w, i_raster.getSize().h); 
    144161                                } 
     
    146163 
    147164                        //ラスタを2値イメージに変換する. 
     165                        //Value of 2 to convert the raster image. 
    148166                        this._tobin_filter.setThreshold(i_threshold); 
    149167                        this._tobin_filter.doFilter(i_raster, this._bin_raster); 
     
    153171                        var l_square_list:FLARSquareStack = this._square_list; 
    154172                        // スクエアコードを探す 
     173                        //Square Code Search 
    155174                        this._square_detect.detectMarker(this._bin_raster, l_square_list); 
    156175 
     
    158177                        var number_of_square:int = l_square_list.getLength(); 
    159178                        // コードは見つかった? 
     179                        //Code found? 
    160180                        if (number_of_square < 1) { 
    161181                                return false; 
     
    163183 
    164184                        // 評価基準になるパターンをイメージから切り出す 
     185                        //Cut out the pattern from an image which criteria 
    165186                        if (!this._patt.pickFromRaster(i_raster, l_square_list.getItem(0) as FLARSquare)) { 
    166187                                // パターンの切り出しに失敗 
     188                                //Failed to cut out the pattern 
    167189                                return false; 
    168190                        } 
    169191                        // パターンを評価器にセット 
     192                        //Pattern set evaluator 
    170193                        if (!this._match_patt.setPatt(this._patt)) { 
    171                                 // 計算に失敗した。 
     194                                // 計算に失敗した。Calculation fails. 
    172195                                return false; 
    173196                        } 
    174197                        // コードと比較する 
     198                        //Code and compare 
    175199                        this._match_patt.evaluate(this._code); 
    176200                        var square_index:int = 0; 
     
    182206                        for (i = 1;i < number_of_square; i++) { 
    183207                                // 次のパターンを取得 
     208                                //Obtain the following pattern: 
    184209                                this._patt.pickFromRaster(i_raster, l_square_list.getItem(i) as FLARSquare); 
    185210                                // 評価器にセットする。 
     211                                //To set the evaluator. 
    186212                                this._match_patt.setPatt(this._patt); 
    187213                                // コードと比較する 
     214                                //Code and compare 
    188215                                this._match_patt.evaluate(this._code); 
    189216                                c2 = this._match_patt.getConfidence(); 
     
    192219                                } 
    193220                                // もっと一致するマーカーがあったぽい 
     221                                //Poi was more consistent marker 
    194222                                square_index = i; 
    195223                                direction = this._match_patt.getDirection(); 
     
    197225                        } 
    198226                        // マーカー情報を保存 
     227                        //Save marker information 
    199228                        this._detected_square = l_square_list.getItem(square_index) as FLARSquare; 
    200229                        this._detected_direction = direction; 
     
    206235                 * 検出したマーカーの変換行列を計算して、o_resultへ値を返します。 
    207236                 * 直前に実行した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> 
    211242                 * @throws FLARException 
    212243                 */ 
     
    223254                /** 
    224255                 * 検出したマーカーの一致度を返します。 
     256                 * <span lang="en">Returns the coincidence of the marker was detected.</span> 
    225257                 *  
    226258                 * @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> 
    227261                 * @throws FLARException 
    228262                 */ 
     
    234268                 * 検出したマーカーの方位を返します。 
    235269                 *  
    236                  * @return 0,1,2,3の何れかを返します。 
     270                 * @return Returns whether any of 0,1,2,3. 
     271                 * 0,1,2,3の何れかを返します。 
    237272                 */ 
    238273                public function getDirection():int { 
     
    245280                 * @param i_is_continue 
    246281                 * TRUEなら、transMatCont互換の計算をします。 FALSEなら、transMat互換の計算をします。 
     282                 * If TRUE, transMatCont calculate the compatibility. If FALSE, transMat calculate the compatibility. 
    247283                 */ 
    248284                public function setContinueMode(i_is_continue:Boolean):void { 
     
    251287                 
    252288                /** 
    253                  * @return 検出した FLARSquare 1 個返す。検出できなかったら null。 
     289                 * @return Total return detected FLARSquare 1. Detection Dekinakattara null. 
     290                 * 検出した FLARSquare 1 個返す。検出できなかったら null。 
    254291                 */ 
    255292                public function getSquare():FLARSquare { 
     
    258295                 
    259296                /** 
    260                  * @return 検出した全ての四角形を含む FLARSquareStack を返す。 
     297                 * @return FLARSquareStack detected rectangle that contains all the returns. 
     298                 * 検出した全ての四角形を含む FLARSquareStack を返す。 
    261299                 */ 
    262300                public function getSquareList():FLARSquareStack { 
     
    266304                /** 
    267305                 * 入力画像のサイズチェックをする/しない的な。(デフォルトではチェックする) 
     306                 * Check that the input image size / an not. (The default is checked) 
    268307                 */ 
    269308                public function get sizeCheckEnabled():Boolean {