1// @ts-nocheck 2 3import camera from '@ohos.multimedia.camera' 4import deviceInfo from '@ohos.deviceInfo' 5import fileio from '@ohos.fileio' 6import image from '@ohos.multimedia.image' 7import media from '@ohos.multimedia.media' 8import mediaLibrary from '@ohos.multimedia.mediaLibrary' 9import Logger from '../model/Logger' 10import MediaUtils from '../model/MediaUtils' 11import prompt from '@ohos.prompt'; 12import fs from '@ohos.file.fs'; 13 14const CameraSize = { 15 WIDTH: 1280, 16 HEIGHT: 720 17} 18 19class CameraService { 20 private tag: string = 'qlw CameraService' 21 private static instance: CameraService = new CameraService() 22 private mediaUtil = MediaUtils.getInstance() 23 private cameraManager: camera.CameraManager = undefined 24 cameras: Array<camera.CameraDevice> = undefined 25 private cameraInput: camera.CameraInput = undefined 26 private previewOutput: camera.PreviewOutput = undefined 27 private photoOutput: camera.PhotoOutput = undefined 28 private cameraOutputCapability: camera.CameraOutputCapability = undefined 29 private captureSession: camera.CaptureSession = undefined 30 private mReceiver: image.ImageReceiver = undefined 31 private fileAsset: mediaLibrary.FileAsset = undefined 32 private fd: number = -1 33 private videoRecorder: media.VideoRecorder = undefined 34 private videoOutput: camera.VideoOutput = undefined 35 private handleTakePicture: (photoUri: string) => void = undefined 36 private videoConfig: any = { 37 audioSourceType: 1, 38 videoSourceType: 0, 39 profile: { 40 audioBitrate: 48000, 41 audioChannels: 2, 42 audioCodec: 'audio/mp4v-es', 43 audioSampleRate: 48000, 44 durationTime: 1000, 45 fileFormat: 'mp4', 46 videoBitrate: 280000, 47 videoCodec: 'video/mp4v-es', 48 videoFrameWidth: 640, 49 videoFrameHeight: 480, 50 videoFrameRate: 15, 51 52 }, 53 rotation: 270, 54 url: '', 55 orientationHint: 0, 56 location: { latitude: 30, longitude: 130 }, 57 maxSize: 10000, 58 maxDuration: 10000 59 } 60 private videoProfileObj: camera.VideoProfile = { 61 format: 1, 62 size: { 63 "width": 640, 64 "height": 480 65 }, 66 frameRateRange: { 67 "min": 5, 68 "max": 5 69 } 70 } 71 private photoProfileObj: camera.Profile = { 72 format: 1, 73 size: { 74 "width": 640, 75 "height": 480 76 } 77 } 78 private videoOutputStopBol: boolean = true 79 resolution: any = null 80 photoResolution: any = null 81 videoResolution: any = null 82 83 constructor() { 84 try { 85 this.mReceiver = image.createImageReceiver(CameraSize.WIDTH, CameraSize.HEIGHT, image.ImageFormat.JPEG, 8) 86 Logger.info(this.tag, 'createImageReceiver') 87 this.mReceiver.on('imageArrival', () => { 88 Logger.info(this.tag, 'imageArrival') 89 this.mReceiver.readNextImage((err, image) => { 90 Logger.info(this.tag, 'readNextImage') 91 if (err || image === undefined) { 92 Logger.error(this.tag, 'failed to get valid image') 93 return 94 } 95 image.getComponent(4, (errMsg, img) => { 96 Logger.info(this.tag, 'getComponent') 97 if (errMsg || img === undefined) { 98 Logger.info(this.tag, 'failed to get valid buffer') 99 return 100 } 101 let buffer 102 if (img.byteBuffer) { 103 buffer = img.byteBuffer 104 } else { 105 Logger.error(this.tag, 'img.byteBuffer is undefined') 106 } 107 this.savePicture(buffer, image) 108 }) 109 }) 110 }) 111 } catch (err) { 112 Logger.info(this.tag, `image Receiver err ${err.message}`) 113 } 114 } 115 116 async savePicture(buffer: ArrayBuffer, img: image.Image) { 117 try { 118 Logger.info(this.tag, 'savePicture') 119 let imgFileAsset = await this.mediaUtil.createAndGetUri(mediaLibrary.MediaType.IMAGE) 120 let imgPhotoUri = imgFileAsset.uri 121 Logger.info(this.tag, `photoUri = ${imgPhotoUri}`) 122 let imgFd = await this.mediaUtil.getFdPath(imgFileAsset) 123 Logger.info(this.tag, `fd = ${imgFd}`) 124 await fileio.write(imgFd, buffer) 125 await imgFileAsset.close(imgFd) 126 await img.release() 127 Logger.info(this.tag, 'save image done') 128 if (this.handleTakePicture) { 129 this.handleTakePicture(imgPhotoUri) 130 } 131 } catch (err) { 132 Logger.info(this.tag, `save picture err ${err.message}`) 133 } 134 } 135 136 async initCamera(surfaceId: number, cameraDeviceIndex: number, obj?, photoIndex?, previewObj?) { 137 try { 138 if (deviceInfo.deviceType === 'default') { 139 this.videoConfig.videoSourceType = 1 140 } else { 141 this.videoConfig.videoSourceType = 0 142 } 143 Logger.info(this.tag, `cameraDeviceIndex success: ${cameraDeviceIndex}`) 144 await this.releaseCamera() 145 await this.getCameraManagerFn() 146 await this.getSupportedCamerasFn() 147 await this.getSupportedOutputCapabilityFn(cameraDeviceIndex) 148 if (previewObj){ 149 previewObj.format = this.cameraOutputCapability.previewProfiles[0].format 150 Logger.info(this.tag, `previewObj format: ${previewObj.format}`) 151 } 152 await this.createPreviewOutputFn(previewObj ? previewObj : this.cameraOutputCapability.previewProfiles[0], surfaceId) 153 // await this.createPhotoOutputFn(this.photoProfileObj) 154 await this.createPhotoOutputFn(obj ? obj : this.cameraOutputCapability.photoProfiles[photoIndex?photoIndex:0]) 155 await this.createCameraInputFn(this.cameras[cameraDeviceIndex]) 156 await this.cameraInputOpenFn() 157 await this.sessionFlowFn() 158 159 } catch (err) { 160 Logger.info(this.tag, 'initCamera err: ' + JSON.stringify(err.message)) 161 } 162 } 163 // 曝光模式 164 isExposureModeSupportedFn(ind) { 165 try { 166 let status = this.captureSession.isExposureModeSupported(ind) 167 Logger.info(this.tag, `isExposureModeSupported success: ${status}`) 168 prompt.showToast({ 169 message: status ? '支持此模式' : '不支持此模式', 170 duration: 2000, 171 bottom: '60%' 172 }) 173 // 设置曝光模式 174 this.captureSession.setExposureMode(ind) 175 Logger.info(this.tag, `setExposureMode success`) 176 // 获取当前曝光模式 177 let exposureMode = this.captureSession.getExposureMode() 178 Logger.info(this.tag, `getExposureMode success: ${exposureMode}`) 179 } catch (err) { 180 Logger.info(this.tag, `isExposureModeSupportedFn fail: ${err} , message: ${err.message}, code: ${err.code}`) 181 } 182 } 183 // 曝光区域 184 isMeteringPoint(Point1) { 185 try { 186 // 获取当前曝光模式 187 let exposureMode = this.captureSession.getExposureMode() 188 Logger.info(this.tag, `getExposureMode success: ${exposureMode}`) 189 // 设置曝光区域中心点 190 this.captureSession.setMeteringPoint(Point1) 191 Logger.info(this.tag, `setMeteringPoint success`) 192 // 查询曝光区域中心点 193 let exposurePoint = this.captureSession.getMeteringPoint() 194 Logger.info(this.tag, `getMeteringPoint success: ${exposurePoint}`) 195 } catch (err) { 196 Logger.info(this.tag, `isMeteringPoint fail err: ${err}, message: ${err.message}, code: ${err.code}`) 197 } 198 } 199 // 曝光补偿 200 isExposureBiasRange(ind) { 201 try { 202 // 查询曝光补偿范围 203 let biasRangeArray = this.captureSession.getExposureBiasRange() 204 Logger.info(this.tag, `getExposureBiasRange success: ${biasRangeArray}`) 205 // 设置曝光补偿 206 this.captureSession.setExposureBias(ind) 207 Logger.info(this.tag, `setExposureBias success: ${ind}`) 208 // 查询当前曝光值 209 let exposureValue = this.captureSession.getExposureValue() 210 Logger.info(this.tag, `getExposureValue success: ${exposureValue}`) 211 } catch (err) { 212 Logger.info(this.tag, `isExposureBiasRange fail err: ${err}, message: ${err.message}, code: ${err.code}`) 213 } 214 } 215 // 对焦模式 216 isFocusMode(ind) { 217 try { 218 // 检测对焦模式是否支持 219 let status = this.captureSession.isFocusModeSupported(ind) 220 Logger.info(this.tag, `isFocusModeSupported success: ${status}`) 221 prompt.showToast({ 222 message: status ? '支持此模式' : '不支持此模式', 223 duration: 2000, 224 bottom: '60%' 225 }) 226 // 设置对焦模式 227 this.captureSession.setFocusMode(ind) 228 Logger.info(this.tag, `setFocusMode success`) 229 // 获取当前对焦模式 230 let afMode = this.captureSession.getFocusMode() 231 Logger.info(this.tag, `getFocusMode success: ${afMode}`) 232 } catch (err) { 233 Logger.info(this.tag, `isFocusMode fail err: ${err}, message: ${err.message}, code: ${err.code}`) 234 } 235 } 236 // 对焦点 237 isFocusPoint(Point) { 238 try { 239 // 设置对焦点 240 this.captureSession.setFocusPoint(Point) 241 Logger.info(this.tag, `setFocusPoint success`) 242 // 获取当前对焦点 243 let point = this.captureSession.getFocusPoint() 244 Logger.info(this.tag, `getFocusPoint success: ${point}`) 245 } catch (err) { 246 Logger.info(this.tag, `isFocusPoint fail err: ${err}, message: ${err.message}, code: ${err.code}`) 247 } 248 } 249 // 闪光灯 250 hasFlashFn(ind) { 251 try { 252 // 检测是否有闪光灯 253 let status = this.captureSession.hasFlash() 254 Logger.info(this.tag, `hasFlash success: ${status}`) 255 // 检测闪光灯模式是否支持 256 let status1 = this.captureSession.isFlashModeSupported(ind) 257 Logger.info(this.tag, `isFlashModeSupported success: ${status1}`) 258 prompt.showToast({ 259 message: status1 ? '支持此模式' : '不支持此模式', 260 duration: 2000, 261 bottom: '60%' 262 }) 263 // 设置闪光灯模式 264 this.captureSession.setFlashMode(ind) 265 Logger.info(this.tag, `setFlashMode success`) 266 // 获取当前设备的闪光灯模式 267 let flashMode = this.captureSession.getFlashMode() 268 Logger.info(this.tag, `getFlashMode success: ${flashMode}`) 269 } catch (err) { 270 Logger.info(this.tag, `hasFlashFn fail err: ${err}, message: ${err.message}, code: ${err.code}`) 271 } 272 } 273 // 变焦 274 setZoomRatioFn(num) { 275 try { 276 // 获取当前支持的变焦范围 277 let zoomRatioRange = this.captureSession.getZoomRatioRange() 278 Logger.info(this.tag, `getZoomRatioRange success: ${zoomRatioRange}`) 279 // 设置变焦比 280 Logger.info(this.tag, `setZoomRatioFn num: ${num}`) 281 this.captureSession.setZoomRatio(num) 282 Logger.info(this.tag, `setZoomRatio success`) 283 // 获取当前对焦比 284 let zoomRatio = this.captureSession.getZoomRatio() 285 Logger.info(this.tag, `getZoomRatio success: ${zoomRatio}`) 286 } catch (err) { 287 Logger.info(this.tag, `setZoomRatioFn fail err: ${err}, message: ${err.message}, code: ${err.code}`) 288 } 289 } 290 // 防抖 291 isVideoStabilizationModeSupportedFn(ind) { 292 try { 293 // 查询是否支持指定的视频防抖模式 294 let isSupported = this.captureSession.isVideoStabilizationModeSupported(ind) 295 Logger.info(this.tag, `isVideoStabilizationModeSupported success: ${isSupported}`) 296 prompt.showToast({ 297 message: isSupported ? '支持此模式' : '不支持此模式', 298 duration: 2000, 299 bottom: '60%' 300 }) 301 // 设置视频防抖 302 this.captureSession.setVideoStabilizationMode(ind) 303 Logger.info(this.tag, `setVideoStabilizationMode success`) 304 // 查询当前正在使用的防抖模式 305 let vsMode = this.captureSession.getActiveVideoStabilizationMode() 306 Logger.info(this.tag, `getActiveVideoStabilizationMode success: ${vsMode}`) 307 } catch (err) { 308 Logger.info(this.tag, `isVideoStabilizationModeSupportedFn fail err: ${err}, message: ${err.message}, code: ${err.code}`) 309 } 310 } 311 312 setTakePictureCallback(callback) { 313 this.handleTakePicture = callback 314 } 315 // 照片方向判断 316 onChangeRotation() { 317 if (globalThis.photoOrientation == 0) { 318 return 0 319 } 320 if (globalThis.photoOrientation == 1) { 321 return 90 322 } 323 if (globalThis.photoOrientation == 2) { 324 return 180 325 } 326 if (globalThis.photoOrientation == 3) { 327 return 270 328 } 329 } 330 // 照片地理位置逻辑,后续靠定位实现,当前传入固定值 331 onChangeLocation() { 332 if (globalThis.settingDataObj.locationBol) { 333 return { 334 latitude: 12, 335 longitude: 77, 336 altitude: 1000 337 } 338 } 339 return { 340 latitude: 0, 341 longitude: 0, 342 altitude: 0 343 } 344 } 345 // 拍照 346 async takePicture(imageRotation?) { 347 try { 348 Logger.info(this.tag, 'takePicture start') 349 let photoSettings = { 350 rotation: imageRotation ? Number(imageRotation) : 0, 351 quality: 1, 352 location: { 353 latitude: 0, 354 longitude: 0, 355 altitude: 0 356 }, 357 mirror: false 358 } 359 Logger.info(this.tag, `photoOutput capture photoSettings: ` + JSON.stringify(photoSettings)) 360 await this.photoOutput.capture(photoSettings) 361 Logger.info(this.tag, 'takePicture end') 362 } catch (err) { 363 Logger.info(this.tag, `takePicture fail err: ${err}, message: ${err.message}, code: ${err.code}`) 364 } 365 } 366 // 获取Fd 367 async getFileFd() { 368 let filesDir = globalThis.abilityContext.filesDir 369 Logger.info(this.tag, `beginConfig 3`) 370 let path = filesDir + '/' + 'test.mp4' 371 Logger.info(this.tag, `beginConfig 4`) 372 let file = fs.openSync(path, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE | fs.OpenMode.TRUNC) 373 Logger.info(this.tag, `getFileFd : ${file.fd}`) 374 return file.fd 375 } 376 // 开始录制 377 async startVideo() { 378 try { 379 Logger.info(this.tag, `startVideo begin`) 380 await this.captureSession.stop() 381 await this.captureSession.beginConfig() 382 this.fd = await this.getFileFd() 383 Logger.info(this.tag, `videoConfig.profile: ${this.videoConfig.profile}`) 384 this.videoRecorder = await media.createVideoRecorder() 385 this.videoConfig.url = `fd://${this.fd}` 386 this.videoConfig.profile.videoFrameWidth = this.cameraOutputCapability.videoProfiles[0].size.width 387 this.videoConfig.profile.videoFrameHeight = this.cameraOutputCapability.videoProfiles[0].size.height 388 await this.videoRecorder.prepare(this.videoConfig) 389 let videoId = await this.videoRecorder.getInputSurface() 390 Logger.info(this.tag, `videoProfileObj: ` + JSON.stringify(this.videoProfileObj)) 391 Logger.info(this.tag, `videoProfileObj: ` + JSON.stringify(this.cameraOutputCapability.videoProfiles[0])) 392// this.videoOutput = await this.cameraManager.createVideoOutput(this.videoProfileObj, videoId) 393 this.videoOutput = await this.cameraManager.createVideoOutput(this.cameraOutputCapability.videoProfiles[0], videoId) 394 Logger.info(this.tag, `createVideoOutput success: ${this.videoOutput}`) 395 await this.captureSession.addOutput(this.videoOutput) 396 await this.captureSession.commitConfig() 397 await this.captureSession.start() 398 // await this.videoOutput.on('frameStart', async () => { 399 // Logger.info(this.tag, `frameStart start`) 400 // try { 401 // await this.videoRecorder.start() 402 // Logger.info(this.tag, `frameStart end`) 403 // } catch (err) { 404 // Logger.info(this.tag, `videoRecorder start fail err: ${err}`) 405 // } 406 // }) 407 await this.videoOutput.start() 408 await this.videoRecorder.start().then(() => { 409 setTimeout(async () => { 410 await this.stopVideo() 411 Logger.info(this.tag, `setTimeout stopVideo end`) 412 }, 3000) 413 }) 414 Logger.info(this.tag, `videoOutput end`) 415 } catch (err) { 416 Logger.info(this.tag, `startVideo fail err: ${err}, message: ${err.message}, code: ${err.code}`) 417 } 418 } 419 // 停止录制 420 async stopVideo() { 421 try { 422 if (this.videoRecorder) { 423 await this.videoRecorder.stop() 424 await this.videoRecorder.release() 425 } 426 if (this.videoOutput) { 427 if (this.videoOutputStopBol) { 428 await this.videoOutput.stop() 429 } 430 await this.videoOutput.release() 431 } 432 if (this.fileAsset) { 433 await this.fileAsset.close(this.fd) 434 return this.fileAsset 435 } 436 Logger.info(this.tag, `stopVideo success`) 437 } catch (err) { 438 Logger.info(this.tag, `stopVideo fail err: ${err}, message: ${err.message}, code: ${err.code}`) 439 } 440 } 441 // 查询相机设备在模式下支持的输出能力 442 async getSupportedOutputCapabilityFn(cameraDeviceIndex) { 443 Logger.info(this.tag, `cameraOutputCapability cameraId: ${this.cameras[cameraDeviceIndex].cameraId}`) 444 // @ts-ignore 445 this.cameraOutputCapability = this.cameraManager.getSupportedOutputCapability(this.cameras[cameraDeviceIndex]) 446 let previewSize = [] 447 let photoSize = [] 448 let videoSize = [] 449 this.cameraOutputCapability.previewProfiles.forEach((item, index) => { 450 Logger.info(this.tag, `cameraOutputCapability previewProfiles index: ${index}, item:` + JSON.stringify(item)) 451 previewSize.push({ 452 value: `${item.size.width}x${item.size.height}` 453 }) 454 }) 455 this.cameraOutputCapability.photoProfiles.forEach((item, index) => { 456 Logger.info(this.tag, `cameraOutputCapability photoProfiles index: ${index}, item:` + JSON.stringify(item)) 457 photoSize.push({ 458 value: `${item.size.width}x${item.size.height}` 459 }) 460 }) 461 this.cameraOutputCapability.videoProfiles.forEach((item, index) => { 462 Logger.info(this.tag, `cameraOutputCapability videoProfiles index: ${index}, item:` + JSON.stringify(item)) 463 videoSize.push({ 464 value: `${item.size.width}x${item.size.height}` 465 }) 466 }) 467 Logger.info(this.tag, `cameraOutputCapability previewProfiles:` + JSON.stringify(this.cameraOutputCapability.previewProfiles)) 468 Logger.info(this.tag, `cameraOutputCapability photoProfiles:` + JSON.stringify(this.cameraOutputCapability.photoProfiles)) 469 Logger.info(this.tag, `cameraOutputCapability videoProfiles:` + JSON.stringify(this.cameraOutputCapability.videoProfiles)) 470 Logger.info(this.tag, `cameraOutputCapability previewProfiles previewSize:` + JSON.stringify(previewSize)) 471 this.resolution = previewSize 472 this.photoResolution = photoSize 473 this.videoResolution = videoSize 474 return previewSize 475 } 476 // 释放会话及其相关参数 477 async releaseCamera() { 478 try { 479 if (this.cameraInput) { 480 await this.cameraInput.release() 481 } 482 if (this.previewOutput) { 483 await this.previewOutput.release() 484 } 485 if (this.photoOutput) { 486 await this.photoOutput.release() 487 } 488 if (this.videoOutput) { 489 await this.videoOutput.release() 490 } 491 if (this.captureSession) { 492 await this.captureSession.release() 493 } 494 Logger.info(this.tag, `releaseCamera success`) 495 } catch (err) { 496 Logger.info(this.tag, `releaseCamera fail err: ${err}, message: ${err.message}, code: ${err.code}`) 497 } 498 } 499 // 释放会话 500 async releaseSession() { 501 await this.previewOutput.stop() 502 await this.photoOutput.release() 503 await this.captureSession.release() 504 Logger.info(this.tag, `releaseSession success`) 505 } 506 // 获取相机管理器实例 507 async getCameraManagerFn() { 508 try { 509 this.cameraManager = await camera.getCameraManager(globalThis.abilityContext) 510 Logger.info(this.tag, `getCameraManager success: ` + JSON.stringify(this.cameraManager)) 511 } catch (err) { 512 Logger.info(this.tag, `getCameraManagerFn fail err: ${err}, message: ${err.message}, code: ${err.code}`) 513 } 514 } 515 // 获取支持指定的相机设备对象 516 async getSupportedCamerasFn() { 517 try { 518 this.cameras = await this.cameraManager.getSupportedCameras() 519 Logger.info(this.tag, `getSupportedCameras success: ` + JSON.stringify(this.cameras)) 520 Logger.info(this.tag, `getSupportedCameras length success: ${this.cameras.length}`) 521 } catch (err) { 522 Logger.info(this.tag, `getSupportedCamerasFn fail err: ${err}, message: ${err.message}, code: ${err.code}`) 523 } 524 } 525 // 创建previewOutput输出对象 526 async createPreviewOutputFn(previewProfilesObj, surfaceId) { 527 try { 528 Logger.info(this.tag, `createPreviewOutputFn previewProfilesObj success: ` + JSON.stringify(previewProfilesObj)) 529 this.previewOutput = await this.cameraManager.createPreviewOutput(previewProfilesObj, surfaceId.toString()) 530 Logger.info(this.tag, `createPreviewOutputFn success: ` + JSON.stringify(this.previewOutput)) 531 } catch (err) { 532 Logger.info(this.tag, `createPreviewOutputFn fail err: ${err}, message: ${err.message}, code: ${err.code}`) 533 } 534 } 535 // 创建photoOutput输出对象 536 async createPhotoOutputFn(photoProfileObj) { 537 try { 538 Logger.info(this.tag, `createPhotoOutputFn photoProfileObj success: ` + JSON.stringify(photoProfileObj)) 539 let mSurfaceId = await this.mReceiver.getReceivingSurfaceId() 540 this.photoOutput = await this.cameraManager.createPhotoOutput(photoProfileObj, mSurfaceId) 541 Logger.info(this.tag, `createPhotoOutputFn success: ` + JSON.stringify(this.photoOutput)) 542 } catch (err) { 543 Logger.info(this.tag, `createPhotoOutputFn fail err: ${err}, message: ${err.message}, code: ${err.code}`) 544 } 545 } 546 // 创建cameraInput输出对象 547 async createCameraInputFn(cameraDeviceIndex) { 548 try { 549 this.cameraInput = await this.cameraManager.createCameraInput(cameraDeviceIndex) 550 Logger.info(this.tag, `createCameraInputFn success: ${this.cameraInput}`) 551 } catch (err) { 552 Logger.info(this.tag, `createCameraInputFn fail err: ${err}, message: ${err.message}, code: ${err.code}`) 553 } 554 } 555 // 打开相机 556 async cameraInputOpenFn() { 557 await this.cameraInput.open() 558 .then((data) => { 559 Logger.info(this.tag, `cameraInputOpenFn open success: ${data}`) 560 }) 561 .catch((err) => { 562 Logger.info(this.tag, `cameraInputOpenFn fail err: ${err}, message: ${err.message}, code: ${err.code}`) 563 }) 564 } 565 // 会话流程 566 async sessionFlowFn() { 567 try { 568 // 创建captureSession实例 569 this.captureSession = await this.cameraManager.createCaptureSession() 570 // 开始配置会话 571 await this.captureSession.beginConfig() 572 // cameraInput加入会话 573 await this.captureSession.addInput(this.cameraInput) 574 // previewOutput加入会话 575 await this.captureSession.addOutput(this.previewOutput) 576 // photoOutput加入会话 577 await this.captureSession.addOutput(this.photoOutput) 578 // 提交配置会话 579 await this.captureSession.commitConfig() 580 // 开启会话 581 await this.captureSession.start() 582 Logger.info(this.tag, `sessionFlowFn success`) 583 } catch (err) { 584 Logger.info(this.tag, `sessionFlowFn fail err: ${err}, message: ${err.message}, code: ${err.code}`) 585 } 586 } 587} 588 589export default new CameraService()