チェンジセット 1992

差分発生行の前後
無視リスト:
コミット日時:
2008/12/10 15:56:43 (3 年前)
コミッタ:
tarotarorg
ログメッセージ:

FLARCode#toString()の内部アルゴリズムが間違っていたので修正。
パターン読み込み時に計算する平均値を保存、他のオブジェクトから取得できるようにした。

ファイル:

凡例:

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

    r1862 r1992  
    5454                private var width:int; 
    5555                private var height:int; 
    56  
     56                private var averagePat:int; 
     57 
     58                public function get averageOfPattern():int  
     59                { 
     60                        return this.averagePat; 
     61                } 
    5762                public function getPat():Array { 
    5863                        return pat; 
     
    168173 
    169174                                l /= (height * width * 3); 
    170  
     175                                this.averagePat = l; 
    171176                                var m:int = 0; 
    172177                                for (var i:int = 0;i < height; i++) { 
     
    220225                        //幅・高さのチェック 
    221226                        if (this.height != patArray.length || this.width != patArray[0].length) { 
     227                                trace(this.height, patArray.length, this.width, patArray[0].length); 
    222228                                throw new ArgumentError("パターンの幅・高さが、Codeの幅・高さと異なっています"); 
    223229                        } 
     
    253259                        } 
    254260                        l /= (this.width * this.height * 3); 
     261                        this.averagePat = l; 
    255262                        for (y = 0; y < this.height; y++) { 
    256263                                for (x = 0; x < this.width; x++) { 
     
    279286                 
    280287                private function generatePatFileString(pat:Array):String { 
    281                         var x:int, y:int, c:int
     288                        var x:int, y:int, c:int, h:int
    282289                        var out:String = ''; 
    283                         for (c = 2; c >= 0; c--) { 
    284                                 for (x = 15; x >= 0; x--) { 
    285                                         for (y = 0; y < 16; y++) { 
    286                                                 out += String('    ' + int(pat[y][x][c])).substr(-4); 
    287                                         } 
    288                                         out += '\n'; 
    289                                 } 
    290                         } 
    291                         out += '\n'; 
    292                         for (c = 2; c >= 0; c--) { 
    293                                 for (y = 15; y >= 0; y--) { 
    294                                         for (x = 15; x >= 0; x--) { 
    295                                                 out += String('    ' + int(pat[y][x][c])).substr(-4); 
    296                                         } 
    297                                         out += '\n'; 
    298                                 } 
    299                         } 
    300                         out += '\n'; 
    301                         for (c = 2; c >= 0; c--) { 
    302                                 for (x = 0; x < 16; x++) { 
    303                                         for (y = 15; y >= 0; y--) { 
    304                                                 out += String('    ' + int(pat[y][x][c])).substr(-4); 
    305                                         } 
    306                                         out += '\n'; 
    307                                 } 
    308                         } 
    309                         out += '\n'; 
    310                         for (c = 2; c >= 0; c--) { 
    311                                 for (y = 0; y < 16; y++) { 
    312                                         for (x = 0; x < 16; x++) { 
    313                                                 out += String('    ' + int(pat[y][x][c])).substr(-4); 
    314                                         } 
    315                                         out += '\n'; 
    316                                 } 
    317                         } 
    318                         out += '\n'; 
     290                        var width:int = this.getWidth(); 
     291                        var height:int = this.getHeight(); 
     292                        for (h = 0; h < pat.length;h++) { 
     293                                for (c = 2; c >= 0; c--) { 
     294                                        for (y = 0; y < height; y++) { 
     295                                                for (x = 0; x < width; x++) { 
     296                                                        out += String('    ' + int((255-(pat[h][y][x][c])-this.averagePat)&0xFF)).substr(-4); 
     297                                                } 
     298                                                out += '\n'; 
     299                                        } 
     300                                } 
     301                                out += '\n'; 
     302                        } 
    319303                        return out; 
    320304                }