チェンジセット 2564
- コミット日時:
- 2009/05/04 11:18:32 (3 年前)
- ファイル:
凡例:
- 変更無し
- 追加
- 削除
- 更新
- コピー
- 移動
js/JSARToolKit/trunk/js/jsar.js
r2563 r2564 40 40 JSAR.prototype.cameraFile = '../swf/camera_para.dat' 41 41 JSAR.prototype.markerFiles; 42 JSAR.prototype.noCache = true; 43 JSAR.prototype.enableMic = false; 42 44 43 45 JSAR.prototype.captureX = 320; … … 55 57 JSAR.prototype.flash_version = '9.0.0'; 56 58 57 JSAR.prototype.markerNoCache = false;58 59 JSAR.prototype.zIndexFlash = 0; 59 60 JSAR.prototype.zIndexCanvas = 1; … … 112 113 var attributes = {}; 113 114 var swf_path = this.jsarSWF; 115 if ( this.noCache ) { 116 swf_path += '?'+Math.floor(Math.random()*900000+100000); // random 117 } 114 118 var inst_path = this.installSWF; 115 119 … … 190 194 opt.displayX = this.displayX; 191 195 opt.displayY = this.displayY; 196 opt.enableMic = !! this.enableMic; 192 197 opt.smoothing = true; 193 198 jsarProxy.initCamera( opt ); … … 218 223 for( var i=0; i<this.markerFiles.length; i++ ) { 219 224 list[i] = this.markerFiles[i]; // copy url 220 if ( this. markerNoCache ) {225 if ( this.noCache ) { 221 226 list[i] += '?'+Math.floor(Math.random()*900000+100000); // random 222 227 } … … 268 273 // console log 269 274 if ( result.detected ) { 270 //this._log( json );275 this._log( json ); 271 276 } 272 277 … … 359 364 360 365 JSAR.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 } 365 369 this.jsar = jsar; 366 370 }; js/JSARToolKit/trunk/src/JSAR.as
r2562 r2564 37 37 import flash.media.Camera; 38 38 import flash.media.Video; 39 import flash.media.Microphone; 39 40 import flash.net.URLLoader; 40 41 import flash.net.URLLoaderDataFormat; 41 42 import flash.net.URLRequest; 42 43 43 44 import flash.external.ExternalInterface; 44 45 … … 77 78 private var _scaleX:Number = 1.0; 78 79 private var _scaleY:Number = 1.0; 80 private var _enableMic:Boolean = false; 79 81 80 82 private var _codeSize:int = 80; … … 89 91 private var _video:Video; 90 92 private var _bmdata:BitmapData; 93 private var _mic:Microphone; 91 94 92 95 public function JSAR() { … … 104 107 if ( opt.smoothing ) this._smoothing = opt.smoothing; 105 108 if ( opt.detectThreshold ) this._detectThreshold = opt.detectThreshold; 109 if ( opt.enableMic ) this._enableMic = opt.enableMic; 106 110 107 111 this._scaleX = 1.0 * this._displayX / this._captureX; … … 118 122 this._video = new Video(this._captureX, this._captureY); 119 123 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 121 135 // Bitmap 122 136 this._bmdata = new BitmapData(this._captureX, this._captureY, false, 0); … … 127 141 this.addChild(bitmap); 128 142 129 // load camera param143 // load camera param 130 144 this._param = new FLARParam(); 131 this._cameraLoader = new URLLoader();145 this._cameraLoader = new URLLoader(); 132 146 this._cameraLoader.addEventListener(IOErrorEvent.IO_ERROR, this.dispatchEvent); 133 147 this._cameraLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, this.dispatchEvent); … … 141 155 this._cameraLoader.removeEventListener(Event.COMPLETE, this._onLoadedParam); 142 156 157 // set camera parameters 143 158 this._param.loadARParam(this._cameraLoader.data); 159 160 // set capture size again 144 161 this._param.changeScreenSize(this._captureX, this._captureY); 145 162 … … 212 229 213 230 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 215 238 if ( ! this._cameraReady ) { 216 arg.error = 'camera_not_ started';239 arg.error = 'camera_not_ready'; 217 240 return; 218 241 } … … 253 276 codeid: res.codeId, 254 277 direction: res.direction, 255 confidence: res.confidence ,278 confidence: res.confidence.toFixed(6), 256 279 vertex: vertex 257 280 }; … … 263 286 arg.markers = markers; 264 287 } 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 } 265 294 } 266 295 267 296 private function _log( mess:String ):void { 268 // trace( mess );269 297 ExternalInterface.call( "(function(){if(window.console)console.log('"+mess+"');})" ); 270 298 }

