configuringSession(photoSession: camera.PhotoSession):void{// 判断设备是否支持闪光灯let flashStatus: boolean =false;try{flashStatus = photoSession.hasFlash();}catch(error){let err = error as BusinessError;console.error(`Failed to hasFlash. error: ${JSON.stringify(err)}`);}console.info(`Returned with the flash light support status: ${flashStatus}`);if(flashStatus){// 判断是否支持自动闪光灯模式let flashModeStatus: boolean =false;try{let status: boolean = photoSession.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO);flashModeStatus = status;}catch(error){let err = error as BusinessError;console.error(`Failed to check whether the flash mode is supported. error: ${JSON.stringify(err)}`);}if(flashModeStatus){// 设置自动闪光灯模式try{photoSession.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO);}catch(error){let err = error as BusinessError;console.error(`Failed to set the flash mode. error: ${JSON.stringify(err)}`);}}}// 判断是否支持连续自动变焦模式let focusModeStatus: boolean =false;try{let status: boolean = photoSession.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_CONTINUOUS_AUTO);focusModeStatus = status;}catch(error){let err = error as BusinessError;console.error(`Failed to check whether the focus mode is supported. error: ${JSON.stringify(err)}`);}if(focusModeStatus){// 设置连续自动变焦模式try{photoSession.setFocusMode(camera.FocusMode.FOCUS_MODE_CONTINUOUS_AUTO);}catch(error){let err = error as BusinessError;console.error(`Failed to set the focus mode. error: ${JSON.stringify(err)}`);}}// 获取相机支持的可变焦距比范围let zoomRatioRange: Array<number>=[];try{zoomRatioRange = photoSession.getZoomRatioRange();}catch(error){let err = error as BusinessError;console.error(`Failed to get the zoom ratio range. error: ${JSON.stringify(err)}`);}if(zoomRatioRange.length <=0){return;}// 设置可变焦距比try{photoSession.setZoomRatio(zoomRatioRange[0]);}catch(error){let err = error as BusinessError;console.error(`Failed to set the zoom ratio value. error: ${JSON.stringify(err)}`);}}
5.拍照
主要通过photoOutput类的capture方法,执行拍照任务
capture(captureLocation: camera.Location, photoOutput: camera.PhotoOutput):void{let settings: camera.PhotoCaptureSetting ={quality: camera.QualityLevel.QUALITY_LEVEL_HIGH,// 设置图片质量高rotation: camera.ImageRotation.ROTATION_0,// 设置图片旋转角度0location: captureLocation,// 设置图片地理位置mirror: false // 设置镜像使能开关(默认关)};photoOutput.capture(settings,(err: BusinessError)=>{if(err){console.error(`Failed to capture the photo. error: ${JSON.stringify(err)}`);this.errorContent ='`Failed to capture the photo. error: '+ JSON.stringify(err)return;}console.info('Callback invoked to indicate the photo capture request success.');this.showContent =' photo capture success'});}
我整理了1000道算法面试题: 获取
先说结论:从Attention is not all you need 这篇论文来看,单纯的不加残差连接且不加MLP的多层多头的Attention堆叠会导致模型输出的秩坍缩到rank-1的矩阵,也就是最后所有的表征都趋向于同一个向量…