1# @ohos.multimedia.camera (相机管理)(系统接口) 2 3本模块为开发者提供一套简单且易于理解的相机服务接口,开发者通过调用接口可以开发相机应用。应用通过访问和操作相机硬件,实现基础操作,如预览、拍照和录像;还可以通过接口组合完成更多操作,如控制闪光灯和曝光时间、对焦或调焦等。 4 5> **说明:** 6> 7> - 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 8> - 当前页面仅包含本模块的系统接口,其他公开接口参见[@ohos.multimedia.camera (相机管理)](js-apis-camera.md)。 9 10## 导入模块 11 12```ts 13import { camera } from '@kit.CameraKit'; 14``` 15 16## SceneMode<sup>11+</sup> 17 18枚举,相机支持模式。 19 20**系统能力:** SystemCapability.Multimedia.Camera.Core 21 22| 名称 | 值 | 说明 | 23| ----------------------- | --------- | ------------ | 24| PORTRAIT_PHOTO | 3 | 人像拍照模式。**系统接口:** 此接口为系统接口。 | 25| NIGHT_PHOTO | 4 | 夜景拍照模式。**系统接口:** 此接口为系统接口。 | 26| PROFESSIONAL_PHOTO<sup>12+</sup> | 5 | 专业拍照模式。**系统接口:** 此接口为系统接口。 | 27| PROFESSIONAL_VIDEO<sup>12+</sup> | 6 | 专业录像模式。**系统接口:** 此接口为系统接口。 | 28| SLOW_MOTION_VIDEO<sup>12+</sup> | 7 | 慢动作模式。**系统接口:** 此接口为系统接口。 | 29| HIGH_RESOLUTION_PHOTO<sup>12+</sup> | 11 | 高像素拍照模式。 **系统接口:** 此接口为系统接口。 | 30| PANORAMA_PHOTO<sup>12+</sup> | 15 | 全景拍照模式。 **系统接口:** 此接口为系统接口。 | 31| TIME_LAPSE_PHOTO<sup>12+</sup> | 16 | 延时摄影模式。 **系统接口:** 此接口为系统接口。 | 32 33## SlowMotionStatus<sup>12+</sup> 34 35枚举,慢动作状态。 36 37**系统能力:** SystemCapability.Multimedia.Camera.Core 38 39| 名称 | 值 | 说明 | 40|----------------|-----|---------------| 41| DISABLED | 0 | 慢动作关闭状态。 | 42| READY | 1 | 慢动作就绪状态。 | 43| VIDEO_START | 2 | 慢动作视频开始状态。 | 44| VIDEO_DONE | 3 | 慢动作视频完成状态。 | 45| FINISHED | 4 | 慢动作结束状态。 | 46 47## LcdFlashStatus<sup>12+</sup> 48 49lcd闪光灯信息项。 50 51**系统接口:** 此接口为系统接口。 52 53**系统能力:** SystemCapability.Multimedia.Camera.Core 54 55| 名称 | 类型 | 只读 | 可选 | 说明 | 56| -------- | ----------------------------- |---- |-----| ------------- | 57| isLcdFlashNeeded | boolean | 是 | 否 | 是否需要lcd闪光灯,true为需要,false为不需要。 | 58| lcdCompensation | number | 是 | 否 | lcd闪光灯补偿值。 | 59 60## Photo<sup>11+</sup> 61 62全质量图对象。 63 64**系统接口:** 此接口为系统接口。 65 66**系统能力:** SystemCapability.Multimedia.Camera.Core 67 68| 名称 | 类型 | 只读 | 可选 | 说明 | 69| ------ | ----------------------------- |-----| ---------- | ---------- | 70| raw<sup>12+</sup> | [image.Image](../apis-image-kit/js-apis-image.md#image9)| NA | 是 | raw图。 | 71 72## ExposureMode 73 74枚举,曝光模式。 75 76**系统接口:** 此接口为系统接口。 77 78**系统能力:** SystemCapability.Multimedia.Camera.Core 79 80| 名称 | 值 | 说明 | 81| ----------------------------- |-----|---------| 82| EXPOSURE_MODE_MANUAL<sup>12+</sup> | 3 | 手动曝光模式。 | 83 84## PolicyType<sup>12+</sup> 85 86枚举,策略类型。 87 88**系统接口:** 此接口为系统接口。 89 90**系统能力:** SystemCapability.Multimedia.Camera.Core 91 92| 名称 | 值 | 说明 | 93| ----------------------------- |-----|---------| 94| PRIVACY<sup>12+</sup> | 1 | 隐私类型。 | 95 96## LightPaintingType<sup>12+</sup> 97 98枚举,流光快门模式类型。 99 100**系统接口:** 此接口为系统接口。 101 102**系统能力:** SystemCapability.Multimedia.Camera.Core 103 104| 名称 | 值 | 说明 | 105| ----------------------------- |-----|---------| 106| TRAFFIC_TRAILS | 0 | 车水马龙。 | 107| STAR_TRAILS | 1 | 绚丽星轨。 | 108| SILKY_WATER | 2 | 丝绢流水。 | 109| LIGHT_GRAFFITI | 3 | 光绘涂鸦。 | 110 111## CameraManager 112 113相机管理器类,使用前需要通过[getCameraManager](js-apis-camera.md#cameragetcameramanager)获取相机管理实例。 114 115### createDepthDataOutput<sup>13+</sup> 116 117createDepthDataOutput(profile: Profile): DepthDataOutput 118 119创建深度输出对象,同步返回结果。 120 121**系统接口:** 此接口为系统接口。 122 123**系统能力:** SystemCapability.Multimedia.Camera.Core 124 125**参数:** 126 127| 参数名 | 类型 | 必填 | 说明 | 128| -------- | ----------------------------------------------- | ---- | ------------------------------- | 129| profile | [Profile](js-apis-camera.md#profile) | 是 | 支持的预览配置信息,通过[getSupportedOutputCapability](js-apis-camera.md#getsupportedoutputcapability11)接口获取。| 130 131**返回值:** 132 133| 类型 | 说明 | 134| ---------- | ----------------------------- | 135| [DepthDataOutput](#depthdataoutput13) | DepthDataOutput实例。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 136 137**错误码:** 138 139以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 140 141| 错误码ID | 错误信息 | 142| --------------- | --------------- | 143| 7400101 | Parameter missing or parameter type incorrect. | 144| 7400201 | Camera service fatal error. | 145 146**示例:** 147 148```ts 149import { BusinessError } from '@kit.BasicServicesKit'; 150 151function createDepthDataOutput(cameraOutputCapability: camera.CameraOutputCapability, cameraManager: camera.CameraManager): camera.DepthDataOutput | undefined { 152 let profile: camera.Profile = cameraOutputCapability.depthProfiles[0]; 153 let depthDataOutput: camera.DepthDataOutput | undefined = undefined; 154 try { 155 depthDataOutput = cameraManager.createDepthDataOutput(profile); 156 } catch (error) { 157 // 失败返回错误码error.code并处理。 158 let err = error as BusinessError; 159 console.error(`The createDepthDataOutput call failed. error code: ${err.code}`); 160 } 161 return depthDataOutput; 162} 163``` 164 165### isCameraMuteSupported 166 167isCameraMuteSupported(): boolean 168 169查询当前设备是否支持禁用相机。 170 171**系统接口:** 此接口为系统接口。 172 173**系统能力:** SystemCapability.Multimedia.Camera.Core 174 175**返回值:** 176 177| 类型 | 说明 | 178| ---------- | ----------------------------- | 179| boolean | 返回true表示相机可以被禁用,返回false表示相机不能被禁用。 | 180 181**示例:** 182 183```ts 184function isCameraMuteSupported(cameraManager: camera.CameraManager): boolean { 185 let isMuteSupported: boolean = cameraManager.isCameraMuteSupported(); 186 return isMuteSupported; 187} 188``` 189 190### muteCamera 191 192muteCamera(mute: boolean): void 193 194禁用相机。 195 196> **说明:** 197>从 API version 10开始支持,从API version 12开始废弃。建议使用[muteCameraPersistent](#mutecamerapersistent12)替代。 198 199**系统接口:** 此接口为系统接口。 200 201**系统能力:** SystemCapability.Multimedia.Camera.Core 202 203**参数:** 204 205| 参数名 | 类型 | 必填 | 说明 | 206| -------- | --------------------------------- | ---- | ---------- | 207| mute | boolean | 是 | 禁用相机。true为禁用;false为解除禁用。 | 208 209**示例:** 210 211```ts 212function muteCamera(cameraManager: camera.CameraManager): void { 213 let mute: boolean = true; 214 cameraManager.muteCamera(mute); 215} 216``` 217 218### muteCameraPersistent<sup>12+</sup> 219 220muteCameraPersistent(mute: boolean, type: PolicyType): void 221 222以持久化的方式禁用相机。 223 224**系统接口:** 此接口为系统接口。 225 226**系统能力:** SystemCapability.Multimedia.Camera.Core 227 228**参数:** 229 230| 参数名 | 类型 | 必填 | 说明 | 231| -------- |-----------------------------| ---- |--------------------------------------------| 232| mute | boolean | 是 | 禁用相机。true为禁用;false为解除禁用。 | 233| type | [PolicyType](#policytype12) | 是 | 策略类型。请使用[PolicyType](#policytype12)里面支持的类型 | 234 235**示例:** 236 237```ts 238function muteCameraPersistent(cameraManager: camera.CameraManager): void { 239 let mute: boolean = true; 240 cameraManager.muteCameraPersistent(mute, camera.PolicyType.PRIVACY); 241} 242``` 243 244### on('cameraMute') 245 246on(type: 'cameraMute', callback: AsyncCallback\<boolean\>): void 247 248禁用回调,通过注册回调函数获取相机禁用状态变化。使用callback异步回调。 249 250**系统接口:** 此接口为系统接口。 251 252**系统能力:** SystemCapability.Multimedia.Camera.Core 253 254**参数:** 255 256| 参数名 | 类型 | 必填 | 说明 | 257| -------- | --------------- | ---- | --------- | 258| type | string | 是 | 监听事件,固定为'cameraMute',系统相机开关,cameraManager对象获取成功后可监听。系统设置打开或禁用相机会触发该事件并返回状态。 | 259| callback | AsyncCallback\<boolean> | 是 | 回调函数,用于获取禁用状态变化信息,返回true为开启状态,返回false为禁用状态。 | 260 261**示例:** 262 263```ts 264import { BusinessError } from '@kit.BasicServicesKit'; 265 266function callback(err: BusinessError, curMuted: boolean): void { 267 if (err !== undefined && err.code !== 0) { 268 console.error(`Callback Error, errorCode: ${err.code}`); 269 return; 270 } 271 let isMuted: boolean = curMuted; 272 console.info(`cameraMute status: ${isMuted}`); 273} 274 275function registerCameraMute(cameraManager: camera.CameraManager): void { 276 cameraManager.on('cameraMute', callback); 277} 278``` 279 280### off('cameraMute') 281 282off(type: 'cameraMute', callback?: AsyncCallback\<boolean\>): void 283 284禁用回调,通过注销注册回调函数获取相机禁用状态变化。 285 286**系统接口:** 此接口为系统接口。 287 288**系统能力:** SystemCapability.Multimedia.Camera.Core 289 290**参数:** 291 292| 参数名 | 类型 | 必填 | 说明 | 293| -------- | --------------- | ---- |---------------------------------------------------------| 294| type | string | 是 | 监听事件,固定为'cameraMute',系统相机开关,cameraManager对象获取成功后可监听。 | 295| callback | AsyncCallback\<boolean> | 否 | 回调函数,可选参数,返回true为开启状态,返回false为禁用状态,有就是匹配on('cameraMute') callback(callback对象不可是匿名函数)。 | 296 297**示例:** 298 299```ts 300import { BusinessError } from '@kit.BasicServicesKit'; 301 302function callback(err: BusinessError, curMuted: boolean): void { 303 let isMuted: boolean = curMuted; 304} 305 306function unregisterCameraMute(cameraManager: camera.CameraManager): void { 307 cameraManager.off('cameraMute', callback); 308} 309``` 310 311### isPrelaunchSupported 312 313isPrelaunchSupported(camera: CameraDevice): boolean 314 315检查指定cameraDevice是否支持预热启动。 316 317**系统接口:** 此接口为系统接口。 318 319**系统能力:** SystemCapability.Multimedia.Camera.Core 320 321**参数:** 322 323| 参数名 | 类型 | 必填 | 说明 | 324| -------- |--------------------------------------------------| ---- | --------- | 325| camera | [CameraDevice](./js-apis-camera.md#cameradevice) | 是 | 相机信息。| 326 327**返回值:** 328 329| 类型 | 说明 | 330| -------- | --------------- | 331| boolean | 返回指定cameraDevice是否支持预热启动,返回true为支持,返回false为不支持。| 332 333**错误码:** 334 335以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 336 337| 错误码ID | 错误信息 | 338| --------------- | --------------- | 339| 202 | Not System Application. | 340| 7400101 | Parameter missing or parameter type incorrect. | 341 342**示例:** 343 344```ts 345import { common } from '@kit.AbilityKit'; 346 347function isPreLaunchSupported(context: common.BaseContext): boolean { 348 let cameraManager: camera.CameraManager = camera.getCameraManager(context); 349 let cameras: Array<camera.CameraDevice> = cameraManager.getSupportedCameras(); 350 let isSupported: boolean = false; 351 if (cameras && cameras.length >= 1) { 352 isSupported = cameraManager.isPrelaunchSupported(cameras[0]); 353 console.info(`PreLaunch supported states: ${isSupported}`); 354 return isSupported; 355 } 356 return isSupported; 357} 358``` 359 360### setPrelaunchConfig 361 362setPrelaunchConfig(prelaunchConfig: PrelaunchConfig): void 363 364设置预热启动的配置参数。 365 366在调用setPrelaunchConfig接口前,需要先检查设备是否支持预热启动,使用[isPrelaunchSupported](#isprelaunchsupported)判断指定cameraDevice是否支持预热启动。 367 368**系统接口:** 此接口为系统接口。 369 370**需要权限:** ohos.permission.CAMERA 371 372**系统能力:** SystemCapability.Multimedia.Camera.Core 373 374**参数:** 375 376| 参数名 | 类型 | 必填 | 说明 | 377| -------- | --------------- | ---- | --------- | 378| prelaunchConfig | [PrelaunchConfig](#prelaunchconfig) | 是 | 预启动配置参数。| 379 380**错误码:** 381 382以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 383 384| 错误码ID | 错误信息 | 385| --------------- | --------------- | 386| 202 | Not System Application. | 387| 7400101 | Parameter missing or parameter type incorrect. | 388| 7400102 | Operation not allowed. | 389| 7400201 | Camera service fatal error. | 390 391**示例:** 392 393```ts 394import { common } from '@kit.AbilityKit'; 395import { BusinessError } from '@kit.BasicServicesKit'; 396 397function setPrelaunchConfig(context: common.BaseContext): void { 398 let cameraManager: camera.CameraManager = camera.getCameraManager(context); 399 let cameras: Array<camera.CameraDevice> = cameraManager.getSupportedCameras(); 400 if (cameras && cameras.length >= 1) { 401 let cameraDevice: camera.CameraDevice = cameras[0]; 402 if(cameraManager.isPrelaunchSupported(cameraDevice)) { 403 try { 404 cameraManager.setPrelaunchConfig({cameraDevice: cameraDevice}); 405 } catch (error) { 406 let err = error as BusinessError; 407 console.error(`setPrelaunchConfig error. Code: ${err.code}, message: ${err.message}`); 408 } 409 } 410 } 411} 412``` 413 414### prelaunch 415 416prelaunch(): void 417 418用户点击系统相机图标,拉起相机应用同时调用,下发预热请求,使能相机预热启动。 419 420**系统接口:** 此接口为系统接口。 421 422**系统能力:** SystemCapability.Multimedia.Camera.Core 423 424**示例:** 425 426```ts 427import { common } from '@kit.AbilityKit'; 428import { BusinessError } from '@kit.BasicServicesKit'; 429 430function preLaunch(context: common.BaseContext): void { 431 let cameraManager: camera.CameraManager = camera.getCameraManager(context); 432 try { 433 cameraManager.prelaunch(); 434 } catch (error) { 435 let err = error as BusinessError; 436 console.error(`prelaunch error. Code: ${err.code}, message: ${err.message}`); 437 } 438} 439``` 440 441### createDeferredPreviewOutput 442 443createDeferredPreviewOutput(profile: Profile): PreviewOutput 444 445创建延迟预览输出对象,在配流时替代普通的预览输出对象加入数据流。 446 447**系统接口:** 此接口为系统接口。 448 449**系统能力:** SystemCapability.Multimedia.Camera.Core 450 451**参数:** 452 453| 参数名 | 类型 | 必填 | 说明 | 454| -------- | --------------- | ---- | --------- | 455| profile | [Profile](js-apis-camera.md#profile) | 是 | 相机预览流的配置文件。 | 456 457**返回值:** 458 459| 类型 | 说明 | 460| -------- | --------------- | 461| [PreviewOutput](#previewoutput) | 返回预览输出对象。 | 462 463**错误码:** 464 465以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 466 467| 错误码ID | 错误信息 | 468| --------------- | --------------- | 469| 202 | Not System Application. | 470| 7400101 | Parameter missing or parameter type incorrect. | 471 472**示例:** 473 474```ts 475import { common } from '@kit.AbilityKit'; 476 477function getDeferredPreviewOutput(context: common.BaseContext, previewProfile: camera.Profile): camera.PreviewOutput { 478 const cameraManager: camera.CameraManager = camera.getCameraManager(context); 479 const output: camera.PreviewOutput = cameraManager.createDeferredPreviewOutput(previewProfile); 480 return output; 481} 482``` 483 484### preSwitchCamera<sup>11+</sup> 485 486preSwitchCamera(cameraId: string): void 487 488预切换相机,提升相机启动速度。 489 490**系统接口:** 此接口为系统接口。 491 492**系统能力:** SystemCapability.Multimedia.Camera.Core 493 494**参数:** 495 496| 参数名 | 类型 | 必填 | 说明 | 497| -------- | --------------- | ---- | --------- | 498| cameraId | string | 是 | 相机id。 | 499 500**错误码:** 501 502以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 503 504| 错误码ID | 错误信息 | 505| ------- |------------------------------------------------| 506| 202 | Not System Application. | 507| 7400101 | Parameter missing or parameter type incorrect. | 508| 7400201 | Camera service fatal error. | 509 510**示例:** 511 512```ts 513import { common } from '@kit.AbilityKit'; 514import { BusinessError } from '@kit.BasicServicesKit'; 515 516function preSwitch(cameraDevice: camera.CameraDevice, context: common.BaseContext): void { 517 let cameraManager: camera.CameraManager = camera.getCameraManager(context); 518 try { 519 cameraManager.preSwitchCamera(cameraDevice.cameraId); 520 } catch (error) { 521 let err = error as BusinessError; 522 console.error(`prelaunch error. Code: ${err.code}, message: ${err.message}`); 523 } 524} 525``` 526 527## CameraOcclusionDetectionResult<sup>12+</sup> 528相机模组被遮挡状态。 529 530**系统接口:** 此接口为系统接口。 531 532**系统能力:** SystemCapability.Multimedia.Camera.Core 533 534| 名称 | 类型 | 只读 | 可选 | 说明 | 535| ----------------------------- | --------------------------------------------------- | ---- | ---- |-------------------| 536| isCameraOccluded | boolean | 是 | 否 |遮挡状态,true为遮挡状态,false为不遮挡状态。 | 537 538## CameraOutputCapability<sup>13+</sup> 539 540相机输出能力项。 541 542**系统接口:** 此接口为系统接口。 543 544**系统能力:** SystemCapability.Multimedia.Camera.Core 545 546| 名称 | 类型 | 只读 | 可选 | 说明 | 547| ----------------------------- | --------------------------------------------------- | ---- | ---- |-------------------| 548| depthProfiles | Array\<[DepthProfile](#depthprofile13)\> | 是 | 否 | 支持的深度流配置信息集合。 | 549 550## CameraFormat 551 552枚举,输出格式。 553 554**系统接口:** 此接口为系统接口。 555 556**系统能力:** SystemCapability.Multimedia.Camera.Core 557 558| 名称 | 值 | 说明 | 559| ----------------------- | --------- | ------------ | 560| CAMERA_FORMAT_DEPTH_16<sup>13+</sup> | 3000 | DEPTH_16格式的深度图。 | 561| CAMERA_FORMAT_DEPTH_32<sup>13+</sup> | 3001 | DEPTH_32格式的深度图。 | 562 563## CameraInput 564 565相机设备输入对象。 566 567会话中[Session](js-apis-camera.md#session11)使用的相机信息。 568 569### on('cameraOcclusionDetection')<sup>12+</sup> 570 571on(type: 'cameraOcclusionDetection', callback: AsyncCallback\<CameraOcclusionDetectionResult\>): void 572 573监听CameraInput的遮挡事件,通过注册回调函数获取结果。使用callback异步回调。 574 575**系统能力:** SystemCapability.Multimedia.Camera.Core 576 577**参数:** 578 579| 参数名 | 类型 | 必填 | 说明 | 580| -------- | -------------------------------- | --- | ------------------------------------------- | 581| type | string | 是 | 监听事件,固定为'cameraOcclusionDetection',CameraInput对象创建成功可监听。相机模组遮挡状态发生改变时触发该事件并返回结果。 | 582| callback | AsyncCallback\<[CameraOcclusionDetectionResult](#cameraocclusiondetectionresult12)\> | 是 | 回调函数,用于获取结果。返回遮挡状态。 | 583 584**示例:** 585 586```ts 587import { BusinessError } from '@kit.BasicServicesKit'; 588 589function callback(err: BusinessError, CameraOcclusionDetectionResult: camera.CameraOcclusionDetectionResult): void { 590 if (err !== undefined && err.code !== 0) { 591 console.error('cameraOcclusionDetection with errorCode = ' + err.code); 592 return; 593 } 594 console.info(`isCameraOccluded : ${CameraOcclusionDetectionResult.isCameraOccluded}`); 595} 596 597function registerCameraOcclusionDetection(cameraInput: camera.CameraInput): void { 598 cameraInput.on('cameraOcclusionDetection', callback); 599} 600``` 601 602### off('cameraOcclusionDetection')<sup>12+</sup> 603 604off(type: 'cameraOcclusionDetection', callback?: AsyncCallback\<CameraOcclusionDetectionResult\>): void 605 606注销CameraInput遮挡监听事件。 607 608**系统能力:** SystemCapability.Multimedia.Camera.Core 609 610**参数:** 611 612| 参数名 | 类型 | 必填 | 说明 | 613| -------- | --------------- | ---- |---------------------------------------------------------| 614| type | string | 是 | 监听事件,固定为'cameraOcclusionDetection',CameraInput对象创建成功可监听。 | 615| callback | AsyncCallback\<[CameraOcclusionDetectionResult](#cameraocclusiondetectionresult12)\> | 否 | 回调函数,可选参数,有就是匹配on('cameraOcclusionDetection') callback(callback对象不可是匿名函数)。 | 616 617**示例:** 618 619```ts 620import { BusinessError } from '@kit.BasicServicesKit'; 621 622function callback(err: BusinessError, CameraOcclusionDetectionResult: camera.CameraOcclusionDetectionResult): void { 623 if (err !== undefined && err.code !== 0) { 624 console.error('cameraOcclusionDetection with errorCode = ' + err.code); 625 return; 626 } 627 console.info(`isCameraOccluded : ${CameraOcclusionDetectionResult.isCameraOccluded}`); 628} 629 630function unregisterCameraOcclusionDetection(cameraInput: camera.CameraInput): void { 631 cameraInput.off('cameraOcclusionDetection', callback); 632} 633``` 634 635## DepthDataAccuracy<sup>13+</sup> 636 637深度数据的精度。 638 639**系统接口:** 此接口为系统接口。 640 641**系统能力:** SystemCapability.Multimedia.Camera.Core 642 643| 名称 | 类型 | 只读 | 可选 | 说明 | 644| -------- | ----------------------------- |----- |---| -------------- | 645| DEPTH_DATA_ACCURACY_RELATIVE | number | 是 | 否 | 相对精度,基于视差计算得到的深度图。 | 646| DEPTH_DATA_ACCURACY_ABSOLUTE | number | 是 | 否 | 绝对精度,基于测距计算得到的深度图。 | 647 648## DepthProfile<sup>13+</sup> 649 650深度数据配置信息项,继承[Profile](js-apis-camera.md#profile)。 651 652**系统接口:** 此接口为系统接口。 653 654**系统能力:** SystemCapability.Multimedia.Camera.Core 655 656| 名称 | 类型 | 只读 | 可选 | 说明 | 657| ------------------------- | ----------------------------------------- | --- | ---- |----------- | 658| depthDataAccuracy | [DepthDataAccuracy](#depthdataaccuracy13) | 是 | 否 | 深度数据的精度,分为相对精度和绝对精度。 | 659 660## DepthDataQualityLevel<sup>13+</sup> 661 662深度数据的质量。 663 664**系统接口:** 此接口为系统接口。 665 666**系统能力:** SystemCapability.Multimedia.Camera.Core 667 668| 名称 | 类型 | 只读 | 可选 | 说明 | 669| -------- | ----------------------------- |----- |---| -------------- | 670| DEPTH_DATA_QUALITY_BAD | number | 是 | 否 | 深度图的质量很差,无法用于虚化等。 | 671| DEPTH_DATA_QUALITY_FAIR | number | 是 | 否 | 深度图的质量一般,无法生成高质量的虚化等。 | 672| DEPTH_DATA_QUALITY_GOOD | number | 是 | 否 | 深度图的质量较高,可以生成高质量的虚化等。 | 673 674## DepthData<sup>13+</sup> 675 676深度数据对象。 677 678### 属性 679 680**系统接口:** 此接口为系统接口。 681 682**系统能力:** SystemCapability.Multimedia.Camera.Core 683 684| 名称 | 类型 | 只读 | 可选 | 说明 | 685| -------- | ----------------------------- |----- |---| -------------- | 686| format | [CameraFormat](#cameraformat) | 是 | 否 | 深度图的格式。 | 687| depthMap | [image.PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7) | 是 | 否 | 深度图。 | 688| qualityLevel | [DepthDataQualityLevel](#depthdataqualitylevel13) | 是 | 否 | 深度图的质量。 | 689| accuracy | [DepthDataAccuracy](#depthdataaccuracy13) | 是 | 否 | 深度图的精度。 | 690 691### release<sup>13+</sup> 692 693release(): void 694 695释放输出资源。 696 697**系统接口:** 此接口为系统接口。 698 699**系统能力:** SystemCapability.Multimedia.Camera.Core 700 701**示例:** 702 703```ts 704function releaseDepthData(depthData: camera.DepthData): void { 705 await depthData.release(); 706} 707``` 708 709## DepthDataOutput<sup>13+</sup> 710 711深度信息输出类。继承[CameraOutput](js-apis-camera.md#cameraoutput)。 712 713### start<sup>13+</sup> 714 715start(): Promise\<void\> 716 717启动深度信息输出流,通过Promise获取结果。 718 719**系统接口:** 此接口为系统接口。 720 721**系统能力:** SystemCapability.Multimedia.Camera.Core 722 723**返回值:** 724 725| 类型 | 说明 | 726| -------------- | ----------------------- | 727| Promise\<void\> | 无返回结果的Promise对象。 | 728 729**错误码:** 730 731以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 732 733| 错误码ID | 错误信息 | 734| --------------- | --------------- | 735| 7400103 | Session not config. | 736| 7400201 | Camera service fatal error. | 737 738**示例:** 739 740```ts 741import { BusinessError } from '@kit.BasicServicesKit'; 742 743function startDepthDataOutput(depthDataOutput: camera.DepthDataOutput): void { 744 depthDataOutput.start().then(() => { 745 console.info('Promise returned to indicate that start method execution success.'); 746 }).catch((error: BusinessError) => { 747 console.error(`Failed to depth data output start, error code: ${error.code}.`); 748 }); 749} 750``` 751 752### stop<sup>13+</sup> 753 754stop(): Promise\<void\> 755 756结束深度信息输出,通过Promise获取结果。 757 758**系统接口:** 此接口为系统接口。 759 760**系统能力:** SystemCapability.Multimedia.Camera.Core 761 762**返回值:** 763 764| 类型 | 说明 | 765| -------------- | ----------------------- | 766| Promise\<void\> | 无返回结果的Promise对象。 | 767 768**示例:** 769 770```ts 771import { BusinessError } from '@kit.BasicServicesKit'; 772 773function stopDepthDataOutput(depthDataOutput: camera.DepthDataOutput): void { 774 depthDataOutput.stop().then(() => { 775 console.info('Promise returned to indicate that stop method execution success.'); 776 }).catch((error: BusinessError) => { 777 console.error(`Failed to depth data output stop, error code: ${error.code}.`); 778 }); 779} 780``` 781 782### on('depthDataAvailable')<sup>13+</sup> 783 784on(type: 'depthDataAvailable', callback: AsyncCallback\<DepthData\>): void 785 786注册监听深度数据上报。使用callback异步回调。 787 788> **说明:** 789> 790> 当前注册监听接口,不支持在on监听的回调方法里,调用off注销回调。 791 792**系统接口:** 此接口为系统接口。 793 794**系统能力:** SystemCapability.Multimedia.Camera.Core 795 796**参数:** 797 798| 参数名 | 类型 | 必填 | 说明 | 799| -------- | ---------- | --- | ------------------------------------ | 800| type | string | 是 | 监听事件,固定为'depthDataAvailable',depthDataOutput创建成功后可监听。 | 801| callback | AsyncCallback\<[DepthData](#depthdata13)\> | 是 | 回调函数,用于监听深度信息上报。 | 802 803**示例:** 804 805```ts 806import { BusinessError } from '@kit.BasicServicesKit'; 807 808function callback(err: BusinessError, depthData: camera.DepthData): void { 809 if (err !== undefined && err.code !== 0) { 810 console.error(`Callback Error, errorCode: ${err.code}`); 811 return; 812 } 813} 814 815function registerDepthDataAvailable(depthDataOutput: camera.DepthDataOutput): void { 816 depthDataOutput.on('depthDataAvailable', callback); 817} 818``` 819 820### off('depthDataAvailable')<sup>13+</sup> 821 822off(type: 'depthDataAvailable', callback?: AsyncCallback\<DepthData\>): void 823 824注销监听深度信息上报。 825 826**系统接口:** 此接口为系统接口。 827 828**系统能力:** SystemCapability.Multimedia.Camera.Core 829 830**参数:** 831 832| 参数名 | 类型 | 必填 | 说明 | 833| -------- | ---------------------- | ---- | ------------------------------------------ | 834| type | string | 是 | 监听事件,固定为'depthDataAvailable',depthDataOutput创建成功后可监听。 | 835| callback | AsyncCallback\<[DepthData](#depthdata13)\> | 否 | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 | 836 837**示例:** 838 839```ts 840import { BusinessError } from '@kit.BasicServicesKit'; 841 842function callback(err: BusinessError, depthData: camera.DepthData): void { 843 if (err !== undefined && err.code !== 0) { 844 console.error(`Callback Error, errorCode: ${err.code}`); 845 return; 846 } 847} 848 849function unRegisterDepthDataAvailable(depthDataOutput: camera.DepthDataOutput): void { 850 depthDataOutput.off('depthDataAvailable', callback); 851} 852``` 853 854### on('error')<sup>13+</sup> 855 856on(type: 'error', callback: ErrorCallback): void 857 858监听深度信息输出的错误事件,通过注册回调函数获取结果。使用callback异步回调。 859 860> **说明:** 861> 862> 当前注册监听接口,不支持在on监听的回调方法里,调用off注销回调。 863 864**系统接口:** 此接口为系统接口。 865 866**系统能力:** SystemCapability.Multimedia.Camera.Core 867 868**参数:** 869 870| 参数名 | 类型 | 必填 | 说明 | 871| -------- | --------------| ---- | ------------------------ | 872| type | string | 是 | 监听事件,固定为'error',depthDataOutput创建成功可监听。 | 873| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 874 875**示例:** 876 877```ts 878import { BusinessError } from '@kit.BasicServicesKit'; 879 880function callback(depthDataOutputError: BusinessError): void { 881 console.error(`Depth data output error code: ${depthDataOutputError.code}`); 882} 883 884function registerDepthDataOutputError(depthDataOutput: camera.DepthDataOutput): void { 885 depthDataOutput.on('error', callback) 886} 887``` 888 889### off('error')<sup>13+</sup> 890 891off(type: 'error', callback?: ErrorCallback): void 892 893注销监听深度信息输出的错误事件。 894 895**系统接口:** 此接口为系统接口。 896 897**系统能力:** SystemCapability.Multimedia.Camera.Core 898 899**参数:** 900 901| 参数名 | 类型 | 必填 | 说明 | 902| -------- | --------------| ---- | ------------------------ | 903| type | string | 是 | 监听事件,固定为'error',depthDataOutput创建成功可监听。 | 904| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | 否 | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 | 905 906**示例:** 907 908```ts 909function unregisterDepthDataOutputError(depthDataOutput: camera.DepthDataOutput): void { 910 depthDataOutput.off('error'); 911} 912``` 913 914## PrelaunchConfig 915 916相机预启动配置参数。 917 918当前sensor级别预热,待扩展流预热参数。 919 920**系统接口:** 此接口为系统接口。 921 922**系统能力:** SystemCapability.Multimedia.Camera.Core 923 924| 名称 | 类型 | 只读 | 必填 | 说明 | 925| ------------------------------- |--------------------------------------------------| ----------- | ------------ | ---------- | 926| cameraDevice | [CameraDevice](./js-apis-camera.md#cameradevice) | 否 | 是 | 相机信息。 | 927| restoreParamType<sup>11+</sup> | [RestoreParamType](#restoreparamtype11) | 否 | 否 | 预保存参数类型。 | 928| activeTime<sup>11+</sup> | number | 否 | 否 | 激活时间,单位min。 | 929| settingParam<sup>11+</sup> | [SettingParam](#settingparam11) | 否 | 否 | 设置参数内容。 | 930 931## RestoreParamType<sup>11+</sup> 932 933预保存参数类型。 934 935**系统接口:** 此接口为系统接口。 936 937**系统能力:** SystemCapability.Multimedia.Camera.Core 938 939| 名称 | 值 | 说明 | 940| ----------------| ---- | ---------| 941| NO_NEED_RESTORE_PARAM | 0 | 不需要预保存参数类型。 | 942| PRESISTENT_DEFAULT_PARAM | 1 | 持久化参数类型,指某一时间点后,使用该参数恢复流信息。 | 943| TRANSIENT_ACTIVE_PARAM | 2 | 临时参数类型,只在关闭相机后一段时间内,使用该参数恢复流信息,优先级高于持久化参数。 | 944 945## SettingParam<sup>11+</sup> 946 947用于预热出图的效果参数。 948 949**系统接口:** 此接口为系统接口。 950 951**系统能力:** SystemCapability.Multimedia.Camera.Core 952 953| 名称 | 类型 | 只读 | 可选 | 说明 | 954| --------------- | ------ | --------- |-----|---------------------------------------------------------------------------------------------------| 955| skinSmoothLevel | number | 否 | 否 | 美颜类型光滑信息,从[Beauty.getSupportedBeautyRange](#getsupportedbeautyrange11)获取支持的光滑范围,例如1表示1级光滑。 | 956| faceSlender | number | 否 | 否 | 美颜类型瘦脸信息,从[Beauty.getSupportedBeautyRange](#getsupportedbeautyrange11)获取支持的瘦脸范围,例如1表示1级瘦脸。 | 957| skinTone | number | 否 | 否 | 美颜类型肤色信息,从[Beauty.getSupportedBeautyRange](#getsupportedbeautyrange11)获取支持的肤色范围,例如0xBF986C表示一个颜色。 | 958 959## PreviewOutput 960 961预览输出类。继承[CameraOutput](js-apis-camera.md#cameraoutput)。 962 963### addDeferredSurface 964 965addDeferredSurface(surfaceId: string): void 966 967配置延迟预览的Surface,可以在[Session.commitConfig](js-apis-camera.md#commitconfig11-1)配流和[Session.start](js-apis-camera.md#start11-1)启流之后运行。 968 969**系统接口:** 此接口为系统接口。 970 971**系统能力:** SystemCapability.Multimedia.Camera.Core 972 973**参数:** 974 975| 参数名 | 类型 | 必填 | 说明 | 976| -------- | --------------| ---- | ------------------------ | 977| surfaceId | string | 是 | 从[XComponent](../apis-arkui/arkui-ts/ts-basic-components-xcomponent.md)组件获取的surfaceId。| 978 979**错误码:** 980 981以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 982 983| 错误码ID | 错误信息 | 984| --------------- | --------------- | 985| 7400101 | Parameter missing or parameter type incorrect. | 986 987**示例:** 988 989```ts 990import { common } from '@kit.AbilityKit'; 991 992async function preview(context: common.BaseContext, cameraDevice: camera.CameraDevice, previewProfile: camera.Profile, photoProfile: camera.Profile, mode: camera.SceneMode, previewSurfaceId: string): Promise<void> { 993 const cameraManager: camera.CameraManager = camera.getCameraManager(context); 994 const cameraInput: camera.CameraInput = cameraManager.createCameraInput(cameraDevice); 995 const previewOutput: camera.PreviewOutput = cameraManager.createDeferredPreviewOutput(previewProfile); 996 const photoOutput: camera.PhotoOutput = cameraManager.createPhotoOutput(photoProfile); 997 const session: camera.Session = cameraManager.createSession(mode); 998 session.beginConfig(); 999 session.addInput(cameraInput); 1000 session.addOutput(previewOutput); 1001 session.addOutput(photoOutput); 1002 await session.commitConfig(); 1003 await session.start(); 1004 previewOutput.addDeferredSurface(previewSurfaceId); 1005} 1006``` 1007 1008### isSketchSupported<sup>11+</sup> 1009 1010isSketchSupported(): boolean 1011 1012查询是否支持画中画能力。 1013 1014**系统接口:** 此接口为系统接口。 1015 1016**系统能力:** SystemCapability.Multimedia.Camera.Core 1017 1018**返回值:** 1019 1020| 类型 | 说明 | 1021| -------------- | ----------------------- | 1022| boolean | 返回是否支持画中画,返回true为支持,返回false为不支持。 | 1023 1024**错误码:** 1025 1026以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1027 1028| 错误码ID | 错误信息 | 1029| --------------- |-------------------------| 1030| 202 | Not System Application. | 1031 1032**示例:** 1033 1034```ts 1035function isSketchSupported(previewOutput: camera.PreviewOutput): boolean { 1036 try { 1037 let isSupported: boolean = previewOutput.isSketchSupported(); 1038 return isSupported; 1039 } catch (error) { 1040 // 失败返回错误码error.code并处理。 1041 let err = error as BusinessError; 1042 console.error(`The isSketchSupported call failed. error code: ${err.code}`); 1043 } 1044 return false; 1045} 1046``` 1047 1048### getSketchRatio<sup>11+</sup> 1049 1050getSketchRatio(): number 1051 1052获取当前状态下启动画中画的Zoom倍率。 1053 1054**系统接口:** 此接口为系统接口。 1055 1056**系统能力:** SystemCapability.Multimedia.Camera.Core 1057 1058**返回值:** 1059 1060| 类型 | 说明 | 1061| -------------- | ----------------------- | 1062| number | 当前状态下启动画中画的Zoom倍率。不支持画中画的情况下,该接口返回-1。 | 1063 1064**错误码:** 1065 1066以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1067 1068| 错误码ID | 错误信息 | 1069| --------------- | --------------- | 1070| 7400103 | Session not config. | 1071| 202 | Not System Application. | 1072 1073**示例:** 1074 1075```ts 1076function getSketchRatio(previewOutput: camera.PreviewOutput): number { 1077 let sketchRatio: number = previewOutput.getSketchRatio(); 1078 return sketchRatio; 1079} 1080``` 1081 1082### enableSketch<sup>11+</sup> 1083 1084enableSketch(enabled: boolean): void 1085 1086使能画中画。 1087 1088**系统接口:** 此接口为系统接口。 1089 1090**系统能力:** SystemCapability.Multimedia.Camera.Core 1091 1092**参数:** 1093 1094| 参数名 | 类型 | 必填 | 说明 | 1095|---------|---------| ---- | ------------------------ | 1096| enabled | boolean | 是 | true表明开启画中画流进行预览,false表明不开启。| 1097 1098**错误码:** 1099 1100以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1101 1102| 错误码ID | 错误信息 | 1103|-----------|-----------------------------| 1104| 202 | Not System Application. | 1105| 7400102 | Operation not allowed. | 1106| 7400103 | Session not config. | 1107| 7400201 | Camera service fatal error. | 1108 1109**示例:** 1110 1111```ts 1112import { BusinessError } from '@kit.BasicServicesKit'; 1113 1114function enableSketch(previewOutput: camera.PreviewOutput, session: camera.Session, cameraInput: camera.CameraInput): void { 1115 try { 1116 session.beginConfig(); 1117 session.addInput(cameraInput); 1118 session.addOutput(previewOutput); 1119 previewOutput.enableSketch(true); 1120 session.commitConfig(); 1121 } catch (error) { 1122 // 失败返回错误码error.code并处理。 1123 let err = error as BusinessError; 1124 console.error(`The enableSketch call failed. error code: ${err.code}`); 1125 } 1126} 1127``` 1128 1129### attachSketchSurface<sup>11+</sup> 1130 1131attachSketchSurface(surfaceId: string): void 1132 1133添加画中画预览的Surface。 1134 1135**系统接口:** 此接口为系统接口。 1136 1137**系统能力:** SystemCapability.Multimedia.Camera.Core 1138 1139**参数:** 1140 1141| 参数名 | 类型 | 必填 | 说明 | 1142| -------- | --------------| ---- | ------------------------ | 1143| surfaceId | string | 是 | 从[XComponent](../apis-arkui/arkui-ts/ts-basic-components-xcomponent.md)组件获取的surfaceId。| 1144 1145**错误码:** 1146 1147以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1148 1149| 错误码ID | 错误信息 | 1150|---------|------------------------------------------------| 1151| 202 | Not System Application. | 1152| 7400101 | Parameter missing or parameter type incorrect. | 1153| 7400103 | Session not config. | 1154| 7400201 | Camera service fatal error. | 1155 1156**示例:** 1157 1158```ts 1159import { BusinessError } from '@kit.BasicServicesKit'; 1160 1161function attachSketchSurface(previewOutput: camera.PreviewOutput, session: camera.Session, cameraInput: camera.CameraInput, sketchSurfaceId: string): void { 1162 try { 1163 session.beginConfig(); 1164 session.addInput(cameraInput); 1165 session.addOutput(previewOutput); 1166 previewOutput.enableSketch(true); 1167 session.commitConfig(); 1168 previewOutput.attachSketchSurface(sketchSurfaceId); 1169 } catch (error) { 1170 // 失败返回错误码error.code并处理。 1171 let err = error as BusinessError; 1172 console.error(`The attachSketchSurface call failed. error code: ${err.code}`); 1173 } 1174} 1175``` 1176 1177### on('sketchStatusChanged')<sup>11+</sup> 1178 1179on(type: 'sketchStatusChanged', callback: AsyncCallback\<SketchStatusData\>): void 1180 1181监听画中画状态信息改变,通过注册回调函数获取SketchStatusData。使用callback异步回调。 1182 1183**系统接口:** 此接口为系统接口。 1184 1185**系统能力:** SystemCapability.Multimedia.Camera.Core 1186 1187**参数:** 1188 1189| 参数名 | 类型 | 必填 | 说明 | 1190| -------- | ---------------------- | ---- | ------------------------------------------ | 1191| type | string | 是 | 监听事件,固定为'sketchStatusChanged',画中画流创建成功后可监听。底层画中画的状态启停以及画中画Zoom值变更会回调该接口。 | 1192| callback | AsyncCallback\<[SketchStatusData](#sketchstatusdata11)\> | 是 | 使用callback的方式获取SketchStatusData。 | 1193 1194**错误码:** 1195 1196以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1197 1198| 错误码ID | 错误信息 | 1199|---------|-------------------------------| 1200| 202 | Not System Application. | 1201 1202**示例:** 1203 1204```ts 1205import { BusinessError } from '@kit.BasicServicesKit'; 1206 1207function callback(error: BusinessError, data: camera.SketchStatusData): void { 1208 if (error !== undefined && error.code !== 0) { 1209 console.error(`Callback Error, errorCode: ${error.code}`); 1210 return; 1211 } 1212 console.info(`sketch errorCode is ${error.code}, data is ${JSON.stringify(data)}`); 1213} 1214 1215function registerSketchStatusChanged(previewOutput: camera.PreviewOutput): void { 1216 previewOutput.on('sketchStatusChanged', callback); 1217} 1218``` 1219 1220### off('sketchStatusChanged')<sup>11+</sup> 1221 1222off(type: 'sketchStatusChanged', callback?: AsyncCallback\<SketchStatusData\>): void 1223 1224注销监听画中画状态信息改变。 1225 1226**系统接口:** 此接口为系统接口。 1227 1228**系统能力:** SystemCapability.Multimedia.Camera.Core 1229 1230**参数:** 1231 1232| 参数名 | 类型 | 必填 | 说明 | 1233| -------- | ---------------------- | ---- | ------------------------------------------ | 1234| type | string | 是 | 监听事件,固定为'sketchStatusChanged',画中画流创建成功后可监听。 | 1235| callback | AsyncCallback\<[SketchStatusData](#sketchstatusdata11)\> | 否 | 回调函数,可选,有就是匹配on('sketchStatusChanged') callback(callback对象不可是匿名函数)。 | 1236 1237**错误码:** 1238 1239以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1240 1241| 错误码ID | 错误信息 | 1242|---------|-------------------------------| 1243| 202 | Not System Application. | 1244 1245**示例:** 1246 1247```ts 1248function unregisterSketchStatusChanged(previewOutput: camera.PreviewOutput): void { 1249 previewOutput.off('sketchStatusChanged'); 1250} 1251``` 1252 1253## DeferredDeliveryImageType<sup>11+</sup> 1254 1255枚举,分段式能力类型。即将拍照/录像分为两个阶段,一阶段以较快速度输出图片/视频提供给用户,二阶段完成优化处理,重新输出高质量图片/视频。 1256 1257**系统接口:** 此接口为系统接口。 1258 1259**系统能力:** SystemCapability.Multimedia.Camera.Core 1260 1261| 名称 | 值 | 说明 | 1262| ------- | ---- | ------------ | 1263| NONE | 0 | 无分段式能力。| 1264| PHOTO | 1 | 分段式拍照。| 1265| VIDEO | 2 | 分段式录像。| 1266 1267## DeferredPhotoProxy<sup>11+</sup> 1268 1269类对象,缩略图代理类。 1270 1271### getThumbnail<sup>11+</sup> 1272 1273getThumbnail(): Promise<image.PixelMap> 1274 1275通过缩略图代理类提供的方法,获取缩略图 PixelMap。 1276 1277**系统接口:** 此接口为系统接口。 1278 1279**系统能力:** SystemCapability.Multimedia.Camera.Core 1280 1281**返回值:** 1282 1283| 类型 | 说明 | 1284| -------------- | ----------------------- | 1285| Promise\<image.PixelMap\> | 缩略图 PixelMap。 | 1286 1287**错误码:** 1288 1289以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1290 1291| 错误码ID | 错误信息 | 1292| --------------- | --------------- | 1293| 202 | Not System Application. | 1294 1295**示例:** 1296 1297```ts 1298import { image } from '@kit.ImageKit'; 1299 1300function getThumbnail(proxyObj: camera.DeferredPhotoProxy): void { 1301 proxyObj.getThumbnail().then((thumbnail: image.PixelMap) => { 1302 AppStorage.setOrCreate('proxyThumbnail', thumbnail); 1303 }); 1304} 1305``` 1306 1307### release<sup>11+</sup> 1308 1309release(): Promise\<void\> 1310 1311释放输出资源,通过Promise获取结果。 1312 1313**系统接口:** 此接口为系统接口。 1314 1315**系统能力:** SystemCapability.Multimedia.Camera.Core 1316 1317**返回值:** 1318 1319| 类型 | 说明 | 1320| -------------- |------------------| 1321| Promise\<void\> | 无返回结果的Promise对象。 | 1322 1323**错误码:** 1324 1325以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1326 1327| 错误码ID | 错误信息 | 1328| --------------- | --------------- | 1329| 202 | Not System Application. | 1330 1331**示例:** 1332 1333```ts 1334async function releaseDeferredPhotoProxy(proxyObj: camera.DeferredPhotoProxy): Promise<void> { 1335 await proxyObj.release(); 1336} 1337``` 1338 1339## PhotoOutput 1340 1341拍照会话中使用的输出信息,继承[CameraOutput](js-apis-camera.md#cameraoutput)。 1342 1343### burstCapture<sup>12+</sup> 1344 1345burstCapture(setting: PhotoCaptureSetting): Promise\<void\> 1346 1347开始连续拍照,一般用于拍照模式下,开始后底层持续上图,可以通过[confirmCapture](#confirmcapture11)取消连续拍照。 1348 1349**系统接口:** 此接口为系统接口。 1350 1351**系统能力:** SystemCapability.Multimedia.Camera.Core 1352 1353**参数:** 1354 1355| 参数名 | 类型 | 必填 | 说明 | 1356| ------- | ------------------------------------------- | ---- | -------- | 1357| setting | [PhotoCaptureSetting](js-apis-camera.md#photocapturesetting) | 是 | 拍照设置,传入undefined类型数据按默认无参处理。 | 1358 1359**返回值:** 1360 1361| 类型 | 说明 | 1362| -------------- | ------------------------ | 1363| Promise\<void\> | 无返回结果的Promise对象。 | 1364 1365**错误码:** 1366 1367以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1368 1369| 错误码ID | 错误信息 | 1370| --------------- | --------------- | 1371| 202 | Not System Application. | 1372| 7400101 | Parameter missing or parameter type incorrect. | 1373| 7400104 | Session not running. | 1374| 7400201 | Camera service fatal error. | 1375 1376**示例:** 1377 1378```ts 1379import { BusinessError } from '@kit.BasicServicesKit'; 1380 1381function burstCapture(photoOutput: camera.PhotoOutput): void { 1382 let captureLocation: camera.Location = { 1383 latitude: 0, 1384 longitude: 0, 1385 altitude: 0 1386 } 1387 let settings: camera.PhotoCaptureSetting = { 1388 quality: camera.QualityLevel.QUALITY_LEVEL_LOW, 1389 rotation: camera.ImageRotation.ROTATION_0, 1390 location: captureLocation, 1391 mirror: false 1392 } 1393 photoOutput.burstCapture(settings).then(() => { 1394 console.info('Promise returned to indicate that photo burstCapture request success.'); 1395 }).catch((error: BusinessError) => { 1396 console.error(`Failed to photo output burstCapture, error code: ${error.code}.`); 1397 }); 1398} 1399``` 1400 1401### confirmCapture<sup>11+</sup> 1402 1403confirmCapture() 1404 1405确认拍照,一般用于夜景模式下,在曝光倒计时过程中如需终止倒计时提前拍照的时候调用。 1406 1407已经调用[burstCapture](#burstcapture12)开始连续拍照后,调用该接口用于结束连续拍照。 1408 1409**系统接口:** 此接口为系统接口。 1410 1411**系统能力:** SystemCapability.Multimedia.Camera.Core 1412 1413**错误码:** 1414 1415以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1416 1417| 错误码ID | 错误信息 | 1418| --------------- | --------------- | 1419| 202 | Not System Application. | 1420| 7400104 | Session not running. | 1421| 7400201 | Camera service fatal error. | 1422 1423**示例:** 1424 1425```ts 1426import { BusinessError } from '@kit.BasicServicesKit'; 1427 1428function confirmCapture(photoOutput: camera.PhotoOutput): void { 1429 try { 1430 photoOutput.confirmCapture(); 1431 } catch (error) { 1432 let err = error as BusinessError; 1433 console.error(`The confirmCapture call failed. error code: ${err.code}`); 1434 } 1435} 1436``` 1437 1438### isDeferredImageDeliverySupported<sup>11+</sup> 1439 1440isDeferredImageDeliverySupported(type: DeferredDeliveryImageType): boolean 1441 1442查询当前模式是否支持相关分段式能力。 1443 1444**系统接口:** 此接口为系统接口。 1445 1446**系统能力:** SystemCapability.Multimedia.Camera.Core 1447 1448**参数:** 1449 1450| 参数名 | 类型 | 必填 | 说明 | 1451| -------- | -------------------- | ---- | ------------------- | 1452| type | [DeferredDeliveryImageType](#deferreddeliveryimagetype11) | 是 | 分段式能力类型。 | 1453 1454**返回值:** 1455 1456| 类型 | 说明 | 1457| -------------- | ----------------------- | 1458| boolean | true: 当前模式支持该类型分段式能力, false: 不支持。 | 1459 1460**错误码:** 1461 1462以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1463 1464| 错误码ID | 错误信息 | 1465| --------------- |-----------------------------------------------------| 1466| 7400101 | Parameter missing or parameter type incorrect. | 1467| 7400104 | Session not running. | 1468| 7400201 | Camera service fatal error. | 1469| 202 | Not System Application. | 1470 1471**示例:** 1472 1473```ts 1474function isDeferredImageDeliverySupported(photoOutput: camera.PhotoOutput, type: camera.DeferredDeliveryImageType): boolean { 1475 let res: boolean = false; 1476 res = photoOutput.isDeferredImageDeliverySupported(type); 1477 return res; 1478} 1479``` 1480 1481### isDeferredImageDeliveryEnabled<sup>11+</sup> 1482 1483isDeferredImageDeliveryEnabled(type: DeferredDeliveryImageType): boolean 1484 1485查询当前模式是否已开启相关分段式能力。 1486 1487**系统接口:** 此接口为系统接口。 1488 1489**系统能力:** SystemCapability.Multimedia.Camera.Core 1490 1491**参数:** 1492 1493| 参数名 | 类型 | 必填 | 说明 | 1494| -------- | -------------------- | ---- | ------------------- | 1495| type | [DeferredDeliveryImageType](#deferreddeliveryimagetype11) | 是 | 分段式能力类型。 | 1496 1497**返回值:** 1498 1499| 类型 | 说明 | 1500| -------------- | ----------------------- | 1501| boolean | true: 当前模式已开启该类型分段式能力, false: 未开启。 | 1502 1503**错误码:** 1504 1505以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1506 1507| 错误码ID | 错误信息 | 1508| --------------- | --------------- | 1509| 7400101 | Parameter missing or parameter type incorrect. | 1510| 7400104 | Session not running. | 1511| 7400201 | Camera service fatal error. | 1512| 202 | Not System Application. | 1513 1514**示例:** 1515 1516```ts 1517function isDeferredImageDeliveryEnabled(photoOutput: camera.PhotoOutput, type: camera.DeferredDeliveryImageType): boolean { 1518 let res: boolean = false; 1519 res = photoOutput.isDeferredImageDeliveryEnabled(type); 1520 return res; 1521} 1522``` 1523 1524### deferImageDelivery<sup>11+</sup> 1525 1526deferImageDelivery(type: DeferredDeliveryImageType): void 1527 1528开启相关类型分段式能力。 1529 1530**系统接口:** 此接口为系统接口。 1531 1532**系统能力:** SystemCapability.Multimedia.Camera.Core 1533 1534**参数:** 1535 1536| 参数名 | 类型 | 必填 | 说明 | 1537| -------- | -------------------- | ---- | ------------------- | 1538| type | [DeferredDeliveryImageType](#deferreddeliveryimagetype11) | 是 | 分段式能力类型。 | 1539 1540**错误码:** 1541 1542以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1543 1544| 错误码ID | 错误信息 | 1545| --------------- | --------------- | 1546| 7400101 | Parameter missing or parameter type incorrect. | 1547| 7400104 | Session not running. | 1548| 7400201 | Camera service fatal error. | 1549| 202 | Not System Application. | 1550 1551**示例:** 1552 1553```ts 1554function deferImageDelivery(photoOutput: camera.PhotoOutput, type: camera.DeferredDeliveryImageType): void { 1555 photoOutput.deferImageDelivery(type); 1556} 1557``` 1558 1559### isAutoHighQualityPhotoSupported<sup>13+</sup> 1560 1561isAutoHighQualityPhotoSupported(): boolean 1562 1563判断当前是否支持自动高画质。 1564 1565**系统接口:** 此接口为系统接口。 1566 1567**系统能力:** SystemCapability.Multimedia.Camera.Core 1568 1569**返回值:** 1570 1571| 类型 | 说明 | 1572| -------------- | ----------------------- | 1573| boolean | 是否支持自动高画质,返回true是支持,返回false是不支持。| 1574 1575**错误码:** 1576 1577以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1578 1579| 错误码ID | 错误信息 | 1580| --------------- | --------------- | 1581| 202 | Not System Application. | 1582| 7400104 | Session not running. | 1583| 7400201 | Camera service fatal error. | 1584 1585**示例:** 1586 1587```ts 1588import { BusinessError } from '@kit.BasicServicesKit'; 1589 1590function isAutoHighQualityPhotoSupported(photoOutput: camera.PhotoOutput): boolean { 1591 return photoOutput.isAutoHighQualityPhotoSupported(); 1592} 1593``` 1594 1595### enableAutoHighQualityPhoto<sup>13+</sup> 1596 1597enableAutoHighQualityPhoto(enabled: boolean): void 1598 1599使能拍照自动高画质。设置拍照自动高画质之前,需要调用[isAutoHighQualityPhotoSupported](#isautohighqualityphotosupported13)判断当前是否支持。 1600 1601**系统接口:** 此接口为系统接口。 1602 1603**系统能力:** SystemCapability.Multimedia.Camera.Core 1604 1605**参数:** 1606 1607| 参数名 | 类型 | 必填 | 说明 | 1608| -------- | -------------------- | ---- | ------------------- | 1609| enabled | boolean | 是 | 是否使能拍照自动高画质,true为使能,false为不使能。 | 1610 1611**错误码:** 1612 1613以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1614 1615| 错误码ID | 错误信息 | 1616| --------------- | --------------- | 1617| 202 | Not System Application. | 1618| 7400101 | Parameter missing or parameter type incorrect. | 1619| 7400104 | Session not running. | 1620| 7400201 | Camera service fatal error. | 1621 1622**示例:** 1623 1624```ts 1625import { BusinessError } from '@kit.BasicServicesKit'; 1626 1627function enableAutoHighQualityPhoto(photoOutput: camera.PhotoOutput): void { 1628 return photoOutput.enableAutoHighQualityPhoto(true); 1629} 1630``` 1631 1632### on('deferredPhotoProxyAvailable')<sup>11+</sup> 1633 1634on(type: 'deferredPhotoProxyAvailable', callback: AsyncCallback\<DeferredPhotoProxy\>): void 1635 1636注册监听缩略图上报。使用callback异步回调。 1637 1638**系统接口:** 此接口为系统接口。 1639 1640**系统能力:** SystemCapability.Multimedia.Camera.Core 1641 1642**参数:** 1643 1644| 参数名 | 类型 | 必填 | 说明 | 1645| -------- | ---------- | --- | ------------------------------------ | 1646| type | string | 是 | 监听事件,固定为'deferredPhotoProxyAvailable',photoOutput创建成功后可监听。 | 1647| callback | AsyncCallback\<[DeferredPhotoProxy](#deferredphotoproxy11)\> | 是 | 回调函数,用于获取相关信息。用于监听缩略图上报。| 1648 1649**错误码:** 1650 1651以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1652 1653| 错误码ID | 错误信息 | 1654| --------------- | --------------- | 1655| 202 | Not System Application. | 1656 1657**示例:** 1658 1659```ts 1660import { BusinessError } from '@kit.BasicServicesKit'; 1661import { image } from '@kit.ImageKit'; 1662 1663function callback(err: BusinessError, proxyObj: camera.DeferredPhotoProxy): void { 1664 if (err !== undefined && err.code !== 0) { 1665 console.error(`Callback Error, errorCode: ${err.code}`); 1666 return; 1667 } 1668 proxyObj.getThumbnail().then((thumbnail: image.PixelMap) => { 1669 AppStorage.setOrCreate('proxyThumbnail', thumbnail); 1670 }); 1671} 1672 1673function registerPhotoOutputDeferredPhotoProxyAvailable(photoOutput: camera.PhotoOutput): void { 1674 photoOutput.on('deferredPhotoProxyAvailable', callback); 1675} 1676``` 1677 1678### off('deferredPhotoProxyAvailable')<sup>11+</sup> 1679 1680off(type: 'deferredPhotoProxyAvailable', callback?: AsyncCallback\<DeferredPhotoProxy\>): void 1681 1682注销监听缩略图上报。 1683 1684**系统接口:** 此接口为系统接口。 1685 1686**系统能力:** SystemCapability.Multimedia.Camera.Core 1687 1688**参数:** 1689 1690| 参数名 | 类型 | 必填 | 说明 | 1691| -------- | ---------------------- | ---- | ------------------------------------------ | 1692| type | string | 是 | 监听事件,固定为'deferredPhotoProxyAvailable',photoOutput创建成功后可监听。 | 1693| callback | AsyncCallback\<[DeferredPhotoProxy](#deferredphotoproxy11)\> | 否 | 回调函数,可选,有就是匹配on('deferredPhotoProxyAvailable') callback(callback对象不可是匿名函数)。 | 1694 1695**错误码:** 1696 1697以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1698 1699| 错误码ID | 错误信息 | 1700| --------------- | --------------- | 1701| 202 | Not System Application. | 1702 1703**示例:** 1704 1705```ts 1706import { BusinessError } from '@kit.BasicServicesKit'; 1707import { image } from '@kit.ImageKit'; 1708 1709function callback(err: BusinessError, proxyObj: camera.DeferredPhotoProxy): void { 1710 proxyObj.getThumbnail().then((thumbnail: image.PixelMap) => { 1711 AppStorage.setOrCreate('proxyThumbnail', thumbnail); 1712 }); 1713} 1714 1715function unRegisterPhotoOutputDeferredPhotoProxyAvailable(photoOutput: camera.PhotoOutput): void { 1716 photoOutput.off('deferredPhotoProxyAvailable', callback); 1717} 1718``` 1719 1720### isQuickThumbnailSupported 1721 1722isQuickThumbnailSupported(): boolean 1723 1724是否支持输出快速缩略图。 1725 1726在[addOutput](js-apis-camera.md#addoutput11)、[addInput](js-apis-camera.md#addinput11)之后,[commitConfig](js-apis-camera.md#commitconfig11-1)之前生效。 1727 1728**系统接口:** 此接口为系统接口。 1729 1730**系统能力:** SystemCapability.Multimedia.Camera.Core 1731 1732**返回值:** 1733 1734| 类型 | 说明 | 1735| --------- | ------ | 1736| boolean | 返回支持情况,如果返回true表示支持,否则不支持。 | 1737 1738**错误码:** 1739 1740以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1741 1742| 错误码ID | 错误信息 | 1743| --------------- | --------------- | 1744| 202 | Not System Application. | 1745| 7400104 | session is not running. | 1746 1747**示例:** 1748 1749```ts 1750import { common } from '@kit.AbilityKit'; 1751 1752async function isQuickThumbnailSupported(context: common.BaseContext, mode: camera.SceneMode, photoProfile: camera.Profile): Promise<boolean> { 1753 let cameraManager: camera.CameraManager = camera.getCameraManager(context); 1754 let cameras: Array<camera.CameraDevice> = cameraManager.getSupportedCameras(); 1755 // 创建CaptureSession实例。 1756 let session: camera.Session = cameraManager.createSession(mode); 1757 // 开始配置会话。 1758 session.beginConfig(); 1759 // 把CameraInput加入到会话。 1760 let cameraInput: camera.CameraInput = cameraManager.createCameraInput(cameras[0]); 1761 await cameraInput.open(); 1762 session.addInput(cameraInput); 1763 // 把photoOutput加入到会话。 1764 let photoOutput: camera.PhotoOutput = cameraManager.createPhotoOutput(photoProfile); 1765 session.addOutput(photoOutput); 1766 let isSupported: boolean = photoOutput.isQuickThumbnailSupported(); 1767 return isSupported; 1768} 1769``` 1770 1771### enableQuickThumbnail 1772 1773enableQuickThumbnail(enabled: boolean): void 1774 1775启用/禁用快速缩略图。 1776 1777在[addOutput](js-apis-camera.md#addoutput11)、[addInput](js-apis-camera.md#addinput11)之后,[commitConfig](js-apis-camera.md#commitconfig11-1)之前生效。 1778 1779**系统接口:** 此接口为系统接口。 1780 1781**系统能力:** SystemCapability.Multimedia.Camera.Core 1782 1783**参数:** 1784 1785| 参数名 | 类型 | 必填 | 说明 | 1786| -------- | ------------- | ---- | ----------------------------------- | 1787| enabled | boolean | 是 | true:使能快速缩略图;false:去使能快速缩略图。 | 1788 1789**错误码:** 1790 1791以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1792 1793| 错误码ID | 错误信息 | 1794| --------------- | --------------- | 1795| 202 | Not System Application. | 1796| 7400101 | Parameter missing or parameter type incorrect. | 1797| 7400104 | session is not running. | 1798| 7400201 | Camera service fatal error. | 1799 1800**示例:** 1801 1802```ts 1803import { common } from '@kit.AbilityKit'; 1804import { BusinessError } from '@kit.BasicServicesKit'; 1805 1806async function enableQuickThumbnail(context: common.BaseContext, mode: camera.SceneMode, photoProfile: camera.Profile): Promise<void> { 1807 let cameraManager: camera.CameraManager = camera.getCameraManager(context); 1808 let cameras: Array<camera.CameraDevice> = cameraManager.getSupportedCameras(); 1809 // 创建CaptureSession实例。 1810 let session: camera.Session = cameraManager.createSession(mode); 1811 // 开始配置会话。 1812 session.beginConfig(); 1813 // 把CameraInput加入到会话。 1814 let cameraInput: camera.CameraInput = cameraManager.createCameraInput(cameras[0]); 1815 await cameraInput.open(); 1816 session.addInput(cameraInput); 1817 // 把PhotoOutPut加入到会话。 1818 let photoOutput: camera.PhotoOutput = cameraManager.createPhotoOutput(photoProfile); 1819 session.addOutput(photoOutput); 1820 let isSupported: boolean = photoOutput.isQuickThumbnailSupported(); 1821 if (!isSupported) { 1822 console.info('Quick Thumbnail is not supported to be turned on.'); 1823 return; 1824 } 1825 try { 1826 photoOutput.enableQuickThumbnail(true); 1827 } catch (error) { 1828 let err = error as BusinessError; 1829 console.error(`The enableQuickThumbnail call failed. error code: ${err.code}`); 1830 } 1831} 1832``` 1833 1834### on('quickThumbnail') 1835 1836on(type: 'quickThumbnail', callback: AsyncCallback\<image.PixelMap>): void 1837 1838监听快速缩略图输出事件。使用callback异步回调。 1839 1840在enableQuickThumbnail(true)使能快速缩略图之后监听生效。 1841 1842**系统接口:** 此接口为系统接口。 1843 1844**系统能力:** SystemCapability.Multimedia.Camera.Core 1845 1846**参数:** 1847 1848| 参数名 | 类型 | 必填 | 说明 | 1849| -------- | ------------- | ---- | ----------------------------------- | 1850| type | string | 是 | 监听事件,固定为'quickThumbnail'。 | 1851| callback | AsyncCallback\<[image.PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7)> | 是 | 回调返回PixelMap。 | 1852 1853**示例:** 1854 1855```ts 1856import { common } from '@kit.AbilityKit'; 1857import { BusinessError } from '@kit.BasicServicesKit'; 1858import { image } from '@kit.ImageKit'; 1859 1860function callback(err: BusinessError, pixelMap: image.PixelMap): void { 1861 if (err || pixelMap === undefined) { 1862 console.error('photoOutput on thumbnail failed'); 1863 return; 1864 } 1865 // 显示或保存pixelMap。 1866 // do something. 1867} 1868 1869async function registerQuickThumbnail(context: common.BaseContext, mode: camera.SceneMode, photoProfile: camera.Profile): Promise<void> { 1870 let cameraManager: camera.CameraManager = camera.getCameraManager(context); 1871 let cameras: Array<camera.CameraDevice> = cameraManager.getSupportedCameras(); 1872 // 创建CaptureSession实例。 1873 let session: camera.Session = cameraManager.createSession(mode); 1874 // 开始配置会话。 1875 session.beginConfig(); 1876 // 把CameraInput加入到会话。 1877 let cameraInput: camera.CameraInput = cameraManager.createCameraInput(cameras[0]); 1878 await cameraInput.open(); 1879 session.addInput(cameraInput); 1880 // 把PhotoOutPut加入到会话。 1881 let photoOutput: camera.PhotoOutput = cameraManager.createPhotoOutput(photoProfile); 1882 session.addOutput(photoOutput); 1883 let isSupported: boolean = photoOutput.isQuickThumbnailSupported(); 1884 if (!isSupported) { 1885 console.info('Quick Thumbnail is not supported to be turned on.'); 1886 return; 1887 } 1888 try { 1889 photoOutput.enableQuickThumbnail(true); 1890 } catch (error) { 1891 let err = error as BusinessError; 1892 console.error(`The enableQuickThumbnail call failed. error code: ${err.code}`); 1893 } 1894 1895 photoOutput.on('quickThumbnail', callback); 1896} 1897``` 1898 1899### off('quickThumbnail') 1900 1901off(type: 'quickThumbnail', callback?: AsyncCallback\<image.PixelMap>): void 1902 1903注销监听快速缩略图输出事件。 1904 1905**系统接口:** 此接口为系统接口。 1906 1907**系统能力:** SystemCapability.Multimedia.Camera.Core 1908 1909**参数:** 1910 1911| 参数名 | 类型 | 必填 | 说明 | 1912| -------- | ------------- | ---- | ----------------------------------- | 1913| type | string | 是 | 监听事件,固定为'quickThumbnail'。 | 1914| callback | AsyncCallback\<[image.PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7)> | 否 | 回调函数,可选,有就是匹配on('quickThumbnail') callback(callback对象不可是匿名函数)。 | 1915 1916**示例:** 1917 1918```ts 1919function unregisterQuickThumbnail(photoOutput: camera.PhotoOutput): void { 1920 photoOutput.off('quickThumbnail'); 1921} 1922``` 1923 1924## MetadataOutput 1925 1926metadata流。继承[CameraOutput](js-apis-camera.md#cameraoutput)。 1927 1928### addMetadataObjectTypes<sup>13+</sup> 1929 1930addMetadataObjectTypes(types: Array\<MetadataObjectType\>): void 1931 1932新增需要上报的检测对象类型。 1933 1934**系统能力:** SystemCapability.Multimedia.Camera.Core 1935 1936**参数:** 1937 1938| 参数名 | 类型 | 必填 | 说明 | 1939| -------------------- | -------------------------------------------------- | --- | ---------------------------- | 1940| metadataObjectTypes | Array\<[MetadataObjectType](#metadataobjecttype)\> | 是 | metadata流类型信息,通过getSupportedOutputCapability接口获取。 | 1941 1942**错误码:** 1943 1944以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1945 1946| 错误码ID | 错误信息 | 1947| --------------- | --------------- | 1948| 202 | Not system application. | 1949| 7400101 | Parameter missing or parameter type incorrect. | 1950| 7400103 | Session not config. | 1951| 7400201 | Camera service fatal error. | 1952 1953**示例:** 1954 1955```ts 1956import { BusinessError } from '@kit.BasicServicesKit'; 1957 1958function addMetadataObjectTypes(metadataOutput: camera.MetadataOutput, types: Array<camera.MetadataObjectType>): void { 1959 try { 1960 metadataOutput.addMetadataObjectTypes(types); 1961 } catch (error) { 1962 // 失败返回错误码error.code并处理。 1963 let err = error as BusinessError; 1964 console.error(`addMetadataObjectTypes error. error code: ${err.code}`); 1965 } 1966} 1967``` 1968 1969### removeMetadataObjectTypes<sup>13+</sup> 1970 1971removeMetadataObjectTypes(types: Array\<MetadataObjectType\>): void 1972 1973删除需要上报的检测对象类型。 1974 1975**系统能力:** SystemCapability.Multimedia.Camera.Core 1976 1977**参数:** 1978 1979| 参数名 | 类型 | 必填 | 说明 | 1980| -------------------- | -------------------------------------------------- | --- | ---------------------------- | 1981| metadataObjectTypes | Array\<[MetadataObjectType](#metadataobjecttype)\> | 是 | metadata流类型信息,通过getSupportedOutputCapability接口获取。 | 1982 1983**错误码:** 1984 1985以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1986 1987| 错误码ID | 错误信息 | 1988| --------------- | --------------- | 1989| 202 | Not system application. | 1990| 7400101 | Parameter missing or parameter type incorrect. | 1991| 7400103 | Session not config. | 1992| 7400201 | Camera service fatal error. | 1993 1994**示例:** 1995 1996```ts 1997import { BusinessError } from '@kit.BasicServicesKit'; 1998 1999function removeMetadataObjectTypes(metadataOutput: camera.MetadataOutput, types: Array<camera.MetadataObjectType>): void { 2000 try { 2001 metadataOutput.removeMetadataObjectTypes(types); 2002 } catch (error) { 2003 // 失败返回错误码error.code并处理。 2004 let err = error as BusinessError; 2005 console.error(`removeMetadataObjectTypes error. error code: ${err.code}`); 2006 } 2007} 2008``` 2009 2010## MetadataObjectType 2011 2012枚举,metadata元数据检测类型。 2013 2014**系统能力:** SystemCapability.Multimedia.Camera.Core 2015 2016| 名称 | 值 | 说明 | 2017| -------------------------- | ---- | ----------------- | 2018| HUMAN_BODY<sup>13+</sup> | 1 | 用于检测人体的metadata类型。 | 2019| CAT_FACE<sup>13+</sup> | 2 | 用于检测猫脸的metadata类型。 | 2020| CAT_BODY<sup>13+</sup> | 3 | 用于检测猫的身体的metadata类型。 | 2021| DOG_FACE<sup>13+</sup> | 4 | 用于检测狗脸的metadata类型。 | 2022| DOG_BODY<sup>13+</sup> | 5 | 用于检测狗的身体的metadata类型。 | 2023| SALIENT_DETECTION<sup>13+</sup> | 6 | 用于显著性检测。 | 2024 2025## Emotion<sup>13+</sup> 2026枚举,人脸检测信息中的情绪类型。 2027 2028**系统能力:** SystemCapability.Multimedia.Camera.Core 2029 2030| 名称 | 值 | 说明 | 2031| -------------------------- | ---- | ----------------- | 2032| NEUTRAL | 0 | 平静。 | 2033| SADNESS | 1 | 悲伤。 | 2034| SMILE | 2 | 微笑。 | 2035| SURPRISE | 3 | 惊讶。 | 2036 2037## MetadataObject 2038 2039相机检测元数据信息的基础类型,[CameraInput](#camerainput)相机信息中的数据来源,通过metadataOutput.[on('metadataObjectsAvailable')](js-apis-camera.md#onmetadataobjectsavailable)接口获取。 2040 2041**系统能力:** SystemCapability.Multimedia.Camera.Core 2042 2043| 名称 | 类型 | 只读 | 可选 |说明 | 2044| ----------- | ------------------------------------------- | ---- | ---- | ----------------- | 2045| objectId<sup>13+</sup> | number | 是 | 否 | metadataObject Id序号。| 2046| confidence<sup>13+</sup> | number | 是 | 否 | 检测置信度,取值范围[0,1]。| 2047 2048## MetadataFaceObject<sup>13+</sup> 2049 2050相机检测到的人脸元数据信息,继承自[MetadataObject](#metadataobject),[CameraInput](#camerainput)相机信息中的数据来源,通过metadataOutput.[on('metadataObjectsAvailable')](js-apis-camera.md#onmetadataobjectsavailable)接口获取。 2051 2052**系统能力:** SystemCapability.Multimedia.Camera.Core 2053 2054| 名称 | 类型 | 只读 | 可选 |说明 | 2055| ---------------------- | --------------------------------- | ---- | ---- | --------------------- | 2056| leftEyeBoundingBox | [Rect](js-apis-camera.md#rect) | 是 | 否 | 左眼区域框| 2057| rightEyeBoundingBox | [Rect](js-apis-camera.md#rect) | 是 | 否 | 右眼区域框。| 2058| emotion | [Emotion](#emotion13) | 是 | 否 | 检测到的情绪类型。| 2059| emotionConfidence | number | 是 | 否 | 情绪检测置信度,取值范围[0,1]。| 2060| pitchAngle | number | 是 | 否 | 俯仰角度,取值范围[-90, 90],以向下为正。| 2061| yawAngle | number | 是 | 否 | 左右旋转角度,取值范围[-90, 90],以向右为正。| 2062| rollAngle | number | 是 | 否 | 平面内旋转角度,取值范围[-180, 180],以顺时针方向为正。| 2063 2064## MetadataHumanBodyObject<sup>13+</sup> 2065 2066相机检测到的人体元数据信息,继承自[MetadataObject](#metadataobject),[CameraInput](#camerainput)相机信息中的数据来源,通过metadataOutput.[on('metadataObjectsAvailable')](js-apis-camera.md#onmetadataobjectsavailable)接口获取。 2067 2068**系统能力:** SystemCapability.Multimedia.Camera.Core 2069 2070## MetadataCatFaceObject<sup>13+</sup> 2071 2072相机检测到的猫脸元数据信息,继承自[MetadataObject](#metadataobject),[CameraInput](#camerainput)相机信息中的数据来源,通过metadataOutput.[on('metadataObjectsAvailable')](js-apis-camera.md#onmetadataobjectsavailable)接口获取。 2073 2074**系统能力:** SystemCapability.Multimedia.Camera.Core 2075 2076| 名称 | 类型 | 只读 | 可选 |说明 | 2077| ---------------------- | --------------------------------- | ---- | ---- | --------------------- | 2078| leftEyeBoundingBox | [Rect](js-apis-camera.md#rect) | 是 | 否 | 左眼区域框。| 2079| rightEyeBoundingBox | [Rect](js-apis-camera.md#rect) | 是 | 否 | 右眼区域框。| 2080 2081## MetadataCatBodyObject<sup>13+</sup> 2082 2083相机检测到的猫的身体元数据信息,继承自[MetadataObject](#metadataobject),[CameraInput](#camerainput)相机信息中的数据来源,通过metadataOutput.[on('metadataObjectsAvailable')](js-apis-camera.md#onmetadataobjectsavailable)接口获取。 2084 2085**系统能力:** SystemCapability.Multimedia.Camera.Core 2086 2087## MetadataDogFaceObject<sup>13+</sup> 2088 2089相机检测到的狗脸元数据信息,继承自[MetadataObject](#metadataobject),[CameraInput](#camerainput)相机信息中的数据来源,通过metadataOutput.[on('metadataObjectsAvailable')](js-apis-camera.md#onmetadataobjectsavailable)接口获取。 2090 2091**系统能力:** SystemCapability.Multimedia.Camera.Core 2092 2093| 名称 | 类型 | 只读 | 可选 |说明 | 2094| ---------------------- | --------------------------------- | ---- | ---- | --------------------- | 2095| leftEyeBoundingBox | [Rect](js-apis-camera.md#rect) | 是 | 否 | 左眼区域框。| 2096| rightEyeBoundingBox | [Rect](js-apis-camera.md#rect) | 是 | 否 | 右眼区域框。| 2097 2098## MetadataDogBodyObject<sup>13+</sup> 2099 2100相机检测到的狗的身体元数据信息,继承自[MetadataObject](#metadataobject),[CameraInput](#camerainput)相机信息中的数据来源,通过metadataOutput.[on('metadataObjectsAvailable')](js-apis-camera.md#onmetadataobjectsavailable)接口获取。 2101 2102**系统能力:** SystemCapability.Multimedia.Camera.Core 2103 2104## MetadataSalientDetectionObject<sup>13+</sup> 2105 2106相机检测到的显著性元数据信息,继承自[MetadataObject](#metadataobject),[CameraInput](#camerainput)相机信息中的数据来源,通过metadataOutput.[on('metadataObjectsAvailable')](js-apis-camera.md#onmetadataobjectsavailable)接口获取。 2107 2108**系统能力:** SystemCapability.Multimedia.Camera.Core 2109 2110## MetadataBarcodeObject<sup>14+</sup> 2111 2112相机检测到的二维码元数据信息,继承自[MetadataObject](#metadataobject),[CameraInput](#camerainput)相机信息中的数据来源,通过metadataOutput.[on('metadataObjectsAvailable')](js-apis-camera.md#onmetadataobjectsavailable)接口获取。 2113 2114**系统能力:** SystemCapability.Multimedia.Camera.Core 2115 2116## PortraitEffect 2117 2118人像效果类型。 2119 2120**系统接口:** 此接口为系统接口。 2121 2122**系统能力:** SystemCapability.Multimedia.Camera.Core 2123 2124| 名称 | 值 | 说明 | 2125| ----------------| ---- | ---------| 2126| OFF | 0 | 关闭。 | 2127| CIRCLES | 1 | 圆形。 | 2128| HEART<sup>11+</sup> | 2 | 心形。 | 2129| ROTATED<sup>11+</sup> | 3 | 旋焦。 | 2130| STUDIO<sup>11+</sup> | 4 | 影棚光。 | 2131| THEATER<sup>11+</sup> | 5 | 剧场光。 | 2132 2133## BeautyQuery<sup>12+</sup> 2134 2135提供了获取和设置美颜效果的方法。 2136 2137### getSupportedBeautyTypes<sup>11+</sup> 2138 2139getSupportedBeautyTypes(): Array\<BeautyType\> 2140 2141获取当前支持的美颜效果列表。 2142 2143**系统接口:** 此接口为系统接口。 2144 2145**系统能力:** SystemCapability.Multimedia.Camera.Core 2146 2147**返回值:** 2148 2149| 类型 | 说明 | 2150| ---------- | ----------------------------- | 2151| Array\<[BeautyType](#beautytype)\>| 返回当前支持的美颜效果列表。 | 2152 2153**错误码:** 2154 2155以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2156 2157| 错误码ID | 错误信息 | 2158| --------------- | --------------- | 2159| 202 | Not System Application. | 2160| 7400103 | Session not config. | 2161 2162**示例:** 2163 2164```ts 2165function getSupportedBeautyTypes(portraitPhotoSession: camera.PortraitPhotoSession): Array<camera.BeautyType> { 2166 let beautyTypes: Array<camera.BeautyType> = portraitPhotoSession.getSupportedBeautyTypes(); 2167 return beautyTypes; 2168} 2169``` 2170 2171### getSupportedBeautyRange<sup>11+</sup> 2172 2173getSupportedBeautyRange(type: BeautyType): Array\<number\> 2174 2175获取指定美颜效果的范围值。在不同设备返回的美颜强度有所不同,下表仅做示例。 2176 2177| 传入参数 | 示例返回值 | 返回值说明 | 2178| ----------------| ---- | ---------| 2179| AUTO | [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] |美颜类型为自动时支持的美颜强度,0表明关闭美颜,其余正值表明自动的美颜强度。 | 2180| SKIN_SMOOTH | [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | 美颜类型为光滑时支持的美颜强度,0表明关闭光滑,其余正值表明光滑的美颜强度。 | 2181| FACE_SLENDER | [0, 1, 2, 3, 4, 5] | 美颜类型为瘦脸时支持的美颜强度,0表明关闭瘦脸,其余正值表明瘦脸的美颜强度。 | 2182| SKIN_TONE | [-1, 16242611] | 美颜类型为美肤时支持的美颜强度,-1表明关闭美肤,其余非负值为使用RGB表示的美肤美颜强度,<br> 16242611转化为16进制为0xF7D7B3,F7为R通道值,D7为G通道值,B3位B通道值。 | 2183 2184**系统接口:** 此接口为系统接口。 2185 2186**系统能力:** SystemCapability.Multimedia.Camera.Core 2187 2188**参数:** 2189 2190| 参数名 | 类型 | 必填 | 说明 | 2191| -------- | --------------------------| ---- | ----------| 2192| type | [BeautyType](#beautytype) | 是 | 美颜类型。 | 2193 2194**返回值:** 2195 2196| 类型 | 说明 | 2197| ---------- | ----------------------------- | 2198| Array\<number\> | 当前美颜类型所支持的美颜强度。 | 2199 2200**错误码:** 2201 2202以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2203 2204| 错误码ID | 错误信息 | 2205| --------------- | --------------- | 2206| 202 | Not System Application. | 2207| 7400103 | Session not config. | 2208 2209**示例:** 2210 2211```ts 2212function getSupportedBeautyRange(portraitPhotoSession: camera.PortraitPhotoSession): Array<number> { 2213 let beautyTypes: Array<camera.BeautyType> = portraitPhotoSession.getSupportedBeautyTypes(); 2214 if (beautyTypes === undefined || beautyTypes.length <= 0) { 2215 return []; 2216 } 2217 let beautyLevels: Array<number> = portraitPhotoSession.getSupportedBeautyRange(beautyTypes[0]); 2218 return beautyLevels; 2219} 2220``` 2221 2222## BeautyType 2223 2224美颜类型。 2225 2226**系统接口:** 此接口为系统接口。 2227 2228**系统能力:** SystemCapability.Multimedia.Camera.Core 2229 2230| 名称 | 值 | 说明 | 2231| ----------------| ---- | ---------| 2232| AUTO | 0 | 自动。 | 2233| SKIN_SMOOTH | 1 | 光滑。 | 2234| FACE_SLENDER | 2 | 瘦脸。 | 2235| SKIN_TONE | 3 | 肤色。 | 2236 2237## ManualExposureQuery<sup>12+</sup> 2238 2239此接口提供了查询设备对手动曝光范围支持的功能。 2240 2241### getSupportedExposureRange<sup>11+</sup> 2242 2243getSupportedExposureRange(): Array\<number\> 2244 2245获取当前支持的手动曝光时长,单位ms。 2246 2247**系统接口:** 此接口为系统接口。 2248 2249**系统能力:** SystemCapability.Multimedia.Camera.Core 2250 2251**返回值:** 2252 2253| 类型 | 说明 | 2254| ---------- | ----------------------------- | 2255| Array\<number\>| 返回当前支持的手动曝光时长,单位ms。 | 2256 2257**错误码:** 2258 2259以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2260 2261| 错误码ID | 错误信息 | 2262| --------------- | --------------- | 2263| 202 | Not System Application. | 2264| 7400101 | Parameter missing or parameter type incorrect. | 2265| 7400103 | Session not config, only throw in session usage. | 2266 2267 **示例:** 2268 2269```ts 2270function getSupportedExposureRange(nightPhotoSession: camera.NightPhotoSession): Array<number> { 2271 let exposureRange: Array<number> = nightPhotoSession.getSupportedExposureRange(); 2272 return exposureRange; 2273} 2274``` 2275 2276## ManualExposure<sup>11+</sup> 2277 2278ManualExposure extends [ManualExposureQuery](#manualexposurequery12) 2279 2280提供了获取和设置曝光值的功能。 2281 2282### getExposure<sup>11+</sup> 2283 2284getExposure(): number 2285 2286查询当前已设置的手动曝光时长,单位为ms。 2287 2288**系统接口:** 此接口为系统接口。 2289 2290**系统能力:** SystemCapability.Multimedia.Camera.Core 2291 2292**返回值:** 2293| 参数名 | 类型 | 必填 | 说明 | 2294| -------- | ------------------------------------------------- | ---- | --------------------- | 2295| value | number | 是 | 手动曝光时长,单位为ms。 | 2296 2297**错误码:** 2298 2299以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2300 2301| 错误码ID | 错误信息 | 2302| --------------- | --------------- | 2303| 202 | Not System Application. | 2304| 7400101 | Parameter missing or parameter type incorrect. | 2305| 7400103 | Session not config. | 2306 2307**示例:** 2308 2309```ts 2310function getExposure(nightPhotoSession: camera.NightPhotoSession): number | undefined { 2311 let exposureRange: Array<number> = nightPhotoSession.getSupportedExposureRange(); 2312 if (exposureRange === undefined || exposureRange.length <= 0) { 2313 return undefined; 2314 } 2315 let exposure: number = nightPhotoSession.getExposure(); 2316 return exposure; 2317} 2318``` 2319 2320### setExposure<sup>11+</sup> 2321 2322setExposure(exposure: number): void 2323 2324设置手动曝光时长。[getSupportedExposureRange](#getsupportedexposurerange11)获取得到支持的手动曝光时长列表选取用户所需的时长下发,单位ms。 2325 2326**系统接口:** 此接口为系统接口。 2327 2328**系统能力:** SystemCapability.Multimedia.Camera.Core 2329 2330**参数:** 2331 2332| 参数名 | 类型 | 必填 | 说明 | 2333| -------- | --------------------------| ---- |-------------------------------------------------------------------------| 2334| value | number | 是 | 手动曝光时长,通过[getSupportedExposureRange](#getsupportedexposurerange11)接口获取。 | 2335 2336 **错误码:** 2337 2338| 错误码ID | 错误信息 | 2339| --------------- | --------------- | 2340| 202 | Not System Application. | 2341| 7400102 | Operation not allowed. | 2342| 7400103 | Session not config. | 2343 2344```ts 2345function setExposure(nightPhotoSession: camera.NightPhotoSession): void { 2346 let exposureRange: Array<number> = nightPhotoSession.getSupportedExposureRange(); 2347 if (exposureRange === undefined || exposureRange.length <= 0) { 2348 return; 2349 } 2350 nightPhotoSession.setExposure(exposureRange[0]); 2351} 2352``` 2353 2354## MacroQuery<sup>12+</sup> 2355 2356提供用于查询设备是否支持相机微距拍摄的方法。 2357 2358### isMacroSupported<sup>11+</sup> 2359 2360isMacroSupported(): boolean 2361 2362检测当前状态下是否支持微距能力,需要在CaptureSession调用[commitConfig](js-apis-camera.md#commitconfig11-1)之后进行调用。 2363 2364**系统接口:** 此接口为系统接口。 2365 2366**系统能力:** SystemCapability.Multimedia.Camera.Core 2367 2368**返回值:** 2369 2370| 类型 | 说明 | 2371| ---------- | ----------------------------- | 2372| boolean | 返回是否支持微距能力,返回true为支持,返回false为不支持。 | 2373 2374**错误码:** 2375 2376以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2377 2378| 错误码ID | 错误信息 | 2379|---------|--------------------------| 2380| 202 | Not System Application. | 2381 2382**示例:** 2383 2384```ts 2385function isMacroSupported(photoSession: camera.PhotoSessionForSys): boolean { 2386 let isSupported: boolean = photoSession.isMacroSupported(); 2387 return isSupported; 2388} 2389``` 2390 2391## Macro<sup>11+</sup> 2392 2393Macro extends [MacroQuery](#macroquery12) 2394 2395提供了使能微距能力的接口。 2396 2397### enableMacro<sup>11+</sup> 2398 2399enableMacro(enabled: boolean): void 2400 2401使能当前的微距能力,需要在支持微距能力的情况下进行调用。 2402 2403**系统接口:** 此接口为系统接口。 2404 2405**系统能力:** SystemCapability.Multimedia.Camera.Core 2406 2407**参数:** 2408 2409| 参数名 | 类型 | 必填 | 说明 | 2410| -------- | -------------------- | ---- | -------------------- | 2411| enabled | boolean | 是 | true:开启微距能力,false:关闭微距能力。 | 2412 2413**错误码:** 2414 2415以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2416 2417| 错误码ID | 错误信息 | 2418|----------|--------------------------| 2419| 202 | Not System Application. | 2420| 7400102 | Operation not allowed. | 2421| 7400103 | Session not config. | 2422 2423**示例:** 2424 2425```ts 2426function enableMacro(photoSession: camera.PhotoSessionForSys): void { 2427 let isSupported: boolean = photoSession.isMacroSupported(); 2428 if (isSupported) { 2429 photoSession.enableMacro(true); 2430 } 2431} 2432``` 2433 2434## TripodStatus<sup>13+</sup> 2435 2436枚举,脚架状态枚举。 2437 2438**系统能力:** SystemCapability.Multimedia.Camera.Core 2439 2440| 名称 | 值 | 说明 | 2441|----------|-----|-------------------------------------| 2442| INVALID | 0 | 错误状态/默认未检测到脚架状态。**系统接口:** 此接口为系统接口。 | 2443| ACTIVE | 1 | 脚架活动状态。**系统接口:** 此接口为系统接口。 | 2444| ENTERING | 2 | 进入脚架稳定状态。**系统接口:** 此接口为系统接口。 | 2445| EXITING | 3 | 退出脚架稳定状态。**系统接口:** 此接口为系统接口。 | 2446 2447 2448## SceneFeatureType<sup>12+</sup> 2449 2450枚举,场景特性枚举。 2451 2452**系统能力:** SystemCapability.Multimedia.Camera.Core 2453 2454| 名称 | 值 | 说明 | 2455|-------------------------------|-----|---------------------------| 2456| MOON_CAPTURE_BOOST | 0 | 月亮场景。**系统接口:** 此接口为系统接口。 | 2457| TRIPOD_DETECTION<sup>13+</sup> | 1 | 使用脚架拍摄的场景。**系统接口:** 此接口为系统接口。 | 2458| LOW_LIGHT_BOOST<sup>13+</sup> | 2 | 长曝光场景。**系统接口:** 此接口为系统接口。 | 2459 2460## SceneFeatureDetectionResult<sup>12+</sup> 2461 2462场景检测结果信息。 2463 2464**系统能力:** SystemCapability.Multimedia.Camera.Core 2465 2466| 名称 | 类型 | 只读 | 必填 | 说明 | 2467| -------- | ---------- | -------- | -------- | ---------- | 2468| featureType | [SceneFeatureType](#scenefeaturetype12) | 是 | 是 | 特性类型。 | 2469| detected | boolean | 是 | 是 | 检测结果。true为检测到指定特性场景,false为未检测到指定特性场景。 | 2470 2471## TripodDetectionResult<sup>13+</sup> 2472 2473TripodDetectionResult extends [SceneFeatureDetectionResult](#scenefeaturedetectionresult12) 2474 2475脚架检测信息。 2476 2477**系统能力:** SystemCapability.Multimedia.Camera.Core 2478 2479| 名称 | 类型 | 只读 | 必填 | 说明 | 2480| -------- |---------------------------------| -------- | -------- |---------| 2481| tripodStatus | [TripodStatus](#tripodstatus13) | 是 | 是 | 脚架状态信息。 | 2482 2483## SceneDetection<sup>12+</sup> 2484 2485场景检测能力。 2486 2487### isSceneFeatureSupported<sup>12+</sup> 2488 2489isSceneFeatureSupported(type: SceneFeatureType): boolean 2490 2491查询是否支持指定特性。 2492 2493**系统接口:** 此接口为系统接口。 2494 2495**系统能力:** SystemCapability.Multimedia.Camera.Core 2496 2497**参数:** 2498 2499| 参数名 | 类型 | 必填 | 说明 | 2500|-------|-------------------------------------------|-----|-------------| 2501| type | [SceneFeatureType](#scenefeaturetype12) | 是 | 指定对应的场景特性。 | 2502 2503**返回值:** 2504 2505| 类型 | 说明 | 2506|-----------|--------------| 2507| boolean | 返回是否支持指定特性,返回true为支持,返回false为不支持。 | 2508 2509**错误码:** 2510 2511以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2512 2513| 错误码ID | 错误信息 | 2514|---------|------------------------------------------------| 2515| 202 | Not System Application. | 2516| 7400101 | Parameter missing or parameter type incorrect. | 2517 2518**示例:** 2519 2520```ts 2521function isSceneFeatureSupported(photoSession: camera.PhotoSession, featureType: camera.SceneFeatureType): boolean { 2522 let isSupported: boolean = photoSession.isSceneFeatureSupported(featureType); 2523 return isSupported; 2524} 2525``` 2526 2527### enableSceneFeature<sup>12+</sup> 2528 2529enableSceneFeature(type: SceneFeatureType, enabled: boolean): void 2530 2531使能指定特性,该接口应当在收到对应场景检测回调结果[SceneFeatureDetectionResult](#scenefeaturedetectionresult12)之后调用。 2532 2533**系统接口:** 此接口为系统接口。 2534 2535**系统能力:** SystemCapability.Multimedia.Camera.Core 2536 2537**参数:** 2538 2539| 参数名 | 类型 | 必填 | 说明 | 2540|---------|-------------------------------------------|-----|-----------------------------| 2541| type | [SceneFeatureType](#scenefeaturetype12) | 是 | 指定需要开启或关闭的特性。 | 2542| enabled | boolean | 是 | true表明开启指定特性,false表明关闭指定特性。 | 2543 2544**错误码:** 2545 2546以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2547 2548| 错误码ID | 错误信息 | 2549|---------|------------------------------------------------| 2550| 202 | Not System Application. | 2551| 7400101 | Parameter missing or parameter type incorrect. | 2552 2553**示例:** 2554 2555```ts 2556import { BusinessError } from '@kit.BasicServicesKit'; 2557 2558function enableSceneFeature(photoSession: camera.PhotoSessionForSys, cameraInput: camera.CameraInput, previewOutput: camera.PreviewOutput): void { 2559 photoSession.beginConfig(); 2560 photoSession.addInput(cameraInput); 2561 photoSession.addOutput(previewOutput); 2562 photoSession.commitConfig(); 2563 2564 photoSession.on('featureDetection', camera.SceneFeatureType.MOON_CAPTURE_BOOST, 2565 (err: BusinessError, statusObject: camera.SceneFeatureDetectionResult) => { 2566 if (err !== undefined && err.code !== 0) { 2567 console.error(`Callback Error, errorCode: ${err.code}`); 2568 return; 2569 } 2570 console.info( 2571 `on featureDetectionStatus featureType:${statusObject.featureType} detected:${statusObject.detected}`); 2572 if (statusObject.featureType === camera.SceneFeatureType.MOON_CAPTURE_BOOST) { 2573 try { 2574 photoSession.enableSceneFeature(statusObject.featureType, statusObject.detected); 2575 } catch (error) { 2576 let err = error as BusinessError; 2577 console.error(`The enableSceneFeature call failed. error code: ${err.code}`); 2578 } 2579 } 2580 }); 2581} 2582``` 2583 2584## ZoomPointInfo<sup>12+</sup> 2585 2586等效焦距信息。 2587 2588**系统接口:** 此接口为系统接口。 2589 2590**系统能力:** SystemCapability.Multimedia.Camera.Core 2591 2592| 名称 | 类型 | 只读 | 可选 | 说明 | 2593| -------- | ---------- | -------- |-----| ---------- | 2594| zoomRatio | number | 是 | 否 | 可变焦距比。 | 2595| equivalentFocalLength | number | 是 | 否 | 当前焦距比对应的等效焦距值。 | 2596 2597## ZoomQuery<sup>12+</sup> 2598 2599提供获取当前模式的等效焦距信息列表的方法。 2600 2601### getZoomPointInfos<sup>12+</sup> 2602 2603getZoomPointInfos(): Array\<ZoomPointInfo\> 2604 2605获取当前模式的等效焦距信息列表。 2606 2607**系统接口:** 此接口为系统接口。 2608 2609**系统能力:** SystemCapability.Multimedia.Camera.Core 2610 2611**返回值:** 2612 2613| 类型 | 说明 | 2614| ---------- | ----------------------------- | 2615| Array\<[ZoomPointInfo](#zoompointinfo12)\>| 获取当前模式的等效焦距信息列表。 | 2616 2617**错误码:** 2618 2619以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2620 2621| 错误码ID | 错误信息 | 2622| --------------- | --------------- | 2623| 202 | Not System Application. | 2624| 7400103 | Session not config. | 2625 2626**示例:** 2627 2628```ts 2629import { BusinessError } from '@kit.BasicServicesKit'; 2630 2631function getZoomPointInfos(): Array<ZoomPointInfo> { 2632 try { 2633 let zoomPointInfos: Array<ZoomPointInfo> = sessionExtendsZoom.getZoomPointInfos(); 2634 return zoomPointInfos; 2635 } catch (error) { 2636 // 失败返回错误码error.code并处理。 2637 let err = error as BusinessError; 2638 console.error(`The getZoomPointInfos call failed. error code: ${err.code}`); 2639 } 2640} 2641``` 2642 2643## Zoom<sup>11+</sup> 2644 2645Zoom extend [ZoomQuery](#zoomquery12) 2646 2647提供了处理设备变焦效果的相关方法,包括获取当前的变焦比,设置变焦比率,以及通过平滑方法设置目标变焦比,以及一些开启和结束变焦的函数。 2648 2649### prepareZoom<sup>11+</sup> 2650 2651prepareZoom(): void 2652 2653通知底层准备变焦,如sensor上电。 2654 2655**系统接口:** 此接口为系统接口。 2656 2657**系统能力:** SystemCapability.Multimedia.Camera.Core 2658 2659**错误码:** 2660 2661以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2662 2663| 错误码ID | 错误信息 | 2664| --------------- | --------------- | 2665| 202 | Not System Application. | 2666| 7400103 | Session not config. | 2667 2668**示例:** 2669 2670```ts 2671import { BusinessError } from '@kit.BasicServicesKit'; 2672 2673function prepareZoom(sessionExtendsZoom: camera.Zoom): void { 2674 try { 2675 sessionExtendsZoom.prepareZoom(); 2676 } catch (error) { 2677 // 失败返回错误码error.code并处理。 2678 let err = error as BusinessError; 2679 console.error(`The prepareZoom call failed. error code: ${err.code}`); 2680 } 2681} 2682``` 2683 2684### unprepareZoom<sup>11+</sup> 2685 2686unprepareZoom(): void 2687 2688通知底层离开变焦准备状态。 2689 2690**系统接口:** 此接口为系统接口。 2691 2692**系统能力:** SystemCapability.Multimedia.Camera.Core 2693 2694**错误码:** 2695 2696以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2697 2698| 错误码ID | 错误信息 | 2699| --------------- | --------------- | 2700| 202 | Not System Application. | 2701| 7400103 | Session not config. | 2702 2703**示例:** 2704 2705```ts 2706import { BusinessError } from '@kit.BasicServicesKit'; 2707 2708function unprepareZoom(sessionExtendsZoom: camera.Zoom): void { 2709 try { 2710 sessionExtendsZoom.unprepareZoom(); 2711 } catch (error) { 2712 // 失败返回错误码error.code并处理。 2713 let err = error as BusinessError; 2714 console.error(`The unprepareZoom call failed. error code: ${err.code}`); 2715 } 2716} 2717``` 2718 2719## ZoomRange<sup>11+</sup> 2720 2721获取支持的变焦范围。变焦范围为[min, max),即包括最小值,不包括最大值。 2722 2723**系统接口:** 此接口为系统接口。 2724 2725**系统能力:** SystemCapability.Multimedia.Camera.Core 2726 2727| 名称 | 类型 | 只读 | 必填 | 说明 | 2728| -------- | ------------- |---- | ---- | -------------| 2729| min | number | 是 | N/A | 获取的可变焦距范围的最小值 | 2730| max | number | 是 | N/A | 获取的可变焦距范围的最大值。 | 2731 2732## Beauty<sup>11+</sup> 2733 2734Beauty extends [BeautyQuery](#beautyquery12) 2735 2736提供了获取和设置美颜效果的方法。 2737 2738### setBeauty<sup>11+</sup> 2739 2740setBeauty(type: BeautyType, value: number): void 2741 2742设置美颜类型以及对应的美颜强度。将通过[getSupportedBeautyTypes](#getsupportedbeautytypes11)获取得到的[BeautyType](#beautytype)都关闭,表明当前美颜关闭;若有一种美颜类型未关闭,表明当前美颜打开。 2743 2744**系统接口:** 此接口为系统接口。 2745 2746**系统能力:** SystemCapability.Multimedia.Camera.Core 2747 2748**参数:** 2749 2750| 参数名 | 类型 | 必填 | 说明 | 2751| -------- | --------------------------| ---- |-------------------------------------------------------------------| 2752| type | [BeautyType](#beautytype) | 是 | 美颜类型。 | 2753| value | number | 是 | 美颜强度,通过[getSupportedBeautyRange](#getsupportedbeautyrange11)接口获取。 | 2754 2755**错误码:** 2756 2757以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2758 2759| 错误码ID | 错误信息 | 2760| --------------- | --------------- | 2761| 202 | Not System Application. | 2762| 7400103 | Session not config. | 2763 2764**示例:** 2765 2766```ts 2767function setBeauty(portraitPhotoSession: camera.PortraitPhotoSession): void { 2768 let beautyTypes: Array<camera.BeautyType> = portraitPhotoSession.getSupportedBeautyTypes(); 2769 if (beautyTypes === undefined || beautyTypes.length <= 0) { 2770 return; 2771 } 2772 let beautyLevels: Array<number> = portraitPhotoSession.getSupportedBeautyRange(beautyTypes[0]); 2773 if (beautyLevels === undefined || beautyLevels.length <= 0) { 2774 return; 2775 } 2776 portraitPhotoSession.setBeauty(beautyTypes[0], beautyLevels[0]); 2777} 2778``` 2779 2780### getBeauty<sup>11+</sup> 2781 2782getBeauty(type: BeautyType): number 2783 2784查询当前已设置的美颜效果对应的美颜强度。 2785 2786**系统接口:** 此接口为系统接口。 2787 2788**系统能力:** SystemCapability.Multimedia.Camera.Core 2789 2790**参数:** 2791 2792| 参数名 | 类型 | 必填 | 说明 | 2793| -------- | ------------------------------------------------- | ---- | --------------------- | 2794| type | [BeautyType](#beautytype) | 是 | 美颜类型。 | 2795 2796**返回值:** 2797| 参数名 | 类型 | 必填 | 说明 | 2798| -------- | ------------------------------------------------- | ---- | --------------------- | 2799| value | number | 是 | 美颜强度。 | 2800 2801**错误码:** 2802 2803以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2804 2805| 错误码ID | 错误信息 | 2806| --------------- | --------------- | 2807| 202 | Not System Application. | 2808| 7400103 | Session not config. | 2809 2810**示例:** 2811 2812```ts 2813function getBeauty(portraitPhotoSession: camera.PortraitPhotoSession): number { 2814 const invalidValue: number = -1; 2815 let beautyTypes = portraitPhotoSession.getSupportedBeautyTypes(); 2816 if (beautyTypes === undefined || beautyTypes.length <= 0) { 2817 return invalidValue; 2818 } 2819 let beautyLevels: Array<number> = portraitPhotoSession.getSupportedBeautyRange(beautyTypes[0]); 2820 if (beautyLevels === undefined || beautyLevels.length <= 0) { 2821 return invalidValue; 2822 } 2823 portraitPhotoSession.setBeauty(beautyTypes[0], beautyLevels[0]); 2824 let beautyLevel: number = portraitPhotoSession.getBeauty(beautyTypes[0]); 2825 return beautyLevel; 2826} 2827``` 2828 2829## ColorEffectQuery<sup>12+</sup> 2830 2831提供了一个查询设备支持的颜色效果类型的方法。 2832 2833### getSupportedColorEffects<sup>11+</sup> 2834 2835getSupportedColorEffects(): Array\<ColorEffectType\> 2836 2837获取支持的色彩效果类型列表。 2838 2839**系统接口:** 此接口为系统接口。 2840 2841**系统能力:** SystemCapability.Multimedia.Camera.Core 2842 2843**返回值:** 2844 2845| 类型 | 说明 | 2846| ----------------------------------------------- | ---------------------------- | 2847| Array<[ColorEffectType](#coloreffecttype11)> | 支持的色彩效果类型列表。 | 2848 2849**错误码:** 2850 2851以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2852 2853| 错误码ID | 错误信息 | 2854| --------------- | --------------- | 2855| 7400103 | Session not config. | 2856| 202 | Not System Application. | 2857 2858**示例:** 2859 2860```ts 2861function getSupportedColorEffects(session: camera.PhotoSessionForSys): Array<camera.ColorEffectType> { 2862 let colorEffects: Array<camera.ColorEffectType> = session.getSupportedColorEffects(); 2863 return colorEffects; 2864} 2865``` 2866 2867## ColorEffect<sup>11+</sup> 2868 2869ColorEffect extends [ColorEffectQuery](#coloreffectquery12) 2870 2871提供了获取和设置镜头色彩效果的相关功能。 2872 2873### setColorEffect<sup>11+</sup> 2874 2875setColorEffect(type: ColorEffectType): void 2876 2877设置色彩效果类型。可以先通过[getSupportedColorEffects](#getsupportedcoloreffects11)获取当前设备所支持的ColorEffects。 2878 2879**系统接口:** 此接口为系统接口。 2880 2881**系统能力:** SystemCapability.Multimedia.Camera.Core 2882 2883**参数:** 2884 2885| 参数名 | 类型 | 必填 | 说明 | 2886| ------------ |--------------------------------------------------------------- | -- | -------------------------- | 2887| type | [ColorEffectType](#coloreffecttype11) | 是 | 色彩效果类型,通过[getSupportedColorEffects](#getsupportedcoloreffects11)接口获取。 | 2888 2889**错误码:** 2890 2891以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2892 2893| 错误码ID | 错误信息 | 2894| --------------- | --------------- | 2895| 7400103 | Session not config. | 2896| 202 | Not System Application. | 2897 2898**示例:** 2899 2900```ts 2901function setColorEffect(session: camera.PhotoSessionForSys, colorEffect: camera.ColorEffectType): void { 2902 session.setColorEffect(colorEffect); 2903} 2904``` 2905 2906### getColorEffect<sup>11+</sup> 2907 2908getColorEffect(): ColorEffectType 2909 2910获取当前设置的色彩效果类型。 2911 2912**系统接口:** 此接口为系统接口。 2913 2914**系统能力:** SystemCapability.Multimedia.Camera.Core 2915 2916**返回值:** 2917 2918| 类型 | 说明 | 2919| ----------------------------------------------- | ---------------------------- | 2920| [ColorEffectType](#coloreffecttype11) | 当前设置的色彩效果类型。 | 2921 2922**错误码:** 2923 2924以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2925 2926| 错误码ID | 错误信息 | 2927| --------------- | --------------- | 2928| 7400103 | Session not config. | 2929| 202 | Not System Application. | 2930 2931**示例:** 2932 2933```ts 2934function getColorEffect(session: camera.PhotoSessionForSys): camera.ColorEffectType { 2935 let colorEffect: camera.ColorEffectType = session.getColorEffect(); 2936 return colorEffect; 2937} 2938``` 2939 2940## ColorEffectType<sup>11+</sup> 2941 2942枚举,色彩效果类型。 2943 2944**系统接口:** 此接口为系统接口。 2945 2946**系统能力:** SystemCapability.Multimedia.Camera.Core 2947 2948| 名称 | 值 | 说明 | 2949| --------------------- | ---- | --------- | 2950| NORMAL | 0 | 常规的色彩效果。 | 2951| BRIGHT | 1 | 明艳的色彩效果。 | 2952| SOFT | 2 | 柔和的色彩效果。 | 2953| BLACK_WHITE<sup>12+</sup> | 3 | 黑白色彩效果。 | 2954 2955## Portrait<sup>11+</sup> 2956 2957人像类,用于设置人像参数。 2958 2959### getSupportedPortraitEffects<sup>10+</sup> 2960 2961getSupportedPortraitEffects(): Array\<PortraitEffect\> 2962 2963获取支持的人像虚化效果列表。 2964 2965**系统接口:** 此接口为系统接口。 2966 2967**系统能力:** SystemCapability.Multimedia.Camera.Core 2968 2969**返回值:** 2970 2971| 类型 | 说明 | 2972| ----------------------------------------------- | ---------------------------- | 2973| Array<[PortraitEffect](#portraiteffect)> | 支持的人像虚化效果列表。 | 2974 2975**错误码:** 2976 2977以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2978 2979| 错误码ID | 错误信息 | 2980| --------------- | --------------- | 2981| 7400103 | Session not config. | 2982| 202 | Not System Application. | 2983 2984**示例:** 2985 2986```ts 2987function getSupportedPortraitEffects(portraitPhotoSession: camera.PortraitPhotoSession): Array<camera.PortraitEffect> { 2988 let portraitEffects: Array<camera.PortraitEffect> = portraitPhotoSession.getSupportedPortraitEffects(); 2989 return portraitEffects; 2990} 2991``` 2992 2993### setPortraitEffect<sup>10+</sup> 2994 2995setPortraitEffect(effect: PortraitEffect): void 2996 2997设置人像虚化效果。需要先检查设备是否支持人像虚化模式,可以通过[getSupportedPortraitEffects](#getsupportedportraiteffects10)获取当前设备所支持的PortraitEffects。 2998 2999**系统接口:** 此接口为系统接口。 3000 3001**系统能力:** SystemCapability.Multimedia.Camera.Core 3002 3003**参数:** 3004 3005| 参数名 | 类型 | 必填 | 说明 | 3006| ------------ |----------------------------- | -- | -------------------------- | 3007| effect | [PortraitEffect](#portraiteffect) | 是 | 人像虚化效果,通过[getSupportedPortraitEffects](#getsupportedportraiteffects10)接口获取。 | 3008 3009**错误码:** 3010 3011以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3012 3013| 错误码ID | 错误信息 | 3014| --------------- | --------------- | 3015| 7400103 | Session not config. | 3016| 202 | Not System Application. | 3017 3018**示例:** 3019 3020```ts 3021import { BusinessError } from '@kit.BasicServicesKit'; 3022 3023function setPortraitEffect(portraitPhotoSession: camera.PortraitPhotoSession, portraitEffects: Array<camera.PortraitEffect>): void { 3024 if (portraitEffects === undefined || portraitEffects.length <= 0) { 3025 return; 3026 } 3027 try { 3028 portraitPhotoSession.setPortraitEffect(portraitEffects[0]); 3029 } catch (error) { 3030 let err = error as BusinessError; 3031 console.error(`The setPortraitEffect call failed. error code: ${err.code}`); 3032 } 3033} 3034``` 3035 3036### getPortraitEffect<sup>10+</sup> 3037 3038getPortraitEffect(): PortraitEffect 3039 3040获取当前设置的人像虚化效果。 3041 3042**系统接口:** 此接口为系统接口。 3043 3044**系统能力:** SystemCapability.Multimedia.Camera.Core 3045 3046**返回值:** 3047 3048| 类型 | 说明 | 3049| ----------------------------------------------- | ---------------------------- | 3050| [PortraitEffect](#portraiteffect) | 当前设置的人像虚化效果。 | 3051 3052**错误码:** 3053 3054以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3055 3056| 错误码ID | 错误信息 | 3057| --------------- | --------------- | 3058| 7400103 | Session not config. | 3059| 202 | Not System Application. | 3060 3061**示例:** 3062 3063```ts 3064function getPortraitEffect(portraitPhotoSession: camera.PortraitPhotoSession): camera.PortraitEffect { 3065 let portraitEffect: camera.PortraitEffect = portraitPhotoSession.getPortraitEffect(); 3066 return portraitEffect; 3067} 3068``` 3069 3070## PhysicalAperture<sup>11+</sup> 3071 3072物理光圈信息。 3073 3074**系统接口:** 此接口为系统接口。 3075 3076**系统能力:** SystemCapability.Multimedia.Camera.Core 3077 3078| 名称 | 类型 | 只读 | 可选 | 说明 | 3079| ---------- | ------------------------- | ----- |-----| ----------------- | 3080| zoomRange | [ZoomRange](#zoomrange11) | 否 | 否 | 特定物理光圈的变焦范围。 | 3081| apertures | Array\<number\> | 否 | 否 | 支持的物理光圈列表。 | 3082 3083## Aperture<sup>11+</sup> 3084 3085光圈类,用于设置光圈参数。 3086 3087### getSupportedVirtualApertures<sup>11+</sup> 3088 3089getSupportedVirtualApertures(): Array\<number\> 3090 3091获取支持的虚拟光圈列表。 3092 3093**系统接口:** 此接口为系统接口。 3094 3095**系统能力:** SystemCapability.Multimedia.Camera.Core 3096 3097**返回值:** 3098 3099| 类型 | 说明 | 3100| ----------------------------------------------- | ---------------------------- | 3101| Array\<number\> | 支持的虚拟光圈列表。 | 3102 3103**错误码:** 3104 3105以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3106 3107| 错误码ID | 错误信息 | 3108| --------------- | --------------- | 3109| 7400103 | Session not config. | 3110| 202 | Not System Application. | 3111 3112**示例:** 3113 3114```ts 3115function getSupportedVirtualApertures(session: camera.PortraitPhotoSession): Array<number> { 3116 let virtualApertures: Array<number> = session.getSupportedVirtualApertures(); 3117 return virtualApertures; 3118} 3119``` 3120 3121### getVirtualAperture<sup>11+</sup> 3122 3123getVirtualAperture(): number 3124 3125获取当前设置的虚拟光圈值。 3126 3127**系统接口:** 此接口为系统接口。 3128 3129**系统能力:** SystemCapability.Multimedia.Camera.Core 3130 3131**返回值:** 3132 3133| 类型 | 说明 | 3134| ----------------------------------------------- | ---------------------------- | 3135| number | 当前设置的虚拟光圈值。 | 3136 3137**错误码:** 3138 3139以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3140 3141| 错误码ID | 错误信息 | 3142| --------------- | --------------- | 3143| 7400103 | Session not config. | 3144| 202 | Not System Application. | 3145 3146**示例:** 3147 3148```ts 3149function getVirtualAperture(session: camera.PortraitPhotoSession): number { 3150 let virtualAperture: number = session.getVirtualAperture(); 3151 return virtualAperture; 3152} 3153``` 3154 3155### setVirtualAperture<sup>11+</sup> 3156 3157setVirtualAperture(aperture: number): void 3158 3159设置虚拟光圈。可以线通过[getSupportedVirtualApertures](#getsupportedvirtualapertures11)获取当前设备所支持的虚拟光圈列表。 3160 3161**系统接口:** 此接口为系统接口。 3162 3163**系统能力:** SystemCapability.Multimedia.Camera.Core 3164 3165**参数:** 3166 3167| 参数名 | 类型 | 必填 | 说明 | 3168| ------------ |------------------------- | -- | -------------------------- | 3169| aperture | number | 是 | 虚拟光圈值,通过[getSupportedVirtualApertures](#getsupportedvirtualapertures11)接口获取。 | 3170 3171**错误码:** 3172 3173以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3174 3175| 错误码ID | 错误信息 | 3176| --------------- | --------------- | 3177| 7400103 | Session not config. | 3178| 202 | Not System Application. | 3179 3180**示例:** 3181 3182```ts 3183function setVirtualAperture(session: camera.PortraitPhotoSession, virtualAperture: number): void { 3184 session.setVirtualAperture(virtualAperture); 3185} 3186``` 3187 3188### getSupportedPhysicalApertures<sup>11+</sup> 3189 3190getSupportedPhysicalApertures(): Array\<PhysicalAperture\> 3191 3192获取支持的物理光圈列表。 3193 3194**系统接口:** 此接口为系统接口。 3195 3196**系统能力:** SystemCapability.Multimedia.Camera.Core 3197 3198**返回值:** 3199 3200| 类型 | 说明 | 3201| ----------------------------------------------- | ---------------------------- | 3202| Array<[PhysicalAperture](#physicalaperture11)> | 支持的物理光圈列表。 | 3203 3204**错误码:** 3205 3206以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3207 3208| 错误码ID | 错误信息 | 3209| --------------- | --------------- | 3210| 7400103 | Session not config. | 3211| 202 | Not System Application. | 3212 3213**示例:** 3214 3215```ts 3216function getSupportedPhysicalApertures(session: camera.PortraitPhotoSession): Array<camera.PhysicalAperture> { 3217 let physicalApertures: Array<camera.PhysicalAperture> = session.getSupportedPhysicalApertures(); 3218 return physicalApertures; 3219} 3220``` 3221 3222### getPhysicalAperture<sup>11+</sup> 3223 3224getPhysicalAperture(): number 3225 3226获取当前设置的物理光圈值。 3227 3228**系统接口:** 此接口为系统接口。 3229 3230**系统能力:** SystemCapability.Multimedia.Camera.Core 3231 3232**返回值:** 3233 3234| 类型 | 说明 | 3235| -------------------- | ---------------------------- | 3236| number | 当前设置的物理光圈值。 | 3237 3238**错误码:** 3239 3240以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3241 3242| 错误码ID | 错误信息 | 3243| --------------- | --------------- | 3244| 7400103 | Session not config. | 3245| 202 | Not System Application. | 3246 3247**示例:** 3248 3249```ts 3250function getPhysicalAperture(session: camera.PortraitPhotoSession): number { 3251 let physicalAperture: number = session.getPhysicalAperture(); 3252 return physicalAperture; 3253} 3254``` 3255 3256### setPhysicalAperture<sup>11+</sup> 3257 3258setPhysicalAperture(aperture: number): void 3259 3260设置物理光圈。可以线通过[getSupportedPhysicalApertures](#getsupportedphysicalapertures11)获取当前设备所支持的物理光圈列表。 3261 3262**系统接口:** 此接口为系统接口。 3263 3264**系统能力:** SystemCapability.Multimedia.Camera.Core 3265 3266**参数:** 3267 3268| 参数名 | 类型 | 必填 | 说明 | 3269| ------------ |------------------------- | -- | -------------------------- | 3270| aperture | number | 是 | 物理光圈值,通过[getSupportedPhysicalApertures](#getsupportedphysicalapertures11)接口获取。 | 3271 3272**错误码:** 3273 3274以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3275 3276| 错误码ID | 错误信息 | 3277| --------------- | --------------- | 3278| 7400103 | Session not config. | 3279| 202 | Not System Application. | 3280 3281**示例:** 3282 3283```ts 3284function setPhysicalAperture(session: camera.PortraitPhotoSession, physicalAperture: number): void { 3285 session.setPhysicalAperture(physicalAperture); 3286} 3287``` 3288 3289## CaptureSession<sup>(deprecated)</sup> 3290 3291拍照会话类,保存一次相机运行所需要的所有资源[CameraInput](js-apis-camera.md#camerainput)、[CameraOutput](js-apis-camera.md#cameraoutput),并向相机设备申请完成相机功能(录像,拍照)。 3292 3293> **说明:** 3294>从 API version 10开始支持,从API version 11开始废弃。建议使用[PhotoSession](#photosession11)、[VideoSession](#videosession11)替代。 3295 3296### getSupportedBeautyTypes<sup>(deprecated)</sup> 3297 3298getSupportedBeautyTypes(): Array\<BeautyType> 3299 3300获取当前支持的美颜效果列表。 3301 3302> **说明:** 3303>从 API version 10开始支持,从API version 11开始废弃。建议使用[Beauty.getSupportedBeautyTypes](#getsupportedbeautytypes11)替代。 3304 3305**系统接口:** 此接口为系统接口。 3306 3307**系统能力:** SystemCapability.Multimedia.Camera.Core 3308 3309**返回值:** 3310 3311| 类型 | 说明 | 3312| ---------- | ----------------------------- | 3313| Array\<[BeautyType](#beautytype)\>| 返回当前支持的美颜效果列表。 | 3314 3315**错误码:** 3316 3317以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3318 3319| 错误码ID | 错误信息 | 3320| --------------- | --------------- | 3321| 7400103 | Session not config. | 3322 3323**示例:** 3324 3325```ts 3326function getSupportedBeautyTypes(captureSession: camera.CaptureSession): Array<camera.BeautyType> { 3327 let beautyTypes: Array<camera.BeautyType> = captureSession.getSupportedBeautyTypes(); 3328 return beautyTypes; 3329} 3330``` 3331 3332### getSupportedBeautyRange<sup>(deprecated)</sup> 3333 3334getSupportedBeautyRange(type: BeautyType): Array\<number\> 3335 3336获取指定美颜效果的范围值。在不同设备返回的美颜强度有所不同,下表仅做示例。 3337 3338| 传入参数 | 示例返回值 | 返回值说明 | 3339| ----------------| ---- | ---------| 3340| AUTO | [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] |美颜类型为自动时支持的美颜强度,0表明关闭美颜,其余正值表明自动的美颜强度。 | 3341| SKIN_SMOOTH | [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | 美颜类型为光滑时支持的美颜强度,0表明关闭光滑,其余正值表明光滑的美颜强度。 | 3342| FACE_SLENDER | [0, 1, 2, 3, 4, 5] | 美颜类型为瘦脸时支持的美颜强度,0表明关闭瘦脸,其余正值表明瘦脸的美颜强度。 | 3343| SKIN_TONE | [-1, 16242611] | 美颜类型为美肤时支持的美颜强度,-1表明关闭美肤,其余非负值为使用RGB表示的美肤美颜强度,<br> 16242611转化为16进制为0xF7D7B3,F7为R通道值,D7为G通道值,B3位B通道值。 | 3344 3345> **说明:** 3346>从 API version 10开始支持,从API version 11开始废弃。建议使用[Beauty.getSupportedBeautyRange](#getsupportedbeautyrange11)替代。 3347 3348**系统接口:** 此接口为系统接口。 3349 3350**系统能力:** SystemCapability.Multimedia.Camera.Core 3351 3352**参数:** 3353 3354| 参数名 | 类型 | 必填 | 说明 | 3355| -------- | --------------------------| ---- | ----------| 3356| type | [BeautyType](#beautytype) | 是 | 美颜类型。 | 3357 3358**返回值:** 3359 3360| 类型 | 说明 | 3361| ---------- | ----------------------------- | 3362| Array\<number\> | 当前美颜类型所支持的美颜强度。 | 3363 3364**错误码:** 3365 3366以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3367 3368| 错误码ID | 错误信息 | 3369| --------------- | --------------- | 3370| 7400103 | Session not config. | 3371 3372**示例:** 3373 3374```ts 3375function getSupportedBeautyRange(captureSession: camera.CaptureSession): Array<number> { 3376 let beautyTypes: Array<camera.BeautyType> = captureSession.getSupportedBeautyTypes(); 3377 if (beautyTypes === undefined || beautyTypes.length <= 0) { 3378 return []; 3379 } 3380 let beautyLevels: Array<number> = captureSession.getSupportedBeautyRange(beautyTypes[0]); 3381 return beautyLevels; 3382} 3383``` 3384 3385### setBeauty<sup>(deprecated)</sup> 3386 3387setBeauty(type: BeautyType, value: number): void 3388 3389设置美颜类型以及对应的美颜强度。将通过[getSupportedBeautyTypes](#getsupportedbeautytypesdeprecated)获取得到的[BeautyType](#beautytype)都关闭,表明当前美颜关闭;若有一种美颜类型未关闭,表明当前美颜打开。 3390 3391> **说明:** 3392>从 API version 10开始支持,从API version 11开始废弃。建议使用[Beauty.setBeauty](#setbeauty11)替代。 3393 3394**系统接口:** 此接口为系统接口。 3395 3396**系统能力:** SystemCapability.Multimedia.Camera.Core 3397 3398**参数:** 3399 3400| 参数名 | 类型 | 必填 | 说明 | 3401| -------- | --------------------------| ---- | --------------------- | 3402| type | [BeautyType](#beautytype) | 是 | 美颜类型 。 | 3403| value | number | 是 | 美颜强度,通过[getSupportedBeautyRange](#getsupportedbeautyrangedeprecated)接口获取。| 3404 3405**错误码:** 3406 3407以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3408 3409| 错误码ID | 错误信息 | 3410| --------------- | --------------- | 3411| 7400103 | Session not config. | 3412 3413**示例:** 3414 3415```ts 3416function setBeauty(captureSession: camera.CaptureSession): void { 3417 let beautyTypes: Array<camera.BeautyType> = captureSession.getSupportedBeautyTypes(); 3418 if (beautyTypes === undefined || beautyTypes.length <= 0) { 3419 return; 3420 } 3421 let beautyLevels: Array<number> = captureSession.getSupportedBeautyRange(beautyTypes[0]); 3422 if (beautyLevels === undefined || beautyLevels.length <= 0) { 3423 return; 3424 } 3425 captureSession.setBeauty(beautyTypes[0], beautyLevels[0]); 3426} 3427``` 3428 3429### getBeauty<sup>(deprecated)</sup> 3430 3431getBeauty(type: BeautyType): number 3432 3433查询当前已设置的美颜效果对应的美颜强度。 3434 3435> **说明:** 3436>从 API version 10开始支持,从API version 11开始废弃。建议使用[Beauty.getBeauty](#getbeauty11)替代。 3437 3438**系统接口:** 此接口为系统接口。 3439 3440**系统能力:** SystemCapability.Multimedia.Camera.Core 3441 3442**参数:** 3443 3444| 参数名 | 类型 | 必填 | 说明 | 3445| -------- | ------------------------------------------------- | ---- | --------------------- | 3446| type | [BeautyType](#beautytype) | 是 | 美颜类型。 | 3447 3448**返回值:** 3449| 参数名 | 类型 | 必填 | 说明 | 3450| -------- | ------------------------------------------------- | ---- | --------------------- | 3451| value | number | 是 | 美颜强度。 | 3452 3453**错误码:** 3454 3455以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3456 3457| 错误码ID | 错误信息 | 3458| --------------- | --------------- | 3459| 7400103 | Session not config. | 3460 3461**示例:** 3462 3463```ts 3464function getBeauty(captureSession: camera.CaptureSession): number { 3465 const invalidValue: number = -1; 3466 let beautyTypes: Array<camera.BeautyType> = captureSession.getSupportedBeautyTypes(); 3467 if (beautyTypes === undefined || beautyTypes.length <= 0) { 3468 return invalidValue; 3469 } 3470 let beautyLevels: Array<number> = captureSession.getSupportedBeautyRange(beautyTypes[0]); 3471 if (beautyLevels === undefined || beautyLevels.length <= 0) { 3472 return invalidValue; 3473 } 3474 captureSession.setBeauty(beautyTypes[0], beautyLevels[0]); 3475 let beautyLevel: number = captureSession.getBeauty(beautyTypes[0]); 3476 return beautyLevel; 3477} 3478``` 3479 3480## PhotoSessionForSys<sup>11+</sup> 3481 3482PhotoSessionForSys extends PhotoSession, Beauty, ColorEffect, ColorManagement, Macro, SceneDetection 3483 3484提供给系统应用的PhotoSession,普通拍照模式会话类,继承自[Session](js-apis-camera.md#session11),用于设置普通拍照模式的参数以及保存所需要的所有资源[CameraInput](js-apis-camera.md#camerainput)、[CameraOutput](js-apis-camera.md#cameraoutput)。 3485 3486**系统接口:** 此接口为系统接口。 3487 3488**系统能力:** SystemCapability.Multimedia.Camera.Core 3489 3490## PhotoSession<sup>11+</sup> 3491 3492PhotoSession extends Session, Flash, AutoExposure, Focus, Zoom, ColorManagement 3493 3494普通拍照模式会话类,继承自[Session](js-apis-camera.md#session11),用于设置普通拍照模式的参数以及保存所需要的所有资源[CameraInput](js-apis-camera.md#camerainput)、[CameraOutput](js-apis-camera.md#cameraoutput)。 3495 3496### on('macroStatusChanged')<sup>11+</sup> 3497 3498on(type: 'macroStatusChanged', callback: AsyncCallback\<boolean\>): void 3499 3500监听相机微距状态变化,通过注册回调函数获取结果。使用callback异步回调。 3501 3502**系统接口:** 此接口为系统接口。 3503 3504**系统能力:** SystemCapability.Multimedia.Camera.Core 3505 3506**参数:** 3507 3508| 参数名 | 类型 | 必填 | 说明 | 3509| -------- | ----------------------------------------- | ---- | ------------------------ | 3510| type | string | 是 | 监听事件,固定为'macroStatusChanged',session创建成功可监听。 | 3511| callback | AsyncCallback\<boolean\> | 是 | 回调函数,用于获取当前微距状态,返回true为开启状态,返回false为禁用状态。 | 3512 3513**错误码:** 3514 3515以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3516 3517| 错误码ID | 错误信息 | 3518|-------|---------------------------| 3519| 202 | Not System Application. | 3520 3521**示例:** 3522 3523```ts 3524import { BusinessError } from '@kit.BasicServicesKit'; 3525 3526function callback(err: BusinessError, macroStatus: boolean): void { 3527 if (err !== undefined && err.code !== 0) { 3528 console.error(`Callback Error, errorCode: ${err.code}`); 3529 return; 3530 } 3531 console.info(`Macro state: ${macroStatus}`); 3532} 3533 3534function registerMacroStatusChanged(photoSession: camera.PhotoSession): void { 3535 photoSession.on('macroStatusChanged', callback); 3536} 3537``` 3538 3539### off('macroStatusChanged')<sup>11+</sup> 3540 3541off(type: 'macroStatusChanged', callback?: AsyncCallback\<boolean\>): void 3542 3543注销监听相机微距状态变化。 3544 3545**系统接口:** 此接口为系统接口。 3546 3547**系统能力:** SystemCapability.Multimedia.Camera.Core 3548 3549**参数:** 3550 3551| 参数名 | 类型 | 必填 | 说明 | 3552| -------- | ------------------------ | ---- | ------------------------ | 3553| type | string | 是 | 监听事件,固定为'macroStatusChanged',session创建成功可监听。| 3554| callback | AsyncCallback\<boolean\> | 否 | 回调函数,可选,有就是匹配on('macroStatusChanged') callback(callback对象不可是匿名函数),返回true为开启状态,返回false为禁用状态。 | 3555 3556**错误码:** 3557 3558以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3559 3560| 错误码ID | 错误信息 | 3561|-------|---------------------------| 3562| 202 | Not System Application. | 3563 3564**示例:** 3565 3566```ts 3567function unregisterMacroStatusChanged(photoSession: camera.PhotoSession): void { 3568 photoSession.off('macroStatusChanged'); 3569} 3570``` 3571 3572### on('featureDetection')<sup>12+</sup> 3573 3574on(type: 'featureDetection', featureType: SceneFeatureType, callback: AsyncCallback\<SceneFeatureDetectionResult\>): void 3575 3576监听相机特性检测状态变化。使用callback异步回调。 3577 3578**系统接口:** 此接口为系统接口。 3579 3580**系统能力:** SystemCapability.Multimedia.Camera.Core 3581 3582**参数:** 3583 3584| 参数名 | 类型 | 必填 | 说明 | 3585| -------- | ----------------------------------------- | ---- | ------------------------ | 3586| type | string | 是 | 监听事件,固定为'featureDetection',photoSession创建成功可监听。 | 3587| featureType | [SceneFeatureType](#scenefeaturetype12) | 是 | 监听指定特性。 | 3588| callback | AsyncCallback\<[SceneFeatureDetectionResult](#scenefeaturedetectionresult12)\> | 是 | 回调函数,用于获取当前监听的特性的状态。 | 3589 3590**错误码:** 3591 3592以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3593 3594| 错误码ID | 错误信息 | 3595|-------|---------------------------| 3596| 202 | Not System Application. | 3597 3598**示例:** 3599 3600```ts 3601import { BusinessError } from '@kit.BasicServicesKit'; 3602 3603function callback(err: BusinessError, result: camera.SceneFeatureDetectionResult): void { 3604 if (err !== undefined && err.code !== 0) { 3605 console.error(`Callback Error, errorCode: ${err.code}`); 3606 return; 3607 } 3608 console.info(`feature type: ${result.featureType}`); 3609 console.info(`feature status: ${result.detected}`); 3610} 3611 3612function registerFeatureDetectionStatus(photoSession: camera.PhotoSession, featureType: camera.SceneFeatureType): void { 3613 photoSession.on('featureDetection', featureType, callback); 3614} 3615``` 3616 3617### off('featureDetection')<sup>12+</sup> 3618 3619off(type: 'featureDetection', featureType: SceneFeatureType, callback?: AsyncCallback\<SceneFeatureDetectionResult\>): void 3620 3621注销监听相机特性检测状态变化。 3622 3623**系统接口:** 此接口为系统接口。 3624 3625**系统能力:** SystemCapability.Multimedia.Camera.Core 3626 3627**参数:** 3628 3629| 参数名 | 类型 | 必填 | 说明 | 3630| -------- | ------------------------ | ---- | ------------------------ | 3631| type | string | 是 | 监听事件,固定为'featureDetection',session创建成功可取消监听。| 3632| featureType | [SceneFeatureType](#scenefeaturetype12) | 是 | 指定特性。 | 3633| callback | AsyncCallback\<[SceneFeatureDetectionResult](#scenefeaturedetectionresult12)\> | 否 | 回调函数,可选,有就是匹配on('featureDetection') callback(callback对象不可是匿名函数)。 | 3634 3635**错误码:** 3636 3637以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3638 3639| 错误码ID | 错误信息 | 3640|-------|---------------------------| 3641| 202 | Not System Application. | 3642 3643**示例:** 3644 3645```ts 3646function unregisterFeatureDetectionStatus(photoSession: camera.PhotoSession, featureType: camera.SceneFeatureType): void { 3647 photoSession.off('featureDetection', featureType); 3648} 3649``` 3650 3651### on('lcdFlashStatus')<sup>13+</sup> 3652 3653on(type: 'lcdFlashStatus', callback: AsyncCallback\<LcdFlashStatus\>): void 3654 3655监听LCD闪光灯状态变化。使用callback异步回调。 3656 3657**系统接口:** 此接口为系统接口。 3658 3659**系统能力:** SystemCapability.Multimedia.Camera.Core 3660 3661**参数:** 3662 3663| 参数名 | 类型 | 必填 | 说明 | 3664| -------- | ----------------------------------------- | ---- |------------------------------------------| 3665| type | string | 是 | 监听事件,固定为'lcdFlashStatus',session创建成功可监听。 | 3666| callback | AsyncCallback\<[LcdFlashStatus](#lcdflashstatus12)\> | 是 | 回调函数,用于获取当前lcd flash状态。 | 3667 3668**错误码:** 3669 3670以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3671 3672| 错误码ID | 错误信息 | 3673|-------|---------------------------| 3674| 202 | Not System Application. | 3675 3676**示例:** 3677 3678```ts 3679import { BusinessError } from '@kit.BasicServicesKit'; 3680 3681function callback(err: BusinessError, lcdFlashStatus: camera.LcdFlashStatus): void { 3682 if (err !== undefined && err.code !== 0) { 3683 console.error(`Callback Error, errorCode: ${err.code}`); 3684 return; 3685 } 3686 console.info(`isLcdFlashNeeded: ${lcdFlashStatus.isLcdFlashNeeded}`); 3687 console.info(`lcdCompensation: ${lcdFlashStatus.lcdCompensation}`); 3688} 3689 3690function registerLcdFlashStatus(photoSession: camera.PhotoSession): void { 3691 photoSession.on('lcdFlashStatus', callback); 3692} 3693``` 3694 3695### off('lcdFlashStatus')<sup>13+</sup> 3696 3697off(type: 'lcdFlashStatus', callback?: AsyncCallback\<LcdFlashStatus\>): void 3698 3699注销监听LCD闪光灯状态变化。 3700 3701**系统接口:** 此接口为系统接口。 3702 3703**系统能力:** SystemCapability.Multimedia.Camera.Core 3704 3705**参数:** 3706 3707| 参数名 | 类型 | 必填 | 说明 | 3708| -------- | ------------------------ | ---- |------------------------------------------------------------------| 3709| type | string | 是 | 监听事件,固定为'lcdFlashStatus',session创建成功可取消监听。 | 3710| callback | AsyncCallback\<[LcdFlashStatus](#lcdflashstatus12)\> | 否 | 回调函数,可选,有就是匹配on('lcdFlashStatus') callback(callback对象不可是匿名函数)。 | 3711 3712**错误码:** 3713 3714以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3715 3716| 错误码ID | 错误信息 | 3717|-------|---------------------------| 3718| 202 | Not System Application. | 3719 3720**示例:** 3721 3722```ts 3723function unregisterLcdFlashStatus(photoSession: camera.PhotoSession): void { 3724 photoSession.off('lcdFlashStatus'); 3725} 3726``` 3727 3728## FocusTrackingMode<sup>15+</sup> 3729 3730枚举,对焦追踪模式。 3731 3732**系统能力**: SystemCapability.Multimedia.Camera.Core 3733 3734| 名称 | 值 | 说明 | 3735| ---- | ---- | ------ | 3736| AUTO | 0 | 自动。 | 3737 3738## FocusTrackingInfo<sup>15+</sup> 3739 3740相机对焦追踪信息,通过VideoSessionForSys.[on('focusTrackingInfoAvailable')](#onfocustrackinginfoavailable15)接口获取。 3741 3742**系统能力**: SystemCapability.Multimedia.Camera.Core 3743 3744| 名称 | 类型 | 只读 | 可选 | 说明 | 3745| -------------- | ----------------------------------------- | ---- | ---- | ---------- | 3746| trackingMode | [FocusTrackingMode](#focustrackingmode15) | 否 | 否 | 跟踪模式。 | 3747| trackingRegion | [Rect](js-apis-camera.md#rect) | 否 | 否 | 跟踪区域。 | 3748 3749## VideoSessionForSys<sup>11+</sup> 3750 3751VideoSessionForSys extends VideoSession, Beauty, ColorEffect, ColorManagement, Macro, Aperture, ColorReservation 3752 3753提供给系统应用的VideoSession,普通录像模式会话类,继承自[Session](js-apis-camera.md#session11),用于设置普通录像模式的参数以及保存所需要的所有资源[CameraInput](js-apis-camera.md#camerainput)、[CameraOutput](js-apis-camera.md#cameraoutput)。 3754 3755**系统接口:** 此接口为系统接口。 3756 3757**系统能力:** SystemCapability.Multimedia.Camera.Core 3758 3759## VideoSession<sup>11+</sup> 3760 3761VideoSession extends Session, Flash, AutoExposure, Focus, Zoom, Stabilization, ColorManagement 3762 3763普通录像模式会话类,继承自[Session](js-apis-camera.md#session11),用于设置普通录像模式的参数以及保存所需要的所有资源[CameraInput](js-apis-camera.md#camerainput)、[CameraOutput](js-apis-camera.md#cameraoutput)。 3764 3765### on('macroStatusChanged')<sup>11+</sup> 3766 3767on(type: 'macroStatusChanged', callback: AsyncCallback\<boolean\>): void 3768 3769监听相机微距状态变化,通过注册回调函数获取结果。使用callback异步回调。 3770 3771**系统接口:** 此接口为系统接口。 3772 3773**系统能力:** SystemCapability.Multimedia.Camera.Core 3774 3775**参数:** 3776 3777| 参数名 | 类型 | 必填 | 说明 | 3778| -------- | ----------------------------------------- | ---- | ------------------------ | 3779| type | string | 是 | 监听事件,固定为'macroStatusChanged',session创建成功可监听。 | 3780| callback | AsyncCallback\<boolean\> | 是 | 回调函数,用于获取当前微距状态,返回true是开启状态,返回false是禁用状态。 | 3781 3782**错误码:** 3783 3784以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3785 3786| 错误码ID | 错误信息 | 3787|-------|---------------------------| 3788| 202 | Not System Application. | 3789 3790**示例:** 3791 3792```ts 3793import { BusinessError } from '@kit.BasicServicesKit'; 3794 3795function callback(err: BusinessError, macroStatus: boolean): void { 3796 if (err !== undefined && err.code !== 0) { 3797 console.error(`Callback Error, errorCode: ${err.code}`); 3798 return; 3799 } 3800 console.info(`Macro state: ${macroStatus}`); 3801} 3802 3803function registerMacroStatusChanged(videoSession: camera.VideoSession): void { 3804 videoSession.on('macroStatusChanged', callback); 3805} 3806``` 3807 3808### off('macroStatusChanged')<sup>11+</sup> 3809 3810off(type: 'macroStatusChanged', callback?: AsyncCallback\<boolean\>): void 3811 3812注销监听相机微距状态变化。 3813 3814**系统接口:** 此接口为系统接口。 3815 3816**系统能力:** SystemCapability.Multimedia.Camera.Core 3817 3818**参数:** 3819 3820| 参数名 | 类型 | 必填 | 说明 | 3821| -------- | ------------------------ | ---- | ------------------------ | 3822| type | string | 是 | 监听事件,固定为'macroStatusChanged',session创建成功可监听。| 3823| callback | AsyncCallback\<boolean\> | 否 | 回调函数,可选,有就是匹配on('macroStatusChanged') callback(callback对象不可是匿名函数),返回true是开启状态,返回false是禁用状态。 | 3824 3825**错误码:** 3826 3827以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3828 3829| 错误码ID | 错误信息 | 3830|-------|---------------------------| 3831| 202 | Not System Application. | 3832 3833**示例:** 3834 3835```ts 3836function unregisterMacroStatusChanged(videoSession: camera.VideoSession): void { 3837 videoSession.off('macroStatusChanged'); 3838} 3839``` 3840 3841### on('lcdFlashStatus')<sup>13+</sup> 3842 3843on(type: 'lcdFlashStatus', callback: AsyncCallback\<LcdFlashStatus\>): void 3844 3845监听LCD闪光灯状态变化。使用callback异步回调。 3846 3847**系统接口:** 此接口为系统接口。 3848 3849**系统能力:** SystemCapability.Multimedia.Camera.Core 3850 3851**参数:** 3852 3853| 参数名 | 类型 | 必填 | 说明 | 3854| -------- | ----------------------------------------- | ---- |------------------------------------------| 3855| type | string | 是 | 监听事件,固定为'lcdFlashStatus',session创建成功可监听。 | 3856| callback | AsyncCallback\<[LcdFlashStatus](#lcdflashstatus12)\> | 是 | 回调函数,用于获取当前lcd flash状态。 | 3857 3858**错误码:** 3859 3860以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3861 3862| 错误码ID | 错误信息 | 3863|-------|---------------------------| 3864| 202 | Not System Application. | 3865 3866**示例:** 3867 3868```ts 3869import { BusinessError } from '@kit.BasicServicesKit'; 3870 3871function callback(err: BusinessError, lcdFlashStatus: camera.LcdFlashStatus): void { 3872 if (err !== undefined && err.code !== 0) { 3873 console.error(`Callback Error, errorCode: ${err.code}`); 3874 return; 3875 } 3876 console.info(`isLcdFlashNeeded: ${lcdFlashStatus.isLcdFlashNeeded}`); 3877 console.info(`lcdCompensation: ${lcdFlashStatus.lcdCompensation}`); 3878} 3879 3880function registerLcdFlashStatus(videoSession: camera.VideoSession): void { 3881 videoSession.on('lcdFlashStatus', callback); 3882} 3883``` 3884 3885### off('lcdFlashStatus')<sup>13+</sup> 3886 3887off(type: 'lcdFlashStatus', callback?: AsyncCallback\<LcdFlashStatus\>): void 3888 3889注销监听LCD闪光灯状态变化。 3890 3891**系统接口:** 此接口为系统接口。 3892 3893**系统能力:** SystemCapability.Multimedia.Camera.Core 3894 3895**参数:** 3896 3897| 参数名 | 类型 | 必填 | 说明 | 3898| -------- | ------------------------ | ---- |------------------------------------------------------------------| 3899| type | string | 是 | 监听事件,固定为'lcdFlashStatus',session创建成功可取消监听。 | 3900| callback | AsyncCallback\<[LcdFlashStatus](#lcdflashstatus12)\> | 否 | 回调函数,可选,有就是匹配on('lcdFlashStatus') callback(callback对象不可是匿名函数)。 | 3901 3902**错误码:** 3903 3904以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3905 3906| 错误码ID | 错误信息 | 3907|-------|---------------------------| 3908| 202 | Not System Application. | 3909 3910**示例:** 3911 3912```ts 3913function unregisterLcdFlashStatus(videoSession: camera.VideoSession): void { 3914 videoSession.off('lcdFlashStatus'); 3915} 3916``` 3917 3918### on('focusTrackingInfoAvailable')<sup>15+</sup> 3919 3920on(type: 'focusTrackingInfoAvailable', callback: Callback\<FocusTrackingInfo\>): void 3921 3922监听相机对焦跟踪信息,通过注册回调函数获取结果。使用callback方式返回结果。 3923 3924**系统接口**: 此接口为系统接口。 3925 3926**系统能力**: SystemCapability.Multimedia.Camera.Core 3927 3928**参数**: 3929 3930| 参数名 | 类型 | 必填 | 说明 | 3931| -------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ | 3932| type | string | 是 | 监听事件,固定为'focusTrackingInfoAvailable',VideoSessionForSys创建成功可监听。 | 3933| callback | Callback\<[FocusTrackingInfo](#focustrackinginfo15)\> | 是 | 回调函数,用于获取当前对焦跟踪信息。 | 3934 3935**错误码**: 3936 3937以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3938 3939| 错误码ID | 错误信息 | 3940| -------- | ----------------------- | 3941| 202 | Not System Application. | 3942 3943**示例**: 3944 3945```ts 3946function callback(focusTrackingInfo: camera.FocusTrackingInfo): void { 3947 console.info(`Focus tracking mode: ${focusTrackingInfo.trackingMode}`); 3948 console.info(`Focus tracking Region: topLeftX ${focusTrackingInfo.trackingRegion.topLeftX} 3949 topLeftY ${focusTrackingInfo.trackingRegion.topLeftY} 3950 width ${focusTrackingInfo.trackingRegion.width} 3951 height ${focusTrackingInfo.trackingRegion.height}`); 3952} 3953 3954function registerFocusTrakingInfoChanged(session: camera.VideoSessionForSys): void { 3955 session.on('focusTrackingInfoAvailable', callback); 3956} 3957``` 3958 3959### off('focusTrackingInfoAvailable')<sup>15+</sup> 3960 3961off(type: 'focusTrackingInfoAvailable', callback?: Callback\<FocusTrackingInfo\>): void 3962 3963注销监听相机对焦跟踪信息。 3964 3965**系统接口**: 此接口为系统接口。 3966 3967**系统能力**: SystemCapability.Multimedia.Camera.Core 3968 3969**参数**: 3970 3971| 参数名 | 类型 | 必填 | 说明 | 3972| -------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ | 3973| type | string | 是 | 监听事件,固定为'focusTrackingInfoAvailable',videoSessionForSys创建成功可监听。 | 3974| callback | Callback\<[FocusTrackingInfo](#focustrackinginfo15)\> | 否 | 回调函数,可选,有就是匹配on('focusTrackingInfoAvailable') callback(callback对象不可是匿名函数)。 | 3975 3976**错误码**: 3977 3978以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3979 3980| 错误码ID | 错误信息 | 3981| -------- | ----------------------- | 3982| 202 | Not System Application. | 3983 3984**示例**: 3985 3986```ts 3987function unregisterFocusTrakingInfoChanged(session: camera.VideoSessionForSys): void { 3988 session.off('focusTrackingInfoAvailable'); 3989} 3990``` 3991 3992## PortraitPhotoSession<sup>11+</sup> 3993 3994PortraitPhotoSession extends Session, Flash, AutoExposure, Focus, Zoom, Beauty, ColorEffect, ColorManagement, Portrait, Aperture 3995 3996人像拍照模式会话类,继承自[Session](js-apis-camera.md#session11),用于设置人像拍照模式的参数以及保存所需要的所有资源[CameraInput](js-apis-camera.md#camerainput)、[CameraOutput](js-apis-camera.md#cameraoutput)。 3997 3998### on('error')<sup>11+</sup> 3999 4000on(type: 'error', callback: ErrorCallback): void 4001 4002监听人像拍照会话的错误事件,通过注册回调函数获取结果。使用callback异步回调。 4003 4004**系统接口:** 此接口为系统接口。 4005 4006**系统能力:** SystemCapability.Multimedia.Camera.Core 4007 4008**参数:** 4009 4010| 参数名 | 类型 | 必填 | 说明 | 4011| -------- | --------------------------------- | ---- | ------------------------------ | 4012| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。session调用相关接口出现错误时会触发该事件,比如调用[beginConfig](js-apis-camera.md#beginconfig11),[commitConfig](js-apis-camera.md#commitconfig11-1),[addInput](js-apis-camera.md#addinput11)等接口发生错误时返回错误信息。 | 4013| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 4014 4015**示例:** 4016 4017```ts 4018import { BusinessError } from '@kit.BasicServicesKit'; 4019 4020function callback(err: BusinessError): void { 4021 console.error(`Portrait photo session error code: ${err.code}`); 4022} 4023 4024function registerSessionError(portraitPhotoSession: camera.PortraitPhotoSession): void { 4025 portraitPhotoSession.on('error', callback); 4026} 4027``` 4028 4029### off('error')<sup>11+</sup> 4030 4031off(type: 'error', callback?: ErrorCallback): void 4032 4033注销监听人像拍照会话的错误事件,通过注册回调函数获取结果。 4034 4035**系统接口:** 此接口为系统接口。 4036 4037**系统能力:** SystemCapability.Multimedia.Camera.Core 4038 4039**参数:** 4040 4041| 参数名 | 类型 | 必填 | 说明 | 4042| -------- | -------------------------- | ---- | ------------------------------ | 4043| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。 | 4044| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 否 | 回调函数,可选,有就是匹配on('error') callback(callback对象不可是匿名函数)。 | 4045 4046**示例:** 4047 4048```ts 4049function unregisterSessionError(portraitPhotoSession: camera.PortraitPhotoSession): void { 4050 portraitPhotoSession.off('error'); 4051} 4052``` 4053 4054### on('focusStateChange')<sup>11+</sup> 4055 4056on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 4057 4058监听相机对焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 4059 4060**系统接口:** 此接口为系统接口。 4061 4062**系统能力:** SystemCapability.Multimedia.Camera.Core 4063 4064**参数:** 4065 4066| 参数名 | 类型 | 必填 | 说明 | 4067| -------- | ---------------- | ---- | ------------------------ | 4068| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。仅当自动对焦模式时,且相机对焦状态发生改变时可触发该事件。 | 4069| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | 是 | 回调函数,用于获取当前对焦状态。 | 4070 4071**示例:** 4072 4073```ts 4074import { BusinessError } from '@kit.BasicServicesKit'; 4075 4076function callback(err: BusinessError, focusState: camera.FocusState): void { 4077 if (err !== undefined && err.code !== 0) { 4078 console.error(`Callback Error, errorCode: ${err.code}`); 4079 return; 4080 } 4081 console.info(`Focus state: ${focusState}`); 4082} 4083 4084function registerFocusStateChange(portraitPhotoSession: camera.PortraitPhotoSession): void { 4085 portraitPhotoSession.on('focusStateChange', callback); 4086} 4087``` 4088 4089### off('focusStateChange')<sup>11+</sup> 4090 4091off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 4092 4093注销监听相机对焦的状态变化。 4094 4095**系统接口:** 此接口为系统接口。 4096 4097**系统能力:** SystemCapability.Multimedia.Camera.Core 4098 4099**参数:** 4100 4101| 参数名 | 类型 | 必填 | 说明 | 4102| -------- | ----------------------------------------- | ---- | ------------------------ | 4103| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。 | 4104| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | 否 | 回调函数,可选,有就是匹配on('focusStateChange') callback(callback对象不可是匿名函数)。 | 4105 4106**示例:** 4107 4108```ts 4109function unregisterFocusStateChange(portraitPhotoSession: camera.PortraitPhotoSession): void { 4110 portraitPhotoSession.off('focusStateChange'); 4111} 4112``` 4113 4114### on('smoothZoomInfoAvailable')<sup>11+</sup> 4115 4116on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 4117 4118监听相机平滑变焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 4119 4120**系统接口:** 此接口为系统接口。 4121 4122**系统能力:** SystemCapability.Multimedia.Camera.Core 4123 4124**参数:** 4125 4126| 参数名 | 类型 | 必填 | 说明 | 4127| -------- | ----------------------- | ---- | ------------------------ | 4128| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 4129| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | 是 | 回调函数,用于获取当前平滑变焦状态。 | 4130 4131**示例:** 4132 4133```ts 4134import { BusinessError } from '@kit.BasicServicesKit'; 4135 4136function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 4137 if (err !== undefined && err.code !== 0) { 4138 console.error(`Callback Error, errorCode: ${err.code}`); 4139 return; 4140 } 4141 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 4142} 4143 4144function registerSmoothZoomInfo(portraitPhotoSession: camera.PortraitPhotoSession): void { 4145 portraitPhotoSession.on('smoothZoomInfoAvailable', callback); 4146} 4147``` 4148 4149### off('smoothZoomInfoAvailable')<sup>11+</sup> 4150 4151off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 4152 4153注销监听相机平滑变焦的状态变化。 4154 4155**系统接口:** 此接口为系统接口。 4156 4157**系统能力:** SystemCapability.Multimedia.Camera.Core 4158 4159**参数:** 4160 4161| 参数名 | 类型 | 必填 | 说明 | 4162| -------- | ----------------------------------------- | ---- | ------------------------ | 4163| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 4164| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | 否 | 回调函数,可选,有就是匹配on('smoothZoomInfoAvailable') callback(callback对象不可是匿名函数)。 | 4165 4166**示例:** 4167 4168```ts 4169function unregisterSmoothZoomInfo(portraitPhotoSession: camera.PortraitPhotoSession): void { 4170 portraitPhotoSession.off('smoothZoomInfoAvailable'); 4171} 4172``` 4173 4174### on('lcdFlashStatus')<sup>13+</sup> 4175 4176on(type: 'lcdFlashStatus', callback: AsyncCallback\<LcdFlashStatus\>): void 4177 4178监听LCD闪光灯状态变化。使用callback异步回调。 4179 4180**系统接口:** 此接口为系统接口。 4181 4182**系统能力:** SystemCapability.Multimedia.Camera.Core 4183 4184**参数:** 4185 4186| 参数名 | 类型 | 必填 | 说明 | 4187| -------- | ----------------------------------------- | ---- |------------------------------------------| 4188| type | string | 是 | 监听事件,固定为'lcdFlashStatus',session创建成功可监听。 | 4189| callback | AsyncCallback\<[LcdFlashStatus](#lcdflashstatus12)\> | 是 | 回调函数,用于获取当前lcd flash状态。 | 4190 4191**错误码:** 4192 4193以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 4194 4195| 错误码ID | 错误信息 | 4196|-------|---------------------------| 4197| 202 | Not System Application. | 4198 4199**示例:** 4200 4201```ts 4202import { BusinessError } from '@kit.BasicServicesKit'; 4203 4204function callback(err: BusinessError, lcdFlashStatus: camera.LcdFlashStatus): void { 4205 if (err !== undefined && err.code !== 0) { 4206 console.error(`Callback Error, errorCode: ${err.code}`); 4207 return; 4208 } 4209 console.info(`isLcdFlashNeeded: ${lcdFlashStatus.isLcdFlashNeeded}`); 4210 console.info(`lcdCompensation: ${lcdFlashStatus.lcdCompensation}`); 4211} 4212 4213function registerLcdFlashStatus(portraitPhotoSession: camera.PortraitPhotoSession): void { 4214 portraitPhotoSession.on('lcdFlashStatus', callback); 4215} 4216``` 4217 4218### off('lcdFlashStatus')<sup>13+</sup> 4219 4220off(type: 'lcdFlashStatus', callback?: AsyncCallback\<LcdFlashStatus\>): void 4221 4222注销监听LCD闪光灯状态变化。 4223 4224**系统接口:** 此接口为系统接口。 4225 4226**系统能力:** SystemCapability.Multimedia.Camera.Core 4227 4228**参数:** 4229 4230| 参数名 | 类型 | 必填 | 说明 | 4231| -------- | ------------------------ | ---- |------------------------------------------------------------------| 4232| type | string | 是 | 监听事件,固定为'lcdFlashStatus',session创建成功可取消监听。 | 4233| callback | AsyncCallback\<[LcdFlashStatus](#lcdflashstatus12)\> | 否 | 回调函数,可选,有就是匹配on('lcdFlashStatus') callback(callback对象不可是匿名函数)。 | 4234 4235**错误码:** 4236 4237以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 4238 4239| 错误码ID | 错误信息 | 4240|-------|---------------------------| 4241| 202 | Not System Application. | 4242 4243**示例:** 4244 4245```ts 4246function unregisterLcdFlashStatus(portraitPhotoSession: camera.PortraitPhotoSession): void { 4247 portraitPhotoSession.off('lcdFlashStatus'); 4248} 4249``` 4250 4251## NightPhotoSession<sup>11+</sup> 4252 4253NightPhotoSession extends Session, Flash, AutoExposure, Focus, Zoom, ColorEffect, ColorManagement, ManualExposure 4254 4255夜景拍照模式会话类,继承自[Session](js-apis-camera.md#session11),用于设置夜景拍照模式的参数以及保存所需要的所有资源[CameraInput](js-apis-camera.md#camerainput)、[CameraOutput](js-apis-camera.md#cameraoutput)。 4256 4257### on('error')<sup>11+</sup> 4258 4259on(type: 'error', callback: ErrorCallback): void 4260 4261监听夜景拍照会话的错误事件,通过注册回调函数获取结果。使用callback异步回调。 4262 4263**系统接口:** 此接口为系统接口。 4264 4265**系统能力:** SystemCapability.Multimedia.Camera.Core 4266 4267**参数:** 4268 4269| 参数名 | 类型 | 必填 | 说明 | 4270| -------- | ----------------------------------------------------------- | ---- | ------------------------------ | 4271| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。session调用相关接口出现错误时会触发该事件,比如调用[beginConfig](js-apis-camera.md#beginconfig11),[commitConfig](js-apis-camera.md#commitconfig11-1),[addInput](js-apis-camera.md#addinput11)等接口发生错误时返回错误信息。 | 4272| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 4273 4274**示例:** 4275 4276```ts 4277import { BusinessError } from '@kit.BasicServicesKit'; 4278 4279function callback(err: BusinessError): void { 4280 console.error(`Night photo session error code: ${err.code}`); 4281} 4282 4283function registerSessionError(nightPhotoSession: camera.NightPhotoSession): void { 4284 nightPhotoSession.on('error', callback); 4285} 4286``` 4287 4288### off('error')<sup>11+</sup> 4289 4290off(type: 'error', callback?: ErrorCallback): void 4291 4292注销监听夜景拍照会话的错误事件,通过注册回调函数获取结果。 4293 4294**系统接口:** 此接口为系统接口。 4295 4296**系统能力:** SystemCapability.Multimedia.Camera.Core 4297 4298**参数:** 4299 4300| 参数名 | 类型 | 必填 | 说明 | 4301| -------- | ------------------------ | ---- | ------------------------------ | 4302| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。 | 4303| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 否 | 回调函数,可选,有就是匹配on('error') callback(callback对象不可是匿名函数)。 | 4304 4305**示例:** 4306 4307```ts 4308function unregisterSessionError(nightPhotoSession: camera.NightPhotoSession): void { 4309 nightPhotoSession.off('error'); 4310} 4311``` 4312 4313### on('focusStateChange')<sup>11+</sup> 4314 4315on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 4316 4317监听相机对焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 4318 4319**系统接口:** 此接口为系统接口。 4320 4321**系统能力:** SystemCapability.Multimedia.Camera.Core 4322 4323**参数:** 4324 4325| 参数名 | 类型 | 必填 | 说明 | 4326| -------- | ---------------- | ---- | ------------------------ | 4327| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。仅当自动对焦模式时,且相机对焦状态发生改变时可触发该事件。 | 4328| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | 是 | 回调函数,用于获取当前对焦状态。 | 4329 4330**示例:** 4331 4332```ts 4333import { BusinessError } from '@kit.BasicServicesKit'; 4334 4335function callback(err: BusinessError, focusState: camera.FocusState): void { 4336 if (err !== undefined && err.code !== 0) { 4337 console.error(`Callback Error, errorCode: ${err.code}`); 4338 return; 4339 } 4340 console.info(`Focus state: ${focusState}`); 4341} 4342 4343function registerFocusStateChange(nightPhotoSession: camera.NightPhotoSession): void { 4344 nightPhotoSession.on('focusStateChange', callback); 4345} 4346``` 4347 4348### off('focusStateChange')<sup>11+</sup> 4349 4350off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 4351 4352注销监听相机对焦的状态变化。 4353 4354**系统接口:** 此接口为系统接口。 4355 4356**系统能力:** SystemCapability.Multimedia.Camera.Core 4357 4358**参数:** 4359 4360| 参数名 | 类型 | 必填 | 说明 | 4361| -------- | ----------------------------------------- | ---- | ------------------------ | 4362| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。 | 4363| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | 否 | 回调函数,可选,有就是匹配on('focusStateChange') callback(callback对象不可是匿名函数)。 | 4364 4365**示例:** 4366 4367```ts 4368function unregisterFocusStateChange(nightPhotoSession: camera.NightPhotoSession): void { 4369 nightPhotoSession.off('focusStateChange'); 4370} 4371``` 4372 4373### on('smoothZoomInfoAvailable')<sup>11+</sup> 4374 4375on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 4376 4377监听相机平滑变焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 4378 4379**系统接口:** 此接口为系统接口。 4380 4381**系统能力:** SystemCapability.Multimedia.Camera.Core 4382 4383**参数:** 4384 4385| 参数名 | 类型 | 必填 | 说明 | 4386| -------- | ----------------------- | ---- | ------------------------ | 4387| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 4388| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | 是 | 回调函数,用于获取当前平滑变焦状态。 | 4389 4390**示例:** 4391 4392```ts 4393import { BusinessError } from '@kit.BasicServicesKit'; 4394 4395function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 4396 if (err !== undefined && err.code !== 0) { 4397 console.error(`Callback Error, errorCode: ${err.code}`); 4398 return; 4399 } 4400 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 4401} 4402 4403function registerSmoothZoomInfo(nightPhotoSession: camera.NightPhotoSession): void { 4404 nightPhotoSession.on('smoothZoomInfoAvailable', callback); 4405} 4406``` 4407 4408### off('smoothZoomInfoAvailable')<sup>11+</sup> 4409 4410off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 4411 4412注销监听相机平滑变焦的状态变化。 4413 4414**系统接口:** 此接口为系统接口。 4415 4416**系统能力:** SystemCapability.Multimedia.Camera.Core 4417 4418**参数:** 4419 4420| 参数名 | 类型 | 必填 | 说明 | 4421| -------- | ----------------------------------------- | ---- | ------------------------ | 4422| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 4423| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | 否 | 回调函数,可选,有就是匹配on('smoothZoomInfoAvailable') callback(callback对象不可是匿名函数)。 | 4424 4425**示例:** 4426 4427```ts 4428function unregisterSmoothZoomInfo(nightPhotoSession: camera.NightPhotoSession): void { 4429 nightPhotoSession.off('smoothZoomInfoAvailable'); 4430} 4431``` 4432 4433### on('lcdFlashStatus')<sup>12+</sup> 4434 4435on(type: 'lcdFlashStatus', callback: AsyncCallback\<[LcdFlashStatus](#lcdflashstatus12)\>): void 4436 4437监听lcd flash状态,通过注册回调函数获取结果。使用callback异步回调。 4438 4439**系统接口:** 此接口为系统接口。 4440 4441**系统能力:** SystemCapability.Multimedia.Camera.Core 4442 4443**参数:** 4444 4445| 参数名 | 类型 | 必填 | 说明 | 4446| -------- | ----------------------- | ---- | ------------------------ | 4447| type | string | 是 | 监听事件,固定为'lcdFlashStatus',session创建成功可监听。| 4448| callback | AsyncCallback\<[LcdFlashStatus](#lcdflashstatus12)\> | 是 | 回调函数,用于获取当前lcd flash状态。 | 4449 4450**错误码:** 4451 4452以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 4453 4454| 错误码ID | 错误信息 | 4455|-------|---------------------------| 4456| 202 | Not System Application. | 4457 4458**示例:** 4459 4460```ts 4461import { BusinessError } from '@kit.BasicServicesKit'; 4462 4463function callback(err: BusinessError, lcdFlashStatus: camera.LcdFlashStatus): void { 4464 if (err !== undefined && err.code !== 0) { 4465 console.error(`Callback Error, errorCode: ${err.code}`); 4466 return; 4467 } 4468 console.info(`lcdFlashStatus: ${lcdFlashStatus}`); 4469} 4470 4471function registerLcdFlashStatus(nightPhotoSession: camera.NightPhotoSession): void { 4472 nightPhotoSession.on('lcdFlashStatus', callback); 4473} 4474``` 4475 4476### off('lcdFlashStatus')<sup>12+</sup> 4477 4478off(type: 'lcdFlashStatus', callback?: AsyncCallback\<[LcdFlashStatus](#lcdflashstatus12)\>): void 4479 4480注销lcd flash状态,通过注册回调函数获取结果。 4481 4482**系统接口:** 此接口为系统接口。 4483 4484**系统能力:** SystemCapability.Multimedia.Camera.Core 4485 4486**参数:** 4487 4488| 参数名 | 类型 | 必填 | 说明 | 4489| -------- | ----------------------------------------- | ---- | ------------------------ | 4490| type | string | 是 | 监听事件,固定为'lcdFlashStatus',session创建成功可监听。| 4491| callback | AsyncCallback\<[LcdFlashStatus](#lcdflashstatus12)\> | 否 | 回调函数,可选,有就是匹配on('lcdFlashStatus') callback(callback对象不可是匿名函数)。 | 4492 4493**错误码:** 4494 4495以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 4496 4497| 错误码ID | 错误信息 | 4498|-------|---------------------------| 4499| 202 | Not System Application. | 4500 4501**示例:** 4502 4503```ts 4504function unregisterLcdFlashStatus(nightPhotoSession: camera.NightPhotoSession): void { 4505 nightPhotoSession.off('lcdFlashStatus'); 4506} 4507``` 4508 4509## HighResolutionPhotoSession<sup>12+</sup> 4510 4511HighResolutionPhotoSession extends Session, AutoExposure, Focus 4512 4513高像素拍照模式会话类,继承自[Session](js-apis-camera.md#session11),用于设置高像素拍照模式的参数以及保存所需要的所有资源[CameraInput](js-apis-camera.md#camerainput)、[CameraOutput](js-apis-camera.md#cameraoutput)。 4514 4515### on('error')<sup>12+</sup> 4516 4517on(type: 'error', callback: ErrorCallback): void 4518 4519监听高像素拍照会话的错误事件,通过注册回调函数获取结果。使用callback异步回调。 4520 4521**系统接口:** 此接口为系统接口。 4522 4523**系统能力:** SystemCapability.Multimedia.Camera.Core 4524 4525**参数:** 4526 4527| 参数名 | 类型 | 必填 | 说明 | 4528| -------- | --------------------------------- | ---- | ------------------------------ | 4529| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。session调用相关接口出现错误时会触发该事件,比如调用[beginConfig](js-apis-camera.md#beginconfig11),[commitConfig](js-apis-camera.md#commitconfig11-1),[addInput](js-apis-camera.md#addinput11)等接口发生错误时返回错误信息。 | 4530| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 4531 4532**错误码:** 4533 4534以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 4535 4536| 错误码ID | 错误信息 | 4537| --------------- | --------------- | 4538| 202 | Not System Application. | 4539 4540**示例:** 4541 4542```ts 4543import { BusinessError } from '@kit.BasicServicesKit'; 4544 4545function callback(err: BusinessError): void { 4546 console.error(`High resolution photo session error code: ${err.code}`); 4547} 4548 4549function registerSessionError(highResolutionPhotoSession: camera.HighResolutionPhotoSession): void { 4550 highResolutionPhotoSession.on('error', callback); 4551} 4552``` 4553### off('error')<sup>12+</sup> 4554 4555off(type: 'error', callback?: ErrorCallback): void 4556 4557注销监听高像素拍照会话的错误事件,通过注册回调函数获取结果。 4558 4559**系统接口:** 此接口为系统接口。 4560 4561**系统能力:** SystemCapability.Multimedia.Camera.Core 4562 4563**参数:** 4564 4565| 参数名 | 类型 | 必填 | 说明 | 4566| -------- | ------------------------ | ---- | ------------------------------ | 4567| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。 | 4568| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 否 | 回调函数,可选,有就是匹配on('error') callback(callback对象不可是匿名函数)。 | 4569 4570**错误码:** 4571 4572以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 4573 4574| 错误码ID | 错误信息 | 4575| --------------- | --------------- | 4576| 202 | Not System Application. | 4577 4578**示例:** 4579 4580```ts 4581function unregisterSessionError(highResolutionPhotoSession: camera.HighResolutionPhotoSession): void { 4582 highResolutionPhotoSession.off('error'); 4583} 4584``` 4585 4586### on('focusStateChange')<sup>12+</sup> 4587 4588on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 4589 4590监听相机对焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 4591 4592**系统接口:** 此接口为系统接口。 4593 4594**系统能力:** SystemCapability.Multimedia.Camera.Core 4595 4596**参数:** 4597 4598| 参数名 | 类型 | 必填 | 说明 | 4599| -------- | ---------------- | ---- | ------------------------ | 4600| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。仅当自动对焦模式时,且相机对焦状态发生改变时可触发该事件。 | 4601| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | 是 | 回调函数,用于获取当前对焦状态。 | 4602 4603**错误码:** 4604 4605以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 4606 4607| 错误码ID | 错误信息 | 4608| --------------- | --------------- | 4609| 202 | Not System Application. | 4610 4611**示例:** 4612 4613```ts 4614import { BusinessError } from '@kit.BasicServicesKit'; 4615 4616function callback(err: BusinessError, focusState: camera.FocusState): void { 4617 if (err !== undefined && err.code !== 0) { 4618 console.error(`Callback Error, errorCode: ${err.code}`); 4619 return; 4620 } 4621 console.info(`Focus state: ${focusState}`); 4622} 4623 4624function registerFocusStateChange(highResolutionPhotoSession: camera.HighResolutionPhotoSession): void { 4625 highResolutionPhotoSession.on('focusStateChange', callback); 4626} 4627``` 4628 4629### off('focusStateChange')<sup>12+</sup> 4630 4631off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 4632 4633注销监听相机对焦的状态变化。 4634 4635**系统接口:** 此接口为系统接口。 4636 4637**系统能力:** SystemCapability.Multimedia.Camera.Core 4638 4639**错误码:** 4640 4641以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 4642 4643| 错误码ID | 错误信息 | 4644| --------------- | --------------- | 4645| 202 | Not System Application. | 4646 4647**参数:** 4648 4649| 参数名 | 类型 | 必填 | 说明 | 4650| -------- | ----------------------------------------- | ---- | ------------------------ | 4651| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。 | 4652| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | 否 | 回调函数,可选,有就是匹配on('focusStateChange') callback(callback对象不可是匿名函数)。 | 4653 4654**示例:** 4655 4656```ts 4657function unregisterFocusStateChange(highResolutionPhotoSession: camera.HighResolutionPhotoSession): void { 4658 highResolutionPhotoSession.off('focusStateChange'); 4659} 4660``` 4661 4662## SketchStatusData<sup>11+</sup> 4663 4664画中画状态返回数据。 4665 4666**系统接口:** 此接口为系统接口。 4667 4668**系统能力:** SystemCapability.Multimedia.Camera.Core 4669 4670| 名称 | 类型 | 只读 | 必填 | 说明 | 4671| ------------- | -------- | ---- | ---- | ---------- | 4672| status | number | 否 | 是 | 画中画当前的状态。0:已停止,1:已启动,2:停止中,3:启动中。| 4673| sketchRatio | number | 否 | 是 | 画中画画面的Zoom倍率。| 4674 4675## SlowMotionVideoSession<sup>12+</sup> 4676 4677SlowMotionVideoSession extends Session, Flash, AutoExposure, Focus, Zoom, ColorEffect 4678 4679慢动作录像模式会话类,继承自[Session](js-apis-camera.md#session11),用于设置慢动作录像模式的参数以及保存所需要的所有资源[CameraInput](js-apis-camera.md#camerainput)、[CameraOutput](js-apis-camera.md#cameraoutput)。 4680 4681> **说明:** 4682> 慢动作模式下只能添加预览流和录像流。 4683### on('error')<sup>12+</sup> 4684 4685on(type: 'error', callback: ErrorCallback): void 4686 4687监听慢动作录像模式会话的错误事件,通过注册回调函数获取结果。使用callback异步回调。 4688 4689**系统接口:** 此接口为系统接口。 4690 4691**系统能力:** SystemCapability.Multimedia.Camera.Core 4692 4693**参数:** 4694 4695| 参数名 | 类型 | 必填 | 说明 | 4696| -------- | --------------------------------- | ---- | ------------------------------ | 4697| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。session调用相关接口出现错误时会触发该事件,比如调用[beginConfig](js-apis-camera.md#beginconfig11),[commitConfig](js-apis-camera.md#commitconfig11-1),[addInput](js-apis-camera.md#addinput11)等接口发生错误时返回错误信息。 | 4698| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 4699 4700**错误码:** 4701 4702以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 4703 4704| 错误码ID | 错误信息 | 4705|---------| --------------- | 4706| 202 | Not System Application. | 4707 4708**示例:** 4709 4710```ts 4711import { BusinessError } from '@kit.BasicServicesKit'; 4712 4713function callback(err: BusinessError): void { 4714 console.error(`Portrait photo session error code: ${err.code}`); 4715} 4716 4717function registerSessionError(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 4718 slowMotionVideoSession.on('error', callback); 4719} 4720``` 4721 4722### off('error')<sup>12+</sup> 4723 4724off(type: 'error', callback?: ErrorCallback): void 4725 4726注销慢动作录像模式会话的错误事件,通过注册回调函数获取结果。 4727 4728**系统接口:** 此接口为系统接口。 4729 4730**系统能力:** SystemCapability.Multimedia.Camera.Core 4731 4732**参数:** 4733 4734| 参数名 | 类型 | 必填 | 说明 | 4735| -------- | -------------------------- | ---- | ------------------------------ | 4736| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。 | 4737| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 否 | 回调函数,可选,有就是匹配on('error') callback(callback对象不可是匿名函数)。 | 4738 4739**错误码:** 4740 4741以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 4742 4743| 错误码ID | 错误信息 | 4744|---------| --------------- | 4745| 202 | Not System Application. | 4746 4747**示例:** 4748 4749```ts 4750function unregisterSessionError(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 4751 slowMotionVideoSession.off('error'); 4752} 4753``` 4754 4755### on('focusStateChange')<sup>12+</sup> 4756 4757on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 4758 4759监听相机对焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 4760 4761**系统接口:** 此接口为系统接口。 4762 4763**系统能力:** SystemCapability.Multimedia.Camera.Core 4764 4765**参数:** 4766 4767| 参数名 | 类型 | 必填 | 说明 | 4768| -------- | ---------------- | ---- | ------------------------ | 4769| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。仅当自动对焦模式时,且相机对焦状态发生改变时可触发该事件。 | 4770| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | 是 | 回调函数,用于获取当前对焦状态。 | 4771 4772**错误码:** 4773 4774以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 4775 4776| 错误码ID | 错误信息 | 4777|---------| --------------- | 4778| 202 | Not System Application. | 4779 4780**示例:** 4781 4782```ts 4783import { BusinessError } from '@kit.BasicServicesKit'; 4784 4785function callback(err: BusinessError, focusState: camera.FocusState): void { 4786 if (err !== undefined && err.code !== 0) { 4787 console.error(`Callback Error, errorCode: ${err.code}`); 4788 return; 4789 } 4790 console.info(`Focus state: ${focusState}`); 4791} 4792 4793function registerFocusStateChange(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 4794 slowMotionVideoSession.on('focusStateChange', callback); 4795} 4796``` 4797 4798### off('focusStateChange')<sup>12+</sup> 4799 4800off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 4801 4802注销监听相机对焦的状态变化。 4803 4804**系统接口:** 此接口为系统接口。 4805 4806**系统能力:** SystemCapability.Multimedia.Camera.Core 4807 4808**参数:** 4809 4810| 参数名 | 类型 | 必填 | 说明 | 4811| -------- | ----------------------------------------- | ---- | ------------------------ | 4812| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。 | 4813| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | 否 | 回调函数,可选,有就是匹配on('focusStateChange') callback(callback对象不可是匿名函数)。 | 4814 4815**错误码:** 4816 4817以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 4818 4819| 错误码ID | 错误信息 | 4820|---------| --------------- | 4821| 202 | Not System Application. | 4822 4823**示例:** 4824 4825```ts 4826function unregisterFocusStateChange(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 4827 slowMotionVideoSession.off('focusStateChange'); 4828} 4829``` 4830 4831### on('smoothZoomInfoAvailable')<sup>12+</sup> 4832 4833on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 4834 4835监听相机平滑变焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 4836 4837**系统接口:** 此接口为系统接口。 4838 4839**系统能力:** SystemCapability.Multimedia.Camera.Core 4840 4841**参数:** 4842 4843| 参数名 | 类型 | 必填 | 说明 | 4844| -------- | ----------------------- | ---- | ------------------------ | 4845| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 4846| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | 是 | 回调函数,用于获取当前平滑变焦状态。 | 4847 4848**错误码:** 4849 4850以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 4851 4852| 错误码ID | 错误信息 | 4853|---------| --------------- | 4854| 202 | Not System Application. | 4855 4856**示例:** 4857 4858```ts 4859import { BusinessError } from '@kit.BasicServicesKit'; 4860 4861function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 4862 if (err !== undefined && err.code !== 0) { 4863 console.error(`Callback Error, errorCode: ${err.code}`); 4864 return; 4865 } 4866 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 4867} 4868 4869function registerSmoothZoomInfo(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 4870 slowMotionVideoSession.on('smoothZoomInfoAvailable', callback); 4871} 4872``` 4873 4874### off('smoothZoomInfoAvailable')<sup>12+</sup> 4875 4876off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 4877 4878注销监听相机平滑变焦的状态变化。 4879 4880**系统接口:** 此接口为系统接口。 4881 4882**系统能力:** SystemCapability.Multimedia.Camera.Core 4883 4884**参数:** 4885 4886| 参数名 | 类型 | 必填 | 说明 | 4887| -------- | ----------------------------------------- | ---- | ------------------------ | 4888| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 4889| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | 否 | 回调函数,可选,有就是匹配on('smoothZoomInfoAvailable') callback(callback对象不可是匿名函数)。 | 4890 4891**错误码:** 4892 4893以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 4894 4895| 错误码ID | 错误信息 | 4896|---------| --------------- | 4897| 202 | Not System Application. | 4898 4899**示例:** 4900 4901```ts 4902function unregisterSmoothZoomInfo(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 4903 slowMotionVideoSession.off('smoothZoomInfoAvailable'); 4904} 4905``` 4906 4907### on('slowMotionStatus')<sup>12+</sup> 4908 4909on(type: 'slowMotionStatus', callback: AsyncCallback\<SlowMotionStatus\>): void 4910 4911监听慢动作状态变化,通过注册回调函数获取结果。使用callback异步回调。 4912 4913**系统接口:** 此接口为系统接口。 4914 4915**系统能力:** SystemCapability.Multimedia.Camera.Core 4916 4917**参数:** 4918 4919| 参数名 | 类型 | 必填 | 说明 | 4920| -------- |---------------------------------------------------------------------------| ---- |--------------------------------------------| 4921| type | string | 是 | 监听事件,固定为'slowMotionStatus',session创建成功可监听。 | 4922| callback | AsyncCallback\<[SlowMotionStatus](#slowmotionstatus12)\> | 是 | 回调函数,用于获取当前慢动作状态。当慢动作状态发生变动时,此回调函数也会被执行。 | 4923 4924**错误码:** 4925 4926以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 4927 4928| 错误码ID | 错误信息 | 4929|---------| --------------- | 4930| 202 | Not System Application. | 4931 4932**示例:** 4933 4934```ts 4935import { BusinessError } from '@kit.BasicServicesKit'; 4936 4937function callback(err: BusinessError, slowMotionStatus: camera.SlowMotionStatus): void { 4938 if (err !== undefined && err.code !== 0) { 4939 console.error(`Callback Error, errorCode: ${err.code}`); 4940 return; 4941 } 4942 console.info(`The slow motion status: ${slowMotionStatus}`); 4943} 4944 4945function registerSlowMotionStatus(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 4946 slowMotionVideoSession.on('slowMotionStatus', callback); 4947} 4948``` 4949 4950### off('slowMotionStatus')<sup>12+</sup> 4951 4952off(type: 'slowMotionStatus', callback?: AsyncCallback\<SlowMotionStatus\>): void 4953 4954注销慢动作状态变化。 4955 4956**系统接口:** 此接口为系统接口。 4957 4958**系统能力:** SystemCapability.Multimedia.Camera.Core 4959 4960**参数:** 4961 4962| 参数名 | 类型 | 必填 | 说明 | 4963| -------- | ----------------------------------------- | ---- | ------------------------ | 4964| type | string | 是 | 监听事件,固定为'slowMotionStatus',session创建成功可监听。| 4965| callback | AsyncCallback\<[SlowMotionStatus](#slowmotionstatus12)\> | 否 | 回调函数,可选,有就是匹配on('slowMotionStatus') callback(callback对象不可是匿名函数)。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 4966 4967**错误码:** 4968 4969以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 4970 4971| 错误码ID | 错误信息 | 4972|---------| --------------- | 4973| 202 | Not System Application. | 4974 4975**示例:** 4976 4977```ts 4978function unregisterSlowMotionStatus(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 4979 slowMotionVideoSession.off('slowMotionStatus'); 4980} 4981``` 4982### isSlowMotionDetectionSupported<sup>12+</sup> 4983 4984isSlowMotionDetectionSupported(): boolean 4985 4986查询当前设备是否支持慢动作检测功能。 4987 4988> **说明:** 4989> 该接口需要在[commitConfig](js-apis-camera.md#commitconfig11-1)之后调用。 4990 4991**系统接口:** 此接口为系统接口。 4992 4993**系统能力:** SystemCapability.Multimedia.Camera.Core 4994 4995**返回值:** 4996 4997| 类型 | 说明 | 4998| ---------- |----------------------------------------------------------------------------------------| 4999| boolean | 返回true表示支持慢动作检测功能,false表示不支持。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 5000 5001**错误码:** 5002 5003以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5004 5005| 错误码ID | 错误信息 | 5006|---------| --------------- | 5007| 202 | Not System Application. | 5008| 7400103 | Session not config. | 5009 5010**示例:** 5011 5012```ts 5013import { BusinessError } from '@kit.BasicServicesKit'; 5014 5015function isSlowMotionDetectionSupported(slowMotionVideoSession: camera.SlowMotionVideoSession): boolean { 5016 let isSupported: boolean = false; 5017 try { 5018 isSupported = slowMotionVideoSession.isSlowMotionDetectionSupported(); 5019 } catch (error) { 5020 // 失败返回错误码error.code并处理。 5021 let err = error as BusinessError; 5022 console.error(`The isFocusModeSupported call failed. error code: ${err.code}`); 5023 } 5024 return isSupported; 5025} 5026``` 5027 5028### setSlowMotionDetectionArea<sup>12+</sup> 5029 5030setSlowMotionDetectionArea(area: Rect): void 5031 5032设置一个进行慢动作检测的区域。 5033 5034> **说明:** 5035> 在调用该方法之前,先调用[isSlowMotionDetectionSupported](#isslowmotiondetectionsupported12)确认设备是否支持慢动作检测功能, 才能保证其他相关方法的正常运行。 5036该接口需要在[commitConfig](js-apis-camera.md#commitconfig11-1)之后调用。 5037 5038**系统接口:** 此接口为系统接口。 5039 5040**系统能力:** SystemCapability.Multimedia.Camera.Core 5041 5042**参数:** 5043 5044| 参数名 | 类型 | 必填 | 说明 | 5045| -------- | ---------------------------------------------- | ---- | --------------------------- | 5046| area | [Rect](js-apis-camera.md#rect) | 是 | 矩形定义。 | 5047 5048**错误码:** 5049 5050以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5051 5052| 错误码ID | 错误信息 | 5053|---------| --------------- | 5054| 202 | Not System Application. | 5055| 7400101 | Parameter missing or parameter type incorrect. | 5056| 7400103 | Session not config. | 5057 5058**示例:** 5059 5060```ts 5061import { BusinessError } from '@kit.BasicServicesKit'; 5062 5063function setSlowMotionDetectionArea(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 5064 try { 5065 slowMotionVideoSession.setSlowMotionDetectionArea({topLeftX: 0.1, topLeftY: 0.1, width: 0.8, height: 0.8}); 5066 } catch (error) { 5067 // 失败返回错误码error.code并处理。 5068 let err = error as BusinessError; 5069 console.error(`The setSlowMotionDetectionArea call failed. error code: ${err.code}`); 5070 } 5071} 5072``` 5073 5074## PanoramaPhotoSession<sup>12+</sup> 5075 5076PanoramaPhotoSession extends Session, Focus, AutoExposure, WhiteBalance, ColorEffect 5077 5078全景拍照模式会话类,继承自[Session](js-apis-camera.md#session11),用于设置全景拍照模式的参数以及保存所需要的所有资源[CameraInput](js-apis-camera.md#camerainput)、[CameraOutput](js-apis-camera.md#cameraoutput)。 5079 5080### on('error')<sup>12+</sup> 5081 5082on(type: 'error', callback: ErrorCallback): void 5083 5084监听全景拍照会话的错误事件,通过注册回调函数获取结果。使用callback异步回调。 5085 5086**系统接口:** 此接口为系统接口。 5087 5088**系统能力:** SystemCapability.Multimedia.Camera.Core 5089 5090**参数:** 5091 5092| 参数名 | 类型 | 必填 | 说明 | 5093| -------- | ----------------------------------------------------------- | ---- | ------------------------------ | 5094| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。session调用相关接口出现错误时会触发该事件,比如调用[beginConfig](js-apis-camera.md#beginconfig11),[commitConfig](js-apis-camera.md#commitconfig11-1),[addInput](js-apis-camera.md#addinput11)等接口发生错误时返回错误信息。 | 5095| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 5096 5097**示例:** 5098 5099```ts 5100import { BusinessError } from '@kit.BasicServicesKit'; 5101 5102function callback(err: BusinessError): void { 5103 console.error(`Panorama photo session error code: ${err.code}`); 5104} 5105 5106function registerSessionError(panoramaPhotoSession: camera.PanoramaPhotoSession): void { 5107 panoramaPhotoSession.on('error', callback); 5108} 5109``` 5110 5111### off('error')<sup>12+</sup> 5112 5113off(type: 'error', callback?: ErrorCallback): void 5114 5115注销监听全景拍照会话的错误事件,通过注册回调函数获取结果。 5116 5117**系统接口:** 此接口为系统接口。 5118 5119**系统能力:** SystemCapability.Multimedia.Camera.Core 5120 5121**参数:** 5122 5123| 参数名 | 类型 | 必填 | 说明 | 5124| -------- | ------------------------ | ---- | ------------------------------ | 5125| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。 | 5126| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 否 | 回调函数,可选,有就是匹配on('error') callback(callback对象不可是匿名函数)。 | 5127 5128**示例:** 5129 5130```ts 5131function unregisterSessionError(panoramaPhotoSession: camera.PanoramaPhotoSession): void { 5132 panoramaPhotoSession.off('error'); 5133} 5134``` 5135 5136### on('focusStateChange')<sup>12+</sup> 5137 5138on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 5139 5140监听相机对焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 5141 5142**系统接口:** 此接口为系统接口。 5143 5144**系统能力:** SystemCapability.Multimedia.Camera.Core 5145 5146**参数:** 5147 5148| 参数名 | 类型 | 必填 | 说明 | 5149| -------- | ---------------- | ---- | ------------------------ | 5150| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。仅当自动对焦模式时,且相机对焦状态发生改变时可触发该事件。 | 5151| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | 是 | 回调函数,用于获取当前对焦状态。 | 5152 5153**示例:** 5154 5155```ts 5156import { BusinessError } from '@kit.BasicServicesKit'; 5157 5158function callback(err: BusinessError, focusState: camera.FocusState): void { 5159 if (err !== undefined && err.code !== 0) { 5160 console.error(`Callback Error, errorCode: ${err.code}`); 5161 return; 5162 } 5163 console.info(`Focus state: ${focusState}`); 5164} 5165 5166function registerFocusStateChange(panoramaPhotoSession: camera.PanoramaPhotoSession): void { 5167 panoramaPhotoSession.on('focusStateChange', callback); 5168} 5169``` 5170 5171### off('focusStateChange')<sup>12+</sup> 5172 5173off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 5174 5175注销监听相机对焦的状态变化。 5176 5177**系统接口:** 此接口为系统接口。 5178 5179**系统能力:** SystemCapability.Multimedia.Camera.Core 5180 5181**参数:** 5182 5183| 参数名 | 类型 | 必填 | 说明 | 5184| -------- | ----------------------------------------- | ---- | ------------------------ | 5185| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。 | 5186| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | 否 | 回调函数,可选,有就是匹配on('focusStateChange') callback(callback对象不可是匿名函数)。 | 5187 5188**示例:** 5189 5190```ts 5191function unregisterFocusStateChange(panoramaPhotoSession: camera.PanoramaPhotoSession): void { 5192 panoramaPhotoSession.off('focusStateChange'); 5193} 5194``` 5195 5196## IsoInfo<sup>12+</sup> 5197 5198ISO参数信息。 5199 5200**系统接口:** 此接口为系统接口。 5201 5202**系统能力:** SystemCapability.Multimedia.Camera.Core 5203 5204| 名称 | 类型 | 只读 | 可选 | 说明 | 5205| ---- | ------- | ---- |--| -------------- | 5206| iso | number | 是 | 是 | ISO值。 | 5207 5208--- 5209 5210## ExposureInfo<sup>12+</sup> 5211 5212曝光参数信息。 5213 5214**系统接口:** 此接口为系统接口。 5215 5216**系统能力:** SystemCapability.Multimedia.Camera.Core 5217 5218| 名称 | 类型 | 只读 | 可选 | 说明 | 5219| ----------------- | ------- | ---- |-----| ------------------ | 5220| exposureTime | number | 是 | 是 | 曝光时间值,单位为毫秒。 | 5221 5222--- 5223 5224## ApertureInfo<sup>12+</sup> 5225 5226光圈参数信息。 5227 5228**系统接口:** 此接口为系统接口。 5229 5230**系统能力:** SystemCapability.Multimedia.Camera.Core 5231 5232| 名称 | 类型 | 只读 | 可选 | 说明 | 5233| --------- | ------- | ---- |-----| ---------- | 5234| aperture | number | 是 | 是 | 光圈值。 | 5235 5236--- 5237 5238## LuminationInfo<sup>12+</sup> 5239 5240光照参数信息。 5241 5242**系统接口:** 此接口为系统接口。 5243 5244**系统能力:** SystemCapability.Multimedia.Camera.Core 5245 5246| 名称 | 类型 | 只读 | 可选 | 说明 | 5247| ----------- | ------- | ---- |-----| ---------- | 5248| lumination | number | 是 | 是 | 范围[0,1],光照值归一化数值| 5249 5250## CameraFormat 5251 5252枚举,输出格式。 5253 5254**系统能力:** SystemCapability.Multimedia.Camera.Core 5255 5256| 名称 | 值 | 说明 | 5257| ----------------------- | --------- | ------------ | 5258| CAMERA_FORMAT_DNG<sup>12+</sup> | 4 | DNG格式的RAW图片。**系统接口:** 此接口为系统接口。 | 5259 5260## ExposureMeteringMode<sup>12+</sup> 5261 5262枚举,测光模式。 5263 5264**系统接口:** 此接口为系统接口。 5265 5266**系统能力:** SystemCapability.Multimedia.Camera.Core 5267 5268| 名称 | 值 | 说明 | 5269| ----------------------------- | ---- | ----------- | 5270| MATRIX | 0 | 对画面广泛区域进行测光。 | 5271| CENTER | 1 | 对整个画面进行测光,但最大比重分配给中央区域。 | 5272| SPOT | 2 | 对画面测光点周围约2.5%进行测光 | 5273 5274## AutoExposureQuery<sup>12+</sup> 5275 5276提供了查询设备是否支持特定曝光模式,曝光补偿的范围,以及是否支持特定的曝光测光模式的方法。 5277 5278### isExposureMeteringModeSupported<sup>12+</sup> 5279 5280isExposureMeteringModeSupported(aeMeteringMode: ExposureMeteringMode): boolean 5281 5282检测传入的测光模式是否支持。 5283 5284**系统接口:** 此接口为系统接口。 5285 5286**系统能力:** SystemCapability.Multimedia.Camera.Core 5287 5288**参数:** 5289 5290| 参数名 | 类型 | 必填 | 说明 | 5291| -------- | -------------------------------| ---- | ----------------------------- | 5292| aeMeteringMode | [ExposureMeteringMode](#exposuremeteringmode12) | 是 | 测光模式。 | 5293 5294**返回值:** 5295 5296| 类型 | 说明 | 5297| ---------- | ----------------------------- | 5298| boolean | 获取是否支持传入的测光模式,返回true为支持,返回false为不支持。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 5299 5300**错误码:** 5301 5302以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5303 5304| 错误码ID | 错误信息 | 5305| --------------- | --------------- | 5306| 202 | Not System Application. | 5307| 7400101 | Parameter missing or parameter type incorrect. | 5308| 7400103 | Session not config. | 5309 5310 5311**示例:** 5312 5313```ts 5314import { BusinessError } from '@kit.BasicServicesKit'; 5315 5316function isExposureMeteringModeSupported(professionalPhotoSession: camera.ProfessionalPhotoSession): boolean { 5317 let isSupported: boolean = false; 5318 try { 5319 isSupported = professionalPhotoSession.isExposureModeSupported(camera.ExposureMeteringMode.CENTER); 5320 } catch (error) { 5321 // 失败返回错误码error.code并处理。 5322 let err = error as BusinessError; 5323 console.error(`The isExposureMeteringModeSupported call failed. error code: ${err.code}`); 5324 } 5325 return isSupported; 5326} 5327``` 5328 5329## AutoExposure 5330 5331AutoExposure extends [AutoExposureQuery](#autoexposurequery12) 5332 5333提供了处理设备自动曝光的相关功能,包括获取和设置曝光模式、测量点,查询补偿范围,设定曝光补偿,和获取设置曝光的测光模式。 5334 5335### getExposureMeteringMode<sup>12+</sup> 5336 5337getExposureMeteringMode(): ExposureMeteringMode 5338 5339获取当前测光模式。 5340 5341**系统接口:** 此接口为系统接口。 5342 5343**系统能力:** SystemCapability.Multimedia.Camera.Core 5344 5345**返回值:** 5346 5347| 类型 | 说明 | 5348| ---------- | ----------------------------- | 5349| [ExposureMeteringMode](#exposuremeteringmode12) | 获取当前测光模式。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 5350 5351**错误码:** 5352 5353以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5354 5355| 错误码ID | 错误信息 | 5356| --------------- | --------------- | 5357| 7400103 | Session not config. | 5358| 202 | Not System Application. | 5359 5360**示例:** 5361 5362```ts 5363import { BusinessError } from '@kit.BasicServicesKit'; 5364 5365function getExposureMeteringMode(professionalPhotoSession: camera.ProfessionalPhotoSession): camera.ExposureMeteringMode | undefined { 5366 let exposureMeteringMode: camera.ExposureMeteringMode | undefined = undefined; 5367 try { 5368 exposureMeteringMode = professionalPhotoSession.getExposureMeteringMode(); 5369 } catch (error) { 5370 // 失败返回错误码error.code并处理。 5371 let err = error as BusinessError; 5372 console.error(`The getExposureMeteringMode call failed. error code: ${err.code}`); 5373 } 5374 return exposureMeteringMode; 5375} 5376``` 5377 5378### setExposureMeteringMode<sup>12+</sup> 5379 5380setExposureMeteringMode(aeMeteringMode: ExposureMeteringMode): void 5381 5382设置测光模式。进行设置之前,需要先检查设备是否支持指定的测光模式,可使用方法[isExposureMeteringModeSupported](#isexposuremeteringmodesupported12)。 5383 5384**系统接口:** 此接口为系统接口。 5385 5386**系统能力:** SystemCapability.Multimedia.Camera.Core 5387 5388**参数:** 5389 5390| 参数名 | 类型 | 必填 | 说明 | 5391| -------- | -------------------------------| ---- | ----------------------- | 5392| aeMeteringMode | [ExposureMeteringMode](#exposuremeteringmode12) | 是 | 测光模式。 | 5393 5394**错误码:** 5395 5396以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5397 5398| 错误码ID | 错误信息 | 5399| --------------- | --------------- | 5400| 202 | Not System Application. | 5401| 7400101 | Parameter missing or parameter type incorrect. | 5402| 7400103 | Session not config. | 5403 5404**示例:** 5405 5406```ts 5407import { BusinessError } from '@kit.BasicServicesKit'; 5408 5409function setExposureMeteringMode(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 5410 try { 5411 professionalPhotoSession.setExposureMeteringMode(camera.ExposureMeteringMode.CENTER); 5412 } catch (error) { 5413 // 失败返回错误码error.code并处理。 5414 let err = error as BusinessError; 5415 console.error(`The setExposureMeteringMode call failed. error code: ${err.code}`); 5416 } 5417} 5418``` 5419 5420## FocusRangeType<sup>15+</sup> 5421 5422枚举,对焦范围类型。 5423 5424**系统能力**: SystemCapability.Multimedia.Camera.Core 5425 5426| 名称 | 值 | 说明 | 5427| ---- | ---- | ---------- | 5428| AUTO | 0 | 自动对焦。 | 5429| NEAR | 1 | 近物对焦。 | 5430 5431## FocusDrivenType<sup>15+</sup> 5432 5433枚举,对焦驱动类型。 5434 5435**系统能力**: SystemCapability.Multimedia.Camera.Core 5436 5437| 名称 | 值 | 说明 | 5438| ---- | ---- | ---------- | 5439| AUTO | 0 | 自动。 | 5440| FACE | 1 | 人脸驱动。 | 5441 5442## FocusQuery<sup>12+</sup> 5443 5444提供了查询是否支持对焦辅助的方法。 5445 5446### isFocusAssistSupported<sup>12+</sup> 5447 5448isFocusAssistSupported(): boolean 5449 5450检测是否支持对焦辅助灯。 5451 5452**系统接口:** 此接口为系统接口。 5453 5454**系统能力:** SystemCapability.Multimedia.Camera.Core 5455 5456**返回值:** 5457 5458| 类型 | 说明 | 5459| ---------- | ----------------------------- | 5460| boolean | 返回true表示支持对焦辅助灯,false表示不支持。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 5461 5462**错误码:** 5463 5464以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5465 5466| 错误码ID | 错误信息 | 5467| --------------- | --------------- | 5468| 7400103 | Session not config. | 5469| 202 | Not System Application. | 5470 5471**示例:** 5472 5473```ts 5474import { BusinessError } from '@kit.BasicServicesKit'; 5475 5476function isFocusAssistSupported(professionalPhotoSession: camera.ProfessionalPhotoSession): boolean { 5477 let status: boolean = false; 5478 try { 5479 status = professionalPhotoSession.isFocusAssistSupported(); 5480 } catch (error) { 5481 // 失败返回错误码error.code并处理。 5482 let err = error as BusinessError; 5483 console.error(`The isFocusAssistSupported call failed. error code: ${err.code}`); 5484 } 5485 return status; 5486} 5487``` 5488 5489### isFocusRangeTypeSupported<sup>15+</sup> 5490 5491isFocusRangeTypeSupported(type: FocusRangeType): boolean 5492 5493查询是否支持指定的对焦范围类型。 5494 5495**系统接口**: 此接口为系统接口。 5496 5497**系统能力**: SystemCapability.Multimedia.Camera.Core 5498 5499**参数**: 5500 5501| 参数名 | 类型 | 必填 | 说明 | 5502| ------ | ----------------------------------- | ---- | ------------------------ | 5503| type | [FocusRangeType](#focusrangetype15) | 是 | 指定对应的对焦范围类型。 | 5504 5505**返回值**: 5506 5507| 类型 | 说明 | 5508| ------- | ------------------------------------------------------------ | 5509| boolean | 返回true表示支持指定的对焦范围类型,false表示不支持。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 5510 5511**错误码**: 5512 5513以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5514 5515| 错误码ID | 错误信息 | 5516| -------- | ------------------------------------------------------------ | 5517| 202 | Not System Application. | 5518| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 5519| 7400103 | Session not config. | 5520 5521**示例**: 5522 5523```ts 5524import { BusinessError } from '@kit.BasicServicesKit'; 5525 5526function isFocusRangeTypeSupported(session: camera.VideoSessionForSys, type: camera.FocusRangeType): boolean { 5527 let status: boolean = false; 5528 try { 5529 status = session.isFocusRangeTypeSupported(type); 5530 } catch (error) { 5531 // 失败返回错误码error.code并处理。 5532 let err = error as BusinessError; 5533 console.error(`The isFocusRangeTypeSupported call failed. error code: ${err.code}`); 5534 } 5535 return status; 5536} 5537``` 5538 5539### isFocusDrivenTypeSupported<sup>15+</sup> 5540 5541isFocusDrivenTypeSupported(type: FocusDrivenType): boolean 5542 5543查询是否支持指定的对焦驱动类型。 5544 5545**系统接口**: 此接口为系统接口。 5546 5547**系统能力**: SystemCapability.Multimedia.Camera.Core 5548 5549**参数**: 5550 5551| 参数名 | 类型 | 必填 | 说明 | 5552| ------ | ------------------------------------- | ---- | ------------------------ | 5553| type | [FocusDrivenType](#focusdriventype15) | 是 | 指定对应的对焦驱动类型。 | 5554 5555**返回值**: 5556 5557| 类型 | 说明 | 5558| ------- | ------------------------------------------------------------ | 5559| boolean | 返回true表示支持指定的对焦驱动类型,false表示不支持。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 5560 5561**错误码**: 5562 5563以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5564 5565| 错误码ID | 错误信息 | 5566| -------- | ------------------------------------------------------------ | 5567| 202 | Not System Application. | 5568| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 5569| 7400103 | Session not config. | 5570 5571**示例**: 5572 5573```ts 5574import { BusinessError } from '@kit.BasicServicesKit'; 5575 5576function isFocusDrivenTypeSupported(session: camera.VideoSessionForSys, type: camera.FocusDrivenType): boolean { 5577 let status: boolean = false; 5578 try { 5579 status = session.isFocusDrivenTypeSupported(type); 5580 } catch (error) { 5581 // 失败返回错误码error.code并处理。 5582 let err = error as BusinessError; 5583 console.error(`The isFocusDrivenTypeSupported call failed. error code: ${err.code}`); 5584 } 5585 return status; 5586} 5587``` 5588 5589## Focus 5590 5591Focus extends [FocusQuery](#focusquery12) 5592 5593提供了获取和设置相机对焦模式和对焦点位置的方法。 5594 5595### setFocusAssist<sup>12+</sup> 5596 5597setFocusAssist(enabled: boolean): void 5598 5599设置对焦辅助灯。进行设置之前,需要先检查设备是否支持对焦辅助灯,可使用方法[isFocusAssistSupported](#isfocusassistsupported12)。 5600 5601**系统接口:** 此接口为系统接口。 5602 5603**系统能力:** SystemCapability.Multimedia.Camera.Core 5604 5605**参数:** 5606 5607| 参数名 | 类型 | 必填 | 说明 | 5608| -------- | ----------------------- | ---- | ------------------- | 5609| enabled | boolean | 是 | true:开启对焦辅助灯,false:关闭对焦辅助灯。 | 5610 5611**错误码:** 5612 5613以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5614 5615| 错误码ID | 错误信息 | 5616| --------------- | --------------- | 5617| 202 | Not System Application. | 5618| 7400101 | Parameter missing or parameter type incorrect. | 5619| 7400103 | Session not config. | 5620 5621 5622**示例:** 5623 5624```ts 5625import { BusinessError } from '@kit.BasicServicesKit'; 5626 5627function setFocusAssist(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 5628 try { 5629 professionalPhotoSession.setFocusAssist(false); 5630 } catch (error) { 5631 // 失败返回错误码error.code并处理。 5632 let err = error as BusinessError; 5633 console.error(`The setFocusAssist call failed. error code: ${err.code}`); 5634 } 5635} 5636``` 5637 5638### getFocusAssist<sup>12+</sup> 5639 5640getFocusAssist(): boolean 5641 5642获取对焦辅助灯是否开启。 5643 5644**系统接口:** 此接口为系统接口。 5645 5646**系统能力:** SystemCapability.Multimedia.Camera.Core 5647 5648**返回值:** 5649 5650| 类型 | 说明 | 5651| ---------- | ----------------------------- | 5652| boolean | 返回true表示相机已打开对焦辅助灯,返回false表示相机已关闭对焦辅助灯。 | 5653 5654**错误码:** 5655 5656以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5657 5658| 错误码ID | 错误信息 | 5659| --------------- | --------------- | 5660| 7400103 | Session not config. | 5661| 202 | Not System Application. | 5662 5663**示例:** 5664 5665```ts 5666import { BusinessError } from '@kit.BasicServicesKit'; 5667 5668function getFocusAssist(professionalPhotoSession: camera.ProfessionalPhotoSession): boolean { 5669 let isFocusAssistOpened: boolean; 5670 try { 5671 isFocusAssistOpened = professionalPhotoSession.getFocusAssist(); 5672 } catch (error) { 5673 // 失败返回错误码error.code并处理。 5674 let err = error as BusinessError; 5675 console.error(`The getFocusAssist call failed. error code: ${err.code}`); 5676 } 5677 return isFocusAssistOpened; 5678} 5679``` 5680 5681### setFocusRange<sup>15+</sup> 5682 5683setFocusRange(type: FocusRangeType): void 5684 5685设置对焦范围类型。进行设置之前,需要先检查设备是否支持指定的对焦范围类型,可使用方法[isFocusRangeTypeSupported](#isfocusrangetypesupported15)。 5686 5687**系统接口**: 此接口为系统接口。 5688 5689**系统能力**: SystemCapability.Multimedia.Camera.Core 5690 5691**参数**: 5692 5693| 参数名 | 类型 | 必填 | 说明 | 5694| ------ | ----------------------------------- | ---- | -------------- | 5695| type | [FocusRangeType](#focusrangetype15) | 是 | 对焦范围类型。 | 5696 5697**错误码**: 5698 5699以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5700 5701| 错误码ID | 错误信息 | 5702| -------- | ------------------------------------------------------------ | 5703| 202 | Not System Application. | 5704| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3.Parameter verification failed. | 5705| 7400102 | Operation not allowed. | 5706| 7400103 | Session not config. | 5707| 7400201 | Camera service fatal error. | 5708 5709**示例**: 5710 5711```ts 5712import { BusinessError } from '@kit.BasicServicesKit'; 5713 5714function setFocusRange(session: camera.VideoSessionForSys, type: camera.FocusRangeType): void { 5715 try { 5716 session.setFocusRange(type); 5717 } catch (error) { 5718 // 失败返回错误码error.code并处理。 5719 let err = error as BusinessError; 5720 console.error(`The setFocusRange call failed. error code: ${err.code}`); 5721 } 5722} 5723``` 5724 5725### getFocusRange<sup>15+</sup> 5726 5727getFocusRange(): FocusRangeType 5728 5729获取当前设置的对焦范围类型。 5730 5731**系统接口**: 此接口为系统接口。 5732 5733**系统能力**: SystemCapability.Multimedia.Camera.Core 5734 5735**返回值**: 5736 5737| 类型 | 说明 | 5738| ----------------------------------- | ------------------------ | 5739| [FocusRangeType](#focusrangetype15) | 当前设置的对焦范围类型。 | 5740 5741**错误码**: 5742 5743以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5744 5745| 错误码ID | 错误信息 | 5746| -------- | ----------------------- | 5747| 202 | Not System Application. | 5748| 7400103 | Session not config. | 5749 5750**示例**: 5751 5752```ts 5753import { BusinessError } from '@kit.BasicServicesKit'; 5754 5755function getFocusRange(session: camera.VideoSessionForSys): camera.FocusRangeType | undefined { 5756 let focusRangeType: camera.FocusRangeType | undefined = undefined; 5757 try { 5758 focusRangeType = session.getFocusRange(); 5759 } catch (error) { 5760 // 失败返回错误码error.code并处理。 5761 let err = error as BusinessError; 5762 console.error(`The getFocusRange call failed. error code: ${err.code}`); 5763 } 5764 return focusRangeType; 5765} 5766``` 5767 5768### setFocusDriven<sup>15+</sup> 5769 5770setFocusDriven(type: FocusDrivenType): void 5771 5772设置对焦驱动类型。进行设置之前,需要先检查设备是否支持指定的对焦驱动类型,可使用方法[isFocusDrivenTypeSupported](#isfocusdriventypesupported15)。 5773 5774**系统接口**: 此接口为系统接口。 5775 5776**系统能力**: SystemCapability.Multimedia.Camera.Core 5777 5778**参数**: 5779 5780| 参数名 | 类型 | 必填 | 说明 | 5781| ------ | ------------------------------------- | ---- | -------------- | 5782| type | [FocusDrivenType](#focusdriventype15) | 是 | 对焦驱动类型。 | 5783 5784**错误码**: 5785 5786以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5787 5788| 错误码ID | 错误信息 | 5789| -------- | ------------------------------------------------------------ | 5790| 202 | Not System Application. | 5791| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3.Parameter verification failed. | 5792| 7400102 | Operation not allowed. | 5793| 7400103 | Session not config. | 5794| 7400201 | Camera service fatal error. | 5795 5796**示例**: 5797 5798```ts 5799import { BusinessError } from '@kit.BasicServicesKit'; 5800 5801function setFocusDriven(session: camera.VideoSessionForSys, type: camera.FocusDrivenType): void { 5802 try { 5803 session.setFocusDriven(type); 5804 } catch (error) { 5805 // 失败返回错误码error.code并处理。 5806 let err = error as BusinessError; 5807 console.error(`The setFocusDriven call failed. error code: ${err.code}`); 5808 } 5809} 5810``` 5811 5812### getFocusDriven<sup>15+</sup> 5813 5814getFocusDriven(): FocusDrivenType 5815 5816获取当前设置的对焦驱动类型。 5817 5818**系统接口**: 此接口为系统接口。 5819 5820**系统能力**: SystemCapability.Multimedia.Camera.Core 5821 5822**返回值**: 5823 5824| 类型 | 说明 | 5825| ------------------------------------- | ------------------------ | 5826| [FocusDrivenType](#focusdriventype15) | 当前设置的对焦驱动类型。 | 5827 5828**错误码**: 5829 5830以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5831 5832| 错误码ID | 错误信息 | 5833| -------- | ----------------------- | 5834| 202 | Not System Application. | 5835| 7400103 | Session not config. | 5836 5837**示例**: 5838 5839```ts 5840import { BusinessError } from '@kit.BasicServicesKit'; 5841 5842function getFocusDriven(session: camera.VideoSessionForSys): camera.FocusDrivenType | undefined { 5843 let focusDrivenType: camera.FocusDrivenType | undefined = undefined; 5844 try { 5845 focusDrivenType = session.getFocusDriven(); 5846 } catch (error) { 5847 // 失败返回错误码error.code并处理。 5848 let err = error as BusinessError; 5849 console.error(`The getFocusDriven call failed. error code: ${err.code}`); 5850 } 5851 return focusDrivenType; 5852} 5853``` 5854 5855## ManualFocus<sup>12+</sup> 5856 5857手动对焦类,对设备手动设置对焦操作。 5858 5859### setFocusDistance<sup>12+</sup> 5860 5861setFocusDistance(distance: number): void 5862 5863手动设置对焦距离,可设置范围为[0,1]之间的浮点数,0表现为近景,1表现为远景。 5864 5865**系统接口:** 此接口为系统接口。 5866 5867**系统能力:** SystemCapability.Multimedia.Camera.Core 5868 5869**参数:** 5870 5871| 参数名 | 类型 | 必填 | 说明 | 5872| -------- | ----------------------- | ---- | ------------------- | 5873| distance | number | 是 | 范围0-1:该值为归一化值,0为近景,1为远景,<br>可在该范围内调节 | 5874 5875**错误码:** 5876 5877以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5878 5879| 错误码ID | 错误信息 | 5880| --------------- | --------------- | 5881| 202 | Not System Application. | 5882| 7400101 | Parameter missing or parameter type incorrect. | 5883| 7400103 | Session not config. | 5884 5885**示例:** 5886 5887```ts 5888import { BusinessError } from '@kit.BasicServicesKit'; 5889 5890function setFocusDistance(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 5891 try { 5892 let distance: number = 0.5; 5893 professionalPhotoSession.setFocusDistance(distance); 5894 } catch (error) { 5895 // 失败返回错误码error.code并处理。 5896 let err = error as BusinessError; 5897 console.error(`The setFocusDistance call failed. error code: ${err.code}`); 5898 } 5899} 5900``` 5901 5902### getFocusDistance<sup>12+</sup> 5903 5904getFocusDistance(): number 5905 5906获取当前的对焦距离。 5907 5908**系统接口:** 此接口为系统接口。 5909 5910**系统能力:** SystemCapability.Multimedia.Camera.Core 5911 5912**返回值:** 5913 5914| 类型 | 说明 | 5915| ---------- | ----------------------------- | 5916| number | 返回当前对焦距离的归一化值。 | 5917 5918**错误码:** 5919 5920以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5921 5922| 错误码ID | 错误信息 | 5923| --------------- | --------------- | 5924| 7400103 | Session not config. | 5925| 202 | Not System Application. | 5926 5927**示例:** 5928 5929```ts 5930import { BusinessError } from '@kit.BasicServicesKit'; 5931 5932function getFocusDistance(professionalPhotoSession: camera.ProfessionalPhotoSession): number { 5933 let distance: number = 0; 5934 try { 5935 distance = professionalPhotoSession.getFocusDistance(); 5936 } catch (error) { 5937 // 失败返回错误码error.code并处理。 5938 let err = error as BusinessError; 5939 console.error(`The getFocusDistance call failed. error code: ${err.code}`); 5940 } 5941 return distance; 5942} 5943``` 5944 5945## ManualIsoQuery<sup>12+</sup> 5946 5947提供了查询设备是否支持手动设置ISO和获取设备支持的ISO范围的方法。 5948 5949### isManualIsoSupported<sup>12+</sup> 5950 5951isManualIsoSupported(): boolean 5952 5953检测是否支持手动ISO。 5954 5955**系统接口:** 此接口为系统接口。 5956 5957**系统能力:** SystemCapability.Multimedia.Camera.Core 5958 5959**返回值:** 5960 5961| 类型 | 说明 | 5962| ---------- | ----------------------------- | 5963| boolean | 返回true表示支持手动调节ISO,false表示不支持。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 5964 5965**错误码:** 5966 5967以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5968 5969| 错误码ID | 错误信息 | 5970| --------------- | --------------- | 5971| 7400103 | Session not config. | 5972| 202 | Not System Application. | 5973 5974**示例:** 5975 5976```ts 5977import { BusinessError } from '@kit.BasicServicesKit'; 5978 5979function isManualIsoSupported(professionalPhotoSession: camera.ProfessionalPhotoSession): boolean { 5980 let status: boolean = false; 5981 try { 5982 status = professionalPhotoSession.isManualIsoSupported(); 5983 } catch (error) { 5984 // 失败返回错误码error.code并处理。 5985 let err = error as BusinessError; 5986 console.error(`The isManualIsoSupported call failed. error code: ${err.code}`); 5987 } 5988 return status; 5989} 5990``` 5991 5992### getIsoRange<sup>12+</sup> 5993 5994getIsoRange(): Array\<number\> 5995 5996获取支持的ISO范围。 5997 5998**系统接口:** 此接口为系统接口。 5999 6000**系统能力:** SystemCapability.Multimedia.Camera.Core 6001 6002**返回值:** 6003 6004| 类型 | 说明 | 6005| ---------- | ----------------------------- | 6006| Array\<number\> | 用于获取ISO范围,范围为[50,100,...,6400],实际根据底层能力返回为准,接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 6007 6008**错误码:** 6009 6010以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 6011 6012| 错误码ID | 错误信息 | 6013| --------------- | --------------- | 6014| 202 | Not System Application. | 6015| 7400103 | Session not config. | 6016 6017**示例:** 6018 6019```ts 6020import { BusinessError } from '@kit.BasicServicesKit'; 6021 6022function getIsoRange(professionalPhotoSession: camera.ProfessionalPhotoSession): Array<number> { 6023 let isoRange: Array<number> = []; 6024 try { 6025 isoRange = professionalPhotoSession.getIsoRange(); 6026 } catch (error) { 6027 // 失败返回错误码error.code并处理。 6028 let err = error as BusinessError; 6029 console.error(`The getIsoRange call failed. error code: ${err.code}`); 6030 } 6031 return isoRange; 6032} 6033``` 6034 6035## ManualIso<sup>12+</sup> 6036 6037ManualIso extends [ManualIsoQuery](#manualisoquery12) 6038 6039提供了获取和设置设备手动ISO(感光度)的功能。 6040 6041### setIso<sup>12+</sup> 6042setIso(iso: number): void 6043 6044设置ISO值。**注意:当ISO值设置为0时,表示设置自动ISO** 6045 6046**系统接口:** 此接口为系统接口。 6047 6048**系统能力:** SystemCapability.Multimedia.Camera.Core 6049 6050**参数:** 6051 6052| 参数名 | 类型 | 必填 | 说明 | 6053| -------- | ----------------------- | ---- | ------------------- | 6054| iso | number | 是 | 设置ISO值。 | 6055 6056**错误码:** 6057 6058以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 6059 6060| 错误码ID | 错误信息 | 6061| --------------- | --------------- | 6062| 202 | Not System Application. | 6063| 7400101 | Parameter missing or parameter type incorrect. | 6064| 7400103 | Session not config. | 6065 6066**示例:** 6067 6068```ts 6069import { BusinessError } from '@kit.BasicServicesKit'; 6070 6071function setIso(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6072 try { 6073 let iso: number = 200; 6074 professionalPhotoSession.setIso(iso); 6075 } catch (error) { 6076 // 失败返回错误码error.code并处理。 6077 let err = error as BusinessError; 6078 console.error(`The setIso call failed. error code: ${err.code}`); 6079 } 6080} 6081``` 6082 6083### getIso<sup>12+</sup> 6084 6085getIso(): number 6086 6087获取当前的ISO值。 6088 6089**系统接口:** 此接口为系统接口。 6090 6091**系统能力:** SystemCapability.Multimedia.Camera.Core 6092 6093**返回值:** 6094 6095| 类型 | 说明 | 6096| ---------- | ----------------------------- | 6097| number | 返回当前ISO值。 | 6098 6099**错误码:** 6100 6101以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 6102 6103| 错误码ID | 错误信息 | 6104| --------------- | --------------- | 6105| 202 | Not System Application. | 6106| 7400103 | Session not config. | 6107 6108**示例:** 6109 6110```ts 6111import { BusinessError } from '@kit.BasicServicesKit'; 6112 6113function getIso(professionalPhotoSession: camera.ProfessionalPhotoSession): number { 6114 let iso: number = 0; 6115 try { 6116 iso = professionalPhotoSession.getIso(); 6117 } catch (error) { 6118 // 失败返回错误码error.code并处理。 6119 let err = error as BusinessError; 6120 console.error(`The getIso call failed. error code: ${err.code}`); 6121 } 6122 return iso; 6123} 6124``` 6125 6126## WhiteBalanceMode<sup>12+</sup> 6127 6128枚举,白平衡模式。 6129 6130**系统接口:** 此接口为系统接口。 6131 6132**系统能力:** SystemCapability.Multimedia.Camera.Core 6133 6134| 名称 | 值 | 说明 | 6135| ----------------------------- | ---- | ----------- | 6136| AUTO | 0 | 自动 | 6137| CLOUDY | 1 | 阴天 | 6138| INCANDESCENT | 2 | 白炽光 | 6139| FLUORESCENT | 3 | 荧光 | 6140| DAYLIGHT | 4 | 日光 | 6141| MANUAL | 5 | 手动 | 6142 6143## WhiteBalanceQuery<sup>12+</sup> 6144 6145提供了查询设备对指定的白平衡模式是否支持,以及获取设备支持的白平衡模式范围的方法。 6146 6147### isWhiteBalanceModeSupported<sup>12+</sup> 6148 6149isWhiteBalanceModeSupported(mode: WhiteBalanceMode): boolean 6150 6151检测是否支持当前传入的白平衡模式。 6152 6153**系统接口:** 此接口为系统接口。 6154 6155**系统能力:** SystemCapability.Multimedia.Camera.Core 6156**参数:** 6157 6158| 参数名 | 类型 | 必填 | 说明 | 6159| -------- | -------------------------------| ---- | ----------------------------- | 6160| mode | [WhiteBalanceMode](#whitebalancemode12) | 是 | 白平衡模式。 | 6161 6162**返回值:** 6163 6164| 类型 | 说明 | 6165| ---------- | ----------------------------- | 6166| boolean | 返回true表示支持该白平衡模式,false表示不支持。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 6167 6168**错误码:** 6169 6170以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 6171 6172| 错误码ID | 错误信息 | 6173| --------------- | --------------- | 6174| 202 | Not System Application. | 6175| 7400101 | Parameter missing or parameter type incorrect. | 6176| 7400103 | Session not config. | 6177 6178**示例:** 6179 6180```ts 6181import { BusinessError } from '@kit.BasicServicesKit'; 6182 6183function isWhiteBalanceModeSupported(professionalPhotoSession: camera.ProfessionalPhotoSession): boolean { 6184 let status: boolean = false; 6185 try { 6186 let mode: WhiteBalanceMode = camera.WhiteBalanceMode.DAYLIGHT; 6187 status = professionalPhotoSession.isWhiteBalanceModeSupported(mode); 6188 } catch (error) { 6189 // 失败返回错误码error.code并处理。 6190 let err = error as BusinessError; 6191 console.error(`The isWhiteBalanceModeSupported call failed. error code: ${err.code}`); 6192 } 6193 return status; 6194} 6195``` 6196 6197### getWhiteBalanceRange<sup>12+</sup> 6198 6199getWhiteBalanceRange(): Array\<number\> 6200 6201获取手动白平衡的调节范围。 6202 6203**系统接口:** 此接口为系统接口。 6204 6205**系统能力:** SystemCapability.Multimedia.Camera.Core 6206 6207**返回值:** 6208 6209| 类型 | 说明 | 6210| ---------- | ----------------------------- | 6211| Array\<number\> | 用于获取手动白平衡值可调范围,如[2800,...,10000],单位为K(Kelvin,温度单位),实际情况根据底层能力返回为准。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 6212 6213**错误码:** 6214 6215以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 6216 6217| 错误码ID | 错误信息 | 6218| --------------- | --------------- | 6219| 202 | Not System Application. | 6220| 7400103 | Session not config. | 6221 6222**示例:** 6223 6224```ts 6225import { BusinessError } from '@kit.BasicServicesKit'; 6226 6227function getWhiteBalanceRange(professionalPhotoSession: camera.ProfessionalPhotoSession): Array<number> { 6228 let range: Array<number> = []; 6229 try { 6230 range = professionalPhotoSession.getWhiteBalanceRange(); 6231 } catch (error) { 6232 // 失败返回错误码error.code并处理。 6233 let err = error as BusinessError; 6234 console.error(`The getWhiteBalanceRange call failed. error code: ${err.code}`); 6235 } 6236 return range; 6237} 6238``` 6239 6240## WhiteBalance<sup>12+</sup> 6241 6242WhiteBalance extends [WhiteBalanceQuery](#whitebalancequery12) 6243 6244提供了处理设备白平衡的相关功能,包括获取和设置白平衡模式和白平衡值。 6245 6246### setWhiteBalanceMode<sup>12+</sup> 6247 6248setWhiteBalanceMode(mode: WhiteBalanceMode): void 6249 6250设置白平衡模式。进行设置之前,需要先检查设备是否支持指定的白平衡模式,可使用方法[isWhiteBalanceModeSupported](#iswhitebalancemodesupported12)。 6251 6252**系统接口:** 此接口为系统接口。 6253 6254**系统能力:** SystemCapability.Multimedia.Camera.Core 6255 6256**参数:** 6257 6258| 参数名 | 类型 | 必填 | 说明 | 6259| -------- | -------------------------------| ---- | ----------------------- | 6260| mode | [WhiteBalanceMode](#whitebalancemode12) | 是 | 白平衡模式。 | 6261 6262**错误码:** 6263 6264以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 6265 6266| 错误码ID | 错误信息 | 6267| --------------- | --------------- | 6268| 202 | Not System Application. | 6269| 7400101 | Parameter missing or parameter type incorrect. | 6270| 7400103 | Session not config. | 6271 6272**示例:** 6273 6274```ts 6275import { BusinessError } from '@kit.BasicServicesKit'; 6276 6277function setWhiteBalanceMode(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6278 try { 6279 professionalPhotoSession.setWhiteBalanceMode(camera.WhiteBalanceMode.DAYLIGHT); 6280 } catch (error) { 6281 // 失败返回错误码error.code并处理。 6282 let err = error as BusinessError; 6283 console.error(`The setWhiteBalanceMode call failed. error code: ${err.code}`); 6284 } 6285} 6286``` 6287 6288### getWhiteBalanceMode<sup>12+</sup> 6289 6290getWhiteBalanceMode(): WhiteBalanceMode 6291 6292获取当前白平衡模式。 6293 6294**系统接口:** 此接口为系统接口。 6295 6296**系统能力:** SystemCapability.Multimedia.Camera.Core 6297 6298**返回值:** 6299 6300| 类型 | 说明 | 6301| ---------- | ----------------------------- | 6302| [WhiteBalanceMode](#whitebalancemode12) | 获取当前白平衡模式。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 6303 6304**错误码:** 6305 6306以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 6307 6308| 错误码ID | 错误信息 | 6309| --------------- | --------------- | 6310| 202 | Not System Application. | 6311| 7400103 | Session not config. | 6312 6313**示例:** 6314 6315```ts 6316import { BusinessError } from '@kit.BasicServicesKit'; 6317 6318function getWhiteBalanceMode(professionalPhotoSession: camera.ProfessionalPhotoSession): camera.WhiteBalanceMode | undefined { 6319 let whiteBalanceMode: camera.WhiteBalanceMode | undefined = undefined; 6320 try { 6321 whiteBalanceMode = professionalPhotoSession.getWhiteBalanceMode(); 6322 } catch (error) { 6323 // 失败返回错误码error.code并处理。 6324 let err = error as BusinessError; 6325 console.error(`The getWhiteBalanceMode call failed. error code: ${err.code}`); 6326 } 6327 return whiteBalanceMode; 6328} 6329``` 6330 6331### setWhiteBalance<sup>12+</sup> 6332setWhiteBalance(whiteBalance: number): void 6333 6334设置手动白平衡值。 6335 6336**系统接口:** 此接口为系统接口。 6337 6338**系统能力:** SystemCapability.Multimedia.Camera.Core 6339 6340**参数:** 6341 6342| 参数名 | 类型 | 必填 | 说明 | 6343| -------- | ----------------------- | ---- | ------------------- | 6344| whiteBalance | number | 是 | 设置手动白平衡值 | 6345 6346**错误码:** 6347 6348以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 6349 6350| 错误码ID | 错误信息 | 6351| --------------- | --------------- | 6352| 202 | Not System Application. | 6353| 7400101 | Parameter missing or parameter type incorrect. | 6354| 7400103 | Session not config. | 6355 6356**示例:** 6357 6358```ts 6359import { BusinessError } from '@kit.BasicServicesKit'; 6360 6361function setWhiteBalance(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6362 try { 6363 let whiteBalance: number = 1000; 6364 professionalPhotoSession.setWhiteBalance(whiteBalance); 6365 } catch (error) { 6366 // 失败返回错误码error.code并处理。 6367 let err = error as BusinessError; 6368 console.error(`The setWhiteBalance call failed. error code: ${err.code}`); 6369 } 6370} 6371``` 6372 6373### getWhiteBalance<sup>12+</sup> 6374 6375getWhiteBalance(): number 6376 6377获取当前手动白平衡的值。 6378 6379**系统接口:** 此接口为系统接口。 6380 6381**系统能力:** SystemCapability.Multimedia.Camera.Core 6382 6383**返回值:** 6384 6385| 类型 | 说明 | 6386| ---------- | ----------------------------- | 6387| number | 返回当前白平衡值。 | 6388 6389**错误码:** 6390 6391以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 6392 6393| 错误码ID | 错误信息 | 6394| --------------- | --------------- | 6395| 202 | Not System Application. | 6396| 7400103 | Session not config. | 6397 6398**示例:** 6399 6400```ts 6401import { BusinessError } from '@kit.BasicServicesKit'; 6402 6403function getWhiteBalance(professionalPhotoSession: camera.ProfessionalPhotoSession): number { 6404 let whiteBalance: number = 0; 6405 try { 6406 whiteBalance = professionalPhotoSession.getWhiteBalance(); 6407 } catch (error) { 6408 // 失败返回错误码error.code并处理。 6409 let err = error as BusinessError; 6410 console.error(`The getWhiteBalance call failed. error code: ${err.code}`); 6411 } 6412 return whiteBalance; 6413} 6414``` 6415 6416## ProfessionalPhotoSession<sup>12+</sup> 6417 6418ProfessionalPhotoSession extends Session, AutoExposure, ManualExposure, Focus, ManualFocus, WhiteBalance, ManualIso, Flash, Zoom, ColorEffect, Aperture 6419 6420专业拍照会话类,继承自[Session](js-apis-camera.md#session12),用于设置专业拍照会话的参数以及保存所需要的所有资源[CameraInput](js-apis-camera.md#camerainput)、[CameraOutput](js-apis-camera.md#cameraoutput)。 6421 6422### on('error')<sup>12+</sup> 6423 6424on(type: 'error', callback: ErrorCallback): void 6425 6426监听专业拍照会话的错误事件,通过注册回调函数获取结果。使用callback异步回调。 6427 6428**系统接口:** 此接口为系统接口。 6429 6430**系统能力:** SystemCapability.Multimedia.Camera.Core 6431 6432**参数:** 6433 6434| 参数名 | 类型 | 必填 | 说明 | 6435| -------- | ----------------------------------------------------------- | ---- | ------------------------------ | 6436| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。session调用相关接口出现错误时会触发该事件,比如调用[beginConfig](js-apis-camera.md#beginconfig11),[commitConfig](js-apis-camera.md#commitconfig11-1),[addInput](js-apis-camera.md#addinput11)等接口发生错误时返回错误信息。 | 6437| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 6438 6439**错误码:** 6440 6441以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 6442 6443| 错误码ID | 错误信息 | 6444|---------| --------------- | 6445| 202 | Not System Application. | 6446 6447**示例:** 6448 6449```ts 6450import { BusinessError } from '@kit.BasicServicesKit'; 6451 6452function callback(err: BusinessError): void { 6453 console.error(`Professional photo session error code: ${err.code}`); 6454} 6455 6456function registerSessionError(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6457 professionalPhotoSession.on('error', callback); 6458} 6459``` 6460 6461### off('error')<sup>12+</sup> 6462 6463off(type: 'error', callback?: ErrorCallback): void 6464 6465注销监听专业拍照会话的错误事件,通过注册回调函数获取结果。 6466 6467**系统接口:** 此接口为系统接口。 6468 6469**系统能力:** SystemCapability.Multimedia.Camera.Core 6470 6471**参数:** 6472 6473| 参数名 | 类型 | 必填 | 说明 | 6474| -------- | ------------------------ | ---- | ------------------------------ | 6475| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。 | 6476| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 否 | 回调函数,可选,有就是匿名函数。 | 6477 6478**错误码:** 6479 6480以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 6481 6482| 错误码ID | 错误信息 | 6483|---------| --------------- | 6484| 202 | Not System Application. | 6485 6486**示例:** 6487 6488```ts 6489function unregisterSessionError(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6490 professionalPhotoSession.off('error'); 6491} 6492``` 6493 6494### on('focusStateChange')<sup>12+</sup> 6495 6496on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 6497 6498监听相机对焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 6499 6500**系统接口:** 此接口为系统接口。 6501 6502**系统能力:** SystemCapability.Multimedia.Camera.Core 6503 6504**参数:** 6505 6506| 参数名 | 类型 | 必填 | 说明 | 6507| -------- | ---------------- | ---- | ------------------------ | 6508| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。仅当自动对焦模式时,且相机对焦状态发生改变时可触发该事件。 | 6509| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | 是 | 回调函数,用于获取当前对焦状态。 | 6510 6511**错误码:** 6512 6513以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 6514 6515| 错误码ID | 错误信息 | 6516|---------| --------------- | 6517| 202 | Not System Application. | 6518 6519**示例:** 6520 6521```ts 6522import { BusinessError } from '@kit.BasicServicesKit'; 6523 6524function callback(err: BusinessError, focusState: camera.FocusState): void { 6525 if (err !== undefined && err.code !== 0) { 6526 console.error(`Callback Error, errorCode: ${err.code}`); 6527 return; 6528 } 6529 console.info(`Focus state: ${focusState}`); 6530} 6531 6532function registerFocusStateChange(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6533 professionalPhotoSession.on('focusStateChange', callback); 6534} 6535``` 6536 6537### off('focusStateChange')<sup>12+</sup> 6538 6539off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 6540 6541注销监听相机对焦的状态变化。 6542 6543**系统接口:** 此接口为系统接口。 6544 6545**系统能力:** SystemCapability.Multimedia.Camera.Core 6546 6547**参数:** 6548 6549| 参数名 | 类型 | 必填 | 说明 | 6550| -------- | ----------------------------------------- | ---- | ------------------------ | 6551| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。 | 6552| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | 否 | 回调函数,可选,有就是匹配on('focusStateChange') callback(callback对象不可是匿名函数)。 | 6553 6554**错误码:** 6555 6556以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 6557 6558| 错误码ID | 错误信息 | 6559|---------| --------------- | 6560| 202 | Not System Application. | 6561 6562**示例:** 6563 6564```ts 6565function unregisterFocusStateChange(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6566 professionalPhotoSession.off('focusStateChange'); 6567} 6568``` 6569 6570### on('smoothZoomInfoAvailable')<sup>12+</sup> 6571 6572on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 6573 6574监听相机平滑变焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 6575 6576**系统接口:** 此接口为系统接口。 6577 6578**系统能力:** SystemCapability.Multimedia.Camera.Core 6579 6580**参数:** 6581 6582| 参数名 | 类型 | 必填 | 说明 | 6583| -------- | ----------------------- | ---- | ------------------------ | 6584| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 6585| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | 是 | 回调函数,用于获取当前平滑变焦状态。 | 6586 6587**错误码:** 6588 6589以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 6590 6591| 错误码ID | 错误信息 | 6592|---------| --------------- | 6593| 202 | Not System Application. | 6594 6595**示例:** 6596 6597```ts 6598import { BusinessError } from '@kit.BasicServicesKit'; 6599 6600function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 6601 if (err !== undefined && err.code !== 0) { 6602 console.error(`Callback Error, errorCode: ${err.code}`); 6603 return; 6604 } 6605 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 6606} 6607 6608function registerSmoothZoomInfo(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6609 professionalPhotoSession.on('smoothZoomInfoAvailable', callback); 6610} 6611``` 6612 6613### off('smoothZoomInfoAvailable')<sup>12+</sup> 6614 6615off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 6616 6617注销监听相机平滑变焦的状态变化。 6618 6619**系统接口:** 此接口为系统接口。 6620 6621**系统能力:** SystemCapability.Multimedia.Camera.Core 6622 6623**参数:** 6624 6625| 参数名 | 类型 | 必填 | 说明 | 6626| -------- | ----------------------------------------- | ---- | ------------------------ | 6627| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 6628| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | 否 | 回调函数,可选,有就是匹配on('smoothZoomInfoAvailable') callback(callback对象不可是匿名函数)。 | 6629 6630**错误码:** 6631 6632以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 6633 6634| 错误码ID | 错误信息 | 6635|---------| --------------- | 6636| 202 | Not System Application. | 6637 6638**示例:** 6639 6640```ts 6641function unregisterSmoothZoomInfo(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6642 professionalPhotoSession.off('smoothZoomInfoAvailable'); 6643} 6644``` 6645 6646### on('isoInfoChange')<sup>12+</sup> 6647 6648on(type: 'isoInfoChange', callback: AsyncCallback\<IsoInfo\>): void 6649 6650监听自动ISO变化事件,通过注册回调函数获取实时ISO信息。使用callback异步回调。 6651 6652**系统接口:** 此接口为系统接口。 6653 6654**系统能力:** SystemCapability.Multimedia.Camera.Core 6655 6656**参数:** 6657 6658| 参数名 | 类型 | 必填 | 说明 | 6659| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6660| type | string | 是 | 监听事件,固定为'isoInfoChange'。 | 6661| callback | AsyncCallback\<[IsoInfo](#isoinfo12)\>| 是 | 回调函数,用于获取ISO信息。 | 6662 6663**错误码:** 6664 6665| 错误码ID | 错误信息 | 6666| ------- | ---------------------- | 6667| 202 | Not System Application. | 6668 6669**示例:** 6670 6671```ts 6672import { BusinessError } from '@kit.BasicServicesKit'; 6673 6674function isoInfoCallback(err: BusinessError, info: camera.IsoInfo): void { 6675 if (err !== undefined && err.code !== 0) { 6676 console.error(`Callback Error, errorCode: ${err.code}`); 6677 return; 6678 } 6679 console.log(`ISO value: ${info.iso}`); 6680} 6681 6682function registerIsoInfoEvent(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6683 professionalPhotoSession.on('isoInfoChange', isoInfoCallback); 6684} 6685``` 6686 6687### off('isoInfoChange')<sup>12+</sup> 6688 6689off(type: 'isoInfoChange', callback?: AsyncCallback\<IsoInfo\>): void 6690 6691注销监听ISO信息事件,通过注册回调函数来注销。 6692 6693**系统接口:** 此接口为系统接口。 6694 6695**系统能力:** SystemCapability.Multimedia.Camera.Core 6696 6697**参数:** 6698 6699| 参数名 | 类型 | 必填 | 说明 | 6700| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6701| type | string | 是 | 监听事件,固定为'isoInfoChange'。 | 6702| callback | AsyncCallback\<[IsoInfo](#isoinfo12)\>| 否 | 回调函数,可选,用于匹配on('isoInfoChange')的callback。 | 6703 6704**错误码:** 6705 6706| 错误码ID | 错误信息 | 6707| ------- | ---------------------- | 6708| 202 | Not System Application. | 6709 6710**示例:** 6711 6712```ts 6713function unregisterIsoInfoEvent(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6714 professionalPhotoSession.off('isoInfoChange'); 6715} 6716``` 6717 6718### on('exposureInfoChange')<sup>12+</sup> 6719 6720on(type: 'exposureInfoChange', callback: AsyncCallback\<ExposureInfo\>): void 6721 6722监听曝光信息事件,通过注册回调函数获取曝光信息。使用callback异步回调。 6723 6724**系统接口:** 此接口为系统接口。 6725 6726**系统能力:** SystemCapability.Multimedia.Camera.Core 6727 6728**参数:** 6729 6730| 参数名 | 类型 | 必填 | 说明 | 6731| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6732| type | string | 是 | 监听事件,固定为'exposureInfoChange'。 | 6733| callback | AsyncCallback\<[ExposureInfo](#exposureinfo12)\>| 是 | 回调函数,用于获取曝光信息。 | 6734 6735**错误码:** 6736 6737| 错误码ID | 错误信息 | 6738| ------- | ---------------------- | 6739| 202 | Not System Application. | 6740 6741**示例:** 6742 6743```ts 6744import { BusinessError } from '@kit.BasicServicesKit'; 6745 6746function exposureInfoCallback(err: BusinessError, info: camera.ExposureInfo): void { 6747 if (err !== undefined && err.code !== 0) { 6748 console.error(`Callback Error, errorCode: ${err.code}`); 6749 return; 6750 } 6751 console.log(`exposureTimeValue: ${info.exposureTime}`); 6752} 6753 6754function registerExposureInfoEvent(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6755 professionalPhotoSession.on('exposureInfoChange', exposureInfoCallback); 6756} 6757``` 6758 6759### off('exposureInfoChange')<sup>12+</sup> 6760 6761off(type: 'exposureInfoChange', callback?: AsyncCallback\<ExposureInfo\>): void 6762 6763注销监听曝光信息事件,通过注册回调函数来注销。 6764 6765**系统接口:** 此接口为系统接口。 6766 6767**系统能力:** SystemCapability.Multimedia.Camera.Core 6768 6769**参数:** 6770 6771| 参数名 | 类型 | 必填 | 说明 | 6772| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6773| type | string | 是 | 监听事件,固定为'exposureInfoChange'。 | 6774| callback | AsyncCallback\<[ExposureInfo](#exposureinfo12)\>| 否 | 回调函数,可选,用于匹配on('exposureInfoChange')的callback。 | 6775 6776**错误码:** 6777 6778| 错误码ID | 错误信息 | 6779| ------- | ---------------------- | 6780| 202 | Not System Application. | 6781 6782**示例:** 6783 6784```ts 6785function unregisterExposureInfoEvent(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6786 professionalPhotoSession.off('exposureInfoChange'); 6787} 6788``` 6789 6790### on('apertureInfoChange')<sup>12+</sup> 6791 6792on(type: 'apertureInfoChange', callback: AsyncCallback\<ApertureInfo\>): void 6793 6794监听物理光圈变化事件,通过注册回调函数获取实时物理光圈信息。使用callback异步回调。 6795 6796**系统接口:** 此接口为系统接口。 6797 6798**系统能力:** SystemCapability.Multimedia.Camera.Core 6799 6800**参数:** 6801 6802| 参数名 | 类型 | 必填 | 说明 | 6803| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6804| type | string | 是 | 监听事件,固定为'apertureInfoChange'。 | 6805| callback | AsyncCallback\<[ApertureInfo](#apertureinfo12)\>| 是 | 回调函数,用于获取物理光圈信息。 | 6806 6807**错误码:** 6808 6809| 错误码ID | 错误信息 | 6810| ------- | ---------------------- | 6811| 202 | Not System Application. | 6812 6813**示例:** 6814 6815```ts 6816import { BusinessError } from '@kit.BasicServicesKit'; 6817 6818function apertureInfoCallback(err: BusinessError, info: camera.ApertureInfo): void { 6819 if (err !== undefined && err.code !== 0) { 6820 console.error(`Callback Error, errorCode: ${err.code}`); 6821 return; 6822 } 6823 console.log(`Aperture value: ${info.aperture}`); 6824} 6825 6826function registerApertureInfoEvent(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6827 professionalPhotoSession.on('apertureInfoChange', apertureInfoCallback); 6828} 6829``` 6830 6831### off('apertureInfoChange')<sup>12+</sup> 6832 6833off(type: 'apertureInfoChange', callback?: AsyncCallback\<ApertureInfo\>): void 6834 6835注销监听物理光圈变化事件,通过注册回调函数来注销。 6836 6837**系统接口:** 此接口为系统接口。 6838 6839**系统能力:** SystemCapability.Multimedia.Camera.Core 6840 6841**参数:** 6842 6843| 参数名 | 类型 | 必填 | 说明 | 6844| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6845| type | string | 是 | 监听事件,固定为'apertureInfoChange'。 | 6846| callback | AsyncCallback\<[ApertureInfo](#apertureinfo12)\>| 否 | 回调函数,可选,用于匹配on('apertureInfoChange')的callback。 | 6847 6848**错误码:** 6849 6850| 错误码ID | 错误信息 | 6851| ------- | ---------------------- | 6852| 202 | Not System Application. | 6853 6854**示例:** 6855 6856```ts 6857function unregisterApertureInfoEvent(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6858 professionalPhotoSession.off('apertureInfoChange'); 6859} 6860``` 6861 6862### on('luminationInfoChange')<sup>12+</sup> 6863 6864on(type: 'luminationInfoChange', callback: AsyncCallback\<LuminationInfo\>): void 6865 6866监听光照变化事件,通过注册回调函数获取实时光照参数。使用callback异步回调。 6867 6868**系统接口:** 此接口为系统接口。 6869 6870**系统能力:** SystemCapability.Multimedia.Camera.Core 6871 6872**参数:** 6873 6874| 参数名 | 类型 | 必填 | 说明 | 6875| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6876| type | string | 是 | 监听事件,固定为'luminationInfoChange'。 | 6877| callback | AsyncCallback\<[LuminationInfo](#luminationinfo12)\>| 是 | 回调函数,用于获取光照参数。 | 6878 6879**错误码:** 6880 6881| 错误码ID | 错误信息 | 6882| ------- | ---------------------- | 6883| 202 | Not System Application. | 6884 6885**示例:** 6886 6887```ts 6888import { BusinessError } from '@kit.BasicServicesKit'; 6889 6890function luminationInfoCallback(err: BusinessError, info: camera.LuminationInfo): void { 6891 if (err !== undefined && err.code !== 0) { 6892 console.error(`Callback Error, errorCode: ${err.code}`); 6893 return; 6894 } 6895 console.log(`Lumination: ${info.lumination}`); 6896} 6897 6898function registerLuminationInfoEvent(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6899 professionalPhotoSession.on('luminationInfoChange', luminationInfoCallback); 6900} 6901``` 6902 6903### off('luminationInfoChange')<sup>12+</sup> 6904 6905off(type: 'luminationInfoChange', callback?: AsyncCallback\<LuminationInfo\>): void 6906 6907注销监听光照变化事件,通过注册回调函数来注销。 6908 6909**系统接口:** 此接口为系统接口。 6910 6911**系统能力:** SystemCapability.Multimedia.Camera.Core 6912 6913**参数:** 6914 6915| 参数名 | 类型 | 必填 | 说明 | 6916| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6917| type | string | 是 | 监听事件,固定为'luminationInfoChange'。 | 6918| callback | AsyncCallback\<[LuminationInfo](#luminationinfo12)\>| 否 | 回调函数,可选,用于匹配on('luminationInfoChange')的callback。 | 6919 6920**错误码:** 6921 6922| 错误码ID | 错误信息 | 6923| ------- | ---------------------- | 6924| 202 | Not System Application. | 6925 6926**示例:** 6927 6928```ts 6929function unregisterLuminationInfoEvent(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6930 professionalPhotoSession.off('luminationInfoChange'); 6931} 6932``` 6933 6934## ProfessionalVideoSession<sup>12+</sup> 6935 6936ProfessionalVideoSession extends Session, AutoExposure, ManualExposure, Focus, ManualFocus, WhiteBalance, ManualIso, Flash, Zoom, ColorEffect, Aperture 6937 6938专业录像模式会话类,继承自[Session](js-apis-camera.md#session12),用于设置专业录像模式的参数以及保存所需要的所有资源[CameraInput](js-apis-camera.md#camerainput)、[CameraOutput](js-apis-camera.md#cameraoutput)。 6939 6940### on('error')<sup>12+</sup> 6941 6942on(type: 'error', callback: ErrorCallback): void 6943 6944监听专业录像会话的错误事件,通过注册回调函数获取结果。使用callback异步回调。 6945 6946**系统接口:** 此接口为系统接口。 6947 6948**系统能力:** SystemCapability.Multimedia.Camera.Core 6949 6950**参数:** 6951 6952| 参数名 | 类型 | 必填 | 说明 | 6953| -------- | ----------------------------------------------------------- | ---- | ------------------------------ | 6954| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。session调用相关接口出现错误时会触发该事件,比如调用[beginConfig](js-apis-camera.md#beginconfig11),[commitConfig](js-apis-camera.md#commitconfig11-1),[addInput](js-apis-camera.md#addinput11)等接口发生错误时返回错误信息。 | 6955| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 6956 6957**错误码:** 6958 6959以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 6960 6961| 错误码ID | 错误信息 | 6962|---------| --------------- | 6963| 202 | Not System Application. | 6964 6965**示例:** 6966 6967```ts 6968import { BusinessError } from '@kit.BasicServicesKit'; 6969 6970function callback(err: BusinessError): void { 6971 console.error(`Professional video session error code: ${err.code}`); 6972} 6973 6974function registerSessionError(professionalVideoSession: camera.ProfessionalVideoSession): void { 6975 professionalVideoSession.on('error', callback); 6976} 6977``` 6978 6979### off('error')<sup>12+</sup> 6980 6981off(type: 'error', callback?: ErrorCallback): void 6982 6983注销监听专业录像会话的错误事件,通过注册回调函数获取结果。 6984 6985**系统接口:** 此接口为系统接口。 6986 6987**系统能力:** SystemCapability.Multimedia.Camera.Core 6988 6989**参数:** 6990 6991| 参数名 | 类型 | 必填 | 说明 | 6992| -------- | ------------------------ | ---- | ------------------------------ | 6993| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。 | 6994| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 否 | 回调函数,可选,有就是匿名函数。 | 6995 6996**错误码:** 6997 6998以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 6999 7000| 错误码ID | 错误信息 | 7001|---------| --------------- | 7002| 202 | Not System Application. | 7003 7004**示例:** 7005 7006```ts 7007function unregisterSessionError(professionalVideoSession: camera.ProfessionalVideoSession): void { 7008 professionalVideoSession.off('error'); 7009} 7010``` 7011 7012### on('focusStateChange')<sup>12+</sup> 7013 7014on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 7015 7016监听相机对焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 7017 7018**系统接口:** 此接口为系统接口。 7019 7020**系统能力:** SystemCapability.Multimedia.Camera.Core 7021 7022**参数:** 7023 7024| 参数名 | 类型 | 必填 | 说明 | 7025| -------- | ---------------- | ---- | ------------------------ | 7026| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。仅当自动对焦模式时,且相机对焦状态发生改变时可触发该事件。 | 7027| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | 是 | 回调函数,用于获取当前对焦状态。 | 7028 7029**错误码:** 7030 7031以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7032 7033| 错误码ID | 错误信息 | 7034|---------| --------------- | 7035| 202 | Not System Application. | 7036 7037**示例:** 7038 7039```ts 7040import { BusinessError } from '@kit.BasicServicesKit'; 7041 7042function callback(err: BusinessError, focusState: camera.FocusState): void { 7043 if (err !== undefined && err.code !== 0) { 7044 console.error(`Callback Error, errorCode: ${err.code}`); 7045 return; 7046 } 7047 console.info(`Focus state: ${focusState}`); 7048} 7049 7050function registerFocusStateChange(professionalVideoSession: camera.ProfessionalVideoSession): void { 7051 professionalVideoSession.on('focusStateChange', callback); 7052} 7053``` 7054 7055### off('focusStateChange')<sup>12+</sup> 7056 7057off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 7058 7059注销监听相机对焦的状态变化。 7060 7061**系统接口:** 此接口为系统接口。 7062 7063**系统能力:** SystemCapability.Multimedia.Camera.Core 7064 7065**参数:** 7066 7067| 参数名 | 类型 | 必填 | 说明 | 7068| -------- | ----------------------------------------- | ---- | ------------------------ | 7069| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。 | 7070| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | 否 | 回调函数,可选,有就是匹配on('focusStateChange') callback(callback对象不可是匿名函数)。 | 7071 7072**错误码:** 7073 7074以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7075 7076| 错误码ID | 错误信息 | 7077|---------| --------------- | 7078| 202 | Not System Application. | 7079 7080**示例:** 7081 7082```ts 7083function unregisterFocusStateChange(professionalVideoSession: camera.ProfessionalVideoSession): void { 7084 professionalVideoSession.off('focusStateChange'); 7085} 7086``` 7087 7088### on('smoothZoomInfoAvailable')<sup>12+</sup> 7089 7090on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 7091 7092监听相机平滑变焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 7093 7094**系统接口:** 此接口为系统接口。 7095 7096**系统能力:** SystemCapability.Multimedia.Camera.Core 7097 7098**参数:** 7099 7100| 参数名 | 类型 | 必填 | 说明 | 7101| -------- | ----------------------- | ---- | ------------------------ | 7102| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 7103| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | 是 | 回调函数,用于获取当前平滑变焦状态。 | 7104 7105**错误码:** 7106 7107以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7108 7109| 错误码ID | 错误信息 | 7110|---------| --------------- | 7111| 202 | Not System Application. | 7112 7113**示例:** 7114 7115```ts 7116import { BusinessError } from '@kit.BasicServicesKit'; 7117 7118function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 7119 if (err !== undefined && err.code !== 0) { 7120 console.error(`Callback Error, errorCode: ${err.code}`); 7121 return; 7122 } 7123 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 7124} 7125 7126function registerSmoothZoomInfo(professionalVideoSession: camera.ProfessionalVideoSession): void { 7127 professionalVideoSession.on('smoothZoomInfoAvailable', callback); 7128} 7129``` 7130 7131### off('smoothZoomInfoAvailable')<sup>12+</sup> 7132 7133off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 7134 7135注销监听相机平滑变焦的状态变化。 7136 7137**系统接口:** 此接口为系统接口。 7138 7139**系统能力:** SystemCapability.Multimedia.Camera.Core 7140 7141**参数:** 7142 7143| 参数名 | 类型 | 必填 | 说明 | 7144| -------- | ----------------------------------------- | ---- | ------------------------ | 7145| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 7146| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | 否 | 回调函数,可选,有就是匹配on('smoothZoomInfoAvailable') callback(callback对象不可是匿名函数)。 | 7147 7148**错误码:** 7149 7150以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7151 7152| 错误码ID | 错误信息 | 7153|---------| --------------- | 7154| 202 | Not System Application. | 7155 7156**示例:** 7157 7158```ts 7159function unregisterSmoothZoomInfo(professionalVideoSession: camera.ProfessionalVideoSession): void { 7160 professionalVideoSession.off('smoothZoomInfoAvailable'); 7161} 7162``` 7163 7164### on('isoInfoChange')<sup>12+</sup> 7165 7166on(type: 'isoInfoChange', callback: AsyncCallback\<IsoInfo\>): void 7167 7168监听自动ISO变化事件,通过注册回调函数获取实时ISO信息。使用callback异步回调。 7169 7170**系统接口:** 此接口为系统接口。 7171 7172**系统能力:** SystemCapability.Multimedia.Camera.Core 7173 7174**参数:** 7175 7176| 参数名 | 类型 | 必填 | 说明 | 7177| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 7178| type | string | 是 | 监听事件,固定为'isoInfoChange'。 | 7179| callback | AsyncCallback\<[IsoInfo](#isoinfo12)\>| 是 | 回调函数,用于获取ISO信息。 | 7180 7181**错误码:** 7182 7183| 错误码ID | 错误信息 | 7184| ------- | ---------------------- | 7185| 202 | Not System Application. | 7186 7187**示例:** 7188 7189```ts 7190import { BusinessError } from '@kit.BasicServicesKit'; 7191 7192function isoInfoCallback(err: BusinessError, info: camera.IsoInfo): void { 7193 if (err !== undefined && err.code !== 0) { 7194 console.error(`Callback Error, errorCode: ${err.code}`); 7195 return; 7196 } 7197 console.log(`ISO value: ${info.iso}`); 7198} 7199 7200function registerIsoInfoEvent(professionalVideoSession: camera.ProfessionalVideoSession): void { 7201 professionalVideoSession.on('isoInfoChange', isoInfoCallback); 7202} 7203``` 7204 7205### off('isoInfoChange')<sup>12+</sup> 7206 7207off(type: 'isoInfoChange', callback?: AsyncCallback\<IsoInfo\>): void 7208 7209注销监听ISO信息事件,通过注册回调函数来注销。 7210 7211**系统接口:** 此接口为系统接口。 7212 7213**系统能力:** SystemCapability.Multimedia.Camera.Core 7214 7215**参数:** 7216 7217| 参数名 | 类型 | 必填 | 说明 | 7218| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 7219| type | string | 是 | 监听事件,固定为'isoInfoChange'。 | 7220| callback | AsyncCallback\<[IsoInfo](#isoinfo12)\>| 否 | 回调函数,可选,用于匹配on('isoInfoChange')的callback。 | 7221 7222**错误码:** 7223 7224| 错误码ID | 错误信息 | 7225| ------- | ---------------------- | 7226| 202 | Not System Application. | 7227 7228**示例:** 7229 7230```ts 7231function unregisterIsoInfoEvent(professionalVideoSession: camera.ProfessionalVideoSession): void { 7232 professionalVideoSession.off('isoInfoChange'); 7233} 7234``` 7235 7236### on('exposureInfoChange')<sup>12+</sup> 7237 7238on(type: 'exposureInfoChange', callback: AsyncCallback\<ExposureInfo\>): void 7239 7240监听曝光信息事件,通过注册回调函数获取曝光信息。使用callback异步回调。 7241 7242**系统接口:** 此接口为系统接口。 7243 7244**系统能力:** SystemCapability.Multimedia.Camera.Core 7245 7246**参数:** 7247 7248| 参数名 | 类型 | 必填 | 说明 | 7249| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 7250| type | string | 是 | 监听事件,固定为'exposureInfoChange'。 | 7251| callback | AsyncCallback\<[ExposureInfo](#exposureinfo12)\>| 是 | 回调函数,用于获取曝光信息。 | 7252 7253**错误码:** 7254 7255| 错误码ID | 错误信息 | 7256| ------- | ---------------------- | 7257| 202 | Not System Application. | 7258 7259**示例:** 7260 7261```ts 7262import { BusinessError } from '@kit.BasicServicesKit'; 7263 7264function exposureInfoCallback(err: BusinessError, info: camera.ExposureInfo): void { 7265 if (err !== undefined && err.code !== 0) { 7266 console.error(`Callback Error, errorCode: ${err.code}`); 7267 return; 7268 } 7269 console.log(`exposureTimeValue: ${info.exposureTime}`); 7270} 7271 7272function registerExposureInfoEvent(professionalVideoSession: camera.ProfessionalVideoSession): void { 7273 professionalVideoSession.on('exposureInfoChange', exposureInfoCallback); 7274} 7275``` 7276 7277### off('exposureInfoChange')<sup>12+</sup> 7278 7279off(type: 'exposureInfoChange', callback?: AsyncCallback\<ExposureInfo\>): void 7280 7281注销监听曝光信息事件,通过注册回调函数来注销。 7282 7283**系统接口:** 此接口为系统接口。 7284 7285**系统能力:** SystemCapability.Multimedia.Camera.Core 7286 7287**参数:** 7288 7289| 参数名 | 类型 | 必填 | 说明 | 7290| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 7291| type | string | 是 | 监听事件,固定为'exposureInfoChange'。 | 7292| callback | AsyncCallback\<[ExposureInfo](#exposureinfo12)\>| 否 | 回调函数,可选,用于匹配on('exposureInfoChange')的callback。 | 7293 7294**错误码:** 7295 7296| 错误码ID | 错误信息 | 7297| ------- | ---------------------- | 7298| 202 | Not System Application. | 7299 7300**示例:** 7301 7302```ts 7303function unregisterExposureInfoEvent(professionalVideoSession: camera.ProfessionalVideoSession): void { 7304 professionalVideoSession.off('exposureInfoChange'); 7305} 7306``` 7307 7308### on('apertureInfoChange')<sup>12+</sup> 7309 7310on(type: 'apertureInfoChange', callback: AsyncCallback\<ApertureInfo\>): void 7311 7312监听物理光圈变化事件,通过注册回调函数获取物理光圈信息。使用callback异步回调。 7313 7314**系统接口:** 此接口为系统接口。 7315 7316**系统能力:** SystemCapability.Multimedia.Camera.Core 7317 7318**参数:** 7319 7320| 参数名 | 类型 | 必填 | 说明 | 7321| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 7322| type | string | 是 | 监听事件,固定为'apertureInfoChange'。 | 7323| callback | AsyncCallback\<[ApertureInfo](#apertureinfo12)\>| 是 | 回调函数,用于获取物理光圈信息。 | 7324 7325**错误码:** 7326 7327| 错误码ID | 错误信息 | 7328| ------- | ---------------------- | 7329| 202 | Not System Application. | 7330 7331**示例:** 7332 7333```ts 7334import { BusinessError } from '@kit.BasicServicesKit'; 7335 7336function apertureInfoCallback(err: BusinessError, info: camera.ApertureInfo): void { 7337 if (err !== undefined && err.code !== 0) { 7338 console.error(`Callback Error, errorCode: ${err.code}`); 7339 return; 7340 } 7341 console.log(`Aperture value: ${info.aperture}`); 7342} 7343 7344function registerApertureInfoEvent(professionalVideoSession: camera.ProfessionalVideoSession): void { 7345 professionalVideoSession.on('apertureInfoChange', apertureInfoCallback); 7346} 7347``` 7348 7349### off('apertureInfoChange')<sup>12+</sup> 7350 7351off(type: 'apertureInfoChange', callback?: AsyncCallback\<ApertureInfo\>): void 7352 7353注销监听物理光圈变化事件,通过注册回调函数来注销。 7354 7355**系统接口:** 此接口为系统接口。 7356 7357**系统能力:** SystemCapability.Multimedia.Camera.Core 7358 7359**参数:** 7360 7361| 参数名 | 类型 | 必填 | 说明 | 7362| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 7363| type | string | 是 | 监听事件,固定为'apertureInfoChange'。 | 7364| callback | AsyncCallback\<[ApertureInfo](#apertureinfo12)\>| 否 | 回调函数,可选,用于匹配on('apertureInfoChange')的callback。 | 7365 7366**错误码:** 7367 7368| 错误码ID | 错误信息 | 7369| ------- | ---------------------- | 7370| 202 | Not System Application. | 7371 7372**示例:** 7373 7374```ts 7375function unregisterApertureInfoEvent(professionalVideoSession: camera.ProfessionalVideoSession): void { 7376 professionalVideoSession.off('apertureInfoChange'); 7377} 7378``` 7379 7380### on('luminationInfoChange')<sup>12+</sup> 7381 7382on(type: 'luminationInfoChange', callback: AsyncCallback\<LuminationInfo\>): void 7383 7384监听光照变化事件,通过注册回调函数获取光照参数。使用callback异步回调。 7385 7386**系统接口:** 此接口为系统接口。 7387 7388**系统能力:** SystemCapability.Multimedia.Camera.Core 7389 7390**参数:** 7391 7392| 参数名 | 类型 | 必填 | 说明 | 7393| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 7394| type | string | 是 | 监听事件,固定为'luminationInfoChange'。 | 7395| callback | AsyncCallback\<[LuminationInfo](#luminationinfo12)\>| 是 | 回调函数,用于获取光照参数。 | 7396 7397**错误码:** 7398 7399| 错误码ID | 错误信息 | 7400| ------- | ---------------------- | 7401| 202 | Not System Application. | 7402 7403**示例:** 7404 7405```ts 7406import { BusinessError } from '@kit.BasicServicesKit'; 7407 7408function luminationInfoCallback(err: BusinessError, info: camera.LuminationInfo): void { 7409 if (err !== undefined && err.code !== 0) { 7410 console.error(`Callback Error, errorCode: ${err.code}`); 7411 return; 7412 } 7413 console.log(`Lumination: ${info.lumination}`); 7414} 7415 7416function registerLuminationInfoEvent(professionalVideoSession: camera.ProfessionalVideoSession): void { 7417 professionalVideoSession.on('luminationInfoChange', luminationInfoCallback); 7418} 7419``` 7420 7421### off('luminationInfoChange')<sup>12+</sup> 7422 7423off(type: 'luminationInfoChange', callback?: AsyncCallback\<LuminationInfo\>): void 7424 7425注销监听光照变化事件,通过注册回调函数来注销。 7426 7427**系统接口:** 此接口为系统接口。 7428 7429**系统能力:** SystemCapability.Multimedia.Camera.Core 7430 7431**参数:** 7432 7433| 参数名 | 类型 | 必填 | 说明 | 7434| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 7435| type | string | 是 | 监听事件,固定为'luminationInfoChange'。 | 7436| callback | AsyncCallback\<[LuminationInfo](#luminationinfo12)\>| 否 | 回调函数,可选,用于匹配on('luminationInfoChange')的callback。 | 7437 7438**错误码:** 7439 7440| 错误码ID | 错误信息 | 7441| ------- | ---------------------- | 7442| 202 | Not System Application. | 7443 7444**示例:** 7445 7446```ts 7447function unregisterLuminationInfoEvent(professionalVideoSession: camera.ProfessionalVideoSession): void { 7448 professionalVideoSession.off('luminationInfoChange'); 7449} 7450``` 7451 7452## MacroPhotoSession<sup>12+</sup> 7453 7454MacroPhotoSession extends Session, Flash, AutoExposure, Focus, Zoom, ColorEffect, ManualFocus 7455 7456微距拍照模式会话类,继承自[Session](js-apis-camera.md#session11),用于设置微距拍照模式的参数以及保存所需要的所有资源[CameraInput](js-apis-camera.md#camerainput)、[CameraOutput](js-apis-camera.md#cameraoutput)。 7457 7458### on('error')<sup>12+</sup> 7459 7460on(type: 'error', callback: ErrorCallback): void 7461 7462监听微距拍照会话的错误事件,通过注册回调函数获取结果。使用callback异步回调。 7463 7464**系统接口:** 此接口为系统接口。 7465 7466**系统能力:** SystemCapability.Multimedia.Camera.Core 7467 7468**参数:** 7469 7470| 参数名 | 类型 | 必填 | 说明 | 7471|----------|---------------------------------------------------------------------------|-----|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------| 7472| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。session调用相关接口出现错误时会触发该事件,比如调用[beginConfig](js-apis-camera.md#beginconfig11),[commitConfig](js-apis-camera.md#commitconfig11-1),[addInput](js-apis-camera.md#addinput11)等接口发生错误时返回错误信息。 | 7473| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 7474 7475**错误码:** 7476 7477以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7478 7479| 错误码ID | 错误信息 | 7480|-------|----------------------------| 7481| 202 | Not System Application. | 7482 7483**示例:** 7484 7485```ts 7486import { BusinessError } from '@kit.BasicServicesKit'; 7487 7488function callback(err: BusinessError): void { 7489 console.error(`MacroPhotoSession error code: ${err.code}`); 7490} 7491 7492function registerSessionError(macroPhotoSession: camera.MacroPhotoSession): void { 7493 macroPhotoSession.on('error', callback); 7494} 7495``` 7496 7497### off('error')<sup>12+</sup> 7498 7499off(type: 'error', callback?: ErrorCallback): void 7500 7501注销监听微距拍照会话的错误事件,通过注册回调函数获取结果。 7502 7503**系统接口:** 此接口为系统接口。 7504 7505**系统能力:** SystemCapability.Multimedia.Camera.Core 7506 7507**参数:** 7508 7509| 参数名 | 类型 | 必填 | 说明 | 7510|----------|---------------------------------------------------------------------------|----|-------------------------------------------------------------| 7511| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。 | 7512| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | 否 | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 | 7513 7514**错误码:** 7515 7516以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7517 7518| 错误码ID | 错误信息 | 7519|-------|----------------------------| 7520| 202 | Not System Application. | 7521 7522**示例:** 7523 7524```ts 7525function unregisterSessionError(macroPhotoSession: camera.MacroPhotoSession): void { 7526 macroPhotoSession.off('error'); 7527} 7528``` 7529 7530### on('focusStateChange')<sup>12+</sup> 7531 7532on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 7533 7534监听相机对焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 7535 7536**系统接口:** 此接口为系统接口。 7537 7538**系统能力:** SystemCapability.Multimedia.Camera.Core 7539 7540**参数:** 7541 7542| 参数名 | 类型 | 必填 | 说明 | 7543|-----------|---------------------------------------------|----|-------------------------------------------------------------------------| 7544| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。仅当自动对焦模式时,且相机对焦状态发生改变时可触发该事件。 | 7545| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | 是 | 回调函数,用于获取当前对焦状态。 | 7546 7547**错误码:** 7548 7549以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7550 7551| 错误码ID | 错误信息 | 7552|-------|----------------------------| 7553| 202 | Not System Application. | 7554 7555**示例:** 7556 7557```ts 7558import { BusinessError } from '@kit.BasicServicesKit'; 7559 7560function callback(err: BusinessError, focusState: camera.FocusState): void { 7561 if (err !== undefined && err.code !== 0) { 7562 console.error(`Callback Error, errorCode: ${err.code}`); 7563 return; 7564 } 7565 console.info(`Focus state: ${focusState}`); 7566} 7567 7568function registerFocusStateChange(macroPhotoSession: camera.MacroPhotoSession): void { 7569 macroPhotoSession.on('focusStateChange', callback); 7570} 7571``` 7572 7573### off('focusStateChange')<sup>12+</sup> 7574 7575off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 7576 7577注销监听相机对焦的状态变化。 7578 7579**系统接口:** 此接口为系统接口。 7580 7581**系统能力:** SystemCapability.Multimedia.Camera.Core 7582 7583**参数:** 7584 7585| 参数名 | 类型 | 必填 | 说明 | 7586|-----------|---------------------------------------------|----|--------------------------------------------------------------| 7587| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。 | 7588| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | 否 | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 | 7589 7590**错误码:** 7591 7592以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7593 7594| 错误码ID | 错误信息 | 7595|-------|----------------------------| 7596| 202 | Not System Application. | 7597 7598**示例:** 7599 7600```ts 7601function unregisterFocusStateChange(macroPhotoSession: camera.MacroPhotoSession): void { 7602 macroPhotoSession.off('focusStateChange'); 7603} 7604``` 7605 7606### on('smoothZoomInfoAvailable')<sup>12+</sup> 7607 7608on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 7609 7610监听相机平滑变焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 7611 7612**系统接口:** 此接口为系统接口。 7613 7614**系统能力:** SystemCapability.Multimedia.Camera.Core 7615 7616**参数:** 7617 7618| 参数名 | 类型 | 必填 | 说明 | 7619| -------- | ----------------------- | ---- | ------------------------ | 7620| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 7621| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | 是 | 回调函数,用于获取当前平滑变焦状态。 | 7622 7623**错误码:** 7624 7625以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7626 7627| 错误码ID | 错误信息 | 7628|-------|----------------------------| 7629| 202 | Not System Application. | 7630 7631**示例:** 7632 7633```ts 7634import { BusinessError } from '@kit.BasicServicesKit'; 7635 7636function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 7637 if (err !== undefined && err.code !== 0) { 7638 console.error(`Callback Error, errorCode: ${err.code}`); 7639 return; 7640 } 7641 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 7642} 7643 7644function registerSmoothZoomInfo(macroPhotoSession: camera.MacroPhotoSession): void { 7645 macroPhotoSession.on('smoothZoomInfoAvailable', callback); 7646} 7647``` 7648 7649### off('smoothZoomInfoAvailable')<sup>12+</sup> 7650 7651off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 7652 7653注销监听相机平滑变焦的状态变化。 7654 7655**系统接口:** 此接口为系统接口。 7656 7657**系统能力:** SystemCapability.Multimedia.Camera.Core 7658 7659**参数:** 7660 7661| 参数名 | 类型 | 必填 | 说明 | 7662| -------- | ----------------------------------------- | ---- | ------------------------ | 7663| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 7664| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | 否 | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 | 7665 7666**错误码:** 7667 7668以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7669 7670| 错误码ID | 错误信息 | 7671|-------|----------------------------| 7672| 202 | Not System Application. | 7673 7674**示例:** 7675 7676```ts 7677function unregisterSmoothZoomInfo(macroPhotoSession: camera.MacroPhotoSession): void { 7678 macroPhotoSession.off('smoothZoomInfoAvailable'); 7679} 7680``` 7681 7682## MacroVideoSession<sup>12+</sup> 7683 7684MacroVideoSession extends Session, Flash, AutoExposure, Focus, Zoom, ColorEffect, ManualFocus 7685 7686微距录像模式会话类,继承自[Session](js-apis-camera.md#session11),用于设置微距录像模式的参数以及保存所需要的所有资源[CameraInput](js-apis-camera.md#camerainput)、[CameraOutput](js-apis-camera.md#cameraoutput)。 7687 7688### on('error')<sup>12+</sup> 7689 7690on(type: 'error', callback: ErrorCallback): void 7691 7692监听微距录像会话的错误事件,通过注册回调函数获取结果。使用callback异步回调。 7693 7694**系统接口:** 此接口为系统接口。 7695 7696**系统能力:** SystemCapability.Multimedia.Camera.Core 7697 7698**参数:** 7699 7700| 参数名 | 类型 | 必填 | 说明 | 7701|----------|---------------------------------------------------------------------------|-----|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------| 7702| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。session调用相关接口出现错误时会触发该事件,比如调用[beginConfig](js-apis-camera.md#beginconfig11),[commitConfig](js-apis-camera.md#commitconfig11-1),[addInput](js-apis-camera.md#addinput11)等接口发生错误时返回错误信息。 | 7703| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 7704 7705**错误码:** 7706 7707以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7708 7709| 错误码ID | 错误信息 | 7710|-------|----------------------------| 7711| 202 | Not System Application. | 7712 7713**示例:** 7714 7715```ts 7716import { BusinessError } from '@kit.BasicServicesKit'; 7717 7718function callback(err: BusinessError): void { 7719 console.error(`MacroPhotoSession error code: ${err.code}`); 7720} 7721 7722function registerSessionError(macroVideoSession: camera.MacroVideoSession): void { 7723 macroVideoSession.on('error', callback); 7724} 7725``` 7726 7727### off('error')<sup>12+</sup> 7728 7729off(type: 'error', callback?: ErrorCallback): void 7730 7731注销监听微距录像会话的错误事件,通过注册回调函数获取结果。 7732 7733**系统接口:** 此接口为系统接口。 7734 7735**系统能力:** SystemCapability.Multimedia.Camera.Core 7736 7737**参数:** 7738 7739| 参数名 | 类型 | 必填 | 说明 | 7740|----------|---------------------------------------------------------------------------|----|-------------------------------------------------------------| 7741| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。 | 7742| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | 否 | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 | 7743 7744**错误码:** 7745 7746以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7747 7748| 错误码ID | 错误信息 | 7749|-------|----------------------------| 7750| 202 | Not System Application. | 7751 7752**示例:** 7753 7754```ts 7755function unregisterSessionError(macroVideoSession: camera.MacroVideoSession): void { 7756 macroVideoSession.off('error'); 7757} 7758``` 7759 7760### on('focusStateChange')<sup>12+</sup> 7761 7762on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 7763 7764监听相机对焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 7765 7766**系统接口:** 此接口为系统接口。 7767 7768**系统能力:** SystemCapability.Multimedia.Camera.Core 7769 7770**参数:** 7771 7772| 参数名 | 类型 | 必填 | 说明 | 7773|-----------|---------------------------------------------|----|-------------------------------------------------------------------------| 7774| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。仅当自动对焦模式时,且相机对焦状态发生改变时可触发该事件。 | 7775| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | 是 | 回调函数,用于获取当前对焦状态。 | 7776 7777**错误码:** 7778 7779以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7780 7781| 错误码ID | 错误信息 | 7782|-------|----------------------------| 7783| 202 | Not System Application. | 7784 7785**示例:** 7786 7787```ts 7788import { BusinessError } from '@kit.BasicServicesKit'; 7789 7790function callback(err: BusinessError, focusState: camera.FocusState): void { 7791 if (err !== undefined && err.code !== 0) { 7792 console.error(`Callback Error, errorCode: ${err.code}`); 7793 return; 7794 } 7795 console.info(`Focus state: ${focusState}`); 7796} 7797 7798function registerFocusStateChange(macroVideoSession: camera.MacroVideoSession): void { 7799 macroVideoSession.on('focusStateChange', callback); 7800} 7801``` 7802 7803### off('focusStateChange')<sup>12+</sup> 7804 7805off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 7806 7807注销监听相机对焦的状态变化。 7808 7809**系统接口:** 此接口为系统接口。 7810 7811**系统能力:** SystemCapability.Multimedia.Camera.Core 7812 7813**参数:** 7814 7815| 参数名 | 类型 | 必填 | 说明 | 7816|-----------|---------------------------------------------|----|--------------------------------------------------------------| 7817| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。 | 7818| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | 否 | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 | 7819 7820**错误码:** 7821 7822以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7823 7824| 错误码ID | 错误信息 | 7825|-------|----------------------------| 7826| 202 | Not System Application. | 7827 7828**示例:** 7829 7830```ts 7831function unregisterFocusStateChange(macroVideoSession: camera.MacroVideoSession): void { 7832 macroVideoSession.off('focusStateChange'); 7833} 7834``` 7835 7836### on('smoothZoomInfoAvailable')<sup>12+</sup> 7837 7838on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 7839 7840监听相机平滑变焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 7841 7842**系统接口:** 此接口为系统接口。 7843 7844**系统能力:** SystemCapability.Multimedia.Camera.Core 7845 7846**参数:** 7847 7848| 参数名 | 类型 | 必填 | 说明 | 7849| -------- | ----------------------- | ---- | ------------------------ | 7850| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 7851| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | 是 | 回调函数,用于获取当前平滑变焦状态。 | 7852 7853**错误码:** 7854 7855以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7856 7857| 错误码ID | 错误信息 | 7858|-------|----------------------------| 7859| 202 | Not System Application. | 7860 7861**示例:** 7862 7863```ts 7864import { BusinessError } from '@kit.BasicServicesKit'; 7865 7866function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 7867 if (err !== undefined && err.code !== 0) { 7868 console.error(`Callback Error, errorCode: ${err.code}`); 7869 return; 7870 } 7871 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 7872} 7873 7874function registerSmoothZoomInfo(macroVideoSession: camera.MacroVideoSession): void { 7875 macroVideoSession.on('smoothZoomInfoAvailable', callback); 7876} 7877``` 7878 7879### off('smoothZoomInfoAvailable')<sup>12+</sup> 7880 7881off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 7882 7883注销监听相机平滑变焦的状态变化。 7884 7885**系统接口:** 此接口为系统接口。 7886 7887**系统能力:** SystemCapability.Multimedia.Camera.Core 7888 7889**参数:** 7890 7891| 参数名 | 类型 | 必填 | 说明 | 7892| -------- | ----------------------------------------- | ---- | ------------------------ | 7893| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 7894| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | 否 | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 | 7895 7896**错误码:** 7897 7898以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7899 7900| 错误码ID | 错误信息 | 7901|-------|----------------------------| 7902| 202 | Not System Application. | 7903 7904**示例:** 7905 7906```ts 7907function unregisterSmoothZoomInfo(macroVideoSession: camera.MacroVideoSession): void { 7908 macroVideoSession.off('smoothZoomInfoAvailable'); 7909} 7910``` 7911 7912## FlashQuery<sup>12+</sup> 7913 7914此接口提供了查阅设备闪光灯信息相应的方法,包括是否支持lcd闪光灯。 7915 7916### isLcdFlashSupported<sup>12+</sup> 7917 7918isLcdFlashSupported(): boolean 7919 7920查询是否支持lcd闪光灯。 7921 7922**系统接口:** 此接口为系统接口。 7923 7924**系统能力:** SystemCapability.Multimedia.Camera.Core 7925 7926**返回值:** 7927 7928| 类型 | 说明 | 7929| -------------- | ----------------------- | 7930| boolean | 查询是否支持lcd闪光灯,返回true为支持,返回false为不支持。| 7931 7932**错误码:** 7933 7934以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7935 7936| 错误码ID | 错误信息 | 7937| --------------- | --------------- | 7938| 202 | Not System Application. | 7939| 7400103 | Session not config, only throw in session usage. | 7940 7941**示例:** 7942 7943```ts 7944function isLcdFlashSupported(nightPhotoSession: camera.NightPhotoSession): boolean { 7945 return nightPhotoSession.isLcdFlashSupported(); 7946} 7947``` 7948 7949## Flash<sup>11+</sup> 7950 7951Flash extends [FlashQuery](js-apis-camera.md#flashquery12) 7952 7953闪光灯类,对设备闪光灯操作。 7954 7955### enableLcdFlash<sup>13+</sup> 7956 7957enableLcdFlash(enabled: boolean): void 7958 7959使能或去使能LCD闪光灯。 7960 7961进行设置之前,需要先检查:设备是否支持LCD闪光灯,可使用方法[isLcdFlashSupported](#islcdflashsupported12)。 7962 7963**系统能力:** SystemCapability.Multimedia.Camera.Core 7964 7965**参数:** 7966 7967| 参数名 | 类型 | 必填 | 说明 | 7968| --------- | ----------------------- | ---- |--------------------------------------------------| 7969| enabled | boolean | 是 | 使能或去使能LCD闪光灯,true为使能,false为去使能。传参为null或者undefined,作为0处理,去使能LCD闪光灯。 | 7970 7971**错误码:** 7972 7973以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7974 7975| 错误码ID | 错误信息 | 7976| --------------- | --------------- | 7977| 7400103 | Session not config. | 7978 7979**示例:** 7980 7981```ts 7982import { BusinessError } from '@kit.BasicServicesKit'; 7983 7984function enableLcdFlash(session: camera.PhotoSessionForSys | camera.VideoSessionForSys | camera.NightPhotoSession): void { 7985 try { 7986 session.enableLcdFlash(true); 7987 } catch (error) { 7988 // 失败返回错误码error.code并处理。 7989 let err = error as BusinessError; 7990 console.error(`The setFlashMode call failed. error code: ${err.code}`); 7991 } 7992} 7993``` 7994 7995## TimeLapseRecordState<sup>12+</sup> 7996 7997枚举,延时摄影录制状态。 7998 7999**系统接口:** 此接口为系统接口。 8000 8001**系统能力:** SystemCapability.Multimedia.Camera.Core 8002 8003| 名称 | 值 | 说明 | 8004| ----------------------------- | ---- | ----------- | 8005| IDLE | 0 | 未录制 | 8006| RECORDING | 1 | 录制中 | 8007 8008## TimeLapsePreviewType<sup>12+</sup> 8009 8010枚举,延时摄影预览类型,影响拍摄算法。 8011 8012**系统接口:** 此接口为系统接口。 8013 8014**系统能力:** SystemCapability.Multimedia.Camera.Core 8015 8016| 名称 | 值 | 说明 | 8017| ----------------------------- | ---- | ----------- | 8018| DARK | 1 | 暗光环境,指光照较差的场景,比如夜晚或暗处。 | 8019| LIGHT | 2 | 亮光环境,指光照较好的场景,比如白天或灯光下。 | 8020 8021## TryAEInfo<sup>12+</sup> 8022 8023TryAE参数信息,TryAE是指延时摄影时硬件会根据环境光照变化上报状态的操作。 8024 8025**系统接口:** 此接口为系统接口。 8026 8027**系统能力:** SystemCapability.Multimedia.Camera.Core 8028 8029| 名称 | 类型 | 只读 | 可选 | 说明 | 8030| ---- | ------- | ---- |--| -------------- | 8031| isTryAEDone | boolean | 是 | 否 | TryAE是否完成。 | 8032| isTryAEHintNeeded | boolean | 是 | 是 | 是否需要TryAE。 | 8033| previewType | [TimeLapsePreviewType](#timelapsepreviewtype12) | 是 | 是 | 预览类型。 | 8034| captureInterval | number | 是 | 是 | 拍摄间隔,单位毫秒(ms)。 | 8035 8036## TimeLapsePhotoSession<sup>12+</sup> 8037 8038TimeLapsePhotoSession extends Session, Focus, ManualFocus, AutoExposure, ManualExposure, ManualIso, WhiteBalance, Zoom, ColorEffect 8039 8040延时摄影会话类,继承自[Session](js-apis-camera.md#session12),用于设置延时摄影会话的参数以及保存所需要的所有资源[CameraInput](js-apis-camera.md#camerainput)、[CameraOutput](js-apis-camera.md#cameraoutput)。 8041 8042### on('error')<sup>12+</sup> 8043 8044on(type: 'error', callback: ErrorCallback): void 8045 8046监听延时摄影会话的错误事件,通过注册回调函数获取结果。使用callback异步回调。 8047 8048**系统接口:** 此接口为系统接口。 8049 8050**系统能力:** SystemCapability.Multimedia.Camera.Core 8051 8052**参数:** 8053 8054| 参数名 | 类型 | 必填 | 说明 | 8055| -------- | ----------------------------------------------------------- | ---- | ------------------------------ | 8056| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。session调用相关接口出现错误时会触发该事件,比如调用[beginConfig](js-apis-camera.md#beginconfig11),[commitConfig](js-apis-camera.md#commitconfig11-1),[addInput](js-apis-camera.md#addinput11)等接口发生错误时返回错误信息。 | 8057| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 8058 8059**错误码:** 8060 8061以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8062 8063| 错误码ID | 错误信息 | 8064|---------| --------------- | 8065| 202 | Not System Application. | 8066 8067**示例:** 8068 8069```ts 8070import { BusinessError } from '@kit.BasicServicesKit'; 8071 8072function callback(err: BusinessError): void { 8073 console.error(`Time lapse photo session error code: ${err.code}`); 8074} 8075 8076function registerSessionError(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8077 timeLapsePhotoSession.on('error', callback); 8078} 8079``` 8080 8081### off('error')<sup>12+</sup> 8082 8083off(type: 'error', callback?: ErrorCallback): void 8084 8085注销监听延时摄影会话的错误事件,通过注册回调函数获取结果。 8086 8087**系统接口:** 此接口为系统接口。 8088 8089**系统能力:** SystemCapability.Multimedia.Camera.Core 8090 8091**参数:** 8092 8093| 参数名 | 类型 | 必填 | 说明 | 8094| -------- | ------------------------ | ---- | ------------------------------ | 8095| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。 | 8096| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 否 | 回调函数,可选,有就是匿名函数。 | 8097 8098**错误码:** 8099 8100以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8101 8102| 错误码ID | 错误信息 | 8103|---------| --------------- | 8104| 202 | Not System Application. | 8105 8106**示例:** 8107 8108```ts 8109function unregisterSessionError(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8110 timeLapsePhotoSession.off('error'); 8111} 8112``` 8113 8114### on('focusStateChange')<sup>12+</sup> 8115 8116on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 8117 8118监听相机对焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 8119 8120**系统接口:** 此接口为系统接口。 8121 8122**系统能力:** SystemCapability.Multimedia.Camera.Core 8123 8124**参数:** 8125 8126| 参数名 | 类型 | 必填 | 说明 | 8127| -------- | ---------------- | ---- | ------------------------ | 8128| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。仅当自动对焦模式时,且相机对焦状态发生改变时可触发该事件。 | 8129| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | 是 | 回调函数,用于获取当前对焦状态。 | 8130 8131**错误码:** 8132 8133以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8134 8135| 错误码ID | 错误信息 | 8136|---------| --------------- | 8137| 202 | Not System Application. | 8138 8139**示例:** 8140 8141```ts 8142import { BusinessError } from '@kit.BasicServicesKit'; 8143 8144function callback(err: BusinessError, focusState: camera.FocusState): void { 8145 if (err !== undefined && err.code !== 0) { 8146 console.error(`Callback Error, errorCode: ${err.code}`); 8147 return; 8148 } 8149 console.info(`Focus state: ${focusState}`); 8150} 8151 8152function registerFocusStateChange(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8153 timeLapsePhotoSession.on('focusStateChange', callback); 8154} 8155``` 8156 8157### off('focusStateChange')<sup>12+</sup> 8158 8159off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 8160 8161注销监听相机对焦的状态变化。 8162 8163**系统接口:** 此接口为系统接口。 8164 8165**系统能力:** SystemCapability.Multimedia.Camera.Core 8166 8167**参数:** 8168 8169| 参数名 | 类型 | 必填 | 说明 | 8170| -------- | ----------------------------------------- | ---- | ------------------------ | 8171| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。 | 8172| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | 否 | 回调函数,可选,有就是匹配on('focusStateChange') callback(callback对象不可是匿名函数)。 | 8173 8174**错误码:** 8175 8176以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8177 8178| 错误码ID | 错误信息 | 8179|---------| --------------- | 8180| 202 | Not System Application. | 8181 8182**示例:** 8183 8184```ts 8185function unregisterFocusStateChange(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8186 timeLapsePhotoSession.off('focusStateChange'); 8187} 8188``` 8189 8190### on('isoInfoChange')<sup>12+</sup> 8191 8192on(type: 'isoInfoChange', callback: AsyncCallback\<IsoInfo\>): void 8193 8194监听自动ISO变化事件,通过注册回调函数获取实时ISO信息。使用callback异步回调。 8195 8196**系统接口:** 此接口为系统接口。 8197 8198**系统能力:** SystemCapability.Multimedia.Camera.Core 8199 8200**参数:** 8201 8202| 参数名 | 类型 | 必填 | 说明 | 8203| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 8204| type | string | 是 | 监听事件,固定为'isoInfoChange'。 | 8205| callback | AsyncCallback\<[IsoInfo](#isoinfo12)\>| 是 | 回调函数,用于获取ISO信息。 | 8206 8207**错误码:** 8208 8209| 错误码ID | 错误信息 | 8210| ------- | ---------------------- | 8211| 202 | Not System Application. | 8212 8213**示例:** 8214 8215```ts 8216import { BusinessError } from '@kit.BasicServicesKit'; 8217 8218function isoInfoCallback(err: BusinessError, info: camera.IsoInfo): void { 8219 if (err !== undefined && err.code !== 0) { 8220 console.error(`Callback Error, errorCode: ${err.code}`); 8221 return; 8222 } 8223 console.log(`ISO value: ${info.iso}`); 8224} 8225 8226function registerIsoInfoEvent(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8227 timeLapsePhotoSession.on('isoInfoChange', isoInfoCallback); 8228} 8229``` 8230 8231### off('isoInfoChange')<sup>12+</sup> 8232 8233off(type: 'isoInfoChange', callback?: AsyncCallback\<IsoInfo\>): void 8234 8235注销监听ISO信息事件,通过注册回调函数来注销。 8236 8237**系统接口:** 此接口为系统接口。 8238 8239**系统能力:** SystemCapability.Multimedia.Camera.Core 8240 8241**参数:** 8242 8243| 参数名 | 类型 | 必填 | 说明 | 8244| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 8245| type | string | 是 | 监听事件,固定为'isoInfoChange'。 | 8246| callback | AsyncCallback\<[IsoInfo](#isoinfo12)\>| 否 | 回调函数,可选,用于匹配on('isoInfoChange')的callback。 | 8247 8248**错误码:** 8249 8250| 错误码ID | 错误信息 | 8251| ------- | ---------------------- | 8252| 202 | Not System Application. | 8253 8254**示例:** 8255 8256```ts 8257function unregisterIsoInfoEvent(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8258 timeLapsePhotoSession.off('isoInfoChange'); 8259} 8260``` 8261 8262### on('exposureInfoChange')<sup>12+</sup> 8263 8264on(type: 'exposureInfoChange', callback: AsyncCallback\<ExposureInfo\>): void 8265 8266监听曝光信息事件,通过注册回调函数获取曝光信息。使用callback异步回调。 8267 8268**系统接口:** 此接口为系统接口。 8269 8270**系统能力:** SystemCapability.Multimedia.Camera.Core 8271 8272**参数:** 8273 8274| 参数名 | 类型 | 必填 | 说明 | 8275| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 8276| type | string | 是 | 监听事件,固定为'exposureInfoChange'。 | 8277| callback | AsyncCallback\<[ExposureInfo](#exposureinfo12)\>| 是 | 回调函数,用于获取曝光信息。 | 8278 8279**错误码:** 8280 8281| 错误码ID | 错误信息 | 8282| ------- | ---------------------- | 8283| 202 | Not System Application. | 8284 8285**示例:** 8286 8287```ts 8288import { BusinessError } from '@kit.BasicServicesKit'; 8289 8290function exposureInfoCallback(err: BusinessError, info: camera.ExposureInfo): void { 8291 if (err !== undefined && err.code !== 0) { 8292 console.error(`Callback Error, errorCode: ${err.code}`); 8293 return; 8294 } 8295 console.log(`exposureTimeValue: ${info.exposureTime}`); 8296} 8297 8298function registerExposureInfoEvent(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8299 timeLapsePhotoSession.on('exposureInfoChange', exposureInfoCallback); 8300} 8301``` 8302 8303### off('exposureInfoChange')<sup>12+</sup> 8304 8305off(type: 'exposureInfoChange', callback?: AsyncCallback\<ExposureInfo\>): void 8306 8307注销监听曝光信息事件,通过注册回调函数来注销。 8308 8309**系统接口:** 此接口为系统接口。 8310 8311**系统能力:** SystemCapability.Multimedia.Camera.Core 8312 8313**参数:** 8314 8315| 参数名 | 类型 | 必填 | 说明 | 8316| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 8317| type | string | 是 | 监听事件,固定为'exposureInfoChange'。 | 8318| callback | AsyncCallback\<[ExposureInfo](#exposureinfo12)\>| 否 | 回调函数,可选,用于匹配on('exposureInfoChange')的callback。 | 8319 8320**错误码:** 8321 8322| 错误码ID | 错误信息 | 8323| ------- | ---------------------- | 8324| 202 | Not System Application. | 8325 8326**示例:** 8327 8328```ts 8329function unregisterExposureInfoEvent(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8330 timeLapsePhotoSession.off('exposureInfoChange'); 8331} 8332``` 8333 8334### on('luminationInfoChange')<sup>12+</sup> 8335 8336on(type: 'luminationInfoChange', callback: AsyncCallback\<LuminationInfo\>): void 8337 8338监听光照变化事件,通过注册回调函数获取实时光照参数。使用callback异步回调。 8339 8340**系统接口:** 此接口为系统接口。 8341 8342**系统能力:** SystemCapability.Multimedia.Camera.Core 8343 8344**参数:** 8345 8346| 参数名 | 类型 | 必填 | 说明 | 8347| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 8348| type | string | 是 | 监听事件,固定为'luminationInfoChange'。 | 8349| callback | AsyncCallback\<[LuminationInfo](#luminationinfo12)\>| 是 | 回调函数,用于获取光照参数。 | 8350 8351**错误码:** 8352 8353| 错误码ID | 错误信息 | 8354| ------- | ---------------------- | 8355| 202 | Not System Application. | 8356 8357**示例:** 8358 8359```ts 8360import { BusinessError } from '@kit.BasicServicesKit'; 8361 8362function luminationInfoCallback(err: BusinessError, info: camera.LuminationInfo): void { 8363 if (err !== undefined && err.code !== 0) { 8364 console.error(`Callback Error, errorCode: ${err.code}`); 8365 return; 8366 } 8367 console.log(`Lumination: ${info.lumination}`); 8368} 8369 8370function registerLuminationInfoEvent(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8371 timeLapsePhotoSession.on('luminationInfoChange', luminationInfoCallback); 8372} 8373``` 8374 8375### off('luminationInfoChange')<sup>12+</sup> 8376 8377off(type: 'luminationInfoChange', callback?: AsyncCallback\<LuminationInfo\>): void 8378 8379注销监听光照变化事件,通过注册回调函数来注销。 8380 8381**系统接口:** 此接口为系统接口。 8382 8383**系统能力:** SystemCapability.Multimedia.Camera.Core 8384 8385**参数:** 8386 8387| 参数名 | 类型 | 必填 | 说明 | 8388| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 8389| type | string | 是 | 监听事件,固定为'luminationInfoChange'。 | 8390| callback | AsyncCallback\<[LuminationInfo](#luminationinfo12)\>| 否 | 回调函数,可选,用于匹配on('luminationInfoChange')的callback。 | 8391 8392**错误码:** 8393 8394| 错误码ID | 错误信息 | 8395| ------- | ---------------------- | 8396| 202 | Not System Application. | 8397 8398**示例:** 8399 8400```ts 8401function unregisterLuminationInfoEvent(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8402 timeLapsePhotoSession.off('luminationInfoChange'); 8403} 8404``` 8405 8406### on('tryAEInfoChange')<sup>12+</sup> 8407 8408on(type: 'tryAEInfoChange', callback: AsyncCallback\<TryAEInfo\>): void 8409 8410监听TryAE变化事件,通过注册回调函数获取实时TryAE参数。使用callback异步回调。 8411 8412**系统接口:** 此接口为系统接口。 8413 8414**系统能力:** SystemCapability.Multimedia.Camera.Core 8415 8416**参数:** 8417 8418| 参数名 | 类型 | 必填 | 说明 | 8419| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 8420| type | string | 是 | 监听事件,固定为'tryAEInfoChange'。 | 8421| callback | AsyncCallback\<[TryAEInfo](#tryaeinfo12)\>| 是 | 回调函数,用于获取TryAE参数。 | 8422 8423**错误码:** 8424 8425| 错误码ID | 错误信息 | 8426| ------- | ---------------------- | 8427| 202 | Not System Application. | 8428 8429**示例:** 8430 8431```ts 8432import { BusinessError } from '@kit.BasicServicesKit'; 8433 8434function tryAEInfoCallback(err: BusinessError, info: camera.TryAEInfo): void { 8435 if (err !== undefined && err.code !== 0) { 8436 console.error(`Callback Error, errorCode: ${err.code}`); 8437 return; 8438 } 8439 console.log(`TryAEInfo: ${info.isTryAEDone}, ${info.isTryAEHintNeeded}, ${info.previewType}, ${info.captureInterval}`); 8440} 8441 8442function registerTryAEInfoEvent(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8443 timeLapsePhotoSession.on('tryAEInfoChange', tryAEInfoCallback); 8444} 8445``` 8446 8447### off('tryAEInfoChange')<sup>12+</sup> 8448 8449off(type: 'tryAEInfoChange', callback?: AsyncCallback\<TryAEInfo\>): void 8450 8451注销监听TryAE变化事件,通过注册回调函数来注销。 8452 8453**系统接口:** 此接口为系统接口。 8454 8455**系统能力:** SystemCapability.Multimedia.Camera.Core 8456 8457**参数:** 8458 8459| 参数名 | 类型 | 必填 | 说明 | 8460| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 8461| type | string | 是 | 监听事件,固定为'tryAEInfoChange'。 | 8462| callback | AsyncCallback\<[TryAEInfo](#tryaeinfo12)\>| 否 | 回调函数,可选,用于匹配on('tryAEInfoChange')的callback。 | 8463 8464**错误码:** 8465 8466| 错误码ID | 错误信息 | 8467| ------- | ---------------------- | 8468| 202 | Not System Application. | 8469 8470**示例:** 8471 8472```ts 8473function unregisterTryAEInfoEvent(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8474 timeLapsePhotoSession.off('tryAEInfoChange'); 8475} 8476``` 8477 8478### isTryAENeeded<sup>12+</sup> 8479 8480isTryAENeeded(): boolean 8481 8482判断是否需要执行TryAE。 8483 8484**系统接口:** 此接口为系统接口。 8485 8486**系统能力:** SystemCapability.Multimedia.Camera.Core 8487 8488**返回值:** 8489 8490| 类型 | 说明 | 8491| ---------- | ----------------------------- | 8492| boolean | 是否需要执行TryAE,返回true为是,返回false为否,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 8493 8494**错误码:** 8495 8496以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8497 8498| 错误码ID | 错误信息 | 8499| --------------- | --------------- | 8500| 202 | Not System Application. | 8501| 7400103 | Session not config. | 8502 8503**示例:** 8504 8505```ts 8506import { BusinessError } from '@kit.BasicServicesKit'; 8507 8508function isTryAENeeded(timeLapsePhotoSession: camera.TimeLapsePhotoSession): boolean { 8509 let needed = false; 8510 try { 8511 needed = timeLapsePhotoSession.isTryAENeeded(); 8512 } catch (error) { 8513 // 失败返回错误码error.code并处理。 8514 let err = error as BusinessError; 8515 console.error(`The isTryAENeeded call failed. error code: ${err.code}`); 8516 } 8517 return needed; 8518} 8519``` 8520 8521### startTryAE<sup>12+</sup> 8522 8523startTryAE(): void 8524 8525开始执行TryAE。 8526 8527**系统接口:** 此接口为系统接口。 8528 8529**系统能力:** SystemCapability.Multimedia.Camera.Core 8530 8531**错误码:** 8532 8533以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8534 8535| 错误码ID | 错误信息 | 8536| --------------- | --------------- | 8537| 202 | Not System Application. | 8538| 7400103 | Session not config. | 8539 8540**示例:** 8541 8542```ts 8543import { BusinessError } from '@kit.BasicServicesKit'; 8544 8545function startTryAE(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8546 try { 8547 timeLapsePhotoSession.startTryAE(); 8548 } catch (error) { 8549 // 失败返回错误码error.code并处理。 8550 let err = error as BusinessError; 8551 console.error(`The startTryAE call failed. error code: ${err.code}`); 8552 } 8553} 8554``` 8555 8556### stopTryAE<sup>12+</sup> 8557 8558stopTryAE(): void 8559 8560停止执行TryAE。 8561 8562**系统接口:** 此接口为系统接口。 8563 8564**系统能力:** SystemCapability.Multimedia.Camera.Core 8565 8566**错误码:** 8567 8568以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8569 8570| 错误码ID | 错误信息 | 8571| --------------- | --------------- | 8572| 202 | Not System Application. | 8573| 7400103 | Session not config. | 8574 8575**示例:** 8576 8577```ts 8578import { BusinessError } from '@kit.BasicServicesKit'; 8579 8580function stopTryAE(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8581 try { 8582 timeLapsePhotoSession.stopTryAE(); 8583 } catch (error) { 8584 // 失败返回错误码error.code并处理。 8585 let err = error as BusinessError; 8586 console.error(`The stopTryAE call failed. error code: ${err.code}`); 8587 } 8588} 8589``` 8590 8591### getSupportedTimeLapseIntervalRange<sup>12+</sup> 8592 8593getSupportedTimeLapseIntervalRange(): Array\<number\> 8594 8595获取支持的拍摄间隔范围。 8596 8597**系统接口:** 此接口为系统接口。 8598 8599**系统能力:** SystemCapability.Multimedia.Camera.Core 8600 8601**返回值:** 8602 8603| 类型 | 说明 | 8604| ---------- | ----------------------------- | 8605| Array\<number\> | 用于获取拍摄间隔范围,单位毫秒(ms),根据底层能力返回为准,接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 8606 8607**错误码:** 8608 8609以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8610 8611| 错误码ID | 错误信息 | 8612| --------------- | --------------- | 8613| 202 | Not System Application. | 8614| 7400103 | Session not config. | 8615 8616**示例:** 8617 8618```ts 8619import { BusinessError } from '@kit.BasicServicesKit'; 8620 8621function getSupportedTimeLapseIntervalRange(timeLapsePhotoSession: camera.TimeLapsePhotoSession): Array<number> { 8622 let intervalRange: Array<number> = []; 8623 try { 8624 intervalRange = timeLapsePhotoSession.getSupportedTimeLapseIntervalRange(); 8625 } catch (error) { 8626 // 失败返回错误码error.code并处理。 8627 let err = error as BusinessError; 8628 console.error(`The getSupportedTimeLapseIntervalRange call failed. error code: ${err.code}`); 8629 } 8630 return intervalRange; 8631} 8632``` 8633 8634### getTimeLapseInterval<sup>12+</sup> 8635 8636getTimeLapseInterval(): number 8637 8638获取当前的拍摄间隔值。 8639 8640**系统接口:** 此接口为系统接口。 8641 8642**系统能力:** SystemCapability.Multimedia.Camera.Core 8643 8644**返回值:** 8645 8646| 类型 | 说明 | 8647| ---------- | ----------------------------- | 8648| number | 返回当前拍摄间隔值,单位毫秒(ms)。 | 8649 8650**错误码:** 8651 8652以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8653 8654| 错误码ID | 错误信息 | 8655| --------------- | --------------- | 8656| 202 | Not System Application. | 8657| 7400103 | Session not config. | 8658 8659**示例:** 8660 8661```ts 8662import { BusinessError } from '@kit.BasicServicesKit'; 8663 8664function getTimeLapseInterval(timeLapsePhotoSession: camera.TimeLapsePhotoSession): number { 8665 let interval: number = 0; 8666 try { 8667 interval = timeLapsePhotoSession.getTimeLapseInterval(); 8668 } catch (error) { 8669 // 失败返回错误码error.code并处理。 8670 let err = error as BusinessError; 8671 console.error(`The getTimeLapseInterval call failed. error code: ${err.code}`); 8672 } 8673 return interval; 8674} 8675``` 8676 8677### setTimeLapseInterval<sup>12+</sup> 8678setTimeLapseInterval(interval: number): void 8679 8680设置拍摄间隔值。 8681 8682**系统接口:** 此接口为系统接口。 8683 8684**系统能力:** SystemCapability.Multimedia.Camera.Core 8685 8686**参数:** 8687 8688| 参数名 | 类型 | 必填 | 说明 | 8689| -------- | ----------------------- | ---- | ------------------- | 8690| interval | number | 是 | 设置拍摄间隔值,单位毫秒(ms)。 | 8691 8692**错误码:** 8693 8694以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8695 8696| 错误码ID | 错误信息 | 8697| --------------- | --------------- | 8698| 202 | Not System Application. | 8699| 7400101 | Parameter missing or parameter type incorrect. | 8700| 7400103 | Session not config. | 8701 8702**示例:** 8703 8704```ts 8705import { BusinessError } from '@kit.BasicServicesKit'; 8706 8707function setTimeLapseInterval(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8708 try { 8709 let interval: number = 10000; 8710 timeLapsePhotoSession.setTimeLapseInterval(interval); 8711 } catch (error) { 8712 // 失败返回错误码error.code并处理。 8713 let err = error as BusinessError; 8714 console.error(`The setTimeLapseInterval call failed. error code: ${err.code}`); 8715 } 8716} 8717``` 8718 8719### getTimeLapseRecordState<sup>12+</sup> 8720 8721getTimeLapseRecordState(): TimeLapseRecordState 8722 8723获取当前拍摄状态。 8724 8725**系统接口:** 此接口为系统接口。 8726 8727**系统能力:** SystemCapability.Multimedia.Camera.Core 8728 8729**返回值:** 8730 8731| 类型 | 说明 | 8732| ---------- | ----------------------------- | 8733| [TimeLapseRecordState](#timelapserecordstate12) | 获取当前拍摄状态。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 8734 8735**错误码:** 8736 8737以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8738 8739| 错误码ID | 错误信息 | 8740| --------------- | --------------- | 8741| 202 | Not System Application. | 8742| 7400103 | Session not config. | 8743 8744**示例:** 8745 8746```ts 8747import { BusinessError } from '@kit.BasicServicesKit'; 8748 8749function getTimeLapseRecordState(timeLapsePhotoSession: camera.TimeLapsePhotoSession): camera.TimeLapseRecordState { 8750 let state = camera.TimeLapseRecordState.IDLE; 8751 try { 8752 state = timeLapsePhotoSession.getTimeLapseRecordState(); 8753 } catch (error) { 8754 // 失败返回错误码error.code并处理。 8755 let err = error as BusinessError; 8756 console.error(`The getTimeLapseRecordState call failed. error code: ${err.code}`); 8757 } 8758 return state; 8759} 8760``` 8761 8762### setTimeLapseRecordState<sup>12+</sup> 8763 8764setTimeLapseRecordState(state: TimeLapseRecordState): void 8765 8766设置当前拍摄状态。 8767 8768**系统接口:** 此接口为系统接口。 8769 8770**系统能力:** SystemCapability.Multimedia.Camera.Core 8771 8772**参数:** 8773 8774| 参数名 | 类型 | 必填 | 说明 | 8775| -------- | -------------------------------| ---- | ----------------------- | 8776| state | [TimeLapseRecordState](#timelapserecordstate12) | 是 | 拍摄状态。 | 8777 8778**错误码:** 8779 8780以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8781 8782| 错误码ID | 错误信息 | 8783| --------------- | --------------- | 8784| 202 | Not System Application. | 8785| 7400101 | Parameter missing or parameter type incorrect. | 8786| 7400103 | Session not config. | 8787 8788**示例:** 8789 8790```ts 8791import { BusinessError } from '@kit.BasicServicesKit'; 8792 8793function setTimeLapseRecordState(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8794 try { 8795 timeLapsePhotoSession.setTimeLapseRecordState(camera.TimeLapseRecordState.RECORDING); 8796 } catch (error) { 8797 // 失败返回错误码error.code并处理。 8798 let err = error as BusinessError; 8799 console.error(`The setTimeLapseRecordState call failed. error code: ${err.code}`); 8800 } 8801} 8802``` 8803 8804### getTimeLapsePreviewType<sup>12+</sup> 8805 8806getTimeLapsePreviewType(): TimeLapsePreviewType 8807 8808获取当前预览类型。 8809 8810**系统接口:** 此接口为系统接口。 8811 8812**系统能力:** SystemCapability.Multimedia.Camera.Core 8813 8814**返回值:** 8815 8816| 类型 | 说明 | 8817| ---------- | ----------------------------- | 8818| [TimeLapsePreviewType](#timelapsepreviewtype12) | 获取当前预览类型。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 8819 8820**错误码:** 8821 8822以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8823 8824| 错误码ID | 错误信息 | 8825| --------------- | --------------- | 8826| 202 | Not System Application. | 8827| 7400103 | Session not config. | 8828 8829**示例:** 8830 8831```ts 8832import { BusinessError } from '@kit.BasicServicesKit'; 8833 8834function getTimeLapsePreviewType(timeLapsePhotoSession: camera.TimeLapsePhotoSession): camera.TimeLapsePreviewType { 8835 let type = camera.TimeLapsePreviewType.DARK; 8836 try { 8837 type = timeLapsePhotoSession.getTimeLapsePreviewType(); 8838 } catch (error) { 8839 // 失败返回错误码error.code并处理。 8840 let err = error as BusinessError; 8841 console.error(`The getTimeLapsePreviewType call failed. error code: ${err.code}`); 8842 } 8843 return type; 8844} 8845``` 8846 8847### setTimeLapsePreviewType<sup>12+</sup> 8848 8849setTimeLapsePreviewType(type: TimeLapsePreviewType): void 8850 8851设置当前预览类型。 8852 8853**系统接口:** 此接口为系统接口。 8854 8855**系统能力:** SystemCapability.Multimedia.Camera.Core 8856 8857**参数:** 8858 8859| 参数名 | 类型 | 必填 | 说明 | 8860| -------- | -------------------------------| ---- | ----------------------- | 8861| state | [TimeLapsePreviewType](#timelapsepreviewtype12) | 是 | 预览类型。 | 8862 8863**错误码:** 8864 8865以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8866 8867| 错误码ID | 错误信息 | 8868| --------------- | --------------- | 8869| 202 | Not System Application. | 8870| 7400101 | Parameter missing or parameter type incorrect. | 8871| 7400103 | Session not config. | 8872 8873**示例:** 8874 8875```ts 8876import { BusinessError } from '@kit.BasicServicesKit'; 8877 8878function setTimeLapsePreviewType(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8879 try { 8880 timeLapsePhotoSession.setTimeLapsePreviewType(camera.TimeLapsePreviewType.LIGHT); 8881 } catch (error) { 8882 // 失败返回错误码error.code并处理。 8883 let err = error as BusinessError; 8884 console.error(`The setTimeLapsePreviewType call failed. error code: ${err.code}`); 8885 } 8886} 8887``` 8888 8889## LightPaintingPhotoSession<sup>12+</sup> 8890 8891LightPaintingPhotoSession extends Session, Flash, Focus, Zoom, ColorEffect 8892 8893流光快门拍照模式会话类,继承自[Session](js-apis-camera.md#session11),用于设置流光快门拍照模式的参数以及保存所需要的所有资源[CameraInput](js-apis-camera.md#camerainput)、[CameraOutput](js-apis-camera.md#cameraoutput)。 8894 8895### on('error')<sup>12+</sup> 8896 8897on(type: 'error', callback: ErrorCallback): void 8898 8899监听流光快门拍照会话的错误事件,通过注册回调函数获取结果。使用callback异步回调。 8900 8901**系统接口:** 此接口为系统接口。 8902 8903**系统能力:** SystemCapability.Multimedia.Camera.Core 8904 8905**参数:** 8906 8907| 参数名 | 类型 | 必填 | 说明 | 8908|----------|---------------------------------------------------------------------------|-----|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------| 8909| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。session调用相关接口出现错误时会触发该事件,比如调用[beginConfig](js-apis-camera.md#beginconfig11),[commitConfig](js-apis-camera.md#commitconfig11-1),[addInput](js-apis-camera.md#addinput11)等接口发生错误时返回错误信息。 | 8910| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](js-apis-camera.md#cameraerrorcode)。 | 8911 8912**错误码:** 8913 8914以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8915 8916| 错误码ID | 错误信息 | 8917|-------|----------------------------| 8918| 202 | Not System Application. | 8919 8920**示例:** 8921 8922```ts 8923import { BusinessError } from '@kit.BasicServicesKit'; 8924 8925function callback(err: BusinessError): void { 8926 console.error(`LightPaintingPhotoSession error code: ${err.code}`); 8927} 8928 8929function registerSessionError(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): void { 8930 lightPaintingPhotoSession.on('error', callback); 8931} 8932``` 8933 8934### off('error')<sup>12+</sup> 8935 8936off(type: 'error', callback?: ErrorCallback): void 8937 8938注销监听流光快门拍照会话的错误事件,通过注册回调函数获取结果。 8939 8940**系统接口:** 此接口为系统接口。 8941 8942**系统能力:** SystemCapability.Multimedia.Camera.Core 8943 8944**参数:** 8945 8946| 参数名 | 类型 | 必填 | 说明 | 8947|----------|---------------------------------------------------------------------------|----|-------------------------------------------------------------| 8948| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。 | 8949| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | 否 | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 | 8950 8951**错误码:** 8952 8953以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8954 8955| 错误码ID | 错误信息 | 8956|-------|----------------------------| 8957| 202 | Not System Application. | 8958 8959**示例:** 8960 8961```ts 8962function unregisterSessionError(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): void { 8963 lightPaintingPhotoSession.off('error'); 8964} 8965``` 8966 8967### on('focusStateChange')<sup>12+</sup> 8968 8969on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 8970 8971监听相机对焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 8972 8973**系统接口:** 此接口为系统接口。 8974 8975**系统能力:** SystemCapability.Multimedia.Camera.Core 8976 8977**参数:** 8978 8979| 参数名 | 类型 | 必填 | 说明 | 8980|-----------|---------------------------------------------|----|-------------------------------------------------------------------------| 8981| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。仅当自动对焦模式时,且相机对焦状态发生改变时可触发该事件。 | 8982| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | 是 | 回调函数,用于获取当前对焦状态。 | 8983 8984**错误码:** 8985 8986以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8987 8988| 错误码ID | 错误信息 | 8989|-------|----------------------------| 8990| 202 | Not System Application. | 8991 8992**示例:** 8993 8994```ts 8995import { BusinessError } from '@kit.BasicServicesKit'; 8996 8997function callback(err: BusinessError, focusState: camera.FocusState): void { 8998 if (err !== undefined && err.code !== 0) { 8999 console.error(`Callback Error, errorCode: ${err.code}`); 9000 return; 9001 } 9002 console.info(`Focus state: ${focusState}`); 9003} 9004 9005function registerFocusStateChange(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): void { 9006 lightPaintingPhotoSession.on('focusStateChange', callback); 9007} 9008``` 9009 9010### off('focusStateChange')<sup>12+</sup> 9011 9012off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 9013 9014注销监听相机对焦的状态变化。 9015 9016**系统接口:** 此接口为系统接口。 9017 9018**系统能力:** SystemCapability.Multimedia.Camera.Core 9019 9020**参数:** 9021 9022| 参数名 | 类型 | 必填 | 说明 | 9023|-----------|---------------------------------------------|----|--------------------------------------------------------------| 9024| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。 | 9025| callback | AsyncCallback\<[FocusState](js-apis-camera.md#focusstate)\> | 否 | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 | 9026 9027**错误码:** 9028 9029以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 9030 9031| 错误码ID | 错误信息 | 9032|-------|----------------------------| 9033| 202 | Not System Application. | 9034 9035**示例:** 9036 9037```ts 9038function unregisterFocusStateChange(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): void { 9039 lightPaintingPhotoSession.off('focusStateChange'); 9040} 9041``` 9042 9043### on('smoothZoomInfoAvailable')<sup>12+</sup> 9044 9045on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 9046 9047监听相机平滑变焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 9048 9049**系统接口:** 此接口为系统接口。 9050 9051**系统能力:** SystemCapability.Multimedia.Camera.Core 9052 9053**参数:** 9054 9055| 参数名 | 类型 | 必填 | 说明 | 9056| -------- | ----------------------- | ---- | ------------------------ | 9057| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 9058| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | 是 | 回调函数,用于获取当前平滑变焦状态。 | 9059 9060**错误码:** 9061 9062以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 9063 9064| 错误码ID | 错误信息 | 9065|-------|----------------------------| 9066| 202 | Not System Application. | 9067 9068**示例:** 9069 9070```ts 9071import { BusinessError } from '@kit.BasicServicesKit'; 9072 9073function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 9074 if (err !== undefined && err.code !== 0) { 9075 console.error(`Callback Error, errorCode: ${err.code}`); 9076 return; 9077 } 9078 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 9079} 9080 9081function registerSmoothZoomInfo(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): void { 9082 lightPaintingPhotoSession.on('smoothZoomInfoAvailable', callback); 9083} 9084``` 9085 9086### off('smoothZoomInfoAvailable')<sup>12+</sup> 9087 9088off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 9089 9090注销监听相机平滑变焦的状态变化。 9091 9092**系统接口:** 此接口为系统接口。 9093 9094**系统能力:** SystemCapability.Multimedia.Camera.Core 9095 9096**参数:** 9097 9098| 参数名 | 类型 | 必填 | 说明 | 9099| -------- | ----------------------------------------- | ---- | ------------------------ | 9100| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 9101| callback | AsyncCallback\<[SmoothZoomInfo](js-apis-camera.md#smoothzoominfo11)\> | 否 | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 | 9102 9103**错误码:** 9104 9105以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 9106 9107| 错误码ID | 错误信息 | 9108|-------|----------------------------| 9109| 202 | Not System Application. | 9110 9111**示例:** 9112 9113```ts 9114function unregisterSmoothZoomInfo(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): void { 9115 lightPaintingPhotoSession.off('smoothZoomInfoAvailable'); 9116} 9117``` 9118 9119### getLightPaintingType<sup>12+</sup> 9120 9121getLightPaintingType(): LightPaintingType 9122 9123获取当前生效的流光快门模式类型。 9124 9125**系统接口:** 此接口为系统接口。 9126 9127**系统能力:** SystemCapability.Multimedia.Camera.Core 9128 9129**返回值:** 9130| 类型 | 说明 | 9131|------------------------------------------------- | --------------------- | 9132| [LightPaintingType](#lightpaintingtype12) | 流光快门模式类型。 | 9133 9134**错误码:** 9135 9136以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 9137 9138| 错误码ID | 错误信息 | 9139| --------------- | --------------- | 9140| 202 | Not System Application. | 9141| 7400103 | Session not config. | 9142 9143**示例:** 9144 9145```ts 9146function getLightPaintingType(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): camera.LightPaintingType { 9147 let type: camera.LightPaintingType = lightPaintingPhotoSession.getLightPaintingType(); 9148 return type; 9149} 9150``` 9151 9152### setLightPaintingType<sup>12+</sup> 9153 9154setLightPaintingType(type: LightPaintingType): void 9155 9156设置当前生效的流光快门模式类型。 9157 9158**系统接口:** 此接口为系统接口。 9159 9160**系统能力:** SystemCapability.Multimedia.Camera.Core 9161 9162**返回值:** 9163| 参数名 | 类型 | 必填 | 说明 | 9164| -------- | ----------------------- | ---- | ------------------- | 9165| type | [LightPaintingType](#lightpaintingtype12) | 是 | 设置流光快门模式的类型。 | 9166 9167**错误码:** 9168 9169以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 9170 9171| 错误码ID | 错误信息 | 9172| --------------- | --------------- | 9173| 202 | Not System Application. | 9174| 7400101 | Parameter missing or parameter type incorrect. | 9175| 7400103 | Session not config. | 9176 9177**示例:** 9178 9179```ts 9180import { BusinessError } from '@kit.BasicServicesKit'; 9181 9182function setLightPaintingType(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): void { 9183 try { 9184 let type: camera.LightPaintingType = camera.LightPaintingType.TRAFFIC_TRAILS; 9185 lightPaintingPhotoSession.setLightPaintingType(type); 9186 } catch (error) { 9187 // 失败返回错误码error.code并处理。 9188 let err = error as BusinessError; 9189 console.error(`The setLightPaintingType call failed. error code: ${err.code}`); 9190 } 9191} 9192``` 9193 9194### getSupportedLightPaintingTypes<sup>12+</sup> 9195 9196getSupportedLightPaintingTypes(): Array\<LightPaintingType\> 9197 9198获取当前支持的流光快门模式类型。 9199 9200**系统接口:** 此接口为系统接口。 9201 9202**系统能力:** SystemCapability.Multimedia.Camera.Core 9203 9204**返回值:** 9205| 类型 | 说明 | 9206|------------------------------------------------- | --------------------- | 9207| Array\<[LightPaintingType](#lightpaintingtype12)\> | 支持的流光快门模式类型。 | 9208 9209**错误码:** 9210 9211以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 9212 9213| 错误码ID | 错误信息 | 9214| --------------- | --------------- | 9215| 202 | Not System Application. | 9216| 7400103 | Session not config. | 9217 9218**示例:** 9219 9220```ts 9221function getSupportedLightPaintingTypes(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): Array<camera.LightPaintingType> { 9222 let types: Array<camera.LightPaintingType> = lightPaintingPhotoSession.getSupportedLightPaintingTypes(); 9223 return types 9224} 9225``` 9226 9227## ColorReservationType<sup>15+</sup> 9228 9229枚举,色彩保留类型。 9230 9231**系统能力**: SystemCapability.Multimedia.Camera.Core 9232 9233| 名称 | 值 | 说明 | 9234| -------- | ---- | ---------------- | 9235| NONE | 0 | 无色彩保留效果。 | 9236| PORTRAIT | 1 | 人像留色。 | 9237 9238## ColorReservationQuery<sup>15+</sup> 9239 9240提供了查询设备支持的色彩保留类型的功能。 9241 9242### getSupportedColorReservationTypes<sup>15+</sup> 9243 9244getSupportedColorReservationTypes(): Array\<ColorReservationType\> 9245 9246获取支持的色彩保留类型列表。 9247 9248**系统接口**: 此接口为系统接口。 9249 9250**系统能力**: SystemCapability.Multimedia.Camera.Core 9251 9252**返回值**: 9253 9254| 类型 | 说明 | 9255| ------------------------------------------------------ | ------------------------ | 9256| Array<[ColorReservationType](#colorreservationtype15)> | 支持的色彩保留类型列表。 | 9257 9258**错误码**: 9259 9260以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 9261 9262| 错误码ID | 错误信息 | 9263| -------- | ----------------------- | 9264| 202 | Not System Application. | 9265| 7400103 | Session not config. | 9266 9267**示例**: 9268 9269```ts 9270import { BusinessError } from '@kit.BasicServicesKit'; 9271 9272function getSupportedColorReservationTypes(session: camera.VideoSessionForSys): Array<camera.ColorReservationType> { 9273 let colorReservationTypes: Array<camera.ColorReservationType> = []; 9274 try { 9275 colorReservationTypes = session.getSupportedColorReservationTypes(); 9276 } catch (error) { 9277 // 失败返回错误码error.code并处理。 9278 let err = error as BusinessError; 9279 console.error(`The getSupportedColorReservationTypes call failed. error code: ${err.code}`); 9280 } 9281 return colorReservationTypes; 9282} 9283``` 9284 9285## ColorReservation<sup>15+</sup> 9286 9287ColorReservation extends [ColorReservationQuery](#colorreservationquery15) 9288 9289提供了获取和设置相机色彩保留类型的方法。 9290 9291### setColorReservation<sup>15+</sup> 9292 9293setColorReservation(type: ColorReservationType): void 9294 9295设置色彩保留类型。可以先通过[getSupportedColorReservationTypes](#getsupportedcolorreservationtypes15)获取当前设备所支持的ColorReservationType。 9296 9297**系统接口**: 此接口为系统接口。 9298 9299**系统能力**: SystemCapability.Multimedia.Camera.Core 9300 9301**参数**: 9302 9303| 参数名 | 类型 | 必填 | 说明 | 9304| ------ | ----------------------------------------------- | ---- | ------------------------------------------------------------ | 9305| type | [ColorReservationType](#colorreservationtype15) | 是 | 色彩保留类型,通过[getSupportedColorReservationTypes](#getsupportedcolorreservationtypes15)接口获取。 | 9306 9307**错误码**: 9308 9309以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 9310 9311| 错误码ID | 错误信息 | 9312| -------- | ------------------------------------------------------------ | 9313| 202 | Not System Application. | 9314| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3.Parameter verification failed. | 9315| 7400102 | Operation not allowed. | 9316| 7400103 | Session not config. | 9317| 7400201 | Camera service fatal error. | 9318 9319**示例**: 9320 9321```ts 9322import { BusinessError } from '@kit.BasicServicesKit'; 9323 9324function setColorReservation(session: camera.VideoSessionForSys, type: camera.ColorReservationType): void { 9325 try { 9326 session.setColorReservation(type); 9327 } catch (error) { 9328 // 失败返回错误码error.code并处理。 9329 let err = error as BusinessError; 9330 console.error(`The setColorReservation call failed. error code: ${err.code}`); 9331 } 9332} 9333``` 9334 9335### getColorReservation<sup>15+</sup> 9336 9337getColorReservation(): ColorReservationType 9338 9339获取当前设置的色彩保留类型。 9340 9341**系统接口**: 此接口为系统接口。 9342 9343**系统能力**: SystemCapability.Multimedia.Camera.Core 9344 9345**返回值**: 9346 9347| 类型 | 说明 | 9348| ----------------------------------------------- | ------------------------ | 9349| [ColorReservationType](#colorreservationtype15) | 当前设置的色彩保留类型。 | 9350 9351**错误码**: 9352 9353以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 9354 9355| 错误码ID | 错误信息 | 9356| -------- | ----------------------- | 9357| 202 | Not System Application. | 9358| 7400103 | Session not config. | 9359 9360**示例**: 9361 9362```ts 9363import { BusinessError } from '@kit.BasicServicesKit'; 9364 9365function getColorReservation(session: camera.VideoSessionForSys): camera.ColorReservationType | undefined { 9366 let colorReservation: camera.ColorReservationType | undefined = undefined; 9367 try { 9368 colorReservation = session.getColorReservation(); 9369 } catch (error) { 9370 // 失败返回错误码error.code并处理。 9371 let err = error as BusinessError; 9372 console.error(`The setColorReservation call failed. error code: ${err.code}`); 9373 } 9374 return colorReservation; 9375} 9376``` 9377