チェンジセット 2564

差分発生行の前後
無視リスト:
コミット日時:
2009/05/04 11:18:32 (3 年前)
コミッタ:
kawanet
ログメッセージ:

JSARToolKit - added enableMic property

ファイル:

凡例:

変更無し
追加
削除
更新
コピー
移動
  • js/JSARToolKit/trunk/js/jsar.js

    r2563 r2564  
    4040JSAR.prototype.cameraFile = '../swf/camera_para.dat' 
    4141JSAR.prototype.markerFiles; 
     42JSAR.prototype.noCache    = true; 
     43JSAR.prototype.enableMic  = false; 
    4244 
    4345JSAR.prototype.captureX  = 320; 
     
    5557JSAR.prototype.flash_version    = '9.0.0'; 
    5658 
    57 JSAR.prototype.markerNoCache = false; 
    5859JSAR.prototype.zIndexFlash   = 0; 
    5960JSAR.prototype.zIndexCanvas  = 1; 
     
    112113    var attributes = {}; 
    113114    var swf_path   = this.jsarSWF; 
     115    if ( this.noCache ) { 
     116        swf_path += '?'+Math.floor(Math.random()*900000+100000); // random 
     117    } 
    114118    var inst_path  = this.installSWF; 
    115119 
     
    190194        opt.displayX   = this.displayX; 
    191195        opt.displayY   = this.displayY; 
     196        opt.enableMic  = !! this.enableMic; 
    192197        opt.smoothing  = true; 
    193198        jsarProxy.initCamera( opt ); 
     
    218223        for( var i=0; i<this.markerFiles.length; i++ ) { 
    219224            list[i] = this.markerFiles[i];           // copy url 
    220             if ( this.markerNoCache ) { 
     225            if ( this.noCache ) { 
    221226                list[i] += '?'+Math.floor(Math.random()*900000+100000);   // random 
    222227            } 
     
    268273    // console log 
    269274    if ( result.detected ) { 
    270         // this._log( json ); 
     275        this._log( json ); 
    271276    } 
    272277 
     
    359364 
    360365JSAR.MarkerDetectorResult = function (obj,jsar) { 
    361     this.codeid     = obj.codeid; 
    362     this.vertex     = obj.vertex; 
    363     this.direction  = obj.direction; 
    364     this.confidence = obj.confidence; 
     366    for( var key in obj ) { 
     367        this[key] = obj[key]; 
     368    } 
    365369    this.jsar       = jsar; 
    366370}; 
  • js/JSARToolKit/trunk/src/JSAR.as

    r2562 r2564  
    3737    import flash.media.Camera; 
    3838    import flash.media.Video; 
     39    import flash.media.Microphone; 
    3940    import flash.net.URLLoader; 
    4041    import flash.net.URLLoaderDataFormat; 
    4142    import flash.net.URLRequest; 
    42  
     43         
    4344    import flash.external.ExternalInterface; 
    4445     
     
    7778        private var _scaleX:Number       = 1.0; 
    7879        private var _scaleY:Number       = 1.0; 
     80                private var _enableMic:Boolean    = false; 
    7981         
    8082        private var _codeSize:int        = 80; 
     
    8991        private var _video:Video; 
    9092        private var _bmdata:BitmapData; 
     93                private var _mic:Microphone; 
    9194 
    9295        public function JSAR() { 
     
    104107            if ( opt.smoothing ) this._smoothing = opt.smoothing; 
    105108            if ( opt.detectThreshold ) this._detectThreshold = opt.detectThreshold; 
     109                        if ( opt.enableMic ) this._enableMic = opt.enableMic; 
    106110 
    107111            this._scaleX = 1.0 * this._displayX / this._captureX; 
     
    118122            this._video = new Video(this._captureX, this._captureY); 
    119123            this._video.attachCamera(this._camera); 
    120              
     124 
     125                        // Mic 
     126                        if (this._enableMic) { 
     127                                this._mic = Microphone.getMicrophone(); 
     128                                if (this._mic) { 
     129                                        // this._mic.gain = 50.0; 
     130                                        // this._mic.setUseEchoSuppression(false); 
     131                                        this._mic.setLoopBack(true); 
     132                                } 
     133                        } 
     134                                 
    121135            // Bitmap 
    122136            this._bmdata = new BitmapData(this._captureX, this._captureY, false, 0); 
     
    127141            this.addChild(bitmap); 
    128142 
    129             // load camera param 
     143                       // load camera param 
    130144            this._param = new FLARParam(); 
    131             this._cameraLoader = new URLLoader(); 
     145                       this._cameraLoader = new URLLoader(); 
    132146            this._cameraLoader.addEventListener(IOErrorEvent.IO_ERROR, this.dispatchEvent); 
    133147            this._cameraLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, this.dispatchEvent); 
     
    141155            this._cameraLoader.removeEventListener(Event.COMPLETE, this._onLoadedParam); 
    142156 
     157                        // set camera parameters 
    143158            this._param.loadARParam(this._cameraLoader.data); 
     159                         
     160                        // set capture size again 
    144161            this._param.changeScreenSize(this._captureX, this._captureY);    
    145162 
     
    212229             
    213230        private function _getDetectResult( arg:Object ):void { 
    214             // check camera param loaded 
     231            // camera is denied by user 
     232            if ( this._camera.muted ) { 
     233                arg.error = 'camera_denied'; 
     234                return; 
     235            } 
     236 
     237                        // param file not loaded 
    215238            if ( ! this._cameraReady ) { 
    216                 arg.error = 'camera_not_started'; 
     239                arg.error = 'camera_not_ready'; 
    217240                return; 
    218241            } 
     
    253276                    codeid:     res.codeId, 
    254277                    direction:  res.direction, 
    255                     confidence: res.confidence
     278                    confidence: res.confidence.toFixed(6)
    256279                    vertex:     vertex 
    257280                }; 
     
    263286                arg.markers  = markers; 
    264287            } 
     288                         
     289                        if (this._mic) { 
     290                                var vol:Number = this._mic.activityLevel 
     291//                              this._log( 'vol='+vol ); 
     292                                if ( vol >= 0 ) arg.mic = vol; 
     293                        } 
    265294        } 
    266295 
    267296        private function _log( mess:String ):void { 
    268 //          trace( mess ); 
    269297            ExternalInterface.call( "(function(){if(window.console)console.log('"+mess+"');})" ); 
    270298        }