1# @ohos.multimedia.camera (相机管理)(系统接口) 2<!--Kit: Camera Kit--> 3<!--Subsystem: Multimedia--> 4<!--Owner: @qano--> 5<!--Designer: @leo_ysl--> 6<!--Tester: @xchaosioda--> 7<!--Adviser: @zengyawen--> 8 9本模块为开发者提供一套简单且易于理解的相机服务接口,开发者通过调用接口可以开发相机应用。应用通过访问和操作相机硬件,实现基础操作,如预览、拍照和录像;还可以通过接口组合完成更多操作,如控制闪光灯和曝光时间、对焦或调焦等。 10 11> **说明:** 12> 13> - 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 14> - 当前页面仅包含本模块的系统接口,其他公开接口参见[@ohos.multimedia.camera (相机管理)](arkts-apis-camera.md)。 15 16## 导入模块 17 18```ts 19import { camera } from '@kit.CameraKit'; 20``` 21 22## SceneMode<sup>11+</sup> 23 24枚举,相机支持模式。 25 26**系统能力:** SystemCapability.Multimedia.Camera.Core 27 28| 名称 | 值 | 说明 | 29| ----------------------- | --------- | ------------ | 30| PORTRAIT_PHOTO | 3 | 人像拍照模式。**系统接口:** 此接口为系统接口。 | 31| NIGHT_PHOTO | 4 | 夜景拍照模式。**系统接口:** 此接口为系统接口。 | 32| PROFESSIONAL_PHOTO<sup>12+</sup> | 5 | 专业拍照模式。**系统接口:** 此接口为系统接口。 | 33| PROFESSIONAL_VIDEO<sup>12+</sup> | 6 | 专业录像模式。**系统接口:** 此接口为系统接口。 | 34| SLOW_MOTION_VIDEO<sup>12+</sup> | 7 | 慢动作模式。**系统接口:** 此接口为系统接口。 | 35| MACRO_PHOTO<sup>12+</sup> | 8 | 微距拍照模式。**系统接口:** 此接口为系统接口。 | 36| MACRO_VIDEO<sup>12+</sup> | 9 | 微距录像模式。**系统接口:** 此接口为系统接口。 | 37| LIGHT_PAINTING_PHOTO<sup>12+</sup> | 10 | 光绘摄影模式。**系统接口:** 此接口为系统接口。 | 38| HIGH_RESOLUTION_PHOTO<sup>12+</sup> | 11 | 高像素拍照模式。 **系统接口:** 此接口为系统接口。 | 39| QUICK_SHOT_PHOTO<sup>12+</sup> | 13 | 闪拍模式。**系统接口:** 此接口为系统接口。 | 40| APERTURE_VIDEO<sup>12+</sup> | 14 | 大光圈录像模式。**系统接口:** 此接口为系统接口。 | 41| PANORAMA_PHOTO<sup>12+</sup> | 15 | 全景拍照模式。 **系统接口:** 此接口为系统接口。 | 42| TIME_LAPSE_PHOTO<sup>12+</sup> | 16 | 延时摄影模式。 **系统接口:** 此接口为系统接口。 | 43| FLUORESCENCE_PHOTO<sup>13+</sup> | 17 | 荧光图片模式。**系统接口:** 此接口为系统接口。 | 44 45## SlowMotionStatus<sup>12+</sup> 46 47枚举,慢动作状态。 48 49**系统能力:** SystemCapability.Multimedia.Camera.Core 50 51| 名称 | 值 | 说明 | 52|----------------|-----|---------------| 53| DISABLED | 0 | 慢动作关闭状态。 | 54| READY | 1 | 慢动作就绪状态。 | 55| VIDEO_START | 2 | 慢动作视频开始状态。 | 56| VIDEO_DONE | 3 | 慢动作视频完成状态。 | 57| FINISHED | 4 | 慢动作结束状态。 | 58 59## LcdFlashStatus<sup>12+</sup> 60 61lcd闪光灯信息项。 62 63**系统接口:** 此接口为系统接口。 64 65**系统能力:** SystemCapability.Multimedia.Camera.Core 66 67| 名称 | 类型 | 只读 | 可选 | 说明 | 68| -------- | ----------------------------- |---- |-----| ------------- | 69| isLcdFlashNeeded | boolean | 是 | 否 | 是否需要lcd闪光灯,true为需要,false为不需要。 | 70| lcdCompensation | number | 是 | 否 | lcd闪光灯补偿值。 | 71 72## Photo<sup>11+</sup> 73 74全质量图对象。 75 76**系统接口:** 此接口为系统接口。 77 78**系统能力:** SystemCapability.Multimedia.Camera.Core 79 80| 名称 | 类型 | 只读 | 可选 | 说明 | 81| ------ | ----------------------------- |-----| ---------- | ---------- | 82| raw<sup>12+</sup> | [image.Image](../apis-image-kit/arkts-apis-image-Image.md)| NA | 是 | raw图。 | 83 84## ExposureMode 85 86枚举,曝光模式。 87 88**系统接口:** 此接口为系统接口。 89 90**系统能力:** SystemCapability.Multimedia.Camera.Core 91 92| 名称 | 值 | 说明 | 93| ----------------------------- |-----|---------| 94| EXPOSURE_MODE_MANUAL<sup>12+</sup> | 3 | 手动曝光模式。 | 95 96## PolicyType<sup>12+</sup> 97 98枚举,策略类型。 99 100**系统接口:** 此接口为系统接口。 101 102**系统能力:** SystemCapability.Multimedia.Camera.Core 103 104| 名称 | 值 | 说明 | 105| ----------------------------- |-----|---------| 106| PRIVACY<sup>12+</sup> | 1 | 隐私类型。 | 107 108## LightPaintingType<sup>12+</sup> 109 110枚举,流光快门模式类型。 111 112**系统接口:** 此接口为系统接口。 113 114**系统能力:** SystemCapability.Multimedia.Camera.Core 115 116| 名称 | 值 | 说明 | 117| ----------------------------- |-----|---------| 118| TRAFFIC_TRAILS | 0 | 车水马龙。 | 119| STAR_TRAILS | 1 | 绚丽星轨。 | 120| SILKY_WATER | 2 | 丝绢流水。 | 121| LIGHT_GRAFFITI | 3 | 光绘涂鸦。 | 122 123## CameraManager 124 125相机管理器类,使用前需要通过[getCameraManager](arkts-apis-camera-f.md#cameragetcameramanager)获取相机管理实例。 126 127### createDepthDataOutput<sup>13+</sup> 128 129createDepthDataOutput(profile: DepthProfile): DepthDataOutput 130 131创建深度输出对象,同步返回结果。 132 133**系统接口:** 此接口为系统接口。 134 135**系统能力:** SystemCapability.Multimedia.Camera.Core 136 137**参数:** 138 139| 参数名 | 类型 | 必填 | 说明 | 140| -------- | ----------------------------------------------- | ---- | ------------------------------- | 141| profile | [DepthProfile](#depthprofile13) | 是 | 支持的预览配置信息,通过[getSupportedOutputCapability](arkts-apis-camera-CameraManager.md#getsupportedoutputcapability11)接口获取。| 142 143**返回值:** 144 145| 类型 | 说明 | 146| ---------- | ----------------------------- | 147| [DepthDataOutput](#depthdataoutput13) | DepthDataOutput实例。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。 | 148 149**错误码:** 150 151以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)和[通用错误码说明文档](../errorcode-universal.md)。 152 153| 错误码ID | 错误信息 | 154| --------------- | --------------- | 155| 202 | Not System Application. | 156| 7400101 | Parameter missing or parameter type incorrect. | 157| 7400201 | Camera service fatal error. | 158 159**示例:** 160 161```ts 162import { BusinessError } from '@kit.BasicServicesKit'; 163 164function createDepthDataOutput(cameraOutputCapability: camera.CameraOutputCapability, cameraManager: camera.CameraManager): camera.DepthDataOutput | undefined { 165 let profile: camera.DepthProfile = cameraOutputCapability.depthProfiles[0]; 166 let depthDataOutput: camera.DepthDataOutput | undefined = undefined; 167 try { 168 depthDataOutput = cameraManager.createDepthDataOutput(profile); 169 } catch (error) { 170 // 失败返回错误码error.code并处理。 171 let err = error as BusinessError; 172 console.error(`The createDepthDataOutput call failed. error code: ${err.code}`); 173 } 174 return depthDataOutput; 175} 176``` 177 178### isCameraMuteSupported 179 180isCameraMuteSupported(): boolean 181 182查询当前设备是否支持禁用相机。 183 184**系统接口:** 此接口为系统接口。 185 186**系统能力:** SystemCapability.Multimedia.Camera.Core 187 188**返回值:** 189 190| 类型 | 说明 | 191| ---------- | ----------------------------- | 192| boolean | 返回true表示相机可以被禁用,返回false表示相机不能被禁用。 | 193 194**错误码:** 195 196以下错误码的详细介绍请参见[通用错误码说明文档](../errorcode-universal.md)。 197 198| 错误码ID | 错误信息 | 199| --------------- | --------------- | 200| 202 | Permission verification failed. A non-system application calls a system API. | 201 202**示例:** 203 204```ts 205function isCameraMuteSupported(cameraManager: camera.CameraManager): boolean { 206 let isMuteSupported: boolean = cameraManager.isCameraMuteSupported(); 207 return isMuteSupported; 208} 209``` 210 211### muteCamera 212 213muteCamera(mute: boolean): void 214 215禁用相机。 216 217> **说明:** 218>从 API version 10开始支持,从API version 12开始废弃。建议使用[muteCameraPersistent](#mutecamerapersistent12)替代。 219 220**系统接口:** 此接口为系统接口。 221 222**系统能力:** SystemCapability.Multimedia.Camera.Core 223 224**参数:** 225 226| 参数名 | 类型 | 必填 | 说明 | 227| -------- | --------------------------------- | ---- | ---------- | 228| mute | boolean | 是 | 禁用相机。true为禁用;false为解除禁用。 | 229 230**示例:** 231 232```ts 233function muteCamera(cameraManager: camera.CameraManager): void { 234 let mute: boolean = true; 235 cameraManager.muteCamera(mute); 236} 237``` 238 239### muteCameraPersistent<sup>12+</sup> 240 241muteCameraPersistent(mute: boolean, type: PolicyType): void 242 243以持久化的方式禁用相机。 244 245**系统接口:** 此接口为系统接口。 246 247**系统能力:** SystemCapability.Multimedia.Camera.Core 248 249**参数:** 250 251| 参数名 | 类型 | 必填 | 说明 | 252| -------- |-----------------------------| ---- |--------------------------------------------| 253| mute | boolean | 是 | 禁用相机。true为禁用;false为解除禁用。 | 254| type | [PolicyType](#policytype12) | 是 | 策略类型。请使用[PolicyType](#policytype12)里面支持的类型 | 255 256**错误码:** 257 258以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)和[通用错误码说明文档](../errorcode-universal.md)。 259 260| 错误码ID | 错误信息 | 261| --------------- | --------------- | 262| 201 | Permission denied. | 263| 202 | Not System Application. | 264| 7400101 | Parameter missing or parameter type incorrect. | 265 266**示例:** 267 268```ts 269function muteCameraPersistent(cameraManager: camera.CameraManager): void { 270 let mute: boolean = true; 271 cameraManager.muteCameraPersistent(mute, camera.PolicyType.PRIVACY); 272} 273``` 274 275### on('cameraMute') 276 277on(type: 'cameraMute', callback: AsyncCallback\<boolean\>): void 278 279禁用回调,通过注册回调函数获取相机禁用状态变化。使用callback异步回调。 280 281**系统接口:** 此接口为系统接口。 282 283**系统能力:** SystemCapability.Multimedia.Camera.Core 284 285**参数:** 286 287| 参数名 | 类型 | 必填 | 说明 | 288| -------- | --------------- | ---- | --------- | 289| type | string | 是 | 监听事件,固定为'cameraMute',系统相机开关,cameraManager对象获取成功后可监听。系统设置打开或禁用相机会触发该事件并返回状态。 | 290| callback | AsyncCallback\<boolean> | 是 | 回调函数,用于获取禁用状态变化信息,返回true为开启状态,返回false为禁用状态。 | 291 292**示例:** 293 294```ts 295import { BusinessError } from '@kit.BasicServicesKit'; 296 297function callback(err: BusinessError, curMuted: boolean): void { 298 if (err !== undefined && err.code !== 0) { 299 console.error(`Callback Error, errorCode: ${err.code}`); 300 return; 301 } 302 let isMuted: boolean = curMuted; 303 console.info(`cameraMute status: ${isMuted}`); 304} 305 306function registerCameraMute(cameraManager: camera.CameraManager): void { 307 cameraManager.on('cameraMute', callback); 308} 309``` 310 311### off('cameraMute') 312 313off(type: 'cameraMute', callback?: AsyncCallback\<boolean\>): void 314 315禁用回调,通过注销注册回调函数获取相机禁用状态变化。 316 317**系统接口:** 此接口为系统接口。 318 319**系统能力:** SystemCapability.Multimedia.Camera.Core 320 321**参数:** 322 323| 参数名 | 类型 | 必填 | 说明 | 324| -------- | --------------- | ---- |---------------------------------------------------------| 325| type | string | 是 | 监听事件,固定为'cameraMute',系统相机开关,cameraManager对象获取成功后可监听。 | 326| callback | AsyncCallback\<boolean> | 否 | 回调函数,可选参数,返回true为开启状态,返回false为禁用状态,有就是匹配on('cameraMute') callback(callback对象不可是匿名函数)。 | 327 328**示例:** 329 330```ts 331import { BusinessError } from '@kit.BasicServicesKit'; 332 333function callback(err: BusinessError, curMuted: boolean): void { 334 let isMuted: boolean = curMuted; 335} 336 337function unregisterCameraMute(cameraManager: camera.CameraManager): void { 338 cameraManager.off('cameraMute', callback); 339} 340``` 341 342### isPrelaunchSupported 343 344isPrelaunchSupported(camera: CameraDevice): boolean 345 346检查指定cameraDevice是否支持预热启动。 347 348**系统接口:** 此接口为系统接口。 349 350**系统能力:** SystemCapability.Multimedia.Camera.Core 351 352**参数:** 353 354| 参数名 | 类型 | 必填 | 说明 | 355| -------- |--------------------------------------------------| ---- | --------- | 356| camera | [CameraDevice](arkts-apis-camera-i.md#cameradevice) | 是 | 相机信息。| 357 358**返回值:** 359 360| 类型 | 说明 | 361| -------- | --------------- | 362| boolean | 返回指定cameraDevice是否支持预热启动,返回true为支持,返回false为不支持。| 363 364**错误码:** 365 366以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 367 368| 错误码ID | 错误信息 | 369| --------------- | --------------- | 370| 202 | Not System Application. | 371| 7400101 | Parameter missing or parameter type incorrect. | 372 373**示例:** 374 375```ts 376import { common } from '@kit.AbilityKit'; 377 378function isPreLaunchSupported(context: common.BaseContext): boolean { 379 let cameraManager: camera.CameraManager = camera.getCameraManager(context); 380 let cameras: Array<camera.CameraDevice> = cameraManager.getSupportedCameras(); 381 let isSupported: boolean = false; 382 if (cameras && cameras.length >= 1) { 383 isSupported = cameraManager.isPrelaunchSupported(cameras[0]); 384 console.info(`PreLaunch supported states: ${isSupported}`); 385 return isSupported; 386 } 387 return isSupported; 388} 389``` 390 391### setPrelaunchConfig 392 393setPrelaunchConfig(prelaunchConfig: PrelaunchConfig): void 394 395设置预热启动的配置参数。 396 397在调用setPrelaunchConfig接口前,需要先检查设备是否支持预热启动,使用[isPrelaunchSupported](#isprelaunchsupported)判断指定cameraDevice是否支持预热启动。 398 399**系统接口:** 此接口为系统接口。 400 401**需要权限:** ohos.permission.CAMERA 402 403**系统能力:** SystemCapability.Multimedia.Camera.Core 404 405**参数:** 406 407| 参数名 | 类型 | 必填 | 说明 | 408| -------- | --------------- | ---- | --------- | 409| prelaunchConfig | [PrelaunchConfig](#prelaunchconfig) | 是 | 预启动配置参数。| 410 411**错误码:** 412 413以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 414 415| 错误码ID | 错误信息 | 416| --------------- | --------------- | 417| 202 | Not System Application. | 418| 7400101 | Parameter missing or parameter type incorrect. | 419| 7400102 | Operation not allowed. | 420| 7400201 | Camera service fatal error. | 421 422**示例:** 423 424```ts 425import { common } from '@kit.AbilityKit'; 426import { BusinessError } from '@kit.BasicServicesKit'; 427 428function setPrelaunchConfig(context: common.BaseContext): void { 429 let cameraManager: camera.CameraManager = camera.getCameraManager(context); 430 let cameras: Array<camera.CameraDevice> = cameraManager.getSupportedCameras(); 431 if (cameras && cameras.length >= 1) { 432 let cameraDevice: camera.CameraDevice = cameras[0]; 433 if(cameraManager.isPrelaunchSupported(cameraDevice)) { 434 try { 435 cameraManager.setPrelaunchConfig({cameraDevice: cameraDevice}); 436 } catch (error) { 437 let err = error as BusinessError; 438 console.error(`setPrelaunchConfig error. Code: ${err.code}, message: ${err.message}`); 439 } 440 } 441 } 442} 443``` 444 445### prelaunch 446 447prelaunch(): void 448 449用户点击系统相机图标,拉起相机应用同时调用,下发预热请求,使能相机预热启动。 450 451**系统接口:** 此接口为系统接口。 452 453**系统能力:** SystemCapability.Multimedia.Camera.Core 454 455**错误码:** 456 457以下错误码的详细介绍请参见[通用错误码说明文档](../errorcode-universal.md)。 458 459| 错误码ID | 错误信息 | 460| --------------- | --------------- | 461| 202 | Not System Application. | 462 463**示例:** 464 465```ts 466import { common } from '@kit.AbilityKit'; 467import { BusinessError } from '@kit.BasicServicesKit'; 468import { camera } from '@kit.CameraKit'; 469 470function preLaunch(context: common.BaseContext): void { 471 let cameraManager: camera.CameraManager = camera.getCameraManager(context); 472 try { 473 cameraManager.prelaunch(); 474 } catch (error) { 475 let err = error as BusinessError; 476 console.error(`prelaunch error. Code: ${err.code}, message: ${err.message}`); 477 } 478} 479``` 480 481### createDeferredPreviewOutput 482 483createDeferredPreviewOutput(profile?: Profile): PreviewOutput 484 485创建延迟预览输出对象,在配流时替代普通的预览输出对象加入数据流。 486 487**系统接口:** 此接口为系统接口。 488 489**系统能力:** SystemCapability.Multimedia.Camera.Core 490 491**参数:** 492 493| 参数名 | 类型 | 必填 | 说明 | 494| -------- | --------------- | ---- | --------- | 495| profile | [Profile](arkts-apis-camera-i.md#profile) | 否 | 相机预览流的配置文件。 | 496 497**返回值:** 498 499| 类型 | 说明 | 500| -------- | --------------- | 501| [PreviewOutput](#previewoutput) | 返回预览输出对象。 | 502 503**错误码:** 504 505以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 506 507| 错误码ID | 错误信息 | 508| --------------- | --------------- | 509| 202 | Not System Application. | 510| 7400101 | Parameter missing or parameter type incorrect. | 511 512**示例:** 513 514```ts 515import { common } from '@kit.AbilityKit'; 516 517function getDeferredPreviewOutput(context: common.BaseContext, previewProfile: camera.Profile): camera.PreviewOutput { 518 const cameraManager: camera.CameraManager = camera.getCameraManager(context); 519 const output: camera.PreviewOutput = cameraManager.createDeferredPreviewOutput(previewProfile); 520 return output; 521} 522``` 523 524### preSwitchCamera<sup>11+</sup> 525 526preSwitchCamera(cameraId: string): void 527 528预切换相机,提升相机启动速度。 529 530**系统接口:** 此接口为系统接口。 531 532**系统能力:** SystemCapability.Multimedia.Camera.Core 533 534**参数:** 535 536| 参数名 | 类型 | 必填 | 说明 | 537| -------- | --------------- | ---- | --------- | 538| cameraId | string | 是 | 相机id。 | 539 540**错误码:** 541 542以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 543 544| 错误码ID | 错误信息 | 545| ------- |------------------------------------------------| 546| 202 | Not System Application. | 547| 7400101 | Parameter missing or parameter type incorrect. | 548| 7400201 | Camera service fatal error. | 549 550**示例:** 551 552```ts 553import { common } from '@kit.AbilityKit'; 554import { BusinessError } from '@kit.BasicServicesKit'; 555 556function preSwitch(cameraDevice: camera.CameraDevice, context: common.BaseContext): void { 557 let cameraManager: camera.CameraManager = camera.getCameraManager(context); 558 try { 559 cameraManager.preSwitchCamera(cameraDevice.cameraId); 560 } catch (error) { 561 let err = error as BusinessError; 562 console.error(`prelaunch error. Code: ${err.code}, message: ${err.message}`); 563 } 564} 565``` 566 567## CameraOcclusionDetectionResult<sup>12+</sup> 568相机模组被遮挡状态。 569 570**系统接口:** 此接口为系统接口。 571 572**系统能力:** SystemCapability.Multimedia.Camera.Core 573 574| 名称 | 类型 | 只读 | 可选 | 说明 | 575| ----------------------------- | --------------------------------------------------- | ---- | ---- |-------------------| 576| isCameraOccluded | boolean | 是 | 否 |遮挡状态,true为遮挡状态,false为不遮挡状态。 | 577 578## CameraOutputCapability<sup>13+</sup> 579 580相机输出能力项。 581 582**系统接口:** 此接口为系统接口。 583 584**系统能力:** SystemCapability.Multimedia.Camera.Core 585 586| 名称 | 类型 | 只读 | 可选 | 说明 | 587| ----------------------------- | --------------------------------------------------- | ---- | ---- |-------------------| 588| depthProfiles | Array\<[DepthProfile](#depthprofile13)\> | 是 | 否 | 支持的深度流配置信息集合。 | 589 590## CameraFormat 591 592枚举,输出格式。 593 594**系统接口:** 此接口为系统接口。 595 596**系统能力:** SystemCapability.Multimedia.Camera.Core 597 598| 名称 | 值 | 说明 | 599| ----------------------- | --------- | ------------ | 600| CAMERA_FORMAT_DEPTH_16<sup>13+</sup> | 3000 | DEPTH_16格式的深度图。 | 601| CAMERA_FORMAT_DEPTH_32<sup>13+</sup> | 3001 | DEPTH_32格式的深度图。 | 602 603## CameraInput 604 605相机设备输入对象。 606 607会话中[Session](arkts-apis-camera-Session.md)使用的相机信息。 608 609### on('cameraOcclusionDetection')<sup>12+</sup> 610 611on(type: 'cameraOcclusionDetection', callback: AsyncCallback\<CameraOcclusionDetectionResult\>): void 612 613监听CameraInput的遮挡事件,通过注册回调函数获取结果。使用callback异步回调。 614 615**系统能力:** SystemCapability.Multimedia.Camera.Core 616 617**参数:** 618 619| 参数名 | 类型 | 必填 | 说明 | 620| -------- | -------------------------------- | --- | ------------------------------------------- | 621| type | string | 是 | 监听事件,固定为'cameraOcclusionDetection',CameraInput对象创建成功可监听。相机模组遮挡状态发生改变时触发该事件并返回结果。 | 622| callback | AsyncCallback\<[CameraOcclusionDetectionResult](#cameraocclusiondetectionresult12)\> | 是 | 回调函数,用于获取结果。返回遮挡状态。 | 623 624**示例:** 625 626```ts 627import { BusinessError } from '@kit.BasicServicesKit'; 628 629function callback(err: BusinessError, CameraOcclusionDetectionResult: camera.CameraOcclusionDetectionResult): void { 630 if (err !== undefined && err.code !== 0) { 631 console.error('cameraOcclusionDetection with errorCode = ' + err.code); 632 return; 633 } 634 console.info(`isCameraOccluded : ${CameraOcclusionDetectionResult.isCameraOccluded}`); 635} 636 637function registerCameraOcclusionDetection(cameraInput: camera.CameraInput): void { 638 cameraInput.on('cameraOcclusionDetection', callback); 639} 640``` 641 642### off('cameraOcclusionDetection')<sup>12+</sup> 643 644off(type: 'cameraOcclusionDetection', callback?: AsyncCallback\<CameraOcclusionDetectionResult\>): void 645 646注销CameraInput遮挡监听事件。 647 648**系统能力:** SystemCapability.Multimedia.Camera.Core 649 650**参数:** 651 652| 参数名 | 类型 | 必填 | 说明 | 653| -------- | --------------- | ---- |---------------------------------------------------------| 654| type | string | 是 | 监听事件,固定为'cameraOcclusionDetection',CameraInput对象创建成功可监听。 | 655| callback | AsyncCallback\<[CameraOcclusionDetectionResult](#cameraocclusiondetectionresult12)\> | 否 | 回调函数,可选参数,有就是匹配on('cameraOcclusionDetection') callback(callback对象不可是匿名函数)。 | 656 657**示例:** 658 659```ts 660import { BusinessError } from '@kit.BasicServicesKit'; 661 662function callback(err: BusinessError, CameraOcclusionDetectionResult: camera.CameraOcclusionDetectionResult): void { 663 if (err !== undefined && err.code !== 0) { 664 console.error('cameraOcclusionDetection with errorCode = ' + err.code); 665 return; 666 } 667 console.info(`isCameraOccluded : ${CameraOcclusionDetectionResult.isCameraOccluded}`); 668} 669 670function unregisterCameraOcclusionDetection(cameraInput: camera.CameraInput): void { 671 cameraInput.off('cameraOcclusionDetection', callback); 672} 673``` 674 675## DepthDataAccuracy<sup>13+</sup> 676 677深度数据的精度。 678 679**系统接口:** 此接口为系统接口。 680 681**系统能力:** SystemCapability.Multimedia.Camera.Core 682 683| 名称 | 类型 | 只读 | 可选 | 说明 | 684| -------- | ----------------------------- |----- |---| -------------- | 685| DEPTH_DATA_ACCURACY_RELATIVE | number | 是 | 否 | 相对精度,基于视差计算得到的深度图。 | 686| DEPTH_DATA_ACCURACY_ABSOLUTE | number | 是 | 否 | 绝对精度,基于测距计算得到的深度图。 | 687 688## DepthProfile<sup>13+</sup> 689 690深度数据配置信息项,继承[Profile](arkts-apis-camera-i.md#profile)。 691 692**系统接口:** 此接口为系统接口。 693 694**系统能力:** SystemCapability.Multimedia.Camera.Core 695 696| 名称 | 类型 | 只读 | 可选 | 说明 | 697| ------------------------- | ----------------------------------------- | --- | ---- |----------- | 698| depthDataAccuracy | [DepthDataAccuracy](#depthdataaccuracy13) | 是 | 否 | 深度数据的精度,分为相对精度和绝对精度。 | 699 700## DepthDataQualityLevel<sup>13+</sup> 701 702深度数据的质量。 703 704**系统接口:** 此接口为系统接口。 705 706**系统能力:** SystemCapability.Multimedia.Camera.Core 707 708| 名称 | 类型 | 只读 | 可选 | 说明 | 709| -------- | ----------------------------- |----- |---| -------------- | 710| DEPTH_DATA_QUALITY_BAD | number | 是 | 否 | 深度图的质量很差,无法用于虚化等。 | 711| DEPTH_DATA_QUALITY_FAIR | number | 是 | 否 | 深度图的质量一般,无法生成高质量的虚化等。 | 712| DEPTH_DATA_QUALITY_GOOD | number | 是 | 否 | 深度图的质量较高,可以生成高质量的虚化等。 | 713 714## DepthData<sup>13+</sup> 715 716深度数据对象。 717 718### 属性 719 720**系统接口:** 此接口为系统接口。 721 722**系统能力:** SystemCapability.Multimedia.Camera.Core 723 724| 名称 | 类型 | 只读 | 可选 | 说明 | 725| -------- | ----------------------------- |----- |---| -------------- | 726| format | [CameraFormat](#cameraformat) | 是 | 否 | 深度图的格式。 | 727| depthMap | [image.PixelMap](../apis-image-kit/arkts-apis-image-PixelMap.md) | 是 | 否 | 深度图。 | 728| qualityLevel | [DepthDataQualityLevel](#depthdataqualitylevel13) | 是 | 否 | 深度图的质量。 | 729| accuracy | [DepthDataAccuracy](#depthdataaccuracy13) | 是 | 否 | 深度图的精度。 | 730 731### release<sup>13+</sup> 732 733release(): void 734 735释放输出资源。 736 737**系统接口:** 此接口为系统接口。 738 739**系统能力:** SystemCapability.Multimedia.Camera.Core 740 741**示例:** 742 743```ts 744async function releaseDepthData(depthData: camera.DepthData): Promise<void> { 745 await depthData.release(); 746} 747``` 748 749## DepthDataOutput<sup>13+</sup> 750 751深度信息输出类。继承[CameraOutput](arkts-apis-camera-CameraOutput.md)。 752 753### start<sup>13+</sup> 754 755start(): Promise\<void\> 756 757启动深度信息输出流。使用Promise异步回调。 758 759**系统接口:** 此接口为系统接口。 760 761**系统能力:** SystemCapability.Multimedia.Camera.Core 762 763**返回值:** 764 765| 类型 | 说明 | 766| -------------- | ----------------------- | 767| Promise\<void\> | Promise对象,无返回结果。 | 768 769**错误码:** 770 771以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 772 773| 错误码ID | 错误信息 | 774| --------------- | --------------- | 775| 7400103 | Session not config. | 776| 7400201 | Camera service fatal error. | 777 778**示例:** 779 780```ts 781import { BusinessError } from '@kit.BasicServicesKit'; 782 783function startDepthDataOutput(depthDataOutput: camera.DepthDataOutput): void { 784 depthDataOutput.start().then(() => { 785 console.info('Promise returned to indicate that start method execution success.'); 786 }).catch((error: BusinessError) => { 787 console.error(`Failed to depth data output start, error code: ${error.code}.`); 788 }); 789} 790``` 791 792### stop<sup>13+</sup> 793 794stop(): Promise\<void\> 795 796结束深度信息输出。使用Promise异步回调。 797 798**系统接口:** 此接口为系统接口。 799 800**系统能力:** SystemCapability.Multimedia.Camera.Core 801 802**返回值:** 803 804| 类型 | 说明 | 805| -------------- | ----------------------- | 806| Promise\<void\> | Promise对象,无返回结果。 | 807 808**示例:** 809 810```ts 811import { BusinessError } from '@kit.BasicServicesKit'; 812 813function stopDepthDataOutput(depthDataOutput: camera.DepthDataOutput): void { 814 depthDataOutput.stop().then(() => { 815 console.info('Promise returned to indicate that stop method execution success.'); 816 }).catch((error: BusinessError) => { 817 console.error(`Failed to depth data output stop, error code: ${error.code}.`); 818 }); 819} 820``` 821 822### on('depthDataAvailable')<sup>13+</sup> 823 824on(type: 'depthDataAvailable', callback: AsyncCallback\<DepthData\>): void 825 826注册监听深度数据上报。使用callback异步回调。 827 828> **说明:** 829> 830> 当前注册监听接口,不支持在on监听的回调方法里,调用off注销回调。 831 832**系统接口:** 此接口为系统接口。 833 834**系统能力:** SystemCapability.Multimedia.Camera.Core 835 836**参数:** 837 838| 参数名 | 类型 | 必填 | 说明 | 839| -------- | ---------- | --- | ------------------------------------ | 840| type | string | 是 | 监听事件,固定为'depthDataAvailable',depthDataOutput创建成功后可监听。 | 841| callback | AsyncCallback\<[DepthData](#depthdata13)\> | 是 | 回调函数,用于监听深度信息上报。 | 842 843**示例:** 844 845```ts 846import { BusinessError } from '@kit.BasicServicesKit'; 847 848function callback(err: BusinessError, depthData: camera.DepthData): void { 849 if (err !== undefined && err.code !== 0) { 850 console.error(`Callback Error, errorCode: ${err.code}`); 851 return; 852 } 853} 854 855function registerDepthDataAvailable(depthDataOutput: camera.DepthDataOutput): void { 856 depthDataOutput.on('depthDataAvailable', callback); 857} 858``` 859 860### off('depthDataAvailable')<sup>13+</sup> 861 862off(type: 'depthDataAvailable', callback?: AsyncCallback\<DepthData\>): void 863 864注销监听深度信息上报。 865 866**系统接口:** 此接口为系统接口。 867 868**系统能力:** SystemCapability.Multimedia.Camera.Core 869 870**参数:** 871 872| 参数名 | 类型 | 必填 | 说明 | 873| -------- | ---------------------- | ---- | ------------------------------------------ | 874| type | string | 是 | 监听事件,固定为'depthDataAvailable',depthDataOutput创建成功后可监听。 | 875| callback | AsyncCallback\<[DepthData](#depthdata13)\> | 否 | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 | 876 877**示例:** 878 879```ts 880import { BusinessError } from '@kit.BasicServicesKit'; 881 882function callback(err: BusinessError, depthData: camera.DepthData): void { 883 if (err !== undefined && err.code !== 0) { 884 console.error(`Callback Error, errorCode: ${err.code}`); 885 return; 886 } 887} 888 889function unRegisterDepthDataAvailable(depthDataOutput: camera.DepthDataOutput): void { 890 depthDataOutput.off('depthDataAvailable', callback); 891} 892``` 893 894### on('error')<sup>13+</sup> 895 896on(type: 'error', callback: ErrorCallback): void 897 898监听深度信息输出的错误事件,通过注册回调函数获取结果。使用callback异步回调。 899 900> **说明:** 901> 902> 当前注册监听接口,不支持在on监听的回调方法里,调用off注销回调。 903 904**系统接口:** 此接口为系统接口。 905 906**系统能力:** SystemCapability.Multimedia.Camera.Core 907 908**参数:** 909 910| 参数名 | 类型 | 必填 | 说明 | 911| -------- | --------------| ---- | ------------------------ | 912| type | string | 是 | 监听事件,固定为'error',depthDataOutput创建成功可监听。 | 913| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。 | 914 915**示例:** 916 917```ts 918import { BusinessError } from '@kit.BasicServicesKit'; 919 920function callback(depthDataOutputError: BusinessError): void { 921 console.error(`Depth data output error code: ${depthDataOutputError.code}`); 922} 923 924function registerDepthDataOutputError(depthDataOutput: camera.DepthDataOutput): void { 925 depthDataOutput.on('error', callback); 926} 927``` 928 929### off('error')<sup>13+</sup> 930 931off(type: 'error', callback?: ErrorCallback): void 932 933注销监听深度信息输出的错误事件。 934 935**系统接口:** 此接口为系统接口。 936 937**系统能力:** SystemCapability.Multimedia.Camera.Core 938 939**参数:** 940 941| 参数名 | 类型 | 必填 | 说明 | 942| -------- | --------------| ---- | ------------------------ | 943| type | string | 是 | 监听事件,固定为'error',depthDataOutput创建成功可监听。 | 944| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | 否 | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 | 945 946**示例:** 947 948```ts 949function unregisterDepthDataOutputError(depthDataOutput: camera.DepthDataOutput): void { 950 depthDataOutput.off('error'); 951} 952``` 953 954## DepthFusionQuery<sup>14+</sup> 955 956深度融合查询类。 957 958### isDepthFusionSupported<sup>14+</sup> 959 960isDepthFusionSupported(): boolean 961 962查询是否支持深度融合,通过返回值获取结果。 963 964**系统接口:** 此接口为系统接口。 965 966**系统能力:** SystemCapability.Multimedia.Camera.Core 967 968**返回值:** 969 970| 类型 | 说明 | 971| -------------- | ----------------------- | 972| boolean | 表示是否支持深度融合。true表示支持深度融合,false表示不支持深度融合。 | 973 974**错误码:** 975 976以下错误码的详细介绍请参见[通用错误码说明文档](../errorcode-universal.md)和[Camera错误码](errorcode-camera.md)。 977 978| 错误码ID | 错误信息 | 979| --------------- | --------------- | 980| 202 | Not System Application. | 981| 7400103 | Session not config, only throw in session usage. | 982 983**示例:** 984```ts 985import { BusinessError } from '@kit.BasicServicesKit'; 986 987function isDepthFusionSupported(DepthFusionQuery: camera.DepthFusionQuery): void { 988 try { 989 let isSupperted: boolean = DepthFusionQuery.isDepthFusionSupported(); 990 console.info('Promise returned to indicate that isDepthFusionSupported method execution success.'); 991 } catch (error) { 992 let err = error as BusinessError; 993 console.error(`Failed to depth fusion query isDepthFusionSupported, error code: ${err.code}.`); 994 } 995} 996 997``` 998### getDepthFusionThreshold<sup>14+</sup> 999 1000getDepthFusionThreshold(): Array\<number\> 1001 1002获取深度融合阈值,通过返回值获取结果。 1003 1004**系统接口:** 此接口为系统接口。 1005 1006**系统能力:** SystemCapability.Multimedia.Camera.Core 1007 1008**返回值:** 1009 1010| 类型 | 说明 | 1011| -------------- | ----------------------- | 1012| Array\<number\> | 深度融合的阈值范围。 | 1013 1014**错误码:** 1015 1016以下错误码的详细介绍请参见[通用错误码说明文档](../errorcode-universal.md)和[Camera错误码](errorcode-camera.md)。 1017 1018| 错误码ID | 错误信息 | 1019| --------------- | --------------- | 1020| 202 | Not System Application. | 1021| 7400103 | Session not config, only throw in session usage. | 1022 1023**示例:** 1024```ts 1025import { BusinessError } from '@kit.BasicServicesKit'; 1026 1027function getDepthFusionThreshold(DepthFusionQuery: camera.DepthFusionQuery): void { 1028 try { 1029 let threshold: Array<number> = DepthFusionQuery.getDepthFusionThreshold(); 1030 console.info('Promise returned to indicate that getDepthFusionThreshold method execution success.'); 1031 } catch (error) { 1032 let err = error as BusinessError; 1033 console.error(`Failed to depth fusion query getDepthFusionThreshold, error code: ${err.code}.`); 1034 } 1035} 1036``` 1037## DepthFusion<sup>14+</sup> 1038 1039深度融合类。继承[DepthFusionQuery](js-apis-camera-sys.md#depthfusionquery14)。 1040 1041### isDepthFusionEnabled<sup>14+</sup> 1042 1043isDepthFusionEnabled(): boolean 1044 1045检测深度融合功能是否已启用,通过返回值获取结果。 1046 1047**系统接口:** 此接口为系统接口。 1048 1049**系统能力:** SystemCapability.Multimedia.Camera.Core 1050 1051**返回值:** 1052 1053| 类型 | 说明 | 1054| -------------- | ----------------------- | 1055| boolean | 表示是否开启深度融合。true表示开启深度融合,false表示未开启深度融合。 | 1056 1057**错误码:** 1058 1059以下错误码的详细介绍请参见[通用错误码说明文档](../errorcode-universal.md)和[Camera错误码](errorcode-camera.md)。 1060 1061| 错误码ID | 错误信息 | 1062| --------------- | --------------- | 1063| 202 | Not System Application. | 1064| 7400103 | Session not config. | 1065 1066**示例:** 1067```ts 1068import { BusinessError } from '@kit.BasicServicesKit'; 1069function isDepthFusionEnabled(DepthFusion: camera.DepthFusion): boolean { 1070 let isEnable: boolean = false; 1071 try { 1072 isEnable = DepthFusion.isDepthFusionEnabled(); 1073 console.info('Promise returned to indicate that isDepthFusionEnabled method execution success.'); 1074 } catch (error) { 1075 let err = error as BusinessError; 1076 console.error(`Failed to depth fusion isDepthFusionEnabled, error code: ${err.code}.`); 1077 }; 1078 return isEnable; 1079} 1080``` 1081 1082### enableDepthFusion<sup>14+</sup> 1083 1084enableDepthFusion(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以下错误码的详细介绍请参见[通用错误码说明文档](../errorcode-universal.md)和[Camera错误码](errorcode-camera.md)。 1101 1102| 错误码ID | 错误信息 | 1103|---------|------------------------------------------------| 1104| 202 | Not System Application. | 1105| 7400101 | Parameter missing or parameter type incorrect. | 1106| 7400103 | Session not config. | 1107| 7400201 | Camera service fatal error. | 1108 1109**示例:** 1110```ts 1111import { BusinessError } from '@kit.BasicServicesKit'; 1112 1113function enableDepthFusion(DepthFusion: camera.DepthFusion): void { 1114 try { 1115 let enabled: boolean = true; 1116 DepthFusion.enableDepthFusion(enabled); 1117 console.info('Promise returned to indicate that enableDepthFusion method execution success.'); 1118 } catch (error) { 1119 let err = error as BusinessError; 1120 console.error(`Failed to depth fusion enableDepthFusion, error code: ${err.code}.`); 1121 }; 1122} 1123``` 1124 1125## PrelaunchConfig 1126 1127相机预启动配置参数。 1128 1129当前sensor级别预热,待扩展流预热参数。 1130 1131**系统接口:** 此接口为系统接口。 1132 1133**系统能力:** SystemCapability.Multimedia.Camera.Core 1134 1135| 名称 | 类型 | 只读 | 必填 | 说明 | 1136| ------------------------------- |--------------------------------------------------| ----------- | ------------ | ---------- | 1137| cameraDevice | [CameraDevice](arkts-apis-camera-i.md#cameradevice) | 否 | 是 | 相机信息。 | 1138| restoreParamType<sup>11+</sup> | [RestoreParamType](#restoreparamtype11) | 否 | 否 | 预保存参数类型。 | 1139| activeTime<sup>11+</sup> | number | 否 | 否 | 激活时间,单位min。 | 1140| settingParam<sup>11+</sup> | [SettingParam](#settingparam11) | 否 | 否 | 设置参数内容。 | 1141 1142## RestoreParamType<sup>11+</sup> 1143 1144预保存参数类型。 1145 1146**系统接口:** 此接口为系统接口。 1147 1148**系统能力:** SystemCapability.Multimedia.Camera.Core 1149 1150| 名称 | 值 | 说明 | 1151| ----------------| ---- | ---------| 1152| NO_NEED_RESTORE_PARAM | 0 | 不需要预保存参数类型。 | 1153| PRESISTENT_DEFAULT_PARAM | 1 | 持久化参数类型,指某一时间点后,使用该参数恢复流信息。 | 1154| TRANSIENT_ACTIVE_PARAM | 2 | 临时参数类型,只在关闭相机后一段时间内,使用该参数恢复流信息,优先级高于持久化参数。 | 1155 1156## SettingParam<sup>11+</sup> 1157 1158用于预热出图的效果参数。 1159 1160**系统接口:** 此接口为系统接口。 1161 1162**系统能力:** SystemCapability.Multimedia.Camera.Core 1163 1164| 名称 | 类型 | 只读 | 可选 | 说明 | 1165| --------------- | ------ | --------- |-----|---------------------------------------------------------------------------------------------------| 1166| skinSmoothLevel | number | 否 | 否 | 美颜类型光滑信息,从[Beauty.getSupportedBeautyRange](#getsupportedbeautyrange11)获取支持的光滑范围,例如1表示1级光滑。 | 1167| faceSlender | number | 否 | 否 | 美颜类型瘦脸信息,从[Beauty.getSupportedBeautyRange](#getsupportedbeautyrange11)获取支持的瘦脸范围,例如1表示1级瘦脸。 | 1168| skinTone | number | 否 | 否 | 美颜类型肤色信息,从[Beauty.getSupportedBeautyRange](#getsupportedbeautyrange11)获取支持的肤色范围,例如0xBF986C表示一个颜色。 | 1169 1170## PreviewOutput 1171 1172预览输出类。继承[CameraOutput](arkts-apis-camera-CameraOutput.md)。 1173 1174### addDeferredSurface 1175 1176addDeferredSurface(surfaceId: string): void 1177 1178配置延迟预览的Surface,可以在[Session.commitConfig](arkts-apis-camera-Session.md#commitconfig11-1)配流和[Session.start](arkts-apis-camera-Session.md#start11-1)启流之后运行。 1179 1180**系统接口:** 此接口为系统接口。 1181 1182**系统能力:** SystemCapability.Multimedia.Camera.Core 1183 1184**参数:** 1185 1186| 参数名 | 类型 | 必填 | 说明 | 1187| -------- | --------------| ---- | ------------------------ | 1188| surfaceId | string | 是 | 从[XComponent](../apis-arkui/arkui-ts/ts-basic-components-xcomponent.md)组件获取的surfaceId。| 1189 1190**错误码:** 1191 1192以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)和[通用错误码说明文档](../errorcode-universal.md)。 1193 1194| 错误码ID | 错误信息 | 1195| --------------- | --------------- | 1196| 202 | Permission verification failed. A non-system application calls a system API. | 1197| 7400101 | Parameter missing or parameter type incorrect. | 1198 1199**示例:** 1200 1201```ts 1202import { common } from '@kit.AbilityKit'; 1203 1204async function preview(context: common.BaseContext, cameraDevice: camera.CameraDevice, previewProfile: camera.Profile, photoProfile: camera.Profile, mode: camera.SceneMode, previewSurfaceId: string): Promise<void> { 1205 const cameraManager: camera.CameraManager = camera.getCameraManager(context); 1206 const cameraInput: camera.CameraInput = cameraManager.createCameraInput(cameraDevice); 1207 const previewOutput: camera.PreviewOutput = cameraManager.createDeferredPreviewOutput(previewProfile); 1208 const photoOutput: camera.PhotoOutput = cameraManager.createPhotoOutput(photoProfile); 1209 const session: camera.Session = cameraManager.createSession(mode); 1210 session.beginConfig(); 1211 session.addInput(cameraInput); 1212 session.addOutput(previewOutput); 1213 session.addOutput(photoOutput); 1214 await session.commitConfig(); 1215 await session.start(); 1216 previewOutput.addDeferredSurface(previewSurfaceId); 1217} 1218``` 1219 1220### isSketchSupported<sup>11+</sup> 1221 1222isSketchSupported(): boolean 1223 1224查询是否支持画中画能力。 1225 1226**系统接口:** 此接口为系统接口。 1227 1228**系统能力:** SystemCapability.Multimedia.Camera.Core 1229 1230**返回值:** 1231 1232| 类型 | 说明 | 1233| -------------- | ----------------------- | 1234| boolean | 返回是否支持画中画,返回true为支持,返回false为不支持。 | 1235 1236**错误码:** 1237 1238以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1239 1240| 错误码ID | 错误信息 | 1241| --------------- |-------------------------| 1242| 202 | Not System Application. | 1243 1244**示例:** 1245 1246```ts 1247import { BusinessError } from '@kit.BasicServicesKit'; 1248 1249function isSketchSupported(previewOutput: camera.PreviewOutput): boolean { 1250 try { 1251 let isSupported: boolean = previewOutput.isSketchSupported(); 1252 return isSupported; 1253 } catch (error) { 1254 // 失败返回错误码error.code并处理。 1255 let err = error as BusinessError; 1256 console.error(`The isSketchSupported call failed. error code: ${err.code}`); 1257 } 1258 return false; 1259} 1260``` 1261 1262### getSketchRatio<sup>11+</sup> 1263 1264getSketchRatio(): number 1265 1266获取当前状态下启动画中画的Zoom倍率。 1267 1268**系统接口:** 此接口为系统接口。 1269 1270**系统能力:** SystemCapability.Multimedia.Camera.Core 1271 1272**返回值:** 1273 1274| 类型 | 说明 | 1275| -------------- | ----------------------- | 1276| number | 当前状态下启动画中画的Zoom倍率。不支持画中画的情况下,该接口返回-1。 | 1277 1278**错误码:** 1279 1280以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1281 1282| 错误码ID | 错误信息 | 1283| --------------- | --------------- | 1284| 7400103 | Session not config. | 1285| 202 | Not System Application. | 1286 1287**示例:** 1288 1289```ts 1290function getSketchRatio(previewOutput: camera.PreviewOutput): number { 1291 let sketchRatio: number = previewOutput.getSketchRatio(); 1292 return sketchRatio; 1293} 1294``` 1295 1296### enableSketch<sup>11+</sup> 1297 1298enableSketch(enabled: boolean): void 1299 1300使能画中画。 1301 1302**系统接口:** 此接口为系统接口。 1303 1304**系统能力:** SystemCapability.Multimedia.Camera.Core 1305 1306**参数:** 1307 1308| 参数名 | 类型 | 必填 | 说明 | 1309|---------|---------| ---- | ------------------------ | 1310| enabled | boolean | 是 | true表明开启画中画流进行预览,false表明不开启。| 1311 1312**错误码:** 1313 1314以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1315 1316| 错误码ID | 错误信息 | 1317|-----------|-----------------------------| 1318| 202 | Not System Application. | 1319| 7400102 | Operation not allowed. | 1320| 7400103 | Session not config. | 1321| 7400201 | Camera service fatal error. | 1322 1323**示例:** 1324 1325```ts 1326import { BusinessError } from '@kit.BasicServicesKit'; 1327 1328function enableSketch(previewOutput: camera.PreviewOutput, session: camera.Session, cameraInput: camera.CameraInput): void { 1329 try { 1330 session.beginConfig(); 1331 session.addInput(cameraInput); 1332 session.addOutput(previewOutput); 1333 previewOutput.enableSketch(true); 1334 session.commitConfig(); 1335 } catch (error) { 1336 // 失败返回错误码error.code并处理。 1337 let err = error as BusinessError; 1338 console.error(`The enableSketch call failed. error code: ${err.code}`); 1339 } 1340} 1341``` 1342 1343### attachSketchSurface<sup>11+</sup> 1344 1345attachSketchSurface(surfaceId: string): void 1346 1347添加画中画预览的Surface。 1348 1349**系统接口:** 此接口为系统接口。 1350 1351**系统能力:** SystemCapability.Multimedia.Camera.Core 1352 1353**参数:** 1354 1355| 参数名 | 类型 | 必填 | 说明 | 1356| -------- | --------------| ---- | ------------------------ | 1357| surfaceId | string | 是 | 从[XComponent](../apis-arkui/arkui-ts/ts-basic-components-xcomponent.md)组件获取的surfaceId。| 1358 1359**错误码:** 1360 1361以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1362 1363| 错误码ID | 错误信息 | 1364|---------|------------------------------------------------| 1365| 202 | Not System Application. | 1366| 7400101 | Parameter missing or parameter type incorrect. | 1367| 7400103 | Session not config. | 1368| 7400201 | Camera service fatal error. | 1369 1370**示例:** 1371 1372```ts 1373import { BusinessError } from '@kit.BasicServicesKit'; 1374 1375function attachSketchSurface(previewOutput: camera.PreviewOutput, session: camera.Session, cameraInput: camera.CameraInput, sketchSurfaceId: string): void { 1376 try { 1377 session.beginConfig(); 1378 session.addInput(cameraInput); 1379 session.addOutput(previewOutput); 1380 previewOutput.enableSketch(true); 1381 session.commitConfig(); 1382 previewOutput.attachSketchSurface(sketchSurfaceId); 1383 } catch (error) { 1384 // 失败返回错误码error.code并处理。 1385 let err = error as BusinessError; 1386 console.error(`The attachSketchSurface call failed. error code: ${err.code}`); 1387 } 1388} 1389``` 1390 1391### on('sketchStatusChanged')<sup>11+</sup> 1392 1393on(type: 'sketchStatusChanged', callback: AsyncCallback\<SketchStatusData\>): void 1394 1395监听画中画状态信息改变,通过注册回调函数获取SketchStatusData。使用callback异步回调。 1396 1397**系统接口:** 此接口为系统接口。 1398 1399**系统能力:** SystemCapability.Multimedia.Camera.Core 1400 1401**参数:** 1402 1403| 参数名 | 类型 | 必填 | 说明 | 1404| -------- | ---------------------- | ---- | ------------------------------------------ | 1405| type | string | 是 | 监听事件,固定为'sketchStatusChanged',画中画流创建成功后可监听。底层画中画的状态启停以及画中画Zoom值变更会回调该接口。 | 1406| callback | AsyncCallback\<[SketchStatusData](#sketchstatusdata11)\> | 是 | 使用callback的方式获取SketchStatusData。 | 1407 1408**错误码:** 1409 1410以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1411 1412| 错误码ID | 错误信息 | 1413|---------|-------------------------------| 1414| 202 | Not System Application. | 1415 1416**示例:** 1417 1418```ts 1419import { BusinessError } from '@kit.BasicServicesKit'; 1420 1421function callback(error: BusinessError, data: camera.SketchStatusData): void { 1422 if (error !== undefined && error.code !== 0) { 1423 console.error(`Callback Error, errorCode: ${error.code}`); 1424 return; 1425 } 1426 console.info(`sketch errorCode is ${error.code}, data is ${JSON.stringify(data)}`); 1427} 1428 1429function registerSketchStatusChanged(previewOutput: camera.PreviewOutput): void { 1430 previewOutput.on('sketchStatusChanged', callback); 1431} 1432``` 1433 1434### off('sketchStatusChanged')<sup>11+</sup> 1435 1436off(type: 'sketchStatusChanged', callback?: AsyncCallback\<SketchStatusData\>): void 1437 1438注销监听画中画状态信息改变。 1439 1440**系统接口:** 此接口为系统接口。 1441 1442**系统能力:** SystemCapability.Multimedia.Camera.Core 1443 1444**参数:** 1445 1446| 参数名 | 类型 | 必填 | 说明 | 1447| -------- | ---------------------- | ---- | ------------------------------------------ | 1448| type | string | 是 | 监听事件,固定为'sketchStatusChanged',画中画流创建成功后可监听。 | 1449| callback | AsyncCallback\<[SketchStatusData](#sketchstatusdata11)\> | 否 | 回调函数,可选,有就是匹配on('sketchStatusChanged') callback(callback对象不可是匿名函数)。 | 1450 1451**错误码:** 1452 1453以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1454 1455| 错误码ID | 错误信息 | 1456|---------|-------------------------------| 1457| 202 | Not System Application. | 1458 1459**示例:** 1460 1461```ts 1462function unregisterSketchStatusChanged(previewOutput: camera.PreviewOutput): void { 1463 previewOutput.off('sketchStatusChanged'); 1464} 1465``` 1466 1467## DeferredDeliveryImageType<sup>11+</sup> 1468 1469枚举,分段式能力类型。即将拍照/录像分为两个阶段,一阶段以较快速度输出图片/视频提供给用户,二阶段完成优化处理,重新输出高质量图片/视频。 1470 1471**系统接口:** 此接口为系统接口。 1472 1473**系统能力:** SystemCapability.Multimedia.Camera.Core 1474 1475| 名称 | 值 | 说明 | 1476| ------- | ---- | ------------ | 1477| NONE | 0 | 无分段式能力。| 1478| PHOTO | 1 | 分段式拍照。| 1479| VIDEO | 2 | 分段式录像。| 1480 1481## DeferredPhotoProxy<sup>11+</sup> 1482 1483类对象,缩略图代理类。 1484 1485### getThumbnail<sup>11+</sup> 1486 1487getThumbnail(): Promise<image.PixelMap> 1488 1489通过缩略图代理类提供的方法,获取缩略图 PixelMap。 1490 1491**系统接口:** 此接口为系统接口。 1492 1493**系统能力:** SystemCapability.Multimedia.Camera.Core 1494 1495**返回值:** 1496 1497| 类型 | 说明 | 1498| -------------- | ----------------------- | 1499| Promise\<image.PixelMap\> | 缩略图 PixelMap。 | 1500 1501**错误码:** 1502 1503以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1504 1505| 错误码ID | 错误信息 | 1506| --------------- | --------------- | 1507| 202 | Not System Application. | 1508 1509**示例:** 1510 1511```ts 1512import { image } from '@kit.ImageKit'; 1513 1514function getThumbnail(proxyObj: camera.DeferredPhotoProxy): void { 1515 proxyObj.getThumbnail().then((thumbnail: image.PixelMap) => { 1516 AppStorage.setOrCreate('proxyThumbnail', thumbnail); 1517 }); 1518} 1519``` 1520 1521### release<sup>11+</sup> 1522 1523release(): Promise\<void\> 1524 1525释放输出资源。使用Promise异步回调。 1526 1527**系统接口:** 此接口为系统接口。 1528 1529**系统能力:** SystemCapability.Multimedia.Camera.Core 1530 1531**返回值:** 1532 1533| 类型 | 说明 | 1534| -------------- |------------------| 1535| Promise\<void\> | Promise对象,无返回结果。 | 1536 1537**错误码:** 1538 1539以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1540 1541| 错误码ID | 错误信息 | 1542| --------------- | --------------- | 1543| 202 | Not System Application. | 1544 1545**示例:** 1546 1547```ts 1548async function releaseDeferredPhotoProxy(proxyObj: camera.DeferredPhotoProxy): Promise<void> { 1549 await proxyObj.release(); 1550} 1551``` 1552 1553## PhotoOutput 1554 1555拍照会话中使用的输出信息,继承[CameraOutput](arkts-apis-camera-CameraOutput.md)。 1556 1557### burstCapture<sup>12+</sup> 1558 1559burstCapture(setting: PhotoCaptureSetting): Promise\<void\> 1560 1561开始连续拍照,一般用于拍照模式下,开始后底层持续上图,可以通过[confirmCapture](#confirmcapture11)取消连续拍照。使用Promise异步回调。 1562 1563**系统接口:** 此接口为系统接口。 1564 1565**系统能力:** SystemCapability.Multimedia.Camera.Core 1566 1567**参数:** 1568 1569| 参数名 | 类型 | 必填 | 说明 | 1570| ------- | ------------------------------------------- | ---- | -------- | 1571| setting | [PhotoCaptureSetting](arkts-apis-camera-i.md#photocapturesetting) | 是 | 拍照设置,传入undefined类型数据按默认无参处理。 | 1572 1573**返回值:** 1574 1575| 类型 | 说明 | 1576| -------------- | ------------------------ | 1577| Promise\<void\> | Promise对象,无返回结果。 | 1578 1579**错误码:** 1580 1581以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1582 1583| 错误码ID | 错误信息 | 1584| --------------- | --------------- | 1585| 202 | Not System Application. | 1586| 7400101 | Parameter missing or parameter type incorrect. | 1587| 7400104 | Session not running. | 1588| 7400201 | Camera service fatal error. | 1589 1590**示例:** 1591 1592```ts 1593import { BusinessError } from '@kit.BasicServicesKit'; 1594 1595function burstCapture(photoOutput: camera.PhotoOutput): void { 1596 let captureLocation: camera.Location = { 1597 latitude: 0, 1598 longitude: 0, 1599 altitude: 0 1600 } 1601 let settings: camera.PhotoCaptureSetting = { 1602 quality: camera.QualityLevel.QUALITY_LEVEL_LOW, 1603 rotation: camera.ImageRotation.ROTATION_0, 1604 location: captureLocation, 1605 mirror: false 1606 } 1607 photoOutput.burstCapture(settings).then(() => { 1608 console.info('Promise returned to indicate that photo burstCapture request success.'); 1609 }).catch((error: BusinessError) => { 1610 console.error(`Failed to photo output burstCapture, error code: ${error.code}.`); 1611 }); 1612} 1613``` 1614 1615### confirmCapture<sup>11+</sup> 1616 1617confirmCapture() 1618 1619确认拍照,一般用于夜景模式下,在曝光倒计时过程中如需终止倒计时提前拍照的时候调用。 1620 1621已经调用[burstCapture](#burstcapture12)开始连续拍照后,调用该接口用于结束连续拍照。 1622 1623**系统接口:** 此接口为系统接口。 1624 1625**系统能力:** SystemCapability.Multimedia.Camera.Core 1626 1627**错误码:** 1628 1629以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1630 1631| 错误码ID | 错误信息 | 1632| --------------- | --------------- | 1633| 202 | Not System Application. | 1634| 7400104 | Session not running. | 1635| 7400201 | Camera service fatal error. | 1636 1637**示例:** 1638 1639```ts 1640import { BusinessError } from '@kit.BasicServicesKit'; 1641 1642function confirmCapture(photoOutput: camera.PhotoOutput): void { 1643 try { 1644 photoOutput.confirmCapture(); 1645 } catch (error) { 1646 let err = error as BusinessError; 1647 console.error(`The confirmCapture call failed. error code: ${err.code}`); 1648 } 1649} 1650``` 1651 1652### isDeferredImageDeliverySupported<sup>11+</sup> 1653 1654isDeferredImageDeliverySupported(type: DeferredDeliveryImageType): boolean 1655 1656查询当前模式是否支持相关分段式能力。 1657 1658**系统接口:** 此接口为系统接口。 1659 1660**系统能力:** SystemCapability.Multimedia.Camera.Core 1661 1662**参数:** 1663 1664| 参数名 | 类型 | 必填 | 说明 | 1665| -------- | -------------------- | ---- | ------------------- | 1666| type | [DeferredDeliveryImageType](#deferreddeliveryimagetype11) | 是 | 分段式能力类型。 | 1667 1668**返回值:** 1669 1670| 类型 | 说明 | 1671| -------------- | ----------------------- | 1672| boolean | true: 当前模式支持该类型分段式能力, false: 不支持。 | 1673 1674**错误码:** 1675 1676以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1677 1678| 错误码ID | 错误信息 | 1679| --------------- |-----------------------------------------------------| 1680| 7400101 | Parameter missing or parameter type incorrect. | 1681| 7400104 | Session not running. | 1682| 7400201 | Camera service fatal error. | 1683| 202 | Not System Application. | 1684 1685**示例:** 1686 1687```ts 1688function isDeferredImageDeliverySupported(photoOutput: camera.PhotoOutput, type: camera.DeferredDeliveryImageType): boolean { 1689 let res: boolean = false; 1690 res = photoOutput.isDeferredImageDeliverySupported(type); 1691 return res; 1692} 1693``` 1694 1695### isDeferredImageDeliveryEnabled<sup>11+</sup> 1696 1697isDeferredImageDeliveryEnabled(type: DeferredDeliveryImageType): boolean 1698 1699查询当前模式是否已开启相关分段式能力。 1700 1701**系统接口:** 此接口为系统接口。 1702 1703**系统能力:** SystemCapability.Multimedia.Camera.Core 1704 1705**参数:** 1706 1707| 参数名 | 类型 | 必填 | 说明 | 1708| -------- | -------------------- | ---- | ------------------- | 1709| type | [DeferredDeliveryImageType](#deferreddeliveryimagetype11) | 是 | 分段式能力类型。 | 1710 1711**返回值:** 1712 1713| 类型 | 说明 | 1714| -------------- | ----------------------- | 1715| boolean | true: 当前模式已开启该类型分段式能力, false: 未开启。 | 1716 1717**错误码:** 1718 1719以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1720 1721| 错误码ID | 错误信息 | 1722| --------------- | --------------- | 1723| 7400101 | Parameter missing or parameter type incorrect. | 1724| 7400104 | Session not running. | 1725| 7400201 | Camera service fatal error. | 1726| 202 | Not System Application. | 1727 1728**示例:** 1729 1730```ts 1731function isDeferredImageDeliveryEnabled(photoOutput: camera.PhotoOutput, type: camera.DeferredDeliveryImageType): boolean { 1732 let res: boolean = false; 1733 res = photoOutput.isDeferredImageDeliveryEnabled(type); 1734 return res; 1735} 1736``` 1737 1738### deferImageDelivery<sup>11+</sup> 1739 1740deferImageDelivery(type: DeferredDeliveryImageType): void 1741 1742开启相关类型分段式能力。 1743 1744**系统接口:** 此接口为系统接口。 1745 1746**系统能力:** SystemCapability.Multimedia.Camera.Core 1747 1748**参数:** 1749 1750| 参数名 | 类型 | 必填 | 说明 | 1751| -------- | -------------------- | ---- | ------------------- | 1752| type | [DeferredDeliveryImageType](#deferreddeliveryimagetype11) | 是 | 分段式能力类型。 | 1753 1754**错误码:** 1755 1756以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1757 1758| 错误码ID | 错误信息 | 1759| --------------- | --------------- | 1760| 7400101 | Parameter missing or parameter type incorrect. | 1761| 7400104 | Session not running. | 1762| 7400201 | Camera service fatal error. | 1763| 202 | Not System Application. | 1764 1765**示例:** 1766 1767```ts 1768function deferImageDelivery(photoOutput: camera.PhotoOutput, type: camera.DeferredDeliveryImageType): void { 1769 photoOutput.deferImageDelivery(type); 1770} 1771``` 1772 1773### isAutoHighQualityPhotoSupported<sup>13+</sup> 1774 1775isAutoHighQualityPhotoSupported(): boolean 1776 1777判断当前是否支持自动高画质。 1778 1779**系统接口:** 此接口为系统接口。 1780 1781**系统能力:** SystemCapability.Multimedia.Camera.Core 1782 1783**返回值:** 1784 1785| 类型 | 说明 | 1786| -------------- | ----------------------- | 1787| boolean | 是否支持自动高画质,返回true是支持,返回false是不支持。| 1788 1789**错误码:** 1790 1791以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1792 1793| 错误码ID | 错误信息 | 1794| --------------- | --------------- | 1795| 202 | Not System Application. | 1796| 7400104 | Session not running. | 1797| 7400201 | Camera service fatal error. | 1798 1799**示例:** 1800 1801```ts 1802import { BusinessError } from '@kit.BasicServicesKit'; 1803 1804function isAutoHighQualityPhotoSupported(photoOutput: camera.PhotoOutput): boolean { 1805 return photoOutput.isAutoHighQualityPhotoSupported(); 1806} 1807``` 1808 1809### enableAutoHighQualityPhoto<sup>13+</sup> 1810 1811enableAutoHighQualityPhoto(enabled: boolean): void 1812 1813使能拍照自动高画质。设置拍照自动高画质之前,需要调用[isAutoHighQualityPhotoSupported](#isautohighqualityphotosupported13)判断当前是否支持。 1814 1815**系统接口:** 此接口为系统接口。 1816 1817**系统能力:** SystemCapability.Multimedia.Camera.Core 1818 1819**参数:** 1820 1821| 参数名 | 类型 | 必填 | 说明 | 1822| -------- | -------------------- | ---- | ------------------- | 1823| enabled | boolean | 是 | 是否使能拍照自动高画质,true为使能,false为不使能。 | 1824 1825**错误码:** 1826 1827以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1828 1829| 错误码ID | 错误信息 | 1830| --------------- | --------------- | 1831| 202 | Not System Application. | 1832| 7400101 | Parameter missing or parameter type incorrect. | 1833| 7400104 | Session not running. | 1834| 7400201 | Camera service fatal error. | 1835 1836**示例:** 1837 1838```ts 1839import { BusinessError } from '@kit.BasicServicesKit'; 1840 1841function enableAutoHighQualityPhoto(photoOutput: camera.PhotoOutput): void { 1842 return photoOutput.enableAutoHighQualityPhoto(true); 1843} 1844``` 1845 1846### on('deferredPhotoProxyAvailable')<sup>11+</sup> 1847 1848on(type: 'deferredPhotoProxyAvailable', callback: AsyncCallback\<DeferredPhotoProxy\>): void 1849 1850注册监听缩略图上报。使用callback异步回调。 1851 1852**系统接口:** 此接口为系统接口。 1853 1854**系统能力:** SystemCapability.Multimedia.Camera.Core 1855 1856**参数:** 1857 1858| 参数名 | 类型 | 必填 | 说明 | 1859| -------- | ---------- | --- | ------------------------------------ | 1860| type | string | 是 | 监听事件,固定为'deferredPhotoProxyAvailable',photoOutput创建成功后可监听。 | 1861| callback | AsyncCallback\<[DeferredPhotoProxy](#deferredphotoproxy11)\> | 是 | 回调函数,用于获取相关信息。用于监听缩略图上报。| 1862 1863**错误码:** 1864 1865以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1866 1867| 错误码ID | 错误信息 | 1868| --------------- | --------------- | 1869| 202 | Not System Application. | 1870 1871**示例:** 1872 1873```ts 1874import { BusinessError } from '@kit.BasicServicesKit'; 1875import { image } from '@kit.ImageKit'; 1876 1877function callback(err: BusinessError, proxyObj: camera.DeferredPhotoProxy): void { 1878 if (err !== undefined && err.code !== 0) { 1879 console.error(`Callback Error, errorCode: ${err.code}`); 1880 return; 1881 } 1882 proxyObj.getThumbnail().then((thumbnail: image.PixelMap) => { 1883 AppStorage.setOrCreate('proxyThumbnail', thumbnail); 1884 }); 1885} 1886 1887function registerPhotoOutputDeferredPhotoProxyAvailable(photoOutput: camera.PhotoOutput): void { 1888 photoOutput.on('deferredPhotoProxyAvailable', callback); 1889} 1890``` 1891 1892### off('deferredPhotoProxyAvailable')<sup>11+</sup> 1893 1894off(type: 'deferredPhotoProxyAvailable', callback?: AsyncCallback\<DeferredPhotoProxy\>): void 1895 1896注销监听缩略图上报。 1897 1898**系统接口:** 此接口为系统接口。 1899 1900**系统能力:** SystemCapability.Multimedia.Camera.Core 1901 1902**参数:** 1903 1904| 参数名 | 类型 | 必填 | 说明 | 1905| -------- | ---------------------- | ---- | ------------------------------------------ | 1906| type | string | 是 | 监听事件,固定为'deferredPhotoProxyAvailable',photoOutput创建成功后可监听。 | 1907| callback | AsyncCallback\<[DeferredPhotoProxy](#deferredphotoproxy11)\> | 否 | 回调函数,可选,有就是匹配on('deferredPhotoProxyAvailable') callback(callback对象不可是匿名函数)。 | 1908 1909**错误码:** 1910 1911以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1912 1913| 错误码ID | 错误信息 | 1914| --------------- | --------------- | 1915| 202 | Not System Application. | 1916 1917**示例:** 1918 1919```ts 1920import { BusinessError } from '@kit.BasicServicesKit'; 1921import { image } from '@kit.ImageKit'; 1922 1923function callback(err: BusinessError, proxyObj: camera.DeferredPhotoProxy): void { 1924 if (err !== undefined && err.code !== 0) { 1925 console.error(`Callback Error, errorCode: ${err.code}`); 1926 return; 1927 } 1928 proxyObj.getThumbnail().then((thumbnail: image.PixelMap) => { 1929 AppStorage.setOrCreate('proxyThumbnail', thumbnail); 1930 }); 1931} 1932 1933function unRegisterPhotoOutputDeferredPhotoProxyAvailable(photoOutput: camera.PhotoOutput): void { 1934 photoOutput.off('deferredPhotoProxyAvailable', callback); 1935} 1936``` 1937 1938### isQuickThumbnailSupported 1939 1940isQuickThumbnailSupported(): boolean 1941 1942是否支持输出快速缩略图。 1943 1944在[addOutput](arkts-apis-camera-Session.md#addoutput11)、[addInput](arkts-apis-camera-Session.md#addinput11)之后,[commitConfig](arkts-apis-camera-Session.md#commitconfig11-1)之前生效。 1945 1946**系统接口:** 此接口为系统接口。 1947 1948**系统能力:** SystemCapability.Multimedia.Camera.Core 1949 1950**返回值:** 1951 1952| 类型 | 说明 | 1953| --------- | ------ | 1954| boolean | 返回支持情况,如果返回true表示支持,否则不支持。 | 1955 1956**错误码:** 1957 1958以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 1959 1960| 错误码ID | 错误信息 | 1961| --------------- | --------------- | 1962| 202 | Not System Application. | 1963| 7400104 | session is not running. | 1964 1965**示例:** 1966 1967```ts 1968import { common } from '@kit.AbilityKit'; 1969 1970async function isQuickThumbnailSupported(context: common.BaseContext, mode: camera.SceneMode, photoProfile: camera.Profile): Promise<boolean> { 1971 let cameraManager: camera.CameraManager = camera.getCameraManager(context); 1972 let cameras: Array<camera.CameraDevice> = cameraManager.getSupportedCameras(); 1973 // 创建CaptureSession实例。 1974 let session: camera.Session = cameraManager.createSession(mode); 1975 // 开始配置会话。 1976 session.beginConfig(); 1977 // 把CameraInput加入到会话。 1978 let cameraInput: camera.CameraInput = cameraManager.createCameraInput(cameras[0]); 1979 await cameraInput.open(); 1980 session.addInput(cameraInput); 1981 // 把photoOutput加入到会话。 1982 let photoOutput: camera.PhotoOutput = cameraManager.createPhotoOutput(photoProfile); 1983 session.addOutput(photoOutput); 1984 let isSupported: boolean = photoOutput.isQuickThumbnailSupported(); 1985 return isSupported; 1986} 1987``` 1988 1989### enableQuickThumbnail 1990 1991enableQuickThumbnail(enabled: boolean): void 1992 1993启用/禁用快速缩略图。 1994 1995在[addOutput](arkts-apis-camera-Session.md#addoutput11)、[addInput](arkts-apis-camera-Session.md#addinput11)之后,[commitConfig](arkts-apis-camera-Session.md#commitconfig11-1)之前生效。 1996 1997**系统接口:** 此接口为系统接口。 1998 1999**系统能力:** SystemCapability.Multimedia.Camera.Core 2000 2001**参数:** 2002 2003| 参数名 | 类型 | 必填 | 说明 | 2004| -------- | ------------- | ---- | ----------------------------------- | 2005| enabled | boolean | 是 | true:使能快速缩略图;false:去使能快速缩略图。 | 2006 2007**错误码:** 2008 2009以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2010 2011| 错误码ID | 错误信息 | 2012| --------------- | --------------- | 2013| 202 | Not System Application. | 2014| 7400101 | Parameter missing or parameter type incorrect. | 2015| 7400104 | session is not running. | 2016| 7400201 | Camera service fatal error. | 2017 2018**示例:** 2019 2020```ts 2021import { common } from '@kit.AbilityKit'; 2022import { BusinessError } from '@kit.BasicServicesKit'; 2023import { camera } from '@kit.CameraKit'; 2024 2025async function enableQuickThumbnail(context: common.BaseContext, mode: camera.SceneMode, photoProfile: camera.Profile): Promise<void> { 2026 let cameraManager: camera.CameraManager = camera.getCameraManager(context); 2027 let cameras: Array<camera.CameraDevice> = cameraManager.getSupportedCameras(); 2028 // 创建CaptureSession实例。 2029 let session: camera.Session = cameraManager.createSession(mode); 2030 // 开始配置会话。 2031 session.beginConfig(); 2032 // 把CameraInput加入到会话。 2033 let cameraInput: camera.CameraInput = cameraManager.createCameraInput(cameras[0]); 2034 await cameraInput.open(); 2035 session.addInput(cameraInput); 2036 // 把PhotoOutPut加入到会话。 2037 let photoOutput: camera.PhotoOutput = cameraManager.createPhotoOutput(photoProfile); 2038 session.addOutput(photoOutput); 2039 let isSupported: boolean = photoOutput.isQuickThumbnailSupported(); 2040 if (!isSupported) { 2041 console.info('Quick Thumbnail is not supported to be turned on.'); 2042 return; 2043 } 2044 try { 2045 photoOutput.enableQuickThumbnail(true); 2046 } catch (error) { 2047 let err = error as BusinessError; 2048 console.error(`The enableQuickThumbnail call failed. error code: ${err.code}`); 2049 } 2050} 2051``` 2052 2053### on('quickThumbnail') 2054 2055on(type: 'quickThumbnail', callback: AsyncCallback\<image.PixelMap>): void 2056 2057监听快速缩略图输出事件。使用callback异步回调。 2058 2059在enableQuickThumbnail(true)使能快速缩略图之后监听生效。 2060 2061**系统接口:** 此接口为系统接口。 2062 2063**系统能力:** SystemCapability.Multimedia.Camera.Core 2064 2065**参数:** 2066 2067| 参数名 | 类型 | 必填 | 说明 | 2068| -------- | ------------- | ---- | ----------------------------------- | 2069| type | string | 是 | 监听事件,固定为'quickThumbnail'。 | 2070| callback | AsyncCallback\<[image.PixelMap](../apis-image-kit/arkts-apis-image-PixelMap.md)> | 是 | 回调返回PixelMap。 | 2071 2072**示例:** 2073 2074```ts 2075import { common } from '@kit.AbilityKit'; 2076import { BusinessError } from '@kit.BasicServicesKit'; 2077import { image } from '@kit.ImageKit'; 2078import { camera } from '@kit.CameraKit'; 2079 2080function callback(err: BusinessError, pixelMap: image.PixelMap): void { 2081 if (err || pixelMap === undefined) { 2082 console.error('photoOutput on thumbnail failed'); 2083 return; 2084 } 2085 // 显示或保存pixelMap。 2086 // 执行操作。 2087} 2088 2089async function registerQuickThumbnail(context: common.BaseContext, mode: camera.SceneMode, photoProfile: camera.Profile): Promise<void> { 2090 let cameraManager: camera.CameraManager = camera.getCameraManager(context); 2091 let cameras: Array<camera.CameraDevice> = cameraManager.getSupportedCameras(); 2092 // 创建CaptureSession实例。 2093 let session: camera.Session = cameraManager.createSession(mode); 2094 // 开始配置会话。 2095 session.beginConfig(); 2096 // 把CameraInput加入到会话。 2097 let cameraInput: camera.CameraInput = cameraManager.createCameraInput(cameras[0]); 2098 await cameraInput.open(); 2099 session.addInput(cameraInput); 2100 // 把PhotoOutPut加入到会话。 2101 let photoOutput: camera.PhotoOutput = cameraManager.createPhotoOutput(photoProfile); 2102 session.addOutput(photoOutput); 2103 let isSupported: boolean = photoOutput.isQuickThumbnailSupported(); 2104 if (!isSupported) { 2105 console.info('Quick Thumbnail is not supported to be turned on.'); 2106 return; 2107 } 2108 try { 2109 photoOutput.enableQuickThumbnail(true); 2110 } catch (error) { 2111 let err = error as BusinessError; 2112 console.error(`The enableQuickThumbnail call failed. error code: ${err.code}`); 2113 } 2114 2115 photoOutput.on('quickThumbnail', callback); 2116} 2117``` 2118 2119### off('quickThumbnail') 2120 2121off(type: 'quickThumbnail', callback?: AsyncCallback\<image.PixelMap>): void 2122 2123注销监听快速缩略图输出事件。 2124 2125**系统接口:** 此接口为系统接口。 2126 2127**系统能力:** SystemCapability.Multimedia.Camera.Core 2128 2129**参数:** 2130 2131| 参数名 | 类型 | 必填 | 说明 | 2132| -------- | ------------- | ---- | ----------------------------------- | 2133| type | string | 是 | 监听事件,固定为'quickThumbnail'。 | 2134| callback | AsyncCallback\<[image.PixelMap](../apis-image-kit/arkts-apis-image-PixelMap.md)> | 否 | 回调函数,可选,有就是匹配on('quickThumbnail') callback(callback对象不可是匿名函数)。 | 2135 2136**示例:** 2137 2138```ts 2139function unregisterQuickThumbnail(photoOutput: camera.PhotoOutput): void { 2140 photoOutput.off('quickThumbnail'); 2141} 2142``` 2143 2144## MetadataOutput 2145 2146metadata流。继承[CameraOutput](arkts-apis-camera-CameraOutput.md)。 2147 2148### addMetadataObjectTypes<sup>13+</sup> 2149 2150addMetadataObjectTypes(types: Array\<MetadataObjectType\>): void 2151 2152新增需要上报的检测对象类型。 2153 2154**系统能力:** SystemCapability.Multimedia.Camera.Core 2155 2156**参数:** 2157 2158| 参数名 | 类型 | 必填 | 说明 | 2159| -------------------- | -------------------------------------------------- | --- | ---------------------------- | 2160| types | Array\<[MetadataObjectType](#metadataobjecttype)\> | 是 | metadata流类型信息,通过getSupportedOutputCapability接口获取。 | 2161 2162**错误码:** 2163 2164以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2165 2166| 错误码ID | 错误信息 | 2167| --------------- | --------------- | 2168| 202 | Not system application. | 2169| 7400101 | Parameter missing or parameter type incorrect. | 2170| 7400103 | Session not config. | 2171| 7400201 | Camera service fatal error. | 2172 2173**示例:** 2174 2175```ts 2176import { BusinessError } from '@kit.BasicServicesKit'; 2177 2178function addMetadataObjectTypes(metadataOutput: camera.MetadataOutput, types: Array<camera.MetadataObjectType>): void { 2179 try { 2180 metadataOutput.addMetadataObjectTypes(types); 2181 } catch (error) { 2182 // 失败返回错误码error.code并处理。 2183 let err = error as BusinessError; 2184 console.error(`addMetadataObjectTypes error. error code: ${err.code}`); 2185 } 2186} 2187``` 2188 2189### removeMetadataObjectTypes<sup>13+</sup> 2190 2191removeMetadataObjectTypes(types: Array\<MetadataObjectType\>): void 2192 2193删除需要上报的检测对象类型。 2194 2195**系统能力:** SystemCapability.Multimedia.Camera.Core 2196 2197**参数:** 2198 2199| 参数名 | 类型 | 必填 | 说明 | 2200| -------------------- | -------------------------------------------------- | --- | ---------------------------- | 2201| types | Array\<[MetadataObjectType](#metadataobjecttype)\> | 是 | metadata流类型信息,通过getSupportedOutputCapability接口获取。 | 2202 2203**错误码:** 2204 2205以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2206 2207| 错误码ID | 错误信息 | 2208| --------------- | --------------- | 2209| 202 | Not system application. | 2210| 7400101 | Parameter missing or parameter type incorrect. | 2211| 7400103 | Session not config. | 2212| 7400201 | Camera service fatal error. | 2213 2214**示例:** 2215 2216```ts 2217import { BusinessError } from '@kit.BasicServicesKit'; 2218 2219function removeMetadataObjectTypes(metadataOutput: camera.MetadataOutput, types: Array<camera.MetadataObjectType>): void { 2220 try { 2221 metadataOutput.removeMetadataObjectTypes(types); 2222 } catch (error) { 2223 // 失败返回错误码error.code并处理。 2224 let err = error as BusinessError; 2225 console.error(`removeMetadataObjectTypes error. error code: ${err.code}`); 2226 } 2227} 2228``` 2229 2230## MetadataObjectType 2231 2232枚举,metadata元数据检测类型。 2233 2234**系统能力:** SystemCapability.Multimedia.Camera.Core 2235 2236| 名称 | 值 | 说明 | 2237| -------------------------- | ---- | ----------------- | 2238| HUMAN_BODY<sup>13+</sup> | 1 | 用于检测人体的metadata类型。 | 2239| CAT_FACE<sup>13+</sup> | 2 | 用于检测猫脸的metadata类型。 | 2240| CAT_BODY<sup>13+</sup> | 3 | 用于检测猫的身体的metadata类型。 | 2241| DOG_FACE<sup>13+</sup> | 4 | 用于检测狗脸的metadata类型。 | 2242| DOG_BODY<sup>13+</sup> | 5 | 用于检测狗的身体的metadata类型。 | 2243| SALIENT_DETECTION<sup>13+</sup> | 6 | 用于显著性检测。 | 2244 2245## Emotion<sup>13+</sup> 2246枚举,人脸检测信息中的情绪类型。 2247 2248**系统能力:** SystemCapability.Multimedia.Camera.Core 2249 2250| 名称 | 值 | 说明 | 2251| -------------------------- | ---- | ----------------- | 2252| NEUTRAL | 0 | 平静。 | 2253| SADNESS | 1 | 悲伤。 | 2254| SMILE | 2 | 微笑。 | 2255| SURPRISE | 3 | 惊讶。 | 2256 2257## MetadataObject 2258 2259相机检测元数据信息的基础类型,[CameraInput](#camerainput)相机信息中的数据来源,通过metadataOutput.[on('metadataObjectsAvailable')](arkts-apis-camera-MetadataOutput.md#onmetadataobjectsavailable)接口获取。 2260 2261**系统能力:** SystemCapability.Multimedia.Camera.Core 2262 2263| 名称 | 类型 | 只读 | 可选 |说明 | 2264| ----------- | ------------------------------------------- | ---- | ---- | ----------------- | 2265| objectId<sup>13+</sup> | number | 是 | 否 | metadataObject Id序号。| 2266| confidence<sup>13+</sup> | number | 是 | 否 | 检测置信度,取值范围[0,1]。| 2267 2268## MetadataFaceObject<sup>13+</sup> 2269 2270相机检测到的人脸元数据信息,继承自[MetadataObject](#metadataobject),[CameraInput](#camerainput)相机信息中的数据来源,通过metadataOutput.[on('metadataObjectsAvailable')](arkts-apis-camera-MetadataOutput.md#onmetadataobjectsavailable)接口获取。 2271 2272**系统能力:** SystemCapability.Multimedia.Camera.Core 2273 2274| 名称 | 类型 | 只读 | 可选 |说明 | 2275| ---------------------- | --------------------------------- | ---- | ---- | --------------------- | 2276| leftEyeBoundingBox | [Rect](arkts-apis-camera-i.md#rect) | 是 | 否 | 左眼区域框| 2277| rightEyeBoundingBox | [Rect](arkts-apis-camera-i.md#rect) | 是 | 否 | 右眼区域框。| 2278| emotion | [Emotion](#emotion13) | 是 | 否 | 检测到的情绪类型。| 2279| emotionConfidence | number | 是 | 否 | 情绪检测置信度,取值范围[0,1]。| 2280| pitchAngle | number | 是 | 否 | 俯仰角度,取值范围[-90, 90],以向下为正。| 2281| yawAngle | number | 是 | 否 | 左右旋转角度,取值范围[-90, 90],以向右为正。| 2282| rollAngle | number | 是 | 否 | 平面内旋转角度,取值范围[-180, 180],以顺时针方向为正。| 2283 2284## MetadataHumanBodyObject<sup>13+</sup> 2285 2286相机检测到的人体元数据信息,继承自[MetadataObject](#metadataobject),[CameraInput](#camerainput)相机信息中的数据来源,通过metadataOutput.[on('metadataObjectsAvailable')](arkts-apis-camera-MetadataOutput.md#onmetadataobjectsavailable)接口获取。 2287 2288**系统能力:** SystemCapability.Multimedia.Camera.Core 2289 2290## MetadataCatFaceObject<sup>13+</sup> 2291 2292相机检测到的猫脸元数据信息,继承自[MetadataObject](#metadataobject),[CameraInput](#camerainput)相机信息中的数据来源,通过metadataOutput.[on('metadataObjectsAvailable')](arkts-apis-camera-MetadataOutput.md#onmetadataobjectsavailable)接口获取。 2293 2294**系统能力:** SystemCapability.Multimedia.Camera.Core 2295 2296| 名称 | 类型 | 只读 | 可选 |说明 | 2297| ---------------------- | --------------------------------- | ---- | ---- | --------------------- | 2298| leftEyeBoundingBox | [Rect](arkts-apis-camera-i.md#rect) | 是 | 否 | 左眼区域框。| 2299| rightEyeBoundingBox | [Rect](arkts-apis-camera-i.md#rect) | 是 | 否 | 右眼区域框。| 2300 2301## MetadataCatBodyObject<sup>13+</sup> 2302 2303相机检测到的猫的身体元数据信息,继承自[MetadataObject](#metadataobject),[CameraInput](#camerainput)相机信息中的数据来源,通过metadataOutput.[on('metadataObjectsAvailable')](arkts-apis-camera-MetadataOutput.md#onmetadataobjectsavailable)接口获取。 2304 2305**系统能力:** SystemCapability.Multimedia.Camera.Core 2306 2307## MetadataDogFaceObject<sup>13+</sup> 2308 2309相机检测到的狗脸元数据信息,继承自[MetadataObject](#metadataobject),[CameraInput](#camerainput)相机信息中的数据来源,通过metadataOutput.[on('metadataObjectsAvailable')](arkts-apis-camera-MetadataOutput.md#onmetadataobjectsavailable)接口获取。 2310 2311**系统能力:** SystemCapability.Multimedia.Camera.Core 2312 2313| 名称 | 类型 | 只读 | 可选 |说明 | 2314| ---------------------- | --------------------------------- | ---- | ---- | --------------------- | 2315| leftEyeBoundingBox | [Rect](arkts-apis-camera-i.md#rect) | 是 | 否 | 左眼区域框。| 2316| rightEyeBoundingBox | [Rect](arkts-apis-camera-i.md#rect) | 是 | 否 | 右眼区域框。| 2317 2318## MetadataDogBodyObject<sup>13+</sup> 2319 2320相机检测到的狗的身体元数据信息,继承自[MetadataObject](#metadataobject),[CameraInput](#camerainput)相机信息中的数据来源,通过metadataOutput.[on('metadataObjectsAvailable')](arkts-apis-camera-MetadataOutput.md#onmetadataobjectsavailable)接口获取。 2321 2322**系统能力:** SystemCapability.Multimedia.Camera.Core 2323 2324## MetadataSalientDetectionObject<sup>13+</sup> 2325 2326相机检测到的显著性元数据信息,继承自[MetadataObject](#metadataobject),[CameraInput](#camerainput)相机信息中的数据来源,通过metadataOutput.[on('metadataObjectsAvailable')](arkts-apis-camera-MetadataOutput.md#onmetadataobjectsavailable)接口获取。 2327 2328**系统能力:** SystemCapability.Multimedia.Camera.Core 2329 2330## MetadataBarcodeObject<sup>14+</sup> 2331 2332相机检测到的二维码元数据信息,继承自[MetadataObject](#metadataobject),[CameraInput](#camerainput)相机信息中的数据来源,通过metadataOutput.[on('metadataObjectsAvailable')](arkts-apis-camera-MetadataOutput.md#onmetadataobjectsavailable)接口获取。 2333 2334**系统能力:** SystemCapability.Multimedia.Camera.Core 2335 2336## PortraitEffect 2337 2338人像效果类型。 2339 2340**系统接口:** 此接口为系统接口。 2341 2342**系统能力:** SystemCapability.Multimedia.Camera.Core 2343 2344| 名称 | 值 | 说明 | 2345| ----------------| ---- | ---------| 2346| OFF | 0 | 关闭。 | 2347| CIRCLES | 1 | 圆形。 | 2348| HEART<sup>11+</sup> | 2 | 心形。 | 2349| ROTATED<sup>11+</sup> | 3 | 旋焦。 | 2350| STUDIO<sup>11+</sup> | 4 | 影棚光。 | 2351| THEATER<sup>11+</sup> | 5 | 剧场光。 | 2352 2353## BeautyQuery<sup>12+</sup> 2354 2355提供了获取和设置美颜效果的方法。 2356 2357### getSupportedBeautyTypes<sup>11+</sup> 2358 2359getSupportedBeautyTypes(): Array\<BeautyType\> 2360 2361获取当前支持的美颜效果列表。 2362 2363**系统接口:** 此接口为系统接口。 2364 2365**系统能力:** SystemCapability.Multimedia.Camera.Core 2366 2367**返回值:** 2368 2369| 类型 | 说明 | 2370| ---------- | ----------------------------- | 2371| Array\<[BeautyType](#beautytype)\>| 返回当前支持的美颜效果列表。 | 2372 2373**错误码:** 2374 2375以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2376 2377| 错误码ID | 错误信息 | 2378| --------------- | --------------- | 2379| 202 | Not System Application. | 2380| 7400103 | Session not config. | 2381 2382**示例:** 2383 2384```ts 2385function getSupportedBeautyTypes(portraitPhotoSession: camera.PortraitPhotoSession): Array<camera.BeautyType> { 2386 let beautyTypes: Array<camera.BeautyType> = portraitPhotoSession.getSupportedBeautyTypes(); 2387 return beautyTypes; 2388} 2389``` 2390 2391### getSupportedBeautyRange<sup>11+</sup> 2392 2393getSupportedBeautyRange(type: BeautyType): Array\<number\> 2394 2395获取指定美颜效果的范围值。在不同设备返回的美颜强度有所不同,下表仅做示例。 2396 2397| 传入参数 | 示例返回值 | 返回值说明 | 2398| ----------------| ---- | ---------| 2399| AUTO | [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] |美颜类型为自动时支持的美颜强度,0表明关闭美颜,其余正值表明自动的美颜强度。 | 2400| SKIN_SMOOTH | [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | 美颜类型为光滑时支持的美颜强度,0表明关闭光滑,其余正值表明光滑的美颜强度。 | 2401| FACE_SLENDER | [0, 1, 2, 3, 4, 5] | 美颜类型为瘦脸时支持的美颜强度,0表明关闭瘦脸,其余正值表明瘦脸的美颜强度。 | 2402| SKIN_TONE | [-1, 16242611] | 美颜类型为美肤时支持的美颜强度,-1表明关闭美肤,其余非负值为使用RGB表示的美肤美颜强度,<br> 16242611转化为16进制为0xF7D7B3,F7为R通道值,D7为G通道值,B3位B通道值。 | 2403 2404**系统接口:** 此接口为系统接口。 2405 2406**系统能力:** SystemCapability.Multimedia.Camera.Core 2407 2408**参数:** 2409 2410| 参数名 | 类型 | 必填 | 说明 | 2411| -------- | --------------------------| ---- | ----------| 2412| type | [BeautyType](#beautytype) | 是 | 美颜类型。 | 2413 2414**返回值:** 2415 2416| 类型 | 说明 | 2417| ---------- | ----------------------------- | 2418| Array\<number\> | 当前美颜类型所支持的美颜强度。 | 2419 2420**错误码:** 2421 2422以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2423 2424| 错误码ID | 错误信息 | 2425| --------------- | --------------- | 2426| 202 | Not System Application. | 2427| 7400103 | Session not config. | 2428 2429**示例:** 2430 2431```ts 2432function getSupportedBeautyRange(portraitPhotoSession: camera.PortraitPhotoSession): Array<number> { 2433 let beautyTypes: Array<camera.BeautyType> = portraitPhotoSession.getSupportedBeautyTypes(); 2434 if (beautyTypes === undefined || beautyTypes.length <= 0) { 2435 return []; 2436 } 2437 let beautyLevels: Array<number> = portraitPhotoSession.getSupportedBeautyRange(beautyTypes[0]); 2438 return beautyLevels; 2439} 2440``` 2441 2442## BeautyType 2443 2444美颜类型。 2445 2446**系统接口:** 此接口为系统接口。 2447 2448**系统能力:** SystemCapability.Multimedia.Camera.Core 2449 2450| 名称 | 值 | 说明 | 2451| ----------------| ---- | ---------| 2452| AUTO | 0 | 自动。 | 2453| SKIN_SMOOTH | 1 | 光滑。 | 2454| FACE_SLENDER | 2 | 瘦脸。 | 2455| SKIN_TONE | 3 | 肤色。 | 2456 2457## ManualExposureQuery<sup>12+</sup> 2458 2459此接口提供了查询设备对手动曝光范围支持的功能。 2460 2461### getSupportedExposureRange<sup>11+</sup> 2462 2463getSupportedExposureRange(): Array\<number\> 2464 2465获取当前支持的手动曝光时长,单位ms。 2466 2467**系统接口:** 此接口为系统接口。 2468 2469**系统能力:** SystemCapability.Multimedia.Camera.Core 2470 2471**返回值:** 2472 2473| 类型 | 说明 | 2474| ---------- | ----------------------------- | 2475| Array\<number\>| 返回当前支持的手动曝光时长,单位ms。 | 2476 2477**错误码:** 2478 2479以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2480 2481| 错误码ID | 错误信息 | 2482| --------------- | --------------- | 2483| 202 | Not System Application. | 2484| 7400101 | Parameter missing or parameter type incorrect. | 2485| 7400103 | Session not config, only throw in session usage. | 2486 2487 **示例:** 2488 2489```ts 2490function getSupportedExposureRange(nightPhotoSession: camera.NightPhotoSession): Array<number> { 2491 let exposureRange: Array<number> = nightPhotoSession.getSupportedExposureRange(); 2492 return exposureRange; 2493} 2494``` 2495 2496## ManualExposure<sup>11+</sup> 2497 2498ManualExposure extends [ManualExposureQuery](#manualexposurequery12) 2499 2500提供了获取和设置曝光值的功能。 2501 2502### getExposure<sup>11+</sup> 2503 2504getExposure(): number 2505 2506查询当前已设置的手动曝光时长,单位为ms。 2507 2508**系统接口:** 此接口为系统接口。 2509 2510**系统能力:** SystemCapability.Multimedia.Camera.Core 2511 2512**返回值:** 2513| 参数名 | 类型 | 必填 | 说明 | 2514| -------- | ------------------------------------------------- | ---- | --------------------- | 2515| value | number | 是 | 手动曝光时长,单位为ms。 | 2516 2517**错误码:** 2518 2519以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2520 2521| 错误码ID | 错误信息 | 2522| --------------- | --------------- | 2523| 202 | Not System Application. | 2524| 7400101 | Parameter missing or parameter type incorrect. | 2525| 7400103 | Session not config. | 2526 2527**示例:** 2528 2529```ts 2530function getExposure(nightPhotoSession: camera.NightPhotoSession): number | undefined { 2531 let exposureRange: Array<number> = nightPhotoSession.getSupportedExposureRange(); 2532 if (exposureRange === undefined || exposureRange.length <= 0) { 2533 return undefined; 2534 } 2535 let exposure: number = nightPhotoSession.getExposure(); 2536 return exposure; 2537} 2538``` 2539 2540### setExposure<sup>11+</sup> 2541 2542setExposure(exposure: number): void 2543 2544设置手动曝光时长。[getSupportedExposureRange](#getsupportedexposurerange11)获取得到支持的手动曝光时长列表选取用户所需的时长下发,单位ms。 2545 2546**系统接口:** 此接口为系统接口。 2547 2548**系统能力:** SystemCapability.Multimedia.Camera.Core 2549 2550**参数:** 2551 2552| 参数名 | 类型 | 必填 | 说明 | 2553| -------- | --------------------------| ---- |-------------------------------------------------------------------------| 2554| value | number | 是 | 手动曝光时长,通过[getSupportedExposureRange](#getsupportedexposurerange11)接口获取。 | 2555 2556 **错误码:** 2557 2558| 错误码ID | 错误信息 | 2559| --------------- | --------------- | 2560| 202 | Not System Application. | 2561| 7400102 | Operation not allowed. | 2562| 7400103 | Session not config. | 2563 2564```ts 2565function setExposure(nightPhotoSession: camera.NightPhotoSession): void { 2566 let exposureRange: Array<number> = nightPhotoSession.getSupportedExposureRange(); 2567 if (exposureRange === undefined || exposureRange.length <= 0) { 2568 return; 2569 } 2570 nightPhotoSession.setExposure(exposureRange[0]); 2571} 2572``` 2573 2574## TripodStatus<sup>13+</sup> 2575 2576枚举,脚架状态枚举。 2577 2578**系统能力:** SystemCapability.Multimedia.Camera.Core 2579 2580| 名称 | 值 | 说明 | 2581|----------|-----|-------------------------------------| 2582| INVALID | 0 | 错误状态/默认未检测到脚架状态。**系统接口:** 此接口为系统接口。 | 2583| ACTIVE | 1 | 脚架活动状态。**系统接口:** 此接口为系统接口。 | 2584| ENTERING | 2 | 进入脚架稳定状态。**系统接口:** 此接口为系统接口。 | 2585| EXITING | 3 | 退出脚架稳定状态。**系统接口:** 此接口为系统接口。 | 2586 2587 2588## SceneFeatureType<sup>12+</sup> 2589 2590枚举,场景特性枚举。 2591 2592**系统能力:** SystemCapability.Multimedia.Camera.Core 2593 2594| 名称 | 值 | 说明 | 2595|-------------------------------|-----|---------------------------| 2596| MOON_CAPTURE_BOOST | 0 | 月亮场景。**系统接口:** 此接口为系统接口。 | 2597| TRIPOD_DETECTION<sup>13+</sup> | 1 | 使用脚架拍摄的场景。**系统接口:** 此接口为系统接口。 | 2598| LOW_LIGHT_BOOST<sup>13+</sup> | 2 | 长曝光场景。**系统接口:** 此接口为系统接口。 | 2599 2600## SceneFeatureDetectionResult<sup>12+</sup> 2601 2602场景检测结果信息。 2603 2604**系统能力:** SystemCapability.Multimedia.Camera.Core 2605 2606| 名称 | 类型 | 只读 | 必填 | 说明 | 2607| -------- | ---------- | -------- | -------- | ---------- | 2608| featureType | [SceneFeatureType](#scenefeaturetype12) | 是 | 是 | 特性类型。 | 2609| detected | boolean | 是 | 是 | 检测结果。true为检测到指定特性场景,false为未检测到指定特性场景。 | 2610 2611## TripodDetectionResult<sup>13+</sup> 2612 2613TripodDetectionResult extends [SceneFeatureDetectionResult](#scenefeaturedetectionresult12) 2614 2615脚架检测信息。 2616 2617**系统能力:** SystemCapability.Multimedia.Camera.Core 2618 2619| 名称 | 类型 | 只读 | 必填 | 说明 | 2620| -------- |---------------------------------| -------- | -------- |---------| 2621| tripodStatus | [TripodStatus](#tripodstatus13) | 是 | 是 | 脚架状态信息。 | 2622 2623## SceneDetection<sup>12+</sup> 2624 2625场景检测能力。 2626 2627### isSceneFeatureSupported<sup>12+</sup> 2628 2629isSceneFeatureSupported(type: SceneFeatureType): boolean 2630 2631查询是否支持指定特性。 2632 2633**系统接口:** 此接口为系统接口。 2634 2635**系统能力:** SystemCapability.Multimedia.Camera.Core 2636 2637**参数:** 2638 2639| 参数名 | 类型 | 必填 | 说明 | 2640|-------|-------------------------------------------|-----|-------------| 2641| type | [SceneFeatureType](#scenefeaturetype12) | 是 | 指定对应的场景特性。 | 2642 2643**返回值:** 2644 2645| 类型 | 说明 | 2646|-----------|--------------| 2647| boolean | 返回是否支持指定特性,返回true为支持,返回false为不支持。 | 2648 2649**错误码:** 2650 2651以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2652 2653| 错误码ID | 错误信息 | 2654|---------|------------------------------------------------| 2655| 202 | Not System Application. | 2656| 7400101 | Parameter missing or parameter type incorrect. | 2657 2658**示例:** 2659 2660```ts 2661function isSceneFeatureSupported(photoSessionForSys: camera.PhotoSessionForSys, featureType: camera.SceneFeatureType): boolean { 2662 let isSupported: boolean = photoSessionForSys.isSceneFeatureSupported(featureType); 2663 return isSupported; 2664} 2665``` 2666 2667### enableSceneFeature<sup>12+</sup> 2668 2669enableSceneFeature(type: SceneFeatureType, enabled: boolean): void 2670 2671使能指定特性,该接口应当在收到对应场景检测回调结果[SceneFeatureDetectionResult](#scenefeaturedetectionresult12)之后调用。 2672 2673**系统接口:** 此接口为系统接口。 2674 2675**系统能力:** SystemCapability.Multimedia.Camera.Core 2676 2677**参数:** 2678 2679| 参数名 | 类型 | 必填 | 说明 | 2680|---------|-------------------------------------------|-----|-----------------------------| 2681| type | [SceneFeatureType](#scenefeaturetype12) | 是 | 指定需要开启或关闭的特性。 | 2682| enabled | boolean | 是 | true表明开启指定特性,false表明关闭指定特性。 | 2683 2684**错误码:** 2685 2686以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2687 2688| 错误码ID | 错误信息 | 2689|---------|------------------------------------------------| 2690| 202 | Not System Application. | 2691| 7400101 | Parameter missing or parameter type incorrect. | 2692 2693**示例:** 2694 2695```ts 2696import { BusinessError } from '@kit.BasicServicesKit'; 2697 2698function enableSceneFeature(photoSession: camera.PhotoSessionForSys, cameraInput: camera.CameraInput, previewOutput: camera.PreviewOutput): void { 2699 photoSession.beginConfig(); 2700 photoSession.addInput(cameraInput); 2701 photoSession.addOutput(previewOutput); 2702 photoSession.commitConfig(); 2703 2704 photoSession.on('featureDetection', camera.SceneFeatureType.MOON_CAPTURE_BOOST, 2705 (err: BusinessError, statusObject: camera.SceneFeatureDetectionResult) => { 2706 if (err !== undefined && err.code !== 0) { 2707 console.error(`Callback Error, errorCode: ${err.code}`); 2708 return; 2709 } 2710 console.info( 2711 `on featureDetectionStatus featureType:${statusObject.featureType} detected:${statusObject.detected}`); 2712 if (statusObject.featureType === camera.SceneFeatureType.MOON_CAPTURE_BOOST) { 2713 try { 2714 photoSession.enableSceneFeature(statusObject.featureType, statusObject.detected); 2715 } catch (error) { 2716 let err = error as BusinessError; 2717 console.error(`The enableSceneFeature call failed. error code: ${err.code}`); 2718 } 2719 } 2720 }); 2721} 2722``` 2723 2724## ZoomPointInfo<sup>12+</sup> 2725 2726等效焦距信息。 2727 2728**系统接口:** 此接口为系统接口。 2729 2730**系统能力:** SystemCapability.Multimedia.Camera.Core 2731 2732| 名称 | 类型 | 只读 | 可选 | 说明 | 2733| -------- | ---------- | -------- |-----| ---------- | 2734| zoomRatio | number | 是 | 否 | 可变焦距比。 | 2735| equivalentFocalLength | number | 是 | 否 | 当前焦距比对应的等效焦距值。 | 2736 2737## ZoomQuery<sup>12+</sup> 2738 2739提供获取当前模式的等效焦距信息列表的方法。 2740 2741### getZoomPointInfos<sup>12+</sup> 2742 2743getZoomPointInfos(): Array\<ZoomPointInfo\> 2744 2745获取当前模式的等效焦距信息列表。 2746 2747**系统接口:** 此接口为系统接口。 2748 2749**系统能力:** SystemCapability.Multimedia.Camera.Core 2750 2751**返回值:** 2752 2753| 类型 | 说明 | 2754| ---------- | ----------------------------- | 2755| Array\<[ZoomPointInfo](#zoompointinfo12)\>| 获取当前模式的等效焦距信息列表。 | 2756 2757**错误码:** 2758 2759以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2760 2761| 错误码ID | 错误信息 | 2762| --------------- | --------------- | 2763| 202 | Not System Application. | 2764| 7400103 | Session not config. | 2765 2766**示例:** 2767 2768```ts 2769import { camera } from '@kit.CameraKit'; 2770import { BusinessError } from '@kit.BasicServicesKit'; 2771 2772function getZoomPointInfos(photoSessionForSys: camera.PhotoSessionForSys): Array<camera.ZoomPointInfo> { 2773 let zoomPointInfos: Array<camera.ZoomPointInfo> = []; 2774 try { 2775 zoomPointInfos = photoSessionForSys.getZoomPointInfos(); 2776 } catch (error) { 2777 // If the operation fails, error.code is returned and processed. 2778 let err = error as BusinessError; 2779 console.error(`The getZoomPointInfos call failed. error code: ${err.code}`); 2780 } 2781 return zoomPointInfos; 2782} 2783``` 2784 2785## Zoom<sup>11+</sup> 2786 2787Zoom extend [ZoomQuery](#zoomquery12) 2788 2789提供了处理设备变焦效果的相关方法,包括获取当前的变焦比,设置变焦比率,以及通过平滑方法设置目标变焦比,以及一些开启和结束变焦的函数。 2790 2791### prepareZoom<sup>11+</sup> 2792 2793prepareZoom(): void 2794 2795通知底层准备变焦,如sensor上电。 2796 2797**系统接口:** 此接口为系统接口。 2798 2799**系统能力:** SystemCapability.Multimedia.Camera.Core 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 2813import { BusinessError } from '@kit.BasicServicesKit'; 2814 2815function prepareZoom(sessionExtendsZoom: camera.Zoom): void { 2816 try { 2817 sessionExtendsZoom.prepareZoom(); 2818 } catch (error) { 2819 // 失败返回错误码error.code并处理。 2820 let err = error as BusinessError; 2821 console.error(`The prepareZoom call failed. error code: ${err.code}`); 2822 } 2823} 2824``` 2825 2826### unprepareZoom<sup>11+</sup> 2827 2828unprepareZoom(): void 2829 2830通知底层离开变焦准备状态。 2831 2832**系统接口:** 此接口为系统接口。 2833 2834**系统能力:** SystemCapability.Multimedia.Camera.Core 2835 2836**错误码:** 2837 2838以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2839 2840| 错误码ID | 错误信息 | 2841| --------------- | --------------- | 2842| 202 | Not System Application. | 2843| 7400103 | Session not config. | 2844 2845**示例:** 2846 2847```ts 2848import { BusinessError } from '@kit.BasicServicesKit'; 2849 2850function unprepareZoom(sessionExtendsZoom: camera.Zoom): void { 2851 try { 2852 sessionExtendsZoom.unprepareZoom(); 2853 } catch (error) { 2854 // 失败返回错误码error.code并处理。 2855 let err = error as BusinessError; 2856 console.error(`The unprepareZoom call failed. error code: ${err.code}`); 2857 } 2858} 2859``` 2860 2861## ZoomRange<sup>11+</sup> 2862 2863获取支持的变焦范围。变焦范围为[min, max),即包括最小值,不包括最大值。 2864 2865**系统接口:** 此接口为系统接口。 2866 2867**系统能力:** SystemCapability.Multimedia.Camera.Core 2868 2869| 名称 | 类型 | 只读 | 必填 | 说明 | 2870| -------- | ------------- |---- | ---- | -------------| 2871| min | number | 是 | N/A | 获取的可变焦距范围的最小值 | 2872| max | number | 是 | N/A | 获取的可变焦距范围的最大值。 | 2873 2874## Beauty<sup>11+</sup> 2875 2876Beauty extends [BeautyQuery](#beautyquery12) 2877 2878提供了获取和设置美颜效果的方法。 2879 2880### setBeauty<sup>11+</sup> 2881 2882setBeauty(type: BeautyType, value: number): void 2883 2884设置美颜类型以及对应的美颜强度。将通过[getSupportedBeautyTypes](#getsupportedbeautytypes11)获取得到的[BeautyType](#beautytype)都关闭,表明当前美颜关闭;若有一种美颜类型未关闭,表明当前美颜打开。 2885 2886**系统接口:** 此接口为系统接口。 2887 2888**系统能力:** SystemCapability.Multimedia.Camera.Core 2889 2890**参数:** 2891 2892| 参数名 | 类型 | 必填 | 说明 | 2893| -------- | --------------------------| ---- |-------------------------------------------------------------------| 2894| type | [BeautyType](#beautytype) | 是 | 美颜类型。 | 2895| value | number | 是 | 美颜强度,通过[getSupportedBeautyRange](#getsupportedbeautyrange11)接口获取。 | 2896 2897**错误码:** 2898 2899以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2900 2901| 错误码ID | 错误信息 | 2902| --------------- | --------------- | 2903| 202 | Not System Application. | 2904| 7400103 | Session not config. | 2905 2906**示例:** 2907 2908```ts 2909function setBeauty(portraitPhotoSession: camera.PortraitPhotoSession): void { 2910 let beautyTypes: Array<camera.BeautyType> = portraitPhotoSession.getSupportedBeautyTypes(); 2911 if (beautyTypes === undefined || beautyTypes.length <= 0) { 2912 return; 2913 } 2914 let beautyLevels: Array<number> = portraitPhotoSession.getSupportedBeautyRange(beautyTypes[0]); 2915 if (beautyLevels === undefined || beautyLevels.length <= 0) { 2916 return; 2917 } 2918 portraitPhotoSession.setBeauty(beautyTypes[0], beautyLevels[0]); 2919} 2920``` 2921 2922### getBeauty<sup>11+</sup> 2923 2924getBeauty(type: BeautyType): number 2925 2926查询当前已设置的美颜效果对应的美颜强度。 2927 2928**系统接口:** 此接口为系统接口。 2929 2930**系统能力:** SystemCapability.Multimedia.Camera.Core 2931 2932**参数:** 2933 2934| 参数名 | 类型 | 必填 | 说明 | 2935| -------- | ------------------------------------------------- | ---- | --------------------- | 2936| type | [BeautyType](#beautytype) | 是 | 美颜类型。 | 2937 2938**返回值:** 2939| 参数名 | 类型 | 必填 | 说明 | 2940| -------- | ------------------------------------------------- | ---- | --------------------- | 2941| value | number | 是 | 美颜强度。 | 2942 2943**错误码:** 2944 2945以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2946 2947| 错误码ID | 错误信息 | 2948| --------------- | --------------- | 2949| 202 | Not System Application. | 2950| 7400103 | Session not config. | 2951 2952**示例:** 2953 2954```ts 2955function getBeauty(portraitPhotoSession: camera.PortraitPhotoSession): number { 2956 const invalidValue: number = -1; 2957 let beautyTypes = portraitPhotoSession.getSupportedBeautyTypes(); 2958 if (beautyTypes === undefined || beautyTypes.length <= 0) { 2959 return invalidValue; 2960 } 2961 let beautyLevels: Array<number> = portraitPhotoSession.getSupportedBeautyRange(beautyTypes[0]); 2962 if (beautyLevels === undefined || beautyLevels.length <= 0) { 2963 return invalidValue; 2964 } 2965 portraitPhotoSession.setBeauty(beautyTypes[0], beautyLevels[0]); 2966 let beautyLevel: number = portraitPhotoSession.getBeauty(beautyTypes[0]); 2967 return beautyLevel; 2968} 2969``` 2970 2971## ColorEffectQuery<sup>12+</sup> 2972 2973提供了一个查询设备支持的颜色效果类型的方法。 2974 2975### getSupportedColorEffects<sup>11+</sup> 2976 2977getSupportedColorEffects(): Array\<ColorEffectType\> 2978 2979获取支持的色彩效果类型列表。 2980 2981**系统接口:** 此接口为系统接口。 2982 2983**系统能力:** SystemCapability.Multimedia.Camera.Core 2984 2985**返回值:** 2986 2987| 类型 | 说明 | 2988| ----------------------------------------------- | ---------------------------- | 2989| Array<[ColorEffectType](#coloreffecttype11)> | 支持的色彩效果类型列表。 | 2990 2991**错误码:** 2992 2993以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 2994 2995| 错误码ID | 错误信息 | 2996| --------------- | --------------- | 2997| 7400103 | Session not config. | 2998| 202 | Not System Application. | 2999 3000**示例:** 3001 3002```ts 3003function getSupportedColorEffects(session: camera.PhotoSessionForSys): Array<camera.ColorEffectType> { 3004 let colorEffects: Array<camera.ColorEffectType> = session.getSupportedColorEffects(); 3005 return colorEffects; 3006} 3007``` 3008 3009## ColorEffect<sup>11+</sup> 3010 3011ColorEffect extends [ColorEffectQuery](#coloreffectquery12) 3012 3013提供了获取和设置镜头色彩效果的相关功能。 3014 3015### setColorEffect<sup>11+</sup> 3016 3017setColorEffect(type: ColorEffectType): void 3018 3019设置色彩效果类型。可以先通过[getSupportedColorEffects](#getsupportedcoloreffects11)获取当前设备所支持的ColorEffects。 3020 3021**系统接口:** 此接口为系统接口。 3022 3023**系统能力:** SystemCapability.Multimedia.Camera.Core 3024 3025**参数:** 3026 3027| 参数名 | 类型 | 必填 | 说明 | 3028| ------------ |--------------------------------------------------------------- | -- | -------------------------- | 3029| type | [ColorEffectType](#coloreffecttype11) | 是 | 色彩效果类型,通过[getSupportedColorEffects](#getsupportedcoloreffects11)接口获取。 | 3030 3031**错误码:** 3032 3033以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3034 3035| 错误码ID | 错误信息 | 3036| --------------- | --------------- | 3037| 7400103 | Session not config. | 3038| 202 | Not System Application. | 3039 3040**示例:** 3041 3042```ts 3043function setColorEffect(session: camera.PhotoSessionForSys, colorEffect: camera.ColorEffectType): void { 3044 session.setColorEffect(colorEffect); 3045} 3046``` 3047 3048### getColorEffect<sup>11+</sup> 3049 3050getColorEffect(): ColorEffectType 3051 3052获取当前设置的色彩效果类型。 3053 3054**系统接口:** 此接口为系统接口。 3055 3056**系统能力:** SystemCapability.Multimedia.Camera.Core 3057 3058**返回值:** 3059 3060| 类型 | 说明 | 3061| ----------------------------------------------- | ---------------------------- | 3062| [ColorEffectType](#coloreffecttype11) | 当前设置的色彩效果类型。 | 3063 3064**错误码:** 3065 3066以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3067 3068| 错误码ID | 错误信息 | 3069| --------------- | --------------- | 3070| 7400103 | Session not config. | 3071| 202 | Not System Application. | 3072 3073**示例:** 3074 3075```ts 3076function getColorEffect(session: camera.PhotoSessionForSys): camera.ColorEffectType { 3077 let colorEffect: camera.ColorEffectType = session.getColorEffect(); 3078 return colorEffect; 3079} 3080``` 3081 3082## ColorEffectType<sup>11+</sup> 3083 3084枚举,色彩效果类型。 3085 3086**系统接口:** 此接口为系统接口。 3087 3088**系统能力:** SystemCapability.Multimedia.Camera.Core 3089 3090| 名称 | 值 | 说明 | 3091| --------------------- | ---- | --------- | 3092| NORMAL | 0 | 常规的色彩效果。 | 3093| BRIGHT | 1 | 明艳的色彩效果。 | 3094| SOFT | 2 | 柔和的色彩效果。 | 3095| BLACK_WHITE<sup>12+</sup> | 3 | 黑白色彩效果。 | 3096 3097## Portrait<sup>11+</sup> 3098 3099人像类,用于设置人像参数。 3100 3101### getSupportedPortraitEffects<sup>10+</sup> 3102 3103getSupportedPortraitEffects(): Array\<PortraitEffect\> 3104 3105获取支持的人像虚化效果列表。 3106 3107**系统接口:** 此接口为系统接口。 3108 3109**系统能力:** SystemCapability.Multimedia.Camera.Core 3110 3111**返回值:** 3112 3113| 类型 | 说明 | 3114| ----------------------------------------------- | ---------------------------- | 3115| Array<[PortraitEffect](#portraiteffect)> | 支持的人像虚化效果列表。 | 3116 3117**错误码:** 3118 3119以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3120 3121| 错误码ID | 错误信息 | 3122| --------------- | --------------- | 3123| 7400103 | Session not config. | 3124| 202 | Not System Application. | 3125 3126**示例:** 3127 3128```ts 3129function getSupportedPortraitEffects(portraitPhotoSession: camera.PortraitPhotoSession): Array<camera.PortraitEffect> { 3130 let portraitEffects: Array<camera.PortraitEffect> = portraitPhotoSession.getSupportedPortraitEffects(); 3131 return portraitEffects; 3132} 3133``` 3134 3135### setPortraitEffect<sup>10+</sup> 3136 3137setPortraitEffect(effect: PortraitEffect): void 3138 3139设置人像虚化效果。需要先检查设备是否支持人像虚化模式,可以通过[getSupportedPortraitEffects](#getsupportedportraiteffects10)获取当前设备所支持的PortraitEffects。 3140 3141**系统接口:** 此接口为系统接口。 3142 3143**系统能力:** SystemCapability.Multimedia.Camera.Core 3144 3145**参数:** 3146 3147| 参数名 | 类型 | 必填 | 说明 | 3148| ------------ |----------------------------- | -- | -------------------------- | 3149| effect | [PortraitEffect](#portraiteffect) | 是 | 人像虚化效果,通过[getSupportedPortraitEffects](#getsupportedportraiteffects10)接口获取。 | 3150 3151**错误码:** 3152 3153以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3154 3155| 错误码ID | 错误信息 | 3156| --------------- | --------------- | 3157| 7400103 | Session not config. | 3158| 202 | Not System Application. | 3159 3160**示例:** 3161 3162```ts 3163import { BusinessError } from '@kit.BasicServicesKit'; 3164 3165function setPortraitEffect(portraitPhotoSession: camera.PortraitPhotoSession, portraitEffects: Array<camera.PortraitEffect>): void { 3166 if (portraitEffects === undefined || portraitEffects.length <= 0) { 3167 return; 3168 } 3169 try { 3170 portraitPhotoSession.setPortraitEffect(portraitEffects[0]); 3171 } catch (error) { 3172 let err = error as BusinessError; 3173 console.error(`The setPortraitEffect call failed. error code: ${err.code}`); 3174 } 3175} 3176``` 3177 3178### getPortraitEffect<sup>10+</sup> 3179 3180getPortraitEffect(): PortraitEffect 3181 3182获取当前设置的人像虚化效果。 3183 3184**系统接口:** 此接口为系统接口。 3185 3186**系统能力:** SystemCapability.Multimedia.Camera.Core 3187 3188**返回值:** 3189 3190| 类型 | 说明 | 3191| ----------------------------------------------- | ---------------------------- | 3192| [PortraitEffect](#portraiteffect) | 当前设置的人像虚化效果。 | 3193 3194**错误码:** 3195 3196以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3197 3198| 错误码ID | 错误信息 | 3199| --------------- | --------------- | 3200| 7400103 | Session not config. | 3201| 202 | Not System Application. | 3202 3203**示例:** 3204 3205```ts 3206function getPortraitEffect(portraitPhotoSession: camera.PortraitPhotoSession): camera.PortraitEffect { 3207 let portraitEffect: camera.PortraitEffect = portraitPhotoSession.getPortraitEffect(); 3208 return portraitEffect; 3209} 3210``` 3211 3212## PhysicalAperture<sup>11+</sup> 3213 3214物理光圈信息。 3215 3216**系统接口:** 此接口为系统接口。 3217 3218**系统能力:** SystemCapability.Multimedia.Camera.Core 3219 3220| 名称 | 类型 | 只读 | 可选 | 说明 | 3221| ---------- | ------------------------- | ----- |-----| ----------------- | 3222| zoomRange | [ZoomRange](#zoomrange11) | 否 | 否 | 特定物理光圈的变焦范围。 | 3223| apertures | Array\<number\> | 否 | 否 | 支持的物理光圈列表。 | 3224 3225## Aperture<sup>11+</sup> 3226 3227光圈类,用于设置光圈参数。 3228 3229### getSupportedVirtualApertures<sup>11+</sup> 3230 3231getSupportedVirtualApertures(): Array\<number\> 3232 3233获取支持的虚拟光圈列表。 3234 3235**系统接口:** 此接口为系统接口。 3236 3237**系统能力:** SystemCapability.Multimedia.Camera.Core 3238 3239**返回值:** 3240 3241| 类型 | 说明 | 3242| ----------------------------------------------- | ---------------------------- | 3243| Array\<number\> | 支持的虚拟光圈列表。 | 3244 3245**错误码:** 3246 3247以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3248 3249| 错误码ID | 错误信息 | 3250| --------------- | --------------- | 3251| 7400103 | Session not config. | 3252| 202 | Not System Application. | 3253 3254**示例:** 3255 3256```ts 3257function getSupportedVirtualApertures(session: camera.PortraitPhotoSession): Array<number> { 3258 let virtualApertures: Array<number> = session.getSupportedVirtualApertures(); 3259 return virtualApertures; 3260} 3261``` 3262 3263### getVirtualAperture<sup>11+</sup> 3264 3265getVirtualAperture(): number 3266 3267获取当前设置的虚拟光圈值。 3268 3269**系统接口:** 此接口为系统接口。 3270 3271**系统能力:** SystemCapability.Multimedia.Camera.Core 3272 3273**返回值:** 3274 3275| 类型 | 说明 | 3276| ----------------------------------------------- | ---------------------------- | 3277| number | 当前设置的虚拟光圈值。 | 3278 3279**错误码:** 3280 3281以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3282 3283| 错误码ID | 错误信息 | 3284| --------------- | --------------- | 3285| 7400103 | Session not config. | 3286| 202 | Not System Application. | 3287 3288**示例:** 3289 3290```ts 3291function getVirtualAperture(session: camera.PortraitPhotoSession): number { 3292 let virtualAperture: number = session.getVirtualAperture(); 3293 return virtualAperture; 3294} 3295``` 3296 3297### setVirtualAperture<sup>11+</sup> 3298 3299setVirtualAperture(aperture: number): void 3300 3301设置虚拟光圈。可以线通过[getSupportedVirtualApertures](#getsupportedvirtualapertures11)获取当前设备所支持的虚拟光圈列表。 3302 3303**系统接口:** 此接口为系统接口。 3304 3305**系统能力:** SystemCapability.Multimedia.Camera.Core 3306 3307**参数:** 3308 3309| 参数名 | 类型 | 必填 | 说明 | 3310| ------------ |------------------------- | -- | -------------------------- | 3311| aperture | number | 是 | 虚拟光圈值,通过[getSupportedVirtualApertures](#getsupportedvirtualapertures11)接口获取。 | 3312 3313**错误码:** 3314 3315以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3316 3317| 错误码ID | 错误信息 | 3318| --------------- | --------------- | 3319| 7400103 | Session not config. | 3320| 202 | Not System Application. | 3321 3322**示例:** 3323 3324```ts 3325function setVirtualAperture(session: camera.PortraitPhotoSession, virtualAperture: number): void { 3326 session.setVirtualAperture(virtualAperture); 3327} 3328``` 3329 3330### getSupportedPhysicalApertures<sup>11+</sup> 3331 3332getSupportedPhysicalApertures(): Array\<PhysicalAperture\> 3333 3334获取支持的物理光圈列表。 3335 3336**系统接口:** 此接口为系统接口。 3337 3338**系统能力:** SystemCapability.Multimedia.Camera.Core 3339 3340**返回值:** 3341 3342| 类型 | 说明 | 3343| ----------------------------------------------- | ---------------------------- | 3344| Array<[PhysicalAperture](#physicalaperture11)> | 支持的物理光圈列表。 | 3345 3346**错误码:** 3347 3348以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3349 3350| 错误码ID | 错误信息 | 3351| --------------- | --------------- | 3352| 7400103 | Session not config. | 3353| 202 | Not System Application. | 3354 3355**示例:** 3356 3357```ts 3358function getSupportedPhysicalApertures(session: camera.PortraitPhotoSession): Array<camera.PhysicalAperture> { 3359 let physicalApertures: Array<camera.PhysicalAperture> = session.getSupportedPhysicalApertures(); 3360 return physicalApertures; 3361} 3362``` 3363 3364### getPhysicalAperture<sup>11+</sup> 3365 3366getPhysicalAperture(): number 3367 3368获取当前设置的物理光圈值。 3369 3370**系统接口:** 此接口为系统接口。 3371 3372**系统能力:** SystemCapability.Multimedia.Camera.Core 3373 3374**返回值:** 3375 3376| 类型 | 说明 | 3377| -------------------- | ---------------------------- | 3378| number | 当前设置的物理光圈值。 | 3379 3380**错误码:** 3381 3382以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3383 3384| 错误码ID | 错误信息 | 3385| --------------- | --------------- | 3386| 7400103 | Session not config. | 3387| 202 | Not System Application. | 3388 3389**示例:** 3390 3391```ts 3392function getPhysicalAperture(session: camera.PortraitPhotoSession): number { 3393 let physicalAperture: number = session.getPhysicalAperture(); 3394 return physicalAperture; 3395} 3396``` 3397 3398### setPhysicalAperture<sup>11+</sup> 3399 3400setPhysicalAperture(aperture: number): void 3401 3402设置物理光圈。可以线通过[getSupportedPhysicalApertures](#getsupportedphysicalapertures11)获取当前设备所支持的物理光圈列表。 3403 3404**系统接口:** 此接口为系统接口。 3405 3406**系统能力:** SystemCapability.Multimedia.Camera.Core 3407 3408**参数:** 3409 3410| 参数名 | 类型 | 必填 | 说明 | 3411| ------------ |------------------------- | -- | -------------------------- | 3412| aperture | number | 是 | 物理光圈值,通过[getSupportedPhysicalApertures](#getsupportedphysicalapertures11)接口获取。 | 3413 3414**错误码:** 3415 3416以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3417 3418| 错误码ID | 错误信息 | 3419| --------------- | --------------- | 3420| 7400103 | Session not config. | 3421| 202 | Not System Application. | 3422 3423**示例:** 3424 3425```ts 3426function setPhysicalAperture(session: camera.PortraitPhotoSession, physicalAperture: number): void { 3427 session.setPhysicalAperture(physicalAperture); 3428} 3429``` 3430 3431## CaptureSession<sup>(deprecated)</sup> 3432 3433拍照会话类,保存一次相机运行所需要的所有资源[CameraInput](arkts-apis-camera-CameraInput.md)、[CameraOutput](arkts-apis-camera-CameraOutput.md),并向相机设备申请完成相机功能(录像,拍照)。 3434 3435> **说明:** 3436>从 API version 10开始支持,从API version 11开始废弃。建议使用[PhotoSession](arkts-apis-camera-PhotoSession.md)、[VideoSession](arkts-apis-camera-VideoSession.md)替代。 3437 3438### getSupportedBeautyTypes<sup>(deprecated)</sup> 3439 3440getSupportedBeautyTypes(): Array\<BeautyType> 3441 3442获取当前支持的美颜效果列表。 3443 3444> **说明:** 3445>从 API version 10开始支持,从API version 11开始废弃。建议使用[Beauty.getSupportedBeautyTypes](#getsupportedbeautytypes11)替代。 3446 3447**系统接口:** 此接口为系统接口。 3448 3449**系统能力:** SystemCapability.Multimedia.Camera.Core 3450 3451**返回值:** 3452 3453| 类型 | 说明 | 3454| ---------- | ----------------------------- | 3455| Array\<[BeautyType](#beautytype)\>| 返回当前支持的美颜效果列表。 | 3456 3457**错误码:** 3458 3459以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3460 3461| 错误码ID | 错误信息 | 3462| --------------- | --------------- | 3463| 7400103 | Session not config. | 3464 3465**示例:** 3466 3467```ts 3468function getSupportedBeautyTypes(captureSession: camera.CaptureSession): Array<camera.BeautyType> { 3469 let beautyTypes: Array<camera.BeautyType> = captureSession.getSupportedBeautyTypes(); 3470 return beautyTypes; 3471} 3472``` 3473 3474### getSupportedBeautyRange<sup>(deprecated)</sup> 3475 3476getSupportedBeautyRange(type: BeautyType): Array\<number\> 3477 3478获取指定美颜效果的范围值。在不同设备返回的美颜强度有所不同,下表仅做示例。 3479 3480| 传入参数 | 示例返回值 | 返回值说明 | 3481| ----------------| ---- | ---------| 3482| AUTO | [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] |美颜类型为自动时支持的美颜强度,0表明关闭美颜,其余正值表明自动的美颜强度。 | 3483| SKIN_SMOOTH | [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | 美颜类型为光滑时支持的美颜强度,0表明关闭光滑,其余正值表明光滑的美颜强度。 | 3484| FACE_SLENDER | [0, 1, 2, 3, 4, 5] | 美颜类型为瘦脸时支持的美颜强度,0表明关闭瘦脸,其余正值表明瘦脸的美颜强度。 | 3485| SKIN_TONE | [-1, 16242611] | 美颜类型为美肤时支持的美颜强度,-1表明关闭美肤,其余非负值为使用RGB表示的美肤美颜强度,<br> 16242611转化为16进制为0xF7D7B3,F7为R通道值,D7为G通道值,B3位B通道值。 | 3486 3487> **说明:** 3488>从 API version 10开始支持,从API version 11开始废弃。建议使用[Beauty.getSupportedBeautyRange](#getsupportedbeautyrange11)替代。 3489 3490**系统接口:** 此接口为系统接口。 3491 3492**系统能力:** SystemCapability.Multimedia.Camera.Core 3493 3494**参数:** 3495 3496| 参数名 | 类型 | 必填 | 说明 | 3497| -------- | --------------------------| ---- | ----------| 3498| type | [BeautyType](#beautytype) | 是 | 美颜类型。 | 3499 3500**返回值:** 3501 3502| 类型 | 说明 | 3503| ---------- | ----------------------------- | 3504| Array\<number\> | 当前美颜类型所支持的美颜强度。 | 3505 3506**错误码:** 3507 3508以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3509 3510| 错误码ID | 错误信息 | 3511| --------------- | --------------- | 3512| 7400103 | Session not config. | 3513 3514**示例:** 3515 3516```ts 3517function getSupportedBeautyRange(captureSession: camera.CaptureSession): Array<number> { 3518 let beautyTypes: Array<camera.BeautyType> = captureSession.getSupportedBeautyTypes(); 3519 if (beautyTypes === undefined || beautyTypes.length <= 0) { 3520 return []; 3521 } 3522 let beautyLevels: Array<number> = captureSession.getSupportedBeautyRange(beautyTypes[0]); 3523 return beautyLevels; 3524} 3525``` 3526 3527### setBeauty<sup>(deprecated)</sup> 3528 3529setBeauty(type: BeautyType, value: number): void 3530 3531设置美颜类型以及对应的美颜强度。将通过[getSupportedBeautyTypes](#getsupportedbeautytypesdeprecated)获取得到的[BeautyType](#beautytype)都关闭,表明当前美颜关闭;若有一种美颜类型未关闭,表明当前美颜打开。 3532 3533> **说明:** 3534>从 API version 10开始支持,从API version 11开始废弃。建议使用[Beauty.setBeauty](#setbeauty11)替代。 3535 3536**系统接口:** 此接口为系统接口。 3537 3538**系统能力:** SystemCapability.Multimedia.Camera.Core 3539 3540**参数:** 3541 3542| 参数名 | 类型 | 必填 | 说明 | 3543| -------- | --------------------------| ---- | --------------------- | 3544| type | [BeautyType](#beautytype) | 是 | 美颜类型 。 | 3545| value | number | 是 | 美颜强度,通过[getSupportedBeautyRange](#getsupportedbeautyrangedeprecated)接口获取。| 3546 3547**错误码:** 3548 3549以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3550 3551| 错误码ID | 错误信息 | 3552| --------------- | --------------- | 3553| 7400103 | Session not config. | 3554 3555**示例:** 3556 3557```ts 3558function setBeauty(captureSession: camera.CaptureSession): void { 3559 let beautyTypes: Array<camera.BeautyType> = captureSession.getSupportedBeautyTypes(); 3560 if (beautyTypes === undefined || beautyTypes.length <= 0) { 3561 return; 3562 } 3563 let beautyLevels: Array<number> = captureSession.getSupportedBeautyRange(beautyTypes[0]); 3564 if (beautyLevels === undefined || beautyLevels.length <= 0) { 3565 return; 3566 } 3567 captureSession.setBeauty(beautyTypes[0], beautyLevels[0]); 3568} 3569``` 3570 3571### getBeauty<sup>(deprecated)</sup> 3572 3573getBeauty(type: BeautyType): number 3574 3575查询当前已设置的美颜效果对应的美颜强度。 3576 3577> **说明:** 3578>从 API version 10开始支持,从API version 11开始废弃。建议使用[Beauty.getBeauty](#getbeauty11)替代。 3579 3580**系统接口:** 此接口为系统接口。 3581 3582**系统能力:** SystemCapability.Multimedia.Camera.Core 3583 3584**参数:** 3585 3586| 参数名 | 类型 | 必填 | 说明 | 3587| -------- | ------------------------------------------------- | ---- | --------------------- | 3588| type | [BeautyType](#beautytype) | 是 | 美颜类型。 | 3589 3590**返回值:** 3591| 参数名 | 类型 | 必填 | 说明 | 3592| -------- | ------------------------------------------------- | ---- | --------------------- | 3593| value | number | 是 | 美颜强度。 | 3594 3595**错误码:** 3596 3597以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3598 3599| 错误码ID | 错误信息 | 3600| --------------- | --------------- | 3601| 7400103 | Session not config. | 3602 3603**示例:** 3604 3605```ts 3606function getBeauty(captureSession: camera.CaptureSession): number { 3607 const invalidValue: number = -1; 3608 let beautyTypes: Array<camera.BeautyType> = captureSession.getSupportedBeautyTypes(); 3609 if (beautyTypes === undefined || beautyTypes.length <= 0) { 3610 return invalidValue; 3611 } 3612 let beautyLevels: Array<number> = captureSession.getSupportedBeautyRange(beautyTypes[0]); 3613 if (beautyLevels === undefined || beautyLevels.length <= 0) { 3614 return invalidValue; 3615 } 3616 captureSession.setBeauty(beautyTypes[0], beautyLevels[0]); 3617 let beautyLevel: number = captureSession.getBeauty(beautyTypes[0]); 3618 return beautyLevel; 3619} 3620``` 3621 3622## PhotoSessionForSys<sup>11+</sup> 3623 3624PhotoSessionForSys extends PhotoSession, Beauty, ColorEffect, ColorManagement, SceneDetection 3625 3626提供给系统应用的PhotoSession,普通拍照模式会话类,继承自[Session](arkts-apis-camera-Session.md),用于设置普通拍照模式的参数以及保存所需要的所有资源[CameraInput](arkts-apis-camera-CameraInput.md)、[CameraOutput](arkts-apis-camera-CameraOutput.md)。 3627 3628**系统接口:** 此接口为系统接口。 3629 3630**系统能力:** SystemCapability.Multimedia.Camera.Core 3631 3632## PhotoSession<sup>11+</sup> 3633 3634PhotoSession extends Session, Flash, AutoExposure, Focus, Zoom, ColorManagement 3635 3636普通拍照模式会话类,继承自[Session](arkts-apis-camera-Session.md),用于设置普通拍照模式的参数以及保存所需要的所有资源[CameraInput](arkts-apis-camera-CameraInput.md)、[CameraOutput](arkts-apis-camera-CameraOutput.md)。 3637 3638### on('featureDetection')<sup>12+</sup> 3639 3640on(type: 'featureDetection', featureType: SceneFeatureType, callback: AsyncCallback\<SceneFeatureDetectionResult\>): void 3641 3642监听相机特性检测状态变化。使用callback异步回调。 3643 3644**系统接口:** 此接口为系统接口。 3645 3646**系统能力:** SystemCapability.Multimedia.Camera.Core 3647 3648**参数:** 3649 3650| 参数名 | 类型 | 必填 | 说明 | 3651| -------- | ----------------------------------------- | ---- | ------------------------ | 3652| type | string | 是 | 监听事件,固定为'featureDetection',photoSession创建成功可监听。 | 3653| featureType | [SceneFeatureType](#scenefeaturetype12) | 是 | 监听指定特性。 | 3654| callback | AsyncCallback\<[SceneFeatureDetectionResult](#scenefeaturedetectionresult12)\> | 是 | 回调函数,用于获取当前监听的特性的状态。 | 3655 3656**错误码:** 3657 3658以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3659 3660| 错误码ID | 错误信息 | 3661|-------|---------------------------| 3662| 202 | Not System Application. | 3663 3664**示例:** 3665 3666```ts 3667import { BusinessError } from '@kit.BasicServicesKit'; 3668 3669function callback(err: BusinessError, result: camera.SceneFeatureDetectionResult): void { 3670 if (err !== undefined && err.code !== 0) { 3671 console.error(`Callback Error, errorCode: ${err.code}`); 3672 return; 3673 } 3674 console.info(`feature type: ${result.featureType}`); 3675 console.info(`feature status: ${result.detected}`); 3676} 3677 3678function registerFeatureDetectionStatus(photoSession: camera.PhotoSession, featureType: camera.SceneFeatureType): void { 3679 photoSession.on('featureDetection', featureType, callback); 3680} 3681``` 3682 3683### off('featureDetection')<sup>12+</sup> 3684 3685off(type: 'featureDetection', featureType: SceneFeatureType, callback?: AsyncCallback\<SceneFeatureDetectionResult\>): void 3686 3687注销监听相机特性检测状态变化。 3688 3689**系统接口:** 此接口为系统接口。 3690 3691**系统能力:** SystemCapability.Multimedia.Camera.Core 3692 3693**参数:** 3694 3695| 参数名 | 类型 | 必填 | 说明 | 3696| -------- | ------------------------ | ---- | ------------------------ | 3697| type | string | 是 | 监听事件,固定为'featureDetection',session创建成功可取消监听。| 3698| featureType | [SceneFeatureType](#scenefeaturetype12) | 是 | 指定特性。 | 3699| callback | AsyncCallback\<[SceneFeatureDetectionResult](#scenefeaturedetectionresult12)\> | 否 | 回调函数,可选,有就是匹配on('featureDetection') callback(callback对象不可是匿名函数)。 | 3700 3701**错误码:** 3702 3703以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3704 3705| 错误码ID | 错误信息 | 3706|-------|---------------------------| 3707| 202 | Not System Application. | 3708 3709**示例:** 3710 3711```ts 3712function unregisterFeatureDetectionStatus(photoSession: camera.PhotoSession, featureType: camera.SceneFeatureType): void { 3713 photoSession.off('featureDetection', featureType); 3714} 3715``` 3716 3717### on('lcdFlashStatus')<sup>13+</sup> 3718 3719on(type: 'lcdFlashStatus', callback: AsyncCallback\<LcdFlashStatus\>): void 3720 3721监听LCD闪光灯状态变化。使用callback异步回调。 3722 3723**系统接口:** 此接口为系统接口。 3724 3725**系统能力:** SystemCapability.Multimedia.Camera.Core 3726 3727**参数:** 3728 3729| 参数名 | 类型 | 必填 | 说明 | 3730| -------- | ----------------------------------------- | ---- |------------------------------------------| 3731| type | string | 是 | 监听事件,固定为'lcdFlashStatus',session创建成功可监听。 | 3732| callback | AsyncCallback\<[LcdFlashStatus](#lcdflashstatus12)\> | 是 | 回调函数,用于获取当前lcd flash状态。 | 3733 3734**错误码:** 3735 3736以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3737 3738| 错误码ID | 错误信息 | 3739|-------|---------------------------| 3740| 202 | Not System Application. | 3741 3742**示例:** 3743 3744```ts 3745import { BusinessError } from '@kit.BasicServicesKit'; 3746 3747function callback(err: BusinessError, lcdFlashStatus: camera.LcdFlashStatus): void { 3748 if (err !== undefined && err.code !== 0) { 3749 console.error(`Callback Error, errorCode: ${err.code}`); 3750 return; 3751 } 3752 console.info(`isLcdFlashNeeded: ${lcdFlashStatus.isLcdFlashNeeded}`); 3753 console.info(`lcdCompensation: ${lcdFlashStatus.lcdCompensation}`); 3754} 3755 3756function registerLcdFlashStatus(photoSession: camera.PhotoSession): void { 3757 photoSession.on('lcdFlashStatus', callback); 3758} 3759``` 3760 3761### off('lcdFlashStatus')<sup>13+</sup> 3762 3763off(type: 'lcdFlashStatus', callback?: AsyncCallback\<LcdFlashStatus\>): void 3764 3765注销监听LCD闪光灯状态变化。 3766 3767**系统接口:** 此接口为系统接口。 3768 3769**系统能力:** SystemCapability.Multimedia.Camera.Core 3770 3771**参数:** 3772 3773| 参数名 | 类型 | 必填 | 说明 | 3774| -------- | ------------------------ | ---- |------------------------------------------------------------------| 3775| type | string | 是 | 监听事件,固定为'lcdFlashStatus',session创建成功可取消监听。 | 3776| callback | AsyncCallback\<[LcdFlashStatus](#lcdflashstatus12)\> | 否 | 回调函数,可选,有就是匹配on('lcdFlashStatus') callback(callback对象不可是匿名函数)。 | 3777 3778**错误码:** 3779 3780以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3781 3782| 错误码ID | 错误信息 | 3783|-------|---------------------------| 3784| 202 | Not System Application. | 3785 3786**示例:** 3787 3788```ts 3789function unregisterLcdFlashStatus(photoSession: camera.PhotoSession): void { 3790 photoSession.off('lcdFlashStatus'); 3791} 3792``` 3793 3794## FocusTrackingMode<sup>15+</sup> 3795 3796枚举,对焦追踪模式。 3797 3798**系统能力**: SystemCapability.Multimedia.Camera.Core 3799 3800| 名称 | 值 | 说明 | 3801| ---- | ---- | ------ | 3802| AUTO | 0 | 自动。 | 3803 3804## FocusTrackingInfo<sup>15+</sup> 3805 3806相机对焦追踪信息,通过VideoSessionForSys.[on('focusTrackingInfoAvailable')](#onfocustrackinginfoavailable15)接口获取。 3807 3808**系统能力**: SystemCapability.Multimedia.Camera.Core 3809 3810| 名称 | 类型 | 只读 | 可选 | 说明 | 3811| -------------- | ----------------------------------------- | ---- | ---- | ---------- | 3812| trackingMode | [FocusTrackingMode](#focustrackingmode15) | 否 | 否 | 跟踪模式。 | 3813| trackingRegion | [Rect](arkts-apis-camera-i.md#rect) | 否 | 否 | 跟踪区域。 | 3814 3815## LightStatus<sup>18+</sup> 3816 3817枚举,相机光线状态(通过VideoSessionForSys.[on('lightStatusChange')](#onlightstatuschange18)接口获取)。 3818 3819**系统接口:** 此接口为系统接口。 3820 3821**系统能力:** SystemCapability.Multimedia.Camera.Core 3822 3823| 名称 | 值 | 说明 | 3824|--------------| ---- |-------| 3825| NORMAL | 0 | 光线正常。 | 3826| INSUFFICIENT | 1 | 光线偏暗。 | 3827 3828## VideoSessionForSys<sup>11+</sup> 3829 3830VideoSessionForSys extends VideoSession, Beauty, ColorEffect, ColorManagement, Aperture, ColorReservation 3831 3832提供给系统应用的VideoSession,普通录像模式会话类,继承自[Session](arkts-apis-camera-Session.md),用于设置普通录像模式的参数以及保存所需要的所有资源[CameraInput](arkts-apis-camera-CameraInput.md)、[CameraOutput](arkts-apis-camera-CameraOutput.md)。 3833 3834**系统接口:** 此接口为系统接口。 3835 3836**系统能力:** SystemCapability.Multimedia.Camera.Core 3837 3838## VideoSession<sup>11+</sup> 3839 3840VideoSession extends Session, Flash, AutoExposure, Focus, Zoom, Stabilization, ColorManagement 3841 3842普通录像模式会话类,继承自[Session](arkts-apis-camera-Session.md),用于设置普通录像模式的参数以及保存所需要的所有资源[CameraInput](arkts-apis-camera-CameraInput.md)、[CameraOutput](arkts-apis-camera-CameraOutput.md)。 3843 3844### on('lcdFlashStatus')<sup>13+</sup> 3845 3846on(type: 'lcdFlashStatus', callback: AsyncCallback\<LcdFlashStatus\>): void 3847 3848监听LCD闪光灯状态变化。使用callback异步回调。 3849 3850**系统接口:** 此接口为系统接口。 3851 3852**系统能力:** SystemCapability.Multimedia.Camera.Core 3853 3854**参数:** 3855 3856| 参数名 | 类型 | 必填 | 说明 | 3857| -------- | ----------------------------------------- | ---- |------------------------------------------| 3858| type | string | 是 | 监听事件,固定为'lcdFlashStatus',session创建成功可监听。 | 3859| callback | AsyncCallback\<[LcdFlashStatus](#lcdflashstatus12)\> | 是 | 回调函数,用于获取当前lcd flash状态。 | 3860 3861**错误码:** 3862 3863以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3864 3865| 错误码ID | 错误信息 | 3866|-------|---------------------------| 3867| 202 | Not System Application. | 3868 3869**示例:** 3870 3871```ts 3872import { BusinessError } from '@kit.BasicServicesKit'; 3873 3874function callback(err: BusinessError, lcdFlashStatus: camera.LcdFlashStatus): void { 3875 if (err !== undefined && err.code !== 0) { 3876 console.error(`Callback Error, errorCode: ${err.code}`); 3877 return; 3878 } 3879 console.info(`isLcdFlashNeeded: ${lcdFlashStatus.isLcdFlashNeeded}`); 3880 console.info(`lcdCompensation: ${lcdFlashStatus.lcdCompensation}`); 3881} 3882 3883function registerLcdFlashStatus(videoSession: camera.VideoSession): void { 3884 videoSession.on('lcdFlashStatus', callback); 3885} 3886``` 3887 3888### off('lcdFlashStatus')<sup>13+</sup> 3889 3890off(type: 'lcdFlashStatus', callback?: AsyncCallback\<LcdFlashStatus\>): void 3891 3892注销监听LCD闪光灯状态变化。 3893 3894**系统接口:** 此接口为系统接口。 3895 3896**系统能力:** SystemCapability.Multimedia.Camera.Core 3897 3898**参数:** 3899 3900| 参数名 | 类型 | 必填 | 说明 | 3901| -------- | ------------------------ | ---- |------------------------------------------------------------------| 3902| type | string | 是 | 监听事件,固定为'lcdFlashStatus',session创建成功可取消监听。 | 3903| callback | AsyncCallback\<[LcdFlashStatus](#lcdflashstatus12)\> | 否 | 回调函数,可选,有就是匹配on('lcdFlashStatus') callback(callback对象不可是匿名函数)。 | 3904 3905**错误码:** 3906 3907以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3908 3909| 错误码ID | 错误信息 | 3910|-------|---------------------------| 3911| 202 | Not System Application. | 3912 3913**示例:** 3914 3915```ts 3916function unregisterLcdFlashStatus(videoSession: camera.VideoSession): void { 3917 videoSession.off('lcdFlashStatus'); 3918} 3919``` 3920 3921### on('focusTrackingInfoAvailable')<sup>15+</sup> 3922 3923on(type: 'focusTrackingInfoAvailable', callback: Callback\<FocusTrackingInfo\>): void 3924 3925监听相机对焦跟踪信息,通过注册回调函数获取结果。使用callback方式返回结果。 3926 3927**系统接口**: 此接口为系统接口。 3928 3929**系统能力**: SystemCapability.Multimedia.Camera.Core 3930 3931**参数**: 3932 3933| 参数名 | 类型 | 必填 | 说明 | 3934| -------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ | 3935| type | string | 是 | 监听事件,固定为'focusTrackingInfoAvailable',VideoSessionForSys创建成功可监听。 | 3936| callback | Callback\<[FocusTrackingInfo](#focustrackinginfo15)\> | 是 | 回调函数,用于获取当前对焦跟踪信息。 | 3937 3938**错误码**: 3939 3940以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3941 3942| 错误码ID | 错误信息 | 3943| -------- | ----------------------- | 3944| 202 | Not System Application. | 3945 3946**示例**: 3947 3948```ts 3949function callback(focusTrackingInfo: camera.FocusTrackingInfo): void { 3950 console.info(`Focus tracking mode: ${focusTrackingInfo.trackingMode}`); 3951 console.info(`Focus tracking Region: topLeftX ${focusTrackingInfo.trackingRegion.topLeftX} 3952 topLeftY ${focusTrackingInfo.trackingRegion.topLeftY} 3953 width ${focusTrackingInfo.trackingRegion.width} 3954 height ${focusTrackingInfo.trackingRegion.height}`); 3955} 3956 3957function registerFocusTrakingInfoChanged(session: camera.VideoSessionForSys): void { 3958 session.on('focusTrackingInfoAvailable', callback); 3959} 3960``` 3961 3962### off('focusTrackingInfoAvailable')<sup>15+</sup> 3963 3964off(type: 'focusTrackingInfoAvailable', callback?: Callback\<FocusTrackingInfo\>): void 3965 3966注销监听相机对焦跟踪信息。 3967 3968**系统接口**: 此接口为系统接口。 3969 3970**系统能力**: SystemCapability.Multimedia.Camera.Core 3971 3972**参数**: 3973 3974| 参数名 | 类型 | 必填 | 说明 | 3975| -------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ | 3976| type | string | 是 | 监听事件,固定为'focusTrackingInfoAvailable',videoSessionForSys创建成功可监听。 | 3977| callback | Callback\<[FocusTrackingInfo](#focustrackinginfo15)\> | 否 | 回调函数,可选,有就是匹配on('focusTrackingInfoAvailable') callback(callback对象不可是匿名函数)。 | 3978 3979**错误码**: 3980 3981以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 3982 3983| 错误码ID | 错误信息 | 3984| -------- | ----------------------- | 3985| 202 | Not System Application. | 3986 3987**示例**: 3988 3989```ts 3990function unregisterFocusTrakingInfoChanged(session: camera.VideoSessionForSys): void { 3991 session.off('focusTrackingInfoAvailable'); 3992} 3993``` 3994 3995### on('lightStatusChange')<sup>18+</sup> 3996 3997on(type: 'lightStatusChange', callback: AsyncCallback\<LightStatus\>): void 3998 3999监听相机获取光线状态。使用Callback方式返回结果。 4000 4001**系统接口:** 此接口为系统接口。 4002 4003**系统能力:** SystemCapability.Multimedia.Camera.Core 4004 4005**参数**: 4006 4007| 参数名 | 类型 | 必填 | 说明 | 4008| -------- |------------------------------------------------| ---- |---------------------------------------------------------------------------------| 4009| type | string | 是 | 监听事件,固定为'lightStatusChange'。<br>'lightStatusChange':VideoSessionForSys创建成功时可监听。 | 4010| callback | AsyncCallback\<[LightStatus](#lightstatus18)\> | 是 | 回调函数,用于获取当前光线状态信息。 | 4011 4012**错误码**: 4013 4014以下错误码的详细介绍请参见[通用错误码说明文档](../errorcode-universal.md)。 4015 4016| 错误码ID | 错误信息 | 4017| -------- | ----------------------- | 4018| 202 | Not System Application. | 4019 4020**示例**: 4021 4022```ts 4023import { BusinessError } from '@kit.BasicServicesKit'; 4024 4025function handleLightStatusCallback(err: BusinessError, lightStatus: camera.LightStatus) : void { 4026 if (err !== undefined && err.code !== 0) { 4027 console.error(`Callback Error, errorCode: ${err.code}`); 4028 return; 4029 } 4030 console.info(`lightStatus: ${lightStatus}`); 4031} 4032 4033function handleLightStatusOn(mSession: camera.VideoSessionForSys): void { 4034 console.info('handleLightStatusOn'); 4035 try { 4036 mSession.on('lightStatusChange', handleLightStatusCallback); 4037 } catch (error) { 4038 let err = error as BusinessError; 4039 console.error(`handleLightStatusOn err:${err}`); 4040 } 4041} 4042``` 4043 4044### off('lightStatusChange')<sup>18+</sup> 4045 4046off(type: 'lightStatusChange', callback?: AsyncCallback\<LightStatus\>): void 4047 4048注销监听相机获取光线状态。 4049 4050**系统接口:** 此接口为系统接口。 4051 4052**系统能力:** SystemCapability.Multimedia.Camera.Core 4053 4054**参数**: 4055 4056| 参数名 | 类型 | 必填 | 说明 | 4057| -------- |------------------------------------------------|----|----------------------------------------------------------------------------------| 4058| type | string | 是 | 监听事件,固定为'lightStatusChange'。<br>'lightStatusChange':当VideoSessionForSys创建成功时,可监听。 | 4059| callback | AsyncCallback\<[LightStatus](#lightstatus18)\> | 否 | 回调函数,可选,有就是匹配on('lightStatusChange') callback(callback对象不可是匿名函数)。 | 4060 4061**错误码**: 4062 4063以下错误码的详细介绍请参见[通用错误码说明文档](../errorcode-universal.md)。 4064 4065| 错误码ID | 错误信息 | 4066| -------- | ----------------------- | 4067| 202 | Not System Application. | 4068 4069**示例**: 4070 4071```ts 4072import { BusinessError } from '@kit.BasicServicesKit'; 4073 4074function LightStatusCallback(err: BusinessError, lightStatus: camera.LightStatus) : void { 4075 if (err !== undefined && err.code !== 0) { 4076 console.error(`Callback Error, errorCode: ${err.code}`); 4077 return; 4078 } 4079 console.info(`lightStatus: ${lightStatus}`); 4080} 4081 4082function handleLightStatusOff(mSession: camera.VideoSessionForSys): void { 4083 console.info('handleLightStatusOff'); 4084 try { 4085 mSession.on('lightStatusChange', LightStatusCallback); 4086 } catch (error) { 4087 let err = error as BusinessError; 4088 console.error(`handleLightStatusOff err:${err}`); 4089 } 4090} 4091``` 4092 4093## PortraitPhotoSession<sup>11+</sup> 4094 4095PortraitPhotoSession extends Session, Flash, AutoExposure, Focus, Zoom, Beauty, ColorEffect, ColorManagement, Portrait, Aperture 4096 4097人像拍照模式会话类,继承自[Session](arkts-apis-camera-Session.md),用于设置人像拍照模式的参数以及保存所需要的所有资源[CameraInput](arkts-apis-camera-CameraInput.md)、[CameraOutput](arkts-apis-camera-CameraOutput.md)。 4098 4099### on('error')<sup>11+</sup> 4100 4101on(type: 'error', callback: ErrorCallback): void 4102 4103监听人像拍照会话的错误事件,通过注册回调函数获取结果。使用callback异步回调。 4104 4105**系统接口:** 此接口为系统接口。 4106 4107**系统能力:** SystemCapability.Multimedia.Camera.Core 4108 4109**参数:** 4110 4111| 参数名 | 类型 | 必填 | 说明 | 4112| -------- | --------------------------------- | ---- | ------------------------------ | 4113| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。session调用相关接口出现错误时会触发该事件,比如调用[beginConfig](arkts-apis-camera-Session.md#beginconfig11),[commitConfig](arkts-apis-camera-Session.md#commitconfig11-1),[addInput](arkts-apis-camera-Session.md#addinput11)等接口发生错误时返回错误信息。 | 4114| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。 | 4115 4116**示例:** 4117 4118```ts 4119import { BusinessError } from '@kit.BasicServicesKit'; 4120 4121function callback(err: BusinessError): void { 4122 console.error(`Portrait photo session error code: ${err.code}`); 4123} 4124 4125function registerSessionError(portraitPhotoSession: camera.PortraitPhotoSession): void { 4126 portraitPhotoSession.on('error', callback); 4127} 4128``` 4129 4130### off('error')<sup>11+</sup> 4131 4132off(type: 'error', callback?: ErrorCallback): void 4133 4134注销监听人像拍照会话的错误事件,通过注册回调函数获取结果。 4135 4136**系统接口:** 此接口为系统接口。 4137 4138**系统能力:** SystemCapability.Multimedia.Camera.Core 4139 4140**参数:** 4141 4142| 参数名 | 类型 | 必填 | 说明 | 4143| -------- | -------------------------- | ---- | ------------------------------ | 4144| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。 | 4145| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 否 | 回调函数,可选,有就是匹配on('error') callback(callback对象不可是匿名函数)。 | 4146 4147**示例:** 4148 4149```ts 4150function unregisterSessionError(portraitPhotoSession: camera.PortraitPhotoSession): void { 4151 portraitPhotoSession.off('error'); 4152} 4153``` 4154 4155### on('focusStateChange')<sup>11+</sup> 4156 4157on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 4158 4159监听相机对焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 4160 4161**系统接口:** 此接口为系统接口。 4162 4163**系统能力:** SystemCapability.Multimedia.Camera.Core 4164 4165**参数:** 4166 4167| 参数名 | 类型 | 必填 | 说明 | 4168| -------- | ---------------- | ---- | ------------------------ | 4169| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。仅当自动对焦模式时,且相机对焦状态发生改变时可触发该事件。 | 4170| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.md#focusstate)\> | 是 | 回调函数,用于获取当前对焦状态。 | 4171 4172**示例:** 4173 4174```ts 4175import { BusinessError } from '@kit.BasicServicesKit'; 4176 4177function callback(err: BusinessError, focusState: camera.FocusState): void { 4178 if (err !== undefined && err.code !== 0) { 4179 console.error(`Callback Error, errorCode: ${err.code}`); 4180 return; 4181 } 4182 console.info(`Focus state: ${focusState}`); 4183} 4184 4185function registerFocusStateChange(portraitPhotoSession: camera.PortraitPhotoSession): void { 4186 portraitPhotoSession.on('focusStateChange', callback); 4187} 4188``` 4189 4190### off('focusStateChange')<sup>11+</sup> 4191 4192off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 4193 4194注销监听相机对焦的状态变化。 4195 4196**系统接口:** 此接口为系统接口。 4197 4198**系统能力:** SystemCapability.Multimedia.Camera.Core 4199 4200**参数:** 4201 4202| 参数名 | 类型 | 必填 | 说明 | 4203| -------- | ----------------------------------------- | ---- | ------------------------ | 4204| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。 | 4205| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.md#focusstate)\> | 否 | 回调函数,可选,有就是匹配on('focusStateChange') callback(callback对象不可是匿名函数)。 | 4206 4207**示例:** 4208 4209```ts 4210function unregisterFocusStateChange(portraitPhotoSession: camera.PortraitPhotoSession): void { 4211 portraitPhotoSession.off('focusStateChange'); 4212} 4213``` 4214 4215### on('smoothZoomInfoAvailable')<sup>11+</sup> 4216 4217on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 4218 4219监听相机平滑变焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 4220 4221**系统接口:** 此接口为系统接口。 4222 4223**系统能力:** SystemCapability.Multimedia.Camera.Core 4224 4225**参数:** 4226 4227| 参数名 | 类型 | 必填 | 说明 | 4228| -------- | ----------------------- | ---- | ------------------------ | 4229| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 4230| callback | AsyncCallback\<[SmoothZoomInfo](arkts-apis-camera-i.md#smoothzoominfo11)\> | 是 | 回调函数,用于获取当前平滑变焦状态。 | 4231 4232**示例:** 4233 4234```ts 4235import { BusinessError } from '@kit.BasicServicesKit'; 4236 4237function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 4238 if (err !== undefined && err.code !== 0) { 4239 console.error(`Callback Error, errorCode: ${err.code}`); 4240 return; 4241 } 4242 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 4243} 4244 4245function registerSmoothZoomInfo(portraitPhotoSession: camera.PortraitPhotoSession): void { 4246 portraitPhotoSession.on('smoothZoomInfoAvailable', callback); 4247} 4248``` 4249 4250### off('smoothZoomInfoAvailable')<sup>11+</sup> 4251 4252off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 4253 4254注销监听相机平滑变焦的状态变化。 4255 4256**系统接口:** 此接口为系统接口。 4257 4258**系统能力:** SystemCapability.Multimedia.Camera.Core 4259 4260**参数:** 4261 4262| 参数名 | 类型 | 必填 | 说明 | 4263| -------- | ----------------------------------------- | ---- | ------------------------ | 4264| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 4265| callback | AsyncCallback\<[SmoothZoomInfo](arkts-apis-camera-i.md#smoothzoominfo11)\> | 否 | 回调函数,可选,有就是匹配on('smoothZoomInfoAvailable') callback(callback对象不可是匿名函数)。 | 4266 4267**示例:** 4268 4269```ts 4270function unregisterSmoothZoomInfo(portraitPhotoSession: camera.PortraitPhotoSession): void { 4271 portraitPhotoSession.off('smoothZoomInfoAvailable'); 4272} 4273``` 4274 4275### on('lcdFlashStatus')<sup>13+</sup> 4276 4277on(type: 'lcdFlashStatus', callback: AsyncCallback\<LcdFlashStatus\>): void 4278 4279监听LCD闪光灯状态变化。使用callback异步回调。 4280 4281**系统接口:** 此接口为系统接口。 4282 4283**系统能力:** SystemCapability.Multimedia.Camera.Core 4284 4285**参数:** 4286 4287| 参数名 | 类型 | 必填 | 说明 | 4288| -------- | ----------------------------------------- | ---- |------------------------------------------| 4289| type | string | 是 | 监听事件,固定为'lcdFlashStatus',session创建成功可监听。 | 4290| callback | AsyncCallback\<[LcdFlashStatus](#lcdflashstatus12)\> | 是 | 回调函数,用于获取当前lcd flash状态。 | 4291 4292**错误码:** 4293 4294以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 4295 4296| 错误码ID | 错误信息 | 4297|-------|---------------------------| 4298| 202 | Not System Application. | 4299 4300**示例:** 4301 4302```ts 4303import { BusinessError } from '@kit.BasicServicesKit'; 4304 4305function callback(err: BusinessError, lcdFlashStatus: camera.LcdFlashStatus): void { 4306 if (err !== undefined && err.code !== 0) { 4307 console.error(`Callback Error, errorCode: ${err.code}`); 4308 return; 4309 } 4310 console.info(`isLcdFlashNeeded: ${lcdFlashStatus.isLcdFlashNeeded}`); 4311 console.info(`lcdCompensation: ${lcdFlashStatus.lcdCompensation}`); 4312} 4313 4314function registerLcdFlashStatus(portraitPhotoSession: camera.PortraitPhotoSession): void { 4315 portraitPhotoSession.on('lcdFlashStatus', callback); 4316} 4317``` 4318 4319### off('lcdFlashStatus')<sup>13+</sup> 4320 4321off(type: 'lcdFlashStatus', callback?: AsyncCallback\<LcdFlashStatus\>): void 4322 4323注销监听LCD闪光灯状态变化。 4324 4325**系统接口:** 此接口为系统接口。 4326 4327**系统能力:** SystemCapability.Multimedia.Camera.Core 4328 4329**参数:** 4330 4331| 参数名 | 类型 | 必填 | 说明 | 4332| -------- | ------------------------ | ---- |------------------------------------------------------------------| 4333| type | string | 是 | 监听事件,固定为'lcdFlashStatus',session创建成功可取消监听。 | 4334| callback | AsyncCallback\<[LcdFlashStatus](#lcdflashstatus12)\> | 否 | 回调函数,可选,有就是匹配on('lcdFlashStatus') callback(callback对象不可是匿名函数)。 | 4335 4336**错误码:** 4337 4338以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 4339 4340| 错误码ID | 错误信息 | 4341|-------|---------------------------| 4342| 202 | Not System Application. | 4343 4344**示例:** 4345 4346```ts 4347function unregisterLcdFlashStatus(portraitPhotoSession: camera.PortraitPhotoSession): void { 4348 portraitPhotoSession.off('lcdFlashStatus'); 4349} 4350``` 4351 4352## NightPhotoSession<sup>11+</sup> 4353 4354NightPhotoSession extends Session, Flash, AutoExposure, Focus, Zoom, ColorEffect, ColorManagement, ManualExposure 4355 4356夜景拍照模式会话类,继承自[Session](arkts-apis-camera-Session.md),用于设置夜景拍照模式的参数以及保存所需要的所有资源[CameraInput](arkts-apis-camera-CameraInput.md)、[CameraOutput](arkts-apis-camera-CameraOutput.md)、[PhotoOutput](arkts-apis-camera-PhotoOutput.md)。 4357 4358夜景拍照需要监听拍照结束事件[onCaptureEnd](arkts-apis-camera-PhotoOutput.md#oncaptureend)作为一次拍照的结束。 4359 4360### on('error')<sup>11+</sup> 4361 4362on(type: 'error', callback: ErrorCallback): void 4363 4364监听夜景拍照会话的错误事件,通过注册回调函数获取结果。使用callback异步回调。 4365 4366**系统接口:** 此接口为系统接口。 4367 4368**系统能力:** SystemCapability.Multimedia.Camera.Core 4369 4370**参数:** 4371 4372| 参数名 | 类型 | 必填 | 说明 | 4373| -------- | ----------------------------------------------------------- | ---- | ------------------------------ | 4374| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。session调用相关接口出现错误时会触发该事件,比如调用[beginConfig](arkts-apis-camera-Session.md#beginconfig11),[commitConfig](arkts-apis-camera-Session.md#commitconfig11-1),[addInput](arkts-apis-camera-Session.md#addinput11)等接口发生错误时返回错误信息。 | 4375| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。 | 4376 4377**示例:** 4378 4379```ts 4380import { BusinessError } from '@kit.BasicServicesKit'; 4381 4382function callback(err: BusinessError): void { 4383 console.error(`Night photo session error code: ${err.code}`); 4384} 4385 4386function registerSessionError(nightPhotoSession: camera.NightPhotoSession): void { 4387 nightPhotoSession.on('error', callback); 4388} 4389``` 4390 4391### off('error')<sup>11+</sup> 4392 4393off(type: 'error', callback?: ErrorCallback): void 4394 4395注销监听夜景拍照会话的错误事件,通过注册回调函数获取结果。 4396 4397**系统接口:** 此接口为系统接口。 4398 4399**系统能力:** SystemCapability.Multimedia.Camera.Core 4400 4401**参数:** 4402 4403| 参数名 | 类型 | 必填 | 说明 | 4404| -------- | ------------------------ | ---- | ------------------------------ | 4405| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。 | 4406| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 否 | 回调函数,可选,有就是匹配on('error') callback(callback对象不可是匿名函数)。 | 4407 4408**示例:** 4409 4410```ts 4411function unregisterSessionError(nightPhotoSession: camera.NightPhotoSession): void { 4412 nightPhotoSession.off('error'); 4413} 4414``` 4415 4416### on('focusStateChange')<sup>11+</sup> 4417 4418on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 4419 4420监听相机对焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 4421 4422**系统接口:** 此接口为系统接口。 4423 4424**系统能力:** SystemCapability.Multimedia.Camera.Core 4425 4426**参数:** 4427 4428| 参数名 | 类型 | 必填 | 说明 | 4429| -------- | ---------------- | ---- | ------------------------ | 4430| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。仅当自动对焦模式时,且相机对焦状态发生改变时可触发该事件。 | 4431| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.md#focusstate)\> | 是 | 回调函数,用于获取当前对焦状态。 | 4432 4433**示例:** 4434 4435```ts 4436import { BusinessError } from '@kit.BasicServicesKit'; 4437 4438function callback(err: BusinessError, focusState: camera.FocusState): void { 4439 if (err !== undefined && err.code !== 0) { 4440 console.error(`Callback Error, errorCode: ${err.code}`); 4441 return; 4442 } 4443 console.info(`Focus state: ${focusState}`); 4444} 4445 4446function registerFocusStateChange(nightPhotoSession: camera.NightPhotoSession): void { 4447 nightPhotoSession.on('focusStateChange', callback); 4448} 4449``` 4450 4451### off('focusStateChange')<sup>11+</sup> 4452 4453off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 4454 4455注销监听相机对焦的状态变化。 4456 4457**系统接口:** 此接口为系统接口。 4458 4459**系统能力:** SystemCapability.Multimedia.Camera.Core 4460 4461**参数:** 4462 4463| 参数名 | 类型 | 必填 | 说明 | 4464| -------- | ----------------------------------------- | ---- | ------------------------ | 4465| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。 | 4466| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.md#focusstate)\> | 否 | 回调函数,可选,有就是匹配on('focusStateChange') callback(callback对象不可是匿名函数)。 | 4467 4468**示例:** 4469 4470```ts 4471function unregisterFocusStateChange(nightPhotoSession: camera.NightPhotoSession): void { 4472 nightPhotoSession.off('focusStateChange'); 4473} 4474``` 4475 4476### on('smoothZoomInfoAvailable')<sup>11+</sup> 4477 4478on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 4479 4480监听相机平滑变焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 4481 4482**系统接口:** 此接口为系统接口。 4483 4484**系统能力:** SystemCapability.Multimedia.Camera.Core 4485 4486**参数:** 4487 4488| 参数名 | 类型 | 必填 | 说明 | 4489| -------- | ----------------------- | ---- | ------------------------ | 4490| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 4491| callback | AsyncCallback\<[SmoothZoomInfo](arkts-apis-camera-i.md#smoothzoominfo11)\> | 是 | 回调函数,用于获取当前平滑变焦状态。 | 4492 4493**示例:** 4494 4495```ts 4496import { BusinessError } from '@kit.BasicServicesKit'; 4497 4498function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 4499 if (err !== undefined && err.code !== 0) { 4500 console.error(`Callback Error, errorCode: ${err.code}`); 4501 return; 4502 } 4503 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 4504} 4505 4506function registerSmoothZoomInfo(nightPhotoSession: camera.NightPhotoSession): void { 4507 nightPhotoSession.on('smoothZoomInfoAvailable', callback); 4508} 4509``` 4510 4511### off('smoothZoomInfoAvailable')<sup>11+</sup> 4512 4513off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 4514 4515注销监听相机平滑变焦的状态变化。 4516 4517**系统接口:** 此接口为系统接口。 4518 4519**系统能力:** SystemCapability.Multimedia.Camera.Core 4520 4521**参数:** 4522 4523| 参数名 | 类型 | 必填 | 说明 | 4524| -------- | ----------------------------------------- | ---- | ------------------------ | 4525| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 4526| callback | AsyncCallback\<[SmoothZoomInfo](arkts-apis-camera-i.md#smoothzoominfo11)\> | 否 | 回调函数,可选,有就是匹配on('smoothZoomInfoAvailable') callback(callback对象不可是匿名函数)。 | 4527 4528**示例:** 4529 4530```ts 4531function unregisterSmoothZoomInfo(nightPhotoSession: camera.NightPhotoSession): void { 4532 nightPhotoSession.off('smoothZoomInfoAvailable'); 4533} 4534``` 4535 4536### on('lcdFlashStatus')<sup>12+</sup> 4537 4538on(type: 'lcdFlashStatus', callback: AsyncCallback\<[LcdFlashStatus](#lcdflashstatus12)\>): void 4539 4540监听lcd flash状态,通过注册回调函数获取结果。使用callback异步回调。 4541 4542**系统接口:** 此接口为系统接口。 4543 4544**系统能力:** SystemCapability.Multimedia.Camera.Core 4545 4546**参数:** 4547 4548| 参数名 | 类型 | 必填 | 说明 | 4549| -------- | ----------------------- | ---- | ------------------------ | 4550| type | string | 是 | 监听事件,固定为'lcdFlashStatus',session创建成功可监听。| 4551| callback | AsyncCallback\<[LcdFlashStatus](#lcdflashstatus12)\> | 是 | 回调函数,用于获取当前lcd flash状态。 | 4552 4553**错误码:** 4554 4555以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 4556 4557| 错误码ID | 错误信息 | 4558|-------|---------------------------| 4559| 202 | Not System Application. | 4560 4561**示例:** 4562 4563```ts 4564import { BusinessError } from '@kit.BasicServicesKit'; 4565 4566function callback(err: BusinessError, lcdFlashStatus: camera.LcdFlashStatus): void { 4567 if (err !== undefined && err.code !== 0) { 4568 console.error(`Callback Error, errorCode: ${err.code}`); 4569 return; 4570 } 4571 console.info(`lcdFlashStatus: ${lcdFlashStatus}`); 4572} 4573 4574function registerLcdFlashStatus(nightPhotoSession: camera.NightPhotoSession): void { 4575 nightPhotoSession.on('lcdFlashStatus', callback); 4576} 4577``` 4578 4579### off('lcdFlashStatus')<sup>12+</sup> 4580 4581off(type: 'lcdFlashStatus', callback?: AsyncCallback\<[LcdFlashStatus](#lcdflashstatus12)\>): void 4582 4583注销lcd flash状态,通过注册回调函数获取结果。 4584 4585**系统接口:** 此接口为系统接口。 4586 4587**系统能力:** SystemCapability.Multimedia.Camera.Core 4588 4589**参数:** 4590 4591| 参数名 | 类型 | 必填 | 说明 | 4592| -------- | ----------------------------------------- | ---- | ------------------------ | 4593| type | string | 是 | 监听事件,固定为'lcdFlashStatus',session创建成功可监听。| 4594| callback | AsyncCallback\<[LcdFlashStatus](#lcdflashstatus12)\> | 否 | 回调函数,可选,有就是匹配on('lcdFlashStatus') callback(callback对象不可是匿名函数)。 | 4595 4596**错误码:** 4597 4598以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 4599 4600| 错误码ID | 错误信息 | 4601|-------|---------------------------| 4602| 202 | Not System Application. | 4603 4604**示例:** 4605 4606```ts 4607function unregisterLcdFlashStatus(nightPhotoSession: camera.NightPhotoSession): void { 4608 nightPhotoSession.off('lcdFlashStatus'); 4609} 4610``` 4611 4612## HighResolutionPhotoSession<sup>12+</sup> 4613 4614HighResolutionPhotoSession extends Session, AutoExposure, Focus 4615 4616高像素拍照模式会话类,继承自[Session](arkts-apis-camera-Session.md),用于设置高像素拍照模式的参数以及保存所需要的所有资源[CameraInput](arkts-apis-camera-CameraInput.md)、[CameraOutput](arkts-apis-camera-CameraOutput.md)。 4617 4618### on('error')<sup>12+</sup> 4619 4620on(type: 'error', callback: ErrorCallback): void 4621 4622监听高像素拍照会话的错误事件,通过注册回调函数获取结果。使用callback异步回调。 4623 4624**系统接口:** 此接口为系统接口。 4625 4626**系统能力:** SystemCapability.Multimedia.Camera.Core 4627 4628**参数:** 4629 4630| 参数名 | 类型 | 必填 | 说明 | 4631| -------- | --------------------------------- | ---- | ------------------------------ | 4632| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。session调用相关接口出现错误时会触发该事件,比如调用[beginConfig](arkts-apis-camera-Session.md#beginconfig11),[commitConfig](arkts-apis-camera-Session.md#commitconfig11-1),[addInput](arkts-apis-camera-Session.md#addinput11)等接口发生错误时返回错误信息。 | 4633| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。 | 4634 4635**错误码:** 4636 4637以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 4638 4639| 错误码ID | 错误信息 | 4640| --------------- | --------------- | 4641| 202 | Not System Application. | 4642 4643**示例:** 4644 4645```ts 4646import { BusinessError } from '@kit.BasicServicesKit'; 4647 4648function callback(err: BusinessError): void { 4649 console.error(`High resolution photo session error code: ${err.code}`); 4650} 4651 4652function registerSessionError(highResolutionPhotoSession: camera.HighResolutionPhotoSession): void { 4653 highResolutionPhotoSession.on('error', callback); 4654} 4655``` 4656### off('error')<sup>12+</sup> 4657 4658off(type: 'error', callback?: ErrorCallback): void 4659 4660注销监听高像素拍照会话的错误事件,通过注册回调函数获取结果。 4661 4662**系统接口:** 此接口为系统接口。 4663 4664**系统能力:** SystemCapability.Multimedia.Camera.Core 4665 4666**参数:** 4667 4668| 参数名 | 类型 | 必填 | 说明 | 4669| -------- | ------------------------ | ---- | ------------------------------ | 4670| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。 | 4671| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 否 | 回调函数,可选,有就是匹配on('error') callback(callback对象不可是匿名函数)。 | 4672 4673**错误码:** 4674 4675以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 4676 4677| 错误码ID | 错误信息 | 4678| --------------- | --------------- | 4679| 202 | Not System Application. | 4680 4681**示例:** 4682 4683```ts 4684function unregisterSessionError(highResolutionPhotoSession: camera.HighResolutionPhotoSession): void { 4685 highResolutionPhotoSession.off('error'); 4686} 4687``` 4688 4689### on('focusStateChange')<sup>12+</sup> 4690 4691on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 4692 4693监听相机对焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 4694 4695**系统接口:** 此接口为系统接口。 4696 4697**系统能力:** SystemCapability.Multimedia.Camera.Core 4698 4699**参数:** 4700 4701| 参数名 | 类型 | 必填 | 说明 | 4702| -------- | ---------------- | ---- | ------------------------ | 4703| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。仅当自动对焦模式时,且相机对焦状态发生改变时可触发该事件。 | 4704| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.md#focusstate)\> | 是 | 回调函数,用于获取当前对焦状态。 | 4705 4706**错误码:** 4707 4708以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 4709 4710| 错误码ID | 错误信息 | 4711| --------------- | --------------- | 4712| 202 | Not System Application. | 4713 4714**示例:** 4715 4716```ts 4717import { BusinessError } from '@kit.BasicServicesKit'; 4718 4719function callback(err: BusinessError, focusState: camera.FocusState): void { 4720 if (err !== undefined && err.code !== 0) { 4721 console.error(`Callback Error, errorCode: ${err.code}`); 4722 return; 4723 } 4724 console.info(`Focus state: ${focusState}`); 4725} 4726 4727function registerFocusStateChange(highResolutionPhotoSession: camera.HighResolutionPhotoSession): void { 4728 highResolutionPhotoSession.on('focusStateChange', callback); 4729} 4730``` 4731 4732### off('focusStateChange')<sup>12+</sup> 4733 4734off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 4735 4736注销监听相机对焦的状态变化。 4737 4738**系统接口:** 此接口为系统接口。 4739 4740**系统能力:** SystemCapability.Multimedia.Camera.Core 4741 4742**错误码:** 4743 4744以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 4745 4746| 错误码ID | 错误信息 | 4747| --------------- | --------------- | 4748| 202 | Not System Application. | 4749 4750**参数:** 4751 4752| 参数名 | 类型 | 必填 | 说明 | 4753| -------- | ----------------------------------------- | ---- | ------------------------ | 4754| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。 | 4755| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.md#focusstate)\> | 否 | 回调函数,可选,有就是匹配on('focusStateChange') callback(callback对象不可是匿名函数)。 | 4756 4757**示例:** 4758 4759```ts 4760function unregisterFocusStateChange(highResolutionPhotoSession: camera.HighResolutionPhotoSession): void { 4761 highResolutionPhotoSession.off('focusStateChange'); 4762} 4763``` 4764 4765## SketchStatusData<sup>11+</sup> 4766 4767画中画状态返回数据。 4768 4769**系统接口:** 此接口为系统接口。 4770 4771**系统能力:** SystemCapability.Multimedia.Camera.Core 4772 4773| 名称 | 类型 | 只读 | 必填 | 说明 | 4774| ------------- | -------- | ---- | ---- | ---------- | 4775| status | number | 否 | 是 | 画中画当前的状态。0:已停止,1:已启动,2:停止中,3:启动中。| 4776| sketchRatio | number | 否 | 是 | 画中画画面的Zoom倍率。| 4777 4778## SlowMotionVideoSession<sup>12+</sup> 4779 4780SlowMotionVideoSession extends Session, Flash, AutoExposure, Focus, Zoom, ColorEffect 4781 4782慢动作录像模式会话类,继承自[Session](arkts-apis-camera-Session.md),用于设置慢动作录像模式的参数以及保存所需要的所有资源[CameraInput](arkts-apis-camera-CameraInput.md)、[CameraOutput](arkts-apis-camera-CameraOutput.md)。 4783 4784> **说明:** 4785> 慢动作模式下只能添加预览流和录像流。 4786### on('error')<sup>12+</sup> 4787 4788on(type: 'error', callback: ErrorCallback): void 4789 4790监听慢动作录像模式会话的错误事件,通过注册回调函数获取结果。使用callback异步回调。 4791 4792**系统接口:** 此接口为系统接口。 4793 4794**系统能力:** SystemCapability.Multimedia.Camera.Core 4795 4796**参数:** 4797 4798| 参数名 | 类型 | 必填 | 说明 | 4799| -------- | --------------------------------- | ---- | ------------------------------ | 4800| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。session调用相关接口出现错误时会触发该事件,比如调用[beginConfig](arkts-apis-camera-Session.md#beginconfig11),[commitConfig](arkts-apis-camera-Session.md#commitconfig11-1),[addInput](arkts-apis-camera-Session.md#addinput11)等接口发生错误时返回错误信息。 | 4801| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。 | 4802 4803**错误码:** 4804 4805以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 4806 4807| 错误码ID | 错误信息 | 4808|---------| --------------- | 4809| 202 | Not System Application. | 4810 4811**示例:** 4812 4813```ts 4814import { BusinessError } from '@kit.BasicServicesKit'; 4815 4816function callback(err: BusinessError): void { 4817 console.error(`Portrait photo session error code: ${err.code}`); 4818} 4819 4820function registerSessionError(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 4821 slowMotionVideoSession.on('error', callback); 4822} 4823``` 4824 4825### off('error')<sup>12+</sup> 4826 4827off(type: 'error', callback?: ErrorCallback): void 4828 4829注销慢动作录像模式会话的错误事件,通过注册回调函数获取结果。 4830 4831**系统接口:** 此接口为系统接口。 4832 4833**系统能力:** SystemCapability.Multimedia.Camera.Core 4834 4835**参数:** 4836 4837| 参数名 | 类型 | 必填 | 说明 | 4838| -------- | -------------------------- | ---- | ------------------------------ | 4839| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。 | 4840| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 否 | 回调函数,可选,有就是匹配on('error') callback(callback对象不可是匿名函数)。 | 4841 4842**错误码:** 4843 4844以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 4845 4846| 错误码ID | 错误信息 | 4847|---------| --------------- | 4848| 202 | Not System Application. | 4849 4850**示例:** 4851 4852```ts 4853function unregisterSessionError(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 4854 slowMotionVideoSession.off('error'); 4855} 4856``` 4857 4858### on('focusStateChange')<sup>12+</sup> 4859 4860on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 4861 4862监听相机对焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 4863 4864**系统接口:** 此接口为系统接口。 4865 4866**系统能力:** SystemCapability.Multimedia.Camera.Core 4867 4868**参数:** 4869 4870| 参数名 | 类型 | 必填 | 说明 | 4871| -------- | ---------------- | ---- | ------------------------ | 4872| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。仅当自动对焦模式时,且相机对焦状态发生改变时可触发该事件。 | 4873| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.md#focusstate)\> | 是 | 回调函数,用于获取当前对焦状态。 | 4874 4875**错误码:** 4876 4877以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 4878 4879| 错误码ID | 错误信息 | 4880|---------| --------------- | 4881| 202 | Not System Application. | 4882 4883**示例:** 4884 4885```ts 4886import { BusinessError } from '@kit.BasicServicesKit'; 4887 4888function callback(err: BusinessError, focusState: camera.FocusState): void { 4889 if (err !== undefined && err.code !== 0) { 4890 console.error(`Callback Error, errorCode: ${err.code}`); 4891 return; 4892 } 4893 console.info(`Focus state: ${focusState}`); 4894} 4895 4896function registerFocusStateChange(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 4897 slowMotionVideoSession.on('focusStateChange', callback); 4898} 4899``` 4900 4901### off('focusStateChange')<sup>12+</sup> 4902 4903off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 4904 4905注销监听相机对焦的状态变化。 4906 4907**系统接口:** 此接口为系统接口。 4908 4909**系统能力:** SystemCapability.Multimedia.Camera.Core 4910 4911**参数:** 4912 4913| 参数名 | 类型 | 必填 | 说明 | 4914| -------- | ----------------------------------------- | ---- | ------------------------ | 4915| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。 | 4916| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.md#focusstate)\> | 否 | 回调函数,可选,有就是匹配on('focusStateChange') callback(callback对象不可是匿名函数)。 | 4917 4918**错误码:** 4919 4920以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 4921 4922| 错误码ID | 错误信息 | 4923|---------| --------------- | 4924| 202 | Not System Application. | 4925 4926**示例:** 4927 4928```ts 4929function unregisterFocusStateChange(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 4930 slowMotionVideoSession.off('focusStateChange'); 4931} 4932``` 4933 4934### on('smoothZoomInfoAvailable')<sup>12+</sup> 4935 4936on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 4937 4938监听相机平滑变焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 4939 4940**系统接口:** 此接口为系统接口。 4941 4942**系统能力:** SystemCapability.Multimedia.Camera.Core 4943 4944**参数:** 4945 4946| 参数名 | 类型 | 必填 | 说明 | 4947| -------- | ----------------------- | ---- | ------------------------ | 4948| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 4949| callback | AsyncCallback\<[SmoothZoomInfo](arkts-apis-camera-i.md#smoothzoominfo11)\> | 是 | 回调函数,用于获取当前平滑变焦状态。 | 4950 4951**错误码:** 4952 4953以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 4954 4955| 错误码ID | 错误信息 | 4956|---------| --------------- | 4957| 202 | Not System Application. | 4958 4959**示例:** 4960 4961```ts 4962import { BusinessError } from '@kit.BasicServicesKit'; 4963 4964function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 4965 if (err !== undefined && err.code !== 0) { 4966 console.error(`Callback Error, errorCode: ${err.code}`); 4967 return; 4968 } 4969 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 4970} 4971 4972function registerSmoothZoomInfo(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 4973 slowMotionVideoSession.on('smoothZoomInfoAvailable', callback); 4974} 4975``` 4976 4977### off('smoothZoomInfoAvailable')<sup>12+</sup> 4978 4979off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 4980 4981注销监听相机平滑变焦的状态变化。 4982 4983**系统接口:** 此接口为系统接口。 4984 4985**系统能力:** SystemCapability.Multimedia.Camera.Core 4986 4987**参数:** 4988 4989| 参数名 | 类型 | 必填 | 说明 | 4990| -------- | ----------------------------------------- | ---- | ------------------------ | 4991| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 4992| callback | AsyncCallback\<[SmoothZoomInfo](arkts-apis-camera-i.md#smoothzoominfo11)\> | 否 | 回调函数,可选,有就是匹配on('smoothZoomInfoAvailable') callback(callback对象不可是匿名函数)。 | 4993 4994**错误码:** 4995 4996以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 4997 4998| 错误码ID | 错误信息 | 4999|---------| --------------- | 5000| 202 | Not System Application. | 5001 5002**示例:** 5003 5004```ts 5005function unregisterSmoothZoomInfo(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 5006 slowMotionVideoSession.off('smoothZoomInfoAvailable'); 5007} 5008``` 5009 5010### on('slowMotionStatus')<sup>12+</sup> 5011 5012on(type: 'slowMotionStatus', callback: AsyncCallback\<SlowMotionStatus\>): void 5013 5014监听慢动作状态变化,通过注册回调函数获取结果。使用callback异步回调。 5015 5016**系统接口:** 此接口为系统接口。 5017 5018**系统能力:** SystemCapability.Multimedia.Camera.Core 5019 5020**参数:** 5021 5022| 参数名 | 类型 | 必填 | 说明 | 5023| -------- |---------------------------------------------------------------------------| ---- |--------------------------------------------| 5024| type | string | 是 | 监听事件,固定为'slowMotionStatus',session创建成功可监听。 | 5025| callback | AsyncCallback\<[SlowMotionStatus](#slowmotionstatus12)\> | 是 | 回调函数,用于获取当前慢动作状态。当慢动作状态发生变动时,此回调函数也会被执行。 | 5026 5027**错误码:** 5028 5029以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5030 5031| 错误码ID | 错误信息 | 5032|---------| --------------- | 5033| 202 | Not System Application. | 5034 5035**示例:** 5036 5037```ts 5038import { BusinessError } from '@kit.BasicServicesKit'; 5039 5040function callback(err: BusinessError, slowMotionStatus: camera.SlowMotionStatus): void { 5041 if (err !== undefined && err.code !== 0) { 5042 console.error(`Callback Error, errorCode: ${err.code}`); 5043 return; 5044 } 5045 console.info(`The slow motion status: ${slowMotionStatus}`); 5046} 5047 5048function registerSlowMotionStatus(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 5049 slowMotionVideoSession.on('slowMotionStatus', callback); 5050} 5051``` 5052 5053### off('slowMotionStatus')<sup>12+</sup> 5054 5055off(type: 'slowMotionStatus', callback?: AsyncCallback\<SlowMotionStatus\>): void 5056 5057注销慢动作状态变化。 5058 5059**系统接口:** 此接口为系统接口。 5060 5061**系统能力:** SystemCapability.Multimedia.Camera.Core 5062 5063**参数:** 5064 5065| 参数名 | 类型 | 必填 | 说明 | 5066| -------- | ----------------------------------------- | ---- | ------------------------ | 5067| type | string | 是 | 监听事件,固定为'slowMotionStatus',session创建成功可监听。| 5068| callback | AsyncCallback\<[SlowMotionStatus](#slowmotionstatus12)\> | 否 | 回调函数,可选,有就是匹配on('slowMotionStatus') callback(callback对象不可是匿名函数)。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。 | 5069 5070**错误码:** 5071 5072以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5073 5074| 错误码ID | 错误信息 | 5075|---------| --------------- | 5076| 202 | Not System Application. | 5077 5078**示例:** 5079 5080```ts 5081function unregisterSlowMotionStatus(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 5082 slowMotionVideoSession.off('slowMotionStatus'); 5083} 5084``` 5085### isSlowMotionDetectionSupported<sup>12+</sup> 5086 5087isSlowMotionDetectionSupported(): boolean 5088 5089查询当前设备是否支持慢动作检测功能。 5090 5091> **说明:** 5092> 该接口需要在[commitConfig](arkts-apis-camera-Session.md#commitconfig11-1)之后调用。 5093 5094**系统接口:** 此接口为系统接口。 5095 5096**系统能力:** SystemCapability.Multimedia.Camera.Core 5097 5098**返回值:** 5099 5100| 类型 | 说明 | 5101| ---------- |----------------------------------------------------------------------------------------| 5102| boolean | 返回true表示支持慢动作检测功能,false表示不支持。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。 | 5103 5104**错误码:** 5105 5106以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5107 5108| 错误码ID | 错误信息 | 5109|---------| --------------- | 5110| 202 | Not System Application. | 5111 5112**示例:** 5113 5114```ts 5115import { BusinessError } from '@kit.BasicServicesKit'; 5116 5117function isSlowMotionDetectionSupported(slowMotionVideoSession: camera.SlowMotionVideoSession): boolean { 5118 let isSupported: boolean = false; 5119 try { 5120 isSupported = slowMotionVideoSession.isSlowMotionDetectionSupported(); 5121 } catch (error) { 5122 // 失败返回错误码error.code并处理。 5123 let err = error as BusinessError; 5124 console.error(`The isFocusModeSupported call failed. error code: ${err.code}`); 5125 } 5126 return isSupported; 5127} 5128``` 5129 5130### setSlowMotionDetectionArea<sup>12+</sup> 5131 5132setSlowMotionDetectionArea(area: Rect): void 5133 5134设置一个进行慢动作检测的区域。 5135 5136> **说明:** 5137> 在调用该方法之前,先调用[isSlowMotionDetectionSupported](#isslowmotiondetectionsupported12)确认设备是否支持慢动作检测功能, 才能保证其他相关方法的正常运行。 5138该接口需要在[commitConfig](arkts-apis-camera-Session.md#commitconfig11-1)之后调用。 5139 5140**系统接口:** 此接口为系统接口。 5141 5142**系统能力:** SystemCapability.Multimedia.Camera.Core 5143 5144**参数:** 5145 5146| 参数名 | 类型 | 必填 | 说明 | 5147| -------- | ---------------------------------------------- | ---- | --------------------------- | 5148| area | [Rect](arkts-apis-camera-i.md#rect) | 是 | 矩形定义。 | 5149 5150**错误码:** 5151 5152以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5153 5154| 错误码ID | 错误信息 | 5155|---------| --------------- | 5156| 202 | Not System Application. | 5157 5158**示例:** 5159 5160```ts 5161import { BusinessError } from '@kit.BasicServicesKit'; 5162 5163function setSlowMotionDetectionArea(slowMotionVideoSession: camera.SlowMotionVideoSession): void { 5164 try { 5165 slowMotionVideoSession.setSlowMotionDetectionArea({topLeftX: 0.1, topLeftY: 0.1, width: 0.8, height: 0.8}); 5166 } catch (error) { 5167 // 失败返回错误码error.code并处理。 5168 let err = error as BusinessError; 5169 console.error(`The setSlowMotionDetectionArea call failed. error code: ${err.code}`); 5170 } 5171} 5172``` 5173 5174## PanoramaPhotoSession<sup>12+</sup> 5175 5176PanoramaPhotoSession extends Session, Focus, AutoExposure, WhiteBalance, ColorEffect 5177 5178全景拍照模式会话类,继承自[Session](arkts-apis-camera-Session.md),用于设置全景拍照模式的参数以及保存所需要的所有资源[CameraInput](arkts-apis-camera-CameraInput.md)、[CameraOutput](arkts-apis-camera-CameraOutput.md)。 5179 5180### on('error')<sup>12+</sup> 5181 5182on(type: 'error', callback: ErrorCallback): void 5183 5184监听全景拍照会话的错误事件,通过注册回调函数获取结果。使用callback异步回调。 5185 5186**系统接口:** 此接口为系统接口。 5187 5188**系统能力:** SystemCapability.Multimedia.Camera.Core 5189 5190**参数:** 5191 5192| 参数名 | 类型 | 必填 | 说明 | 5193| -------- | ----------------------------------------------------------- | ---- | ------------------------------ | 5194| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。session调用相关接口出现错误时会触发该事件,比如调用[beginConfig](arkts-apis-camera-Session.md#beginconfig11),[commitConfig](arkts-apis-camera-Session.md#commitconfig11-1),[addInput](arkts-apis-camera-Session.md#addinput11)等接口发生错误时返回错误信息。 | 5195| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。 | 5196 5197**示例:** 5198 5199```ts 5200import { BusinessError } from '@kit.BasicServicesKit'; 5201 5202function callback(err: BusinessError): void { 5203 console.error(`Panorama photo session error code: ${err.code}`); 5204} 5205 5206function registerSessionError(panoramaPhotoSession: camera.PanoramaPhotoSession): void { 5207 panoramaPhotoSession.on('error', callback); 5208} 5209``` 5210 5211### off('error')<sup>12+</sup> 5212 5213off(type: 'error', callback?: ErrorCallback): void 5214 5215注销监听全景拍照会话的错误事件,通过注册回调函数获取结果。 5216 5217**系统接口:** 此接口为系统接口。 5218 5219**系统能力:** SystemCapability.Multimedia.Camera.Core 5220 5221**参数:** 5222 5223| 参数名 | 类型 | 必填 | 说明 | 5224| -------- | ------------------------ | ---- | ------------------------------ | 5225| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。 | 5226| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 否 | 回调函数,可选,有就是匹配on('error') callback(callback对象不可是匿名函数)。 | 5227 5228**示例:** 5229 5230```ts 5231function unregisterSessionError(panoramaPhotoSession: camera.PanoramaPhotoSession): void { 5232 panoramaPhotoSession.off('error'); 5233} 5234``` 5235 5236### on('focusStateChange')<sup>12+</sup> 5237 5238on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 5239 5240监听相机对焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 5241 5242**系统接口:** 此接口为系统接口。 5243 5244**系统能力:** SystemCapability.Multimedia.Camera.Core 5245 5246**参数:** 5247 5248| 参数名 | 类型 | 必填 | 说明 | 5249| -------- | ---------------- | ---- | ------------------------ | 5250| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。仅当自动对焦模式时,且相机对焦状态发生改变时可触发该事件。 | 5251| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.md#focusstate)\> | 是 | 回调函数,用于获取当前对焦状态。 | 5252 5253**示例:** 5254 5255```ts 5256import { BusinessError } from '@kit.BasicServicesKit'; 5257 5258function callback(err: BusinessError, focusState: camera.FocusState): void { 5259 if (err !== undefined && err.code !== 0) { 5260 console.error(`Callback Error, errorCode: ${err.code}`); 5261 return; 5262 } 5263 console.info(`Focus state: ${focusState}`); 5264} 5265 5266function registerFocusStateChange(panoramaPhotoSession: camera.PanoramaPhotoSession): void { 5267 panoramaPhotoSession.on('focusStateChange', callback); 5268} 5269``` 5270 5271### off('focusStateChange')<sup>12+</sup> 5272 5273off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 5274 5275注销监听相机对焦的状态变化。 5276 5277**系统接口:** 此接口为系统接口。 5278 5279**系统能力:** SystemCapability.Multimedia.Camera.Core 5280 5281**参数:** 5282 5283| 参数名 | 类型 | 必填 | 说明 | 5284| -------- | ----------------------------------------- | ---- | ------------------------ | 5285| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。 | 5286| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.md#focusstate)\> | 否 | 回调函数,可选,有就是匹配on('focusStateChange') callback(callback对象不可是匿名函数)。 | 5287 5288**示例:** 5289 5290```ts 5291function unregisterFocusStateChange(panoramaPhotoSession: camera.PanoramaPhotoSession): void { 5292 panoramaPhotoSession.off('focusStateChange'); 5293} 5294``` 5295 5296## IsoInfo<sup>12+</sup> 5297 5298ISO参数信息。 5299 5300**系统接口:** 此接口为系统接口。 5301 5302**系统能力:** SystemCapability.Multimedia.Camera.Core 5303 5304| 名称 | 类型 | 只读 | 可选 | 说明 | 5305| ---- | ------- | ---- |--| -------------- | 5306| iso | number | 是 | 是 | ISO值。 | 5307 5308--- 5309 5310## ExposureInfo<sup>12+</sup> 5311 5312曝光参数信息。 5313 5314**系统接口:** 此接口为系统接口。 5315 5316**系统能力:** SystemCapability.Multimedia.Camera.Core 5317 5318| 名称 | 类型 | 只读 | 可选 | 说明 | 5319| ----------------- | ------- | ---- |-----| ------------------ | 5320| exposureTime | number | 是 | 是 | 曝光时间值,单位为毫秒。 | 5321 5322--- 5323 5324## ApertureInfo<sup>12+</sup> 5325 5326光圈参数信息。 5327 5328**系统接口:** 此接口为系统接口。 5329 5330**系统能力:** SystemCapability.Multimedia.Camera.Core 5331 5332| 名称 | 类型 | 只读 | 可选 | 说明 | 5333| --------- | ------- | ---- |-----| ---------- | 5334| aperture | number | 是 | 是 | 光圈值。 | 5335 5336--- 5337 5338## LuminationInfo<sup>12+</sup> 5339 5340光照参数信息。 5341 5342**系统接口:** 此接口为系统接口。 5343 5344**系统能力:** SystemCapability.Multimedia.Camera.Core 5345 5346| 名称 | 类型 | 只读 | 可选 | 说明 | 5347| ----------- | ------- | ---- |-----| ---------- | 5348| lumination | number | 是 | 是 | 范围[0,1],光照值归一化数值| 5349 5350## CameraFormat 5351 5352枚举,输出格式。 5353 5354**系统能力:** SystemCapability.Multimedia.Camera.Core 5355 5356| 名称 | 值 | 说明 | 5357| ----------------------- | --------- | ------------ | 5358| CAMERA_FORMAT_DNG<sup>12+</sup> | 4 | DNG格式的RAW图片。**系统接口:** 此接口为系统接口。 | 5359| CAMERA_FORMAT_DNG_XDRAW<sup>18+</sup> | 5 | DNG格式的增强RAW图片,JPG和RAW图片封装在同一个文件中,最高支持16bit的RAW数据。**系统接口:** 此接口为系统接口。 | 5360## ExposureMeteringMode<sup>12+</sup> 5361 5362枚举,测光模式。 5363 5364**系统接口:** 此接口为系统接口。 5365 5366**系统能力:** SystemCapability.Multimedia.Camera.Core 5367 5368| 名称 | 值 | 说明 | 5369| ----------------------------- | ---- | ----------- | 5370| MATRIX | 0 | 对画面广泛区域进行测光。 | 5371| CENTER | 1 | 对整个画面进行测光,但最大比重分配给中央区域。 | 5372| SPOT | 2 | 对画面测光点周围约2.5%进行测光 | 5373 5374## AutoExposureQuery<sup>12+</sup> 5375 5376提供了查询设备是否支持特定曝光模式,曝光补偿的范围,以及是否支持特定的曝光测光模式的方法。 5377 5378### isExposureMeteringModeSupported<sup>12+</sup> 5379 5380isExposureMeteringModeSupported(aeMeteringMode: ExposureMeteringMode): boolean 5381 5382检测传入的测光模式是否支持。 5383 5384**系统接口:** 此接口为系统接口。 5385 5386**系统能力:** SystemCapability.Multimedia.Camera.Core 5387 5388**参数:** 5389 5390| 参数名 | 类型 | 必填 | 说明 | 5391| -------- | -------------------------------| ---- | ----------------------------- | 5392| aeMeteringMode | [ExposureMeteringMode](#exposuremeteringmode12) | 是 | 测光模式。 | 5393 5394**返回值:** 5395 5396| 类型 | 说明 | 5397| ---------- | ----------------------------- | 5398| boolean | 获取是否支持传入的测光模式,返回true为支持,返回false为不支持。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。 | 5399 5400**错误码:** 5401 5402以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5403 5404| 错误码ID | 错误信息 | 5405| --------------- | --------------- | 5406| 202 | Not System Application. | 5407| 7400101 | Parameter missing or parameter type incorrect. | 5408| 7400103 | Session not config. | 5409 5410 5411**示例:** 5412 5413```ts 5414import { BusinessError } from '@kit.BasicServicesKit'; 5415 5416function isExposureMeteringModeSupported(professionalPhotoSession: camera.ProfessionalPhotoSession): boolean { 5417 let isSupported: boolean = false; 5418 try { 5419 isSupported = professionalPhotoSession.isExposureMeteringModeSupported(camera.ExposureMeteringMode.CENTER); 5420 } catch (error) { 5421 // 失败返回错误码error.code并处理。 5422 let err = error as BusinessError; 5423 console.error(`The isExposureMeteringModeSupported call failed. error code: ${err.code}`); 5424 } 5425 return isSupported; 5426} 5427``` 5428 5429## AutoExposure 5430 5431AutoExposure extends [AutoExposureQuery](#autoexposurequery12) 5432 5433提供了处理设备自动曝光的相关功能,包括获取和设置曝光模式、测量点,查询补偿范围,设定曝光补偿,和获取设置曝光的测光模式。 5434 5435### getExposureMeteringMode<sup>12+</sup> 5436 5437getExposureMeteringMode(): ExposureMeteringMode 5438 5439获取当前测光模式。 5440 5441**系统接口:** 此接口为系统接口。 5442 5443**系统能力:** SystemCapability.Multimedia.Camera.Core 5444 5445**返回值:** 5446 5447| 类型 | 说明 | 5448| ---------- | ----------------------------- | 5449| [ExposureMeteringMode](#exposuremeteringmode12) | 获取当前测光模式。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。 | 5450 5451**错误码:** 5452 5453以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5454 5455| 错误码ID | 错误信息 | 5456| --------------- | --------------- | 5457| 7400103 | Session not config. | 5458| 202 | Not System Application. | 5459 5460**示例:** 5461 5462```ts 5463import { BusinessError } from '@kit.BasicServicesKit'; 5464 5465function getExposureMeteringMode(professionalPhotoSession: camera.ProfessionalPhotoSession): camera.ExposureMeteringMode | undefined { 5466 let exposureMeteringMode: camera.ExposureMeteringMode | undefined = undefined; 5467 try { 5468 exposureMeteringMode = professionalPhotoSession.getExposureMeteringMode(); 5469 } catch (error) { 5470 // 失败返回错误码error.code并处理。 5471 let err = error as BusinessError; 5472 console.error(`The getExposureMeteringMode call failed. error code: ${err.code}`); 5473 } 5474 return exposureMeteringMode; 5475} 5476``` 5477 5478### setExposureMeteringMode<sup>12+</sup> 5479 5480setExposureMeteringMode(aeMeteringMode: ExposureMeteringMode): void 5481 5482设置测光模式。进行设置之前,需要先检查设备是否支持指定的测光模式,可使用方法[isExposureMeteringModeSupported](#isexposuremeteringmodesupported12)。 5483 5484**系统接口:** 此接口为系统接口。 5485 5486**系统能力:** SystemCapability.Multimedia.Camera.Core 5487 5488**参数:** 5489 5490| 参数名 | 类型 | 必填 | 说明 | 5491| -------- | -------------------------------| ---- | ----------------------- | 5492| aeMeteringMode | [ExposureMeteringMode](#exposuremeteringmode12) | 是 | 测光模式。 | 5493 5494**错误码:** 5495 5496以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5497 5498| 错误码ID | 错误信息 | 5499| --------------- | --------------- | 5500| 202 | Not System Application. | 5501| 7400101 | Parameter missing or parameter type incorrect. | 5502| 7400103 | Session not config. | 5503 5504**示例:** 5505 5506```ts 5507import { BusinessError } from '@kit.BasicServicesKit'; 5508 5509function setExposureMeteringMode(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 5510 try { 5511 professionalPhotoSession.setExposureMeteringMode(camera.ExposureMeteringMode.CENTER); 5512 } catch (error) { 5513 // 失败返回错误码error.code并处理。 5514 let err = error as BusinessError; 5515 console.error(`The setExposureMeteringMode call failed. error code: ${err.code}`); 5516 } 5517} 5518``` 5519 5520## FocusRangeType<sup>15+</sup> 5521 5522枚举,对焦范围类型。 5523 5524**系统能力**: SystemCapability.Multimedia.Camera.Core 5525 5526| 名称 | 值 | 说明 | 5527| ---- | ---- | ---------- | 5528| AUTO | 0 | 自动对焦。 | 5529| NEAR | 1 | 近物对焦。 | 5530 5531## FocusDrivenType<sup>15+</sup> 5532 5533枚举,对焦驱动类型。 5534 5535**系统能力**: SystemCapability.Multimedia.Camera.Core 5536 5537| 名称 | 值 | 说明 | 5538| ---- | ---- | ---------- | 5539| AUTO | 0 | 自动。 | 5540| FACE | 1 | 人脸驱动。 | 5541 5542## FocusQuery<sup>12+</sup> 5543 5544提供了查询是否支持对焦辅助的方法。 5545 5546### isFocusAssistSupported<sup>12+</sup> 5547 5548isFocusAssistSupported(): boolean 5549 5550检测是否支持对焦辅助灯。 5551 5552**系统接口:** 此接口为系统接口。 5553 5554**系统能力:** SystemCapability.Multimedia.Camera.Core 5555 5556**返回值:** 5557 5558| 类型 | 说明 | 5559| ---------- | ----------------------------- | 5560| boolean | 返回true表示支持对焦辅助灯,false表示不支持。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。 | 5561 5562**错误码:** 5563 5564以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5565 5566| 错误码ID | 错误信息 | 5567| --------------- | --------------- | 5568| 7400103 | Session not config. | 5569| 202 | Not System Application. | 5570 5571**示例:** 5572 5573```ts 5574import { BusinessError } from '@kit.BasicServicesKit'; 5575 5576function isFocusAssistSupported(professionalPhotoSession: camera.ProfessionalPhotoSession): boolean { 5577 let status: boolean = false; 5578 try { 5579 status = professionalPhotoSession.isFocusAssistSupported(); 5580 } catch (error) { 5581 // 失败返回错误码error.code并处理。 5582 let err = error as BusinessError; 5583 console.error(`The isFocusAssistSupported call failed. error code: ${err.code}`); 5584 } 5585 return status; 5586} 5587``` 5588 5589### isFocusRangeTypeSupported<sup>15+</sup> 5590 5591isFocusRangeTypeSupported(type: FocusRangeType): boolean 5592 5593查询是否支持指定的对焦范围类型。 5594 5595**系统接口**: 此接口为系统接口。 5596 5597**系统能力**: SystemCapability.Multimedia.Camera.Core 5598 5599**参数**: 5600 5601| 参数名 | 类型 | 必填 | 说明 | 5602| ------ | ----------------------------------- | ---- | ------------------------ | 5603| type | [FocusRangeType](#focusrangetype15) | 是 | 指定对应的对焦范围类型。 | 5604 5605**返回值**: 5606 5607| 类型 | 说明 | 5608| ------- | ------------------------------------------------------------ | 5609| boolean | 返回true表示支持指定的对焦范围类型,false表示不支持。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。 | 5610 5611**错误码**: 5612 5613以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5614 5615| 错误码ID | 错误信息 | 5616| -------- | ------------------------------------------------------------ | 5617| 202 | Not System Application. | 5618| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 5619| 7400103 | Session not config. | 5620 5621**示例**: 5622 5623```ts 5624import { BusinessError } from '@kit.BasicServicesKit'; 5625 5626function isFocusRangeTypeSupported(session: camera.VideoSessionForSys, type: camera.FocusRangeType): boolean { 5627 let status: boolean = false; 5628 try { 5629 status = session.isFocusRangeTypeSupported(type); 5630 } catch (error) { 5631 // 失败返回错误码error.code并处理。 5632 let err = error as BusinessError; 5633 console.error(`The isFocusRangeTypeSupported call failed. error code: ${err.code}`); 5634 } 5635 return status; 5636} 5637``` 5638 5639### isFocusDrivenTypeSupported<sup>15+</sup> 5640 5641isFocusDrivenTypeSupported(type: FocusDrivenType): boolean 5642 5643查询是否支持指定的对焦驱动类型。 5644 5645**系统接口**: 此接口为系统接口。 5646 5647**系统能力**: SystemCapability.Multimedia.Camera.Core 5648 5649**参数**: 5650 5651| 参数名 | 类型 | 必填 | 说明 | 5652| ------ | ------------------------------------- | ---- | ------------------------ | 5653| type | [FocusDrivenType](#focusdriventype15) | 是 | 指定对应的对焦驱动类型。 | 5654 5655**返回值**: 5656 5657| 类型 | 说明 | 5658| ------- | ------------------------------------------------------------ | 5659| boolean | 返回true表示支持指定的对焦驱动类型,false表示不支持。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。 | 5660 5661**错误码**: 5662 5663以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5664 5665| 错误码ID | 错误信息 | 5666| -------- | ------------------------------------------------------------ | 5667| 202 | Not System Application. | 5668| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 5669| 7400103 | Session not config. | 5670 5671**示例**: 5672 5673```ts 5674import { BusinessError } from '@kit.BasicServicesKit'; 5675 5676function isFocusDrivenTypeSupported(session: camera.VideoSessionForSys, type: camera.FocusDrivenType): boolean { 5677 let status: boolean = false; 5678 try { 5679 status = session.isFocusDrivenTypeSupported(type); 5680 } catch (error) { 5681 // 失败返回错误码error.code并处理。 5682 let err = error as BusinessError; 5683 console.error(`The isFocusDrivenTypeSupported call failed. error code: ${err.code}`); 5684 } 5685 return status; 5686} 5687``` 5688 5689## Focus 5690 5691Focus extends [FocusQuery](#focusquery12) 5692 5693提供了获取和设置相机对焦模式和对焦点位置的方法。 5694 5695### setFocusAssist<sup>12+</sup> 5696 5697setFocusAssist(enabled: boolean): void 5698 5699设置对焦辅助灯。进行设置之前,需要先检查设备是否支持对焦辅助灯,可使用方法[isFocusAssistSupported](#isfocusassistsupported12)。 5700 5701**系统接口:** 此接口为系统接口。 5702 5703**系统能力:** SystemCapability.Multimedia.Camera.Core 5704 5705**参数:** 5706 5707| 参数名 | 类型 | 必填 | 说明 | 5708| -------- | ----------------------- | ---- | ------------------- | 5709| enabled | boolean | 是 | true:开启对焦辅助灯,false:关闭对焦辅助灯。 | 5710 5711**错误码:** 5712 5713以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5714 5715| 错误码ID | 错误信息 | 5716| --------------- | --------------- | 5717| 202 | Not System Application. | 5718| 7400101 | Parameter missing or parameter type incorrect. | 5719| 7400103 | Session not config. | 5720 5721 5722**示例:** 5723 5724```ts 5725import { BusinessError } from '@kit.BasicServicesKit'; 5726 5727function setFocusAssist(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 5728 try { 5729 professionalPhotoSession.setFocusAssist(false); 5730 } catch (error) { 5731 // 失败返回错误码error.code并处理。 5732 let err = error as BusinessError; 5733 console.error(`The setFocusAssist call failed. error code: ${err.code}`); 5734 } 5735} 5736``` 5737 5738### getFocusAssist<sup>12+</sup> 5739 5740getFocusAssist(): boolean 5741 5742获取对焦辅助灯是否开启。 5743 5744**系统接口:** 此接口为系统接口。 5745 5746**系统能力:** SystemCapability.Multimedia.Camera.Core 5747 5748**返回值:** 5749 5750| 类型 | 说明 | 5751| ---------- | ----------------------------- | 5752| boolean | 返回true表示相机已打开对焦辅助灯,返回false表示相机已关闭对焦辅助灯。 | 5753 5754**错误码:** 5755 5756以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5757 5758| 错误码ID | 错误信息 | 5759| --------------- | --------------- | 5760| 7400103 | Session not config. | 5761| 202 | Not System Application. | 5762 5763**示例:** 5764 5765```ts 5766function getFocusAssist(professionalPhotoSession: camera.ProfessionalPhotoSession): boolean { 5767 let isFocusAssistOpened: boolean = false; 5768 try { 5769 isFocusAssistOpened = professionalPhotoSession.getFocusAssist(); 5770 } catch (error) { 5771 // 失败返回错误码error.code并处理。 5772 let err = error as BusinessError; 5773 console.error(`The getFocusAssist call failed. error code: ${err.code}`); 5774 } 5775 return isFocusAssistOpened; 5776} 5777``` 5778 5779### setFocusRange<sup>15+</sup> 5780 5781setFocusRange(type: FocusRangeType): void 5782 5783设置对焦范围类型。进行设置之前,需要先检查设备是否支持指定的对焦范围类型,可使用方法[isFocusRangeTypeSupported](#isfocusrangetypesupported15)。 5784 5785**系统接口**: 此接口为系统接口。 5786 5787**系统能力**: SystemCapability.Multimedia.Camera.Core 5788 5789**参数**: 5790 5791| 参数名 | 类型 | 必填 | 说明 | 5792| ------ | ----------------------------------- | ---- | -------------- | 5793| type | [FocusRangeType](#focusrangetype15) | 是 | 对焦范围类型。 | 5794 5795**错误码**: 5796 5797以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5798 5799| 错误码ID | 错误信息 | 5800| -------- | ------------------------------------------------------------ | 5801| 202 | Not System Application. | 5802| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3.Parameter verification failed. | 5803| 7400102 | Operation not allowed. | 5804| 7400103 | Session not config. | 5805| 7400201 | Camera service fatal error. | 5806 5807**示例**: 5808 5809```ts 5810import { BusinessError } from '@kit.BasicServicesKit'; 5811 5812function setFocusRange(session: camera.VideoSessionForSys, type: camera.FocusRangeType): void { 5813 try { 5814 session.setFocusRange(type); 5815 } catch (error) { 5816 // 失败返回错误码error.code并处理。 5817 let err = error as BusinessError; 5818 console.error(`The setFocusRange call failed. error code: ${err.code}`); 5819 } 5820} 5821``` 5822 5823### getFocusRange<sup>15+</sup> 5824 5825getFocusRange(): FocusRangeType 5826 5827获取当前设置的对焦范围类型。 5828 5829**系统接口**: 此接口为系统接口。 5830 5831**系统能力**: SystemCapability.Multimedia.Camera.Core 5832 5833**返回值**: 5834 5835| 类型 | 说明 | 5836| ----------------------------------- | ------------------------ | 5837| [FocusRangeType](#focusrangetype15) | 当前设置的对焦范围类型。 | 5838 5839**错误码**: 5840 5841以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5842 5843| 错误码ID | 错误信息 | 5844| -------- | ----------------------- | 5845| 202 | Not System Application. | 5846| 7400103 | Session not config. | 5847 5848**示例**: 5849 5850```ts 5851import { BusinessError } from '@kit.BasicServicesKit'; 5852 5853function getFocusRange(session: camera.VideoSessionForSys): camera.FocusRangeType | undefined { 5854 let focusRangeType: camera.FocusRangeType | undefined = undefined; 5855 try { 5856 focusRangeType = session.getFocusRange(); 5857 } catch (error) { 5858 // 失败返回错误码error.code并处理。 5859 let err = error as BusinessError; 5860 console.error(`The getFocusRange call failed. error code: ${err.code}`); 5861 } 5862 return focusRangeType; 5863} 5864``` 5865 5866### setFocusDriven<sup>15+</sup> 5867 5868setFocusDriven(type: FocusDrivenType): void 5869 5870设置对焦驱动类型。进行设置之前,需要先检查设备是否支持指定的对焦驱动类型,可使用方法[isFocusDrivenTypeSupported](#isfocusdriventypesupported15)。 5871 5872**系统接口**: 此接口为系统接口。 5873 5874**系统能力**: SystemCapability.Multimedia.Camera.Core 5875 5876**参数**: 5877 5878| 参数名 | 类型 | 必填 | 说明 | 5879| ------ | ------------------------------------- | ---- | -------------- | 5880| type | [FocusDrivenType](#focusdriventype15) | 是 | 对焦驱动类型。 | 5881 5882**错误码**: 5883 5884以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5885 5886| 错误码ID | 错误信息 | 5887| -------- | ------------------------------------------------------------ | 5888| 202 | Not System Application. | 5889| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3.Parameter verification failed. | 5890| 7400102 | Operation not allowed. | 5891| 7400103 | Session not config. | 5892| 7400201 | Camera service fatal error. | 5893 5894**示例**: 5895 5896```ts 5897import { BusinessError } from '@kit.BasicServicesKit'; 5898 5899function setFocusDriven(session: camera.VideoSessionForSys, type: camera.FocusDrivenType): void { 5900 try { 5901 session.setFocusDriven(type); 5902 } catch (error) { 5903 // 失败返回错误码error.code并处理。 5904 let err = error as BusinessError; 5905 console.error(`The setFocusDriven call failed. error code: ${err.code}`); 5906 } 5907} 5908``` 5909 5910### getFocusDriven<sup>15+</sup> 5911 5912getFocusDriven(): FocusDrivenType 5913 5914获取当前设置的对焦驱动类型。 5915 5916**系统接口**: 此接口为系统接口。 5917 5918**系统能力**: SystemCapability.Multimedia.Camera.Core 5919 5920**返回值**: 5921 5922| 类型 | 说明 | 5923| ------------------------------------- | ------------------------ | 5924| [FocusDrivenType](#focusdriventype15) | 当前设置的对焦驱动类型。 | 5925 5926**错误码**: 5927 5928以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5929 5930| 错误码ID | 错误信息 | 5931| -------- | ----------------------- | 5932| 202 | Not System Application. | 5933| 7400103 | Session not config. | 5934 5935**示例**: 5936 5937```ts 5938import { BusinessError } from '@kit.BasicServicesKit'; 5939 5940function getFocusDriven(session: camera.VideoSessionForSys): camera.FocusDrivenType | undefined { 5941 let focusDrivenType: camera.FocusDrivenType | undefined = undefined; 5942 try { 5943 focusDrivenType = session.getFocusDriven(); 5944 } catch (error) { 5945 // 失败返回错误码error.code并处理。 5946 let err = error as BusinessError; 5947 console.error(`The getFocusDriven call failed. error code: ${err.code}`); 5948 } 5949 return focusDrivenType; 5950} 5951``` 5952 5953## ManualFocus<sup>12+</sup> 5954 5955手动对焦类,对设备手动设置对焦操作。 5956 5957### setFocusDistance<sup>12+</sup> 5958 5959setFocusDistance(distance: number): void 5960 5961手动设置对焦距离,可设置范围为[0,1]之间的浮点数,0表现为近景,1表现为远景。 5962 5963**系统接口:** 此接口为系统接口。 5964 5965**系统能力:** SystemCapability.Multimedia.Camera.Core 5966 5967**参数:** 5968 5969| 参数名 | 类型 | 必填 | 说明 | 5970| -------- | ----------------------- | ---- | ------------------- | 5971| distance | number | 是 | 范围0-1:该值为归一化值,0为近景,1为远景,<br>可在该范围内调节 | 5972 5973**错误码:** 5974 5975以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 5976 5977| 错误码ID | 错误信息 | 5978| --------------- | --------------- | 5979| 202 | Not System Application. | 5980| 7400101 | Parameter missing or parameter type incorrect. | 5981| 7400103 | Session not config. | 5982 5983**示例:** 5984 5985```ts 5986import { BusinessError } from '@kit.BasicServicesKit'; 5987 5988function setFocusDistance(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 5989 try { 5990 let distance: number = 0.5; 5991 professionalPhotoSession.setFocusDistance(distance); 5992 } catch (error) { 5993 // 失败返回错误码error.code并处理。 5994 let err = error as BusinessError; 5995 console.error(`The setFocusDistance call failed. error code: ${err.code}`); 5996 } 5997} 5998``` 5999 6000### getFocusDistance<sup>12+</sup> 6001 6002getFocusDistance(): number 6003 6004获取当前的对焦距离。 6005 6006**系统接口:** 此接口为系统接口。 6007 6008**系统能力:** SystemCapability.Multimedia.Camera.Core 6009 6010**返回值:** 6011 6012| 类型 | 说明 | 6013| ---------- | ----------------------------- | 6014| number | 返回当前对焦距离的归一化值。 | 6015 6016**错误码:** 6017 6018以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 6019 6020| 错误码ID | 错误信息 | 6021| --------------- | --------------- | 6022| 7400103 | Session not config. | 6023| 202 | Not System Application. | 6024 6025**示例:** 6026 6027```ts 6028import { BusinessError } from '@kit.BasicServicesKit'; 6029 6030function getFocusDistance(professionalPhotoSession: camera.ProfessionalPhotoSession): number { 6031 let distance: number = 0; 6032 try { 6033 distance = professionalPhotoSession.getFocusDistance(); 6034 } catch (error) { 6035 // 失败返回错误码error.code并处理。 6036 let err = error as BusinessError; 6037 console.error(`The getFocusDistance call failed. error code: ${err.code}`); 6038 } 6039 return distance; 6040} 6041``` 6042 6043## ManualIsoQuery<sup>12+</sup> 6044 6045提供了查询设备是否支持手动设置ISO和获取设备支持的ISO范围的方法。 6046 6047### isManualIsoSupported<sup>12+</sup> 6048 6049isManualIsoSupported(): boolean 6050 6051检测是否支持手动ISO。 6052 6053**系统接口:** 此接口为系统接口。 6054 6055**系统能力:** SystemCapability.Multimedia.Camera.Core 6056 6057**返回值:** 6058 6059| 类型 | 说明 | 6060| ---------- | ----------------------------- | 6061| boolean | 返回true表示支持手动调节ISO,false表示不支持。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。 | 6062 6063**错误码:** 6064 6065以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 6066 6067| 错误码ID | 错误信息 | 6068| --------------- | --------------- | 6069| 7400103 | Session not config. | 6070| 202 | Not System Application. | 6071 6072**示例:** 6073 6074```ts 6075import { BusinessError } from '@kit.BasicServicesKit'; 6076 6077function isManualIsoSupported(professionalPhotoSession: camera.ProfessionalPhotoSession): boolean { 6078 let status: boolean = false; 6079 try { 6080 status = professionalPhotoSession.isManualIsoSupported(); 6081 } catch (error) { 6082 // 失败返回错误码error.code并处理。 6083 let err = error as BusinessError; 6084 console.error(`The isManualIsoSupported call failed. error code: ${err.code}`); 6085 } 6086 return status; 6087} 6088``` 6089 6090### getIsoRange<sup>12+</sup> 6091 6092getIsoRange(): Array\<number\> 6093 6094获取支持的ISO范围。 6095 6096**系统接口:** 此接口为系统接口。 6097 6098**系统能力:** SystemCapability.Multimedia.Camera.Core 6099 6100**返回值:** 6101 6102| 类型 | 说明 | 6103| ---------- | ----------------------------- | 6104| Array\<number\> | 用于获取ISO范围,范围为[50,100,...,6400],实际根据底层能力返回为准,接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。 | 6105 6106**错误码:** 6107 6108以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 6109 6110| 错误码ID | 错误信息 | 6111| --------------- | --------------- | 6112| 202 | Not System Application. | 6113| 7400103 | Session not config. | 6114 6115**示例:** 6116 6117```ts 6118import { BusinessError } from '@kit.BasicServicesKit'; 6119 6120function getIsoRange(professionalPhotoSession: camera.ProfessionalPhotoSession): Array<number> { 6121 let isoRange: Array<number> = []; 6122 try { 6123 isoRange = professionalPhotoSession.getIsoRange(); 6124 } catch (error) { 6125 // 失败返回错误码error.code并处理。 6126 let err = error as BusinessError; 6127 console.error(`The getIsoRange call failed. error code: ${err.code}`); 6128 } 6129 return isoRange; 6130} 6131``` 6132 6133## ManualIso<sup>12+</sup> 6134 6135ManualIso extends [ManualIsoQuery](#manualisoquery12) 6136 6137提供了获取和设置设备手动ISO(感光度)的功能。 6138 6139### setIso<sup>12+</sup> 6140setIso(iso: number): void 6141 6142设置ISO值。**注意:当ISO值设置为0时,表示设置自动ISO** 6143 6144**系统接口:** 此接口为系统接口。 6145 6146**系统能力:** SystemCapability.Multimedia.Camera.Core 6147 6148**参数:** 6149 6150| 参数名 | 类型 | 必填 | 说明 | 6151| -------- | ----------------------- | ---- | ------------------- | 6152| iso | number | 是 | 设置ISO值。 | 6153 6154**错误码:** 6155 6156以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 6157 6158| 错误码ID | 错误信息 | 6159| --------------- | --------------- | 6160| 202 | Not System Application. | 6161| 7400101 | Parameter missing or parameter type incorrect. | 6162| 7400103 | Session not config. | 6163 6164**示例:** 6165 6166```ts 6167import { BusinessError } from '@kit.BasicServicesKit'; 6168 6169function setIso(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6170 try { 6171 let iso: number = 200; 6172 professionalPhotoSession.setIso(iso); 6173 } catch (error) { 6174 // 失败返回错误码error.code并处理。 6175 let err = error as BusinessError; 6176 console.error(`The setIso call failed. error code: ${err.code}`); 6177 } 6178} 6179``` 6180 6181### getIso<sup>12+</sup> 6182 6183getIso(): number 6184 6185获取当前的ISO值。 6186 6187**系统接口:** 此接口为系统接口。 6188 6189**系统能力:** SystemCapability.Multimedia.Camera.Core 6190 6191**返回值:** 6192 6193| 类型 | 说明 | 6194| ---------- | ----------------------------- | 6195| number | 返回当前ISO值。 | 6196 6197**错误码:** 6198 6199以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 6200 6201| 错误码ID | 错误信息 | 6202| --------------- | --------------- | 6203| 202 | Not System Application. | 6204| 7400103 | Session not config. | 6205 6206**示例:** 6207 6208```ts 6209import { BusinessError } from '@kit.BasicServicesKit'; 6210 6211function getIso(professionalPhotoSession: camera.ProfessionalPhotoSession): number { 6212 let iso: number = 0; 6213 try { 6214 iso = professionalPhotoSession.getIso(); 6215 } catch (error) { 6216 // 失败返回错误码error.code并处理。 6217 let err = error as BusinessError; 6218 console.error(`The getIso call failed. error code: ${err.code}`); 6219 } 6220 return iso; 6221} 6222``` 6223 6224## ProfessionalPhotoSession<sup>12+</sup> 6225 6226ProfessionalPhotoSession extends Session, AutoExposure, ManualExposure, Focus, ManualFocus, WhiteBalance, ManualIso, Flash, Zoom, ColorEffect, Aperture 6227 6228专业拍照会话类,继承自[Session](arkts-apis-camera-Session.md),用于设置专业拍照会话的参数以及保存所需要的所有资源[CameraInput](arkts-apis-camera-CameraInput.md)、[CameraOutput](arkts-apis-camera-CameraOutput.md)。 6229 6230### on('error')<sup>12+</sup> 6231 6232on(type: 'error', callback: ErrorCallback): void 6233 6234监听专业拍照会话的错误事件,通过注册回调函数获取结果。使用callback异步回调。 6235 6236**系统接口:** 此接口为系统接口。 6237 6238**系统能力:** SystemCapability.Multimedia.Camera.Core 6239 6240**参数:** 6241 6242| 参数名 | 类型 | 必填 | 说明 | 6243| -------- | ----------------------------------------------------------- | ---- | ------------------------------ | 6244| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。session调用相关接口出现错误时会触发该事件,比如调用[beginConfig](arkts-apis-camera-Session.md#beginconfig11),[commitConfig](arkts-apis-camera-Session.md#commitconfig11-1),[addInput](arkts-apis-camera-Session.md#addinput11)等接口发生错误时返回错误信息。 | 6245| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。 | 6246 6247**错误码:** 6248 6249以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 6250 6251| 错误码ID | 错误信息 | 6252|---------| --------------- | 6253| 202 | Not System Application. | 6254 6255**示例:** 6256 6257```ts 6258import { BusinessError } from '@kit.BasicServicesKit'; 6259 6260function callback(err: BusinessError): void { 6261 console.error(`Professional photo session error code: ${err.code}`); 6262} 6263 6264function registerSessionError(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6265 professionalPhotoSession.on('error', callback); 6266} 6267``` 6268 6269### off('error')<sup>12+</sup> 6270 6271off(type: 'error', callback?: ErrorCallback): void 6272 6273注销监听专业拍照会话的错误事件,通过注册回调函数获取结果。 6274 6275**系统接口:** 此接口为系统接口。 6276 6277**系统能力:** SystemCapability.Multimedia.Camera.Core 6278 6279**参数:** 6280 6281| 参数名 | 类型 | 必填 | 说明 | 6282| -------- | ------------------------ | ---- | ------------------------------ | 6283| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。 | 6284| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 否 | 回调函数,可选,有就是匿名函数。 | 6285 6286**错误码:** 6287 6288以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 6289 6290| 错误码ID | 错误信息 | 6291|---------| --------------- | 6292| 202 | Not System Application. | 6293 6294**示例:** 6295 6296```ts 6297function unregisterSessionError(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6298 professionalPhotoSession.off('error'); 6299} 6300``` 6301 6302### on('focusStateChange')<sup>12+</sup> 6303 6304on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 6305 6306监听相机对焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 6307 6308**系统接口:** 此接口为系统接口。 6309 6310**系统能力:** SystemCapability.Multimedia.Camera.Core 6311 6312**参数:** 6313 6314| 参数名 | 类型 | 必填 | 说明 | 6315| -------- | ---------------- | ---- | ------------------------ | 6316| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。仅当自动对焦模式时,且相机对焦状态发生改变时可触发该事件。 | 6317| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.md#focusstate)\> | 是 | 回调函数,用于获取当前对焦状态。 | 6318 6319**错误码:** 6320 6321以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 6322 6323| 错误码ID | 错误信息 | 6324|---------| --------------- | 6325| 202 | Not System Application. | 6326 6327**示例:** 6328 6329```ts 6330import { BusinessError } from '@kit.BasicServicesKit'; 6331 6332function callback(err: BusinessError, focusState: camera.FocusState): void { 6333 if (err !== undefined && err.code !== 0) { 6334 console.error(`Callback Error, errorCode: ${err.code}`); 6335 return; 6336 } 6337 console.info(`Focus state: ${focusState}`); 6338} 6339 6340function registerFocusStateChange(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6341 professionalPhotoSession.on('focusStateChange', callback); 6342} 6343``` 6344 6345### off('focusStateChange')<sup>12+</sup> 6346 6347off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 6348 6349注销监听相机对焦的状态变化。 6350 6351**系统接口:** 此接口为系统接口。 6352 6353**系统能力:** SystemCapability.Multimedia.Camera.Core 6354 6355**参数:** 6356 6357| 参数名 | 类型 | 必填 | 说明 | 6358| -------- | ----------------------------------------- | ---- | ------------------------ | 6359| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。 | 6360| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.md#focusstate)\> | 否 | 回调函数,可选,有就是匹配on('focusStateChange') callback(callback对象不可是匿名函数)。 | 6361 6362**错误码:** 6363 6364以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 6365 6366| 错误码ID | 错误信息 | 6367|---------| --------------- | 6368| 202 | Not System Application. | 6369 6370**示例:** 6371 6372```ts 6373function unregisterFocusStateChange(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6374 professionalPhotoSession.off('focusStateChange'); 6375} 6376``` 6377 6378### on('smoothZoomInfoAvailable')<sup>12+</sup> 6379 6380on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 6381 6382监听相机平滑变焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 6383 6384**系统接口:** 此接口为系统接口。 6385 6386**系统能力:** SystemCapability.Multimedia.Camera.Core 6387 6388**参数:** 6389 6390| 参数名 | 类型 | 必填 | 说明 | 6391| -------- | ----------------------- | ---- | ------------------------ | 6392| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 6393| callback | AsyncCallback\<[SmoothZoomInfo](arkts-apis-camera-i.md#smoothzoominfo11)\> | 是 | 回调函数,用于获取当前平滑变焦状态。 | 6394 6395**错误码:** 6396 6397以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 6398 6399| 错误码ID | 错误信息 | 6400|---------| --------------- | 6401| 202 | Not System Application. | 6402 6403**示例:** 6404 6405```ts 6406import { BusinessError } from '@kit.BasicServicesKit'; 6407 6408function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 6409 if (err !== undefined && err.code !== 0) { 6410 console.error(`Callback Error, errorCode: ${err.code}`); 6411 return; 6412 } 6413 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 6414} 6415 6416function registerSmoothZoomInfo(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6417 professionalPhotoSession.on('smoothZoomInfoAvailable', callback); 6418} 6419``` 6420 6421### off('smoothZoomInfoAvailable')<sup>12+</sup> 6422 6423off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 6424 6425注销监听相机平滑变焦的状态变化。 6426 6427**系统接口:** 此接口为系统接口。 6428 6429**系统能力:** SystemCapability.Multimedia.Camera.Core 6430 6431**参数:** 6432 6433| 参数名 | 类型 | 必填 | 说明 | 6434| -------- | ----------------------------------------- | ---- | ------------------------ | 6435| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 6436| callback | AsyncCallback\<[SmoothZoomInfo](arkts-apis-camera-i.md#smoothzoominfo11)\> | 否 | 回调函数,可选,有就是匹配on('smoothZoomInfoAvailable') callback(callback对象不可是匿名函数)。 | 6437 6438**错误码:** 6439 6440以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 6441 6442| 错误码ID | 错误信息 | 6443|---------| --------------- | 6444| 202 | Not System Application. | 6445 6446**示例:** 6447 6448```ts 6449function unregisterSmoothZoomInfo(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6450 professionalPhotoSession.off('smoothZoomInfoAvailable'); 6451} 6452``` 6453 6454### on('isoInfoChange')<sup>12+</sup> 6455 6456on(type: 'isoInfoChange', callback: AsyncCallback\<IsoInfo\>): void 6457 6458监听自动ISO变化事件,通过注册回调函数获取实时ISO信息。使用callback异步回调。 6459 6460**系统接口:** 此接口为系统接口。 6461 6462**系统能力:** SystemCapability.Multimedia.Camera.Core 6463 6464**参数:** 6465 6466| 参数名 | 类型 | 必填 | 说明 | 6467| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6468| type | string | 是 | 监听事件,固定为'isoInfoChange'。 | 6469| callback | AsyncCallback\<[IsoInfo](#isoinfo12)\>| 是 | 回调函数,用于获取ISO信息。 | 6470 6471**错误码:** 6472 6473| 错误码ID | 错误信息 | 6474| ------- | ---------------------- | 6475| 202 | Not System Application. | 6476 6477**示例:** 6478 6479```ts 6480import { BusinessError } from '@kit.BasicServicesKit'; 6481 6482function isoInfoCallback(err: BusinessError, info: camera.IsoInfo): void { 6483 if (err !== undefined && err.code !== 0) { 6484 console.error(`Callback Error, errorCode: ${err.code}`); 6485 return; 6486 } 6487 console.log(`ISO value: ${info.iso}`); 6488} 6489 6490function registerIsoInfoEvent(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6491 professionalPhotoSession.on('isoInfoChange', isoInfoCallback); 6492} 6493``` 6494 6495### off('isoInfoChange')<sup>12+</sup> 6496 6497off(type: 'isoInfoChange', callback?: AsyncCallback\<IsoInfo\>): void 6498 6499注销监听ISO信息事件,通过注册回调函数来注销。 6500 6501**系统接口:** 此接口为系统接口。 6502 6503**系统能力:** SystemCapability.Multimedia.Camera.Core 6504 6505**参数:** 6506 6507| 参数名 | 类型 | 必填 | 说明 | 6508| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6509| type | string | 是 | 监听事件,固定为'isoInfoChange'。 | 6510| callback | AsyncCallback\<[IsoInfo](#isoinfo12)\>| 否 | 回调函数,可选,用于匹配on('isoInfoChange')的callback。 | 6511 6512**错误码:** 6513 6514| 错误码ID | 错误信息 | 6515| ------- | ---------------------- | 6516| 202 | Not System Application. | 6517 6518**示例:** 6519 6520```ts 6521function unregisterIsoInfoEvent(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6522 professionalPhotoSession.off('isoInfoChange'); 6523} 6524``` 6525 6526### on('exposureInfoChange')<sup>12+</sup> 6527 6528on(type: 'exposureInfoChange', callback: AsyncCallback\<ExposureInfo\>): void 6529 6530监听曝光信息事件,通过注册回调函数获取曝光信息。使用callback异步回调。 6531 6532**系统接口:** 此接口为系统接口。 6533 6534**系统能力:** SystemCapability.Multimedia.Camera.Core 6535 6536**参数:** 6537 6538| 参数名 | 类型 | 必填 | 说明 | 6539| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6540| type | string | 是 | 监听事件,固定为'exposureInfoChange'。 | 6541| callback | AsyncCallback\<[ExposureInfo](#exposureinfo12)\>| 是 | 回调函数,用于获取曝光信息。 | 6542 6543**错误码:** 6544 6545| 错误码ID | 错误信息 | 6546| ------- | ---------------------- | 6547| 202 | Not System Application. | 6548 6549**示例:** 6550 6551```ts 6552import { BusinessError } from '@kit.BasicServicesKit'; 6553 6554function exposureInfoCallback(err: BusinessError, info: camera.ExposureInfo): void { 6555 if (err !== undefined && err.code !== 0) { 6556 console.error(`Callback Error, errorCode: ${err.code}`); 6557 return; 6558 } 6559 console.log(`exposureTimeValue: ${info.exposureTime}`); 6560} 6561 6562function registerExposureInfoEvent(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6563 professionalPhotoSession.on('exposureInfoChange', exposureInfoCallback); 6564} 6565``` 6566 6567### off('exposureInfoChange')<sup>12+</sup> 6568 6569off(type: 'exposureInfoChange', callback?: AsyncCallback\<ExposureInfo\>): void 6570 6571注销监听曝光信息事件,通过注册回调函数来注销。 6572 6573**系统接口:** 此接口为系统接口。 6574 6575**系统能力:** SystemCapability.Multimedia.Camera.Core 6576 6577**参数:** 6578 6579| 参数名 | 类型 | 必填 | 说明 | 6580| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6581| type | string | 是 | 监听事件,固定为'exposureInfoChange'。 | 6582| callback | AsyncCallback\<[ExposureInfo](#exposureinfo12)\>| 否 | 回调函数,可选,用于匹配on('exposureInfoChange')的callback。 | 6583 6584**错误码:** 6585 6586| 错误码ID | 错误信息 | 6587| ------- | ---------------------- | 6588| 202 | Not System Application. | 6589 6590**示例:** 6591 6592```ts 6593function unregisterExposureInfoEvent(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6594 professionalPhotoSession.off('exposureInfoChange'); 6595} 6596``` 6597 6598### on('apertureInfoChange')<sup>12+</sup> 6599 6600on(type: 'apertureInfoChange', callback: AsyncCallback\<ApertureInfo\>): void 6601 6602监听物理光圈变化事件,通过注册回调函数获取实时物理光圈信息。使用callback异步回调。 6603 6604**系统接口:** 此接口为系统接口。 6605 6606**系统能力:** SystemCapability.Multimedia.Camera.Core 6607 6608**参数:** 6609 6610| 参数名 | 类型 | 必填 | 说明 | 6611| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6612| type | string | 是 | 监听事件,固定为'apertureInfoChange'。 | 6613| callback | AsyncCallback\<[ApertureInfo](#apertureinfo12)\>| 是 | 回调函数,用于获取物理光圈信息。 | 6614 6615**错误码:** 6616 6617| 错误码ID | 错误信息 | 6618| ------- | ---------------------- | 6619| 202 | Not System Application. | 6620 6621**示例:** 6622 6623```ts 6624import { BusinessError } from '@kit.BasicServicesKit'; 6625 6626function apertureInfoCallback(err: BusinessError, info: camera.ApertureInfo): void { 6627 if (err !== undefined && err.code !== 0) { 6628 console.error(`Callback Error, errorCode: ${err.code}`); 6629 return; 6630 } 6631 console.log(`Aperture value: ${info.aperture}`); 6632} 6633 6634function registerApertureInfoEvent(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6635 professionalPhotoSession.on('apertureInfoChange', apertureInfoCallback); 6636} 6637``` 6638 6639### off('apertureInfoChange')<sup>12+</sup> 6640 6641off(type: 'apertureInfoChange', callback?: AsyncCallback\<ApertureInfo\>): void 6642 6643注销监听物理光圈变化事件,通过注册回调函数来注销。 6644 6645**系统接口:** 此接口为系统接口。 6646 6647**系统能力:** SystemCapability.Multimedia.Camera.Core 6648 6649**参数:** 6650 6651| 参数名 | 类型 | 必填 | 说明 | 6652| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6653| type | string | 是 | 监听事件,固定为'apertureInfoChange'。 | 6654| callback | AsyncCallback\<[ApertureInfo](#apertureinfo12)\>| 否 | 回调函数,可选,用于匹配on('apertureInfoChange')的callback。 | 6655 6656**错误码:** 6657 6658| 错误码ID | 错误信息 | 6659| ------- | ---------------------- | 6660| 202 | Not System Application. | 6661 6662**示例:** 6663 6664```ts 6665function unregisterApertureInfoEvent(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6666 professionalPhotoSession.off('apertureInfoChange'); 6667} 6668``` 6669 6670### on('luminationInfoChange')<sup>12+</sup> 6671 6672on(type: 'luminationInfoChange', callback: AsyncCallback\<LuminationInfo\>): void 6673 6674监听光照变化事件,通过注册回调函数获取实时光照参数。使用callback异步回调。 6675 6676**系统接口:** 此接口为系统接口。 6677 6678**系统能力:** SystemCapability.Multimedia.Camera.Core 6679 6680**参数:** 6681 6682| 参数名 | 类型 | 必填 | 说明 | 6683| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6684| type | string | 是 | 监听事件,固定为'luminationInfoChange'。 | 6685| callback | AsyncCallback\<[LuminationInfo](#luminationinfo12)\>| 是 | 回调函数,用于获取光照参数。 | 6686 6687**错误码:** 6688 6689| 错误码ID | 错误信息 | 6690| ------- | ---------------------- | 6691| 202 | Not System Application. | 6692 6693**示例:** 6694 6695```ts 6696import { BusinessError } from '@kit.BasicServicesKit'; 6697 6698function luminationInfoCallback(err: BusinessError, info: camera.LuminationInfo): void { 6699 if (err !== undefined && err.code !== 0) { 6700 console.error(`Callback Error, errorCode: ${err.code}`); 6701 return; 6702 } 6703 console.log(`Lumination: ${info.lumination}`); 6704} 6705 6706function registerLuminationInfoEvent(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6707 professionalPhotoSession.on('luminationInfoChange', luminationInfoCallback); 6708} 6709``` 6710 6711### off('luminationInfoChange')<sup>12+</sup> 6712 6713off(type: 'luminationInfoChange', callback?: AsyncCallback\<LuminationInfo\>): void 6714 6715注销监听光照变化事件,通过注册回调函数来注销。 6716 6717**系统接口:** 此接口为系统接口。 6718 6719**系统能力:** SystemCapability.Multimedia.Camera.Core 6720 6721**参数:** 6722 6723| 参数名 | 类型 | 必填 | 说明 | 6724| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6725| type | string | 是 | 监听事件,固定为'luminationInfoChange'。 | 6726| callback | AsyncCallback\<[LuminationInfo](#luminationinfo12)\>| 否 | 回调函数,可选,用于匹配on('luminationInfoChange')的callback。 | 6727 6728**错误码:** 6729 6730| 错误码ID | 错误信息 | 6731| ------- | ---------------------- | 6732| 202 | Not System Application. | 6733 6734**示例:** 6735 6736```ts 6737function unregisterLuminationInfoEvent(professionalPhotoSession: camera.ProfessionalPhotoSession): void { 6738 professionalPhotoSession.off('luminationInfoChange'); 6739} 6740``` 6741 6742## ProfessionalVideoSession<sup>12+</sup> 6743 6744ProfessionalVideoSession extends Session, AutoExposure, ManualExposure, Focus, ManualFocus, WhiteBalance, ManualIso, Flash, Zoom, ColorEffect, Aperture 6745 6746专业录像模式会话类,继承自[Session](arkts-apis-camera-Session.md),用于设置专业录像模式的参数以及保存所需要的所有资源[CameraInput](arkts-apis-camera-CameraInput.md)、[CameraOutput](arkts-apis-camera-CameraOutput.md)。 6747 6748### on('error')<sup>12+</sup> 6749 6750on(type: 'error', callback: ErrorCallback): void 6751 6752监听专业录像会话的错误事件,通过注册回调函数获取结果。使用callback异步回调。 6753 6754**系统接口:** 此接口为系统接口。 6755 6756**系统能力:** SystemCapability.Multimedia.Camera.Core 6757 6758**参数:** 6759 6760| 参数名 | 类型 | 必填 | 说明 | 6761| -------- | ----------------------------------------------------------- | ---- | ------------------------------ | 6762| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。session调用相关接口出现错误时会触发该事件,比如调用[beginConfig](arkts-apis-camera-Session.md#beginconfig11),[commitConfig](arkts-apis-camera-Session.md#commitconfig11-1),[addInput](arkts-apis-camera-Session.md#addinput11)等接口发生错误时返回错误信息。 | 6763| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。 | 6764 6765**错误码:** 6766 6767以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 6768 6769| 错误码ID | 错误信息 | 6770|---------| --------------- | 6771| 202 | Not System Application. | 6772 6773**示例:** 6774 6775```ts 6776import { BusinessError } from '@kit.BasicServicesKit'; 6777 6778function callback(err: BusinessError): void { 6779 console.error(`Professional video session error code: ${err.code}`); 6780} 6781 6782function registerSessionError(professionalVideoSession: camera.ProfessionalVideoSession): void { 6783 professionalVideoSession.on('error', callback); 6784} 6785``` 6786 6787### off('error')<sup>12+</sup> 6788 6789off(type: 'error', callback?: ErrorCallback): void 6790 6791注销监听专业录像会话的错误事件,通过注册回调函数获取结果。 6792 6793**系统接口:** 此接口为系统接口。 6794 6795**系统能力:** SystemCapability.Multimedia.Camera.Core 6796 6797**参数:** 6798 6799| 参数名 | 类型 | 必填 | 说明 | 6800| -------- | ------------------------ | ---- | ------------------------------ | 6801| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。 | 6802| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 否 | 回调函数,可选,有就是匿名函数。 | 6803 6804**错误码:** 6805 6806以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 6807 6808| 错误码ID | 错误信息 | 6809|---------| --------------- | 6810| 202 | Not System Application. | 6811 6812**示例:** 6813 6814```ts 6815function unregisterSessionError(professionalVideoSession: camera.ProfessionalVideoSession): void { 6816 professionalVideoSession.off('error'); 6817} 6818``` 6819 6820### on('focusStateChange')<sup>12+</sup> 6821 6822on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 6823 6824监听相机对焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 6825 6826**系统接口:** 此接口为系统接口。 6827 6828**系统能力:** SystemCapability.Multimedia.Camera.Core 6829 6830**参数:** 6831 6832| 参数名 | 类型 | 必填 | 说明 | 6833| -------- | ---------------- | ---- | ------------------------ | 6834| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。仅当自动对焦模式时,且相机对焦状态发生改变时可触发该事件。 | 6835| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.md#focusstate)\> | 是 | 回调函数,用于获取当前对焦状态。 | 6836 6837**错误码:** 6838 6839以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 6840 6841| 错误码ID | 错误信息 | 6842|---------| --------------- | 6843| 202 | Not System Application. | 6844 6845**示例:** 6846 6847```ts 6848import { BusinessError } from '@kit.BasicServicesKit'; 6849 6850function callback(err: BusinessError, focusState: camera.FocusState): void { 6851 if (err !== undefined && err.code !== 0) { 6852 console.error(`Callback Error, errorCode: ${err.code}`); 6853 return; 6854 } 6855 console.info(`Focus state: ${focusState}`); 6856} 6857 6858function registerFocusStateChange(professionalVideoSession: camera.ProfessionalVideoSession): void { 6859 professionalVideoSession.on('focusStateChange', callback); 6860} 6861``` 6862 6863### off('focusStateChange')<sup>12+</sup> 6864 6865off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 6866 6867注销监听相机对焦的状态变化。 6868 6869**系统接口:** 此接口为系统接口。 6870 6871**系统能力:** SystemCapability.Multimedia.Camera.Core 6872 6873**参数:** 6874 6875| 参数名 | 类型 | 必填 | 说明 | 6876| -------- | ----------------------------------------- | ---- | ------------------------ | 6877| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。 | 6878| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.md#focusstate)\> | 否 | 回调函数,可选,有就是匹配on('focusStateChange') callback(callback对象不可是匿名函数)。 | 6879 6880**错误码:** 6881 6882以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 6883 6884| 错误码ID | 错误信息 | 6885|---------| --------------- | 6886| 202 | Not System Application. | 6887 6888**示例:** 6889 6890```ts 6891function unregisterFocusStateChange(professionalVideoSession: camera.ProfessionalVideoSession): void { 6892 professionalVideoSession.off('focusStateChange'); 6893} 6894``` 6895 6896### on('smoothZoomInfoAvailable')<sup>12+</sup> 6897 6898on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 6899 6900监听相机平滑变焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 6901 6902**系统接口:** 此接口为系统接口。 6903 6904**系统能力:** SystemCapability.Multimedia.Camera.Core 6905 6906**参数:** 6907 6908| 参数名 | 类型 | 必填 | 说明 | 6909| -------- | ----------------------- | ---- | ------------------------ | 6910| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 6911| callback | AsyncCallback\<[SmoothZoomInfo](arkts-apis-camera-i.md#smoothzoominfo11)\> | 是 | 回调函数,用于获取当前平滑变焦状态。 | 6912 6913**错误码:** 6914 6915以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 6916 6917| 错误码ID | 错误信息 | 6918|---------| --------------- | 6919| 202 | Not System Application. | 6920 6921**示例:** 6922 6923```ts 6924import { BusinessError } from '@kit.BasicServicesKit'; 6925 6926function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 6927 if (err !== undefined && err.code !== 0) { 6928 console.error(`Callback Error, errorCode: ${err.code}`); 6929 return; 6930 } 6931 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 6932} 6933 6934function registerSmoothZoomInfo(professionalVideoSession: camera.ProfessionalVideoSession): void { 6935 professionalVideoSession.on('smoothZoomInfoAvailable', callback); 6936} 6937``` 6938 6939### off('smoothZoomInfoAvailable')<sup>12+</sup> 6940 6941off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 6942 6943注销监听相机平滑变焦的状态变化。 6944 6945**系统接口:** 此接口为系统接口。 6946 6947**系统能力:** SystemCapability.Multimedia.Camera.Core 6948 6949**参数:** 6950 6951| 参数名 | 类型 | 必填 | 说明 | 6952| -------- | ----------------------------------------- | ---- | ------------------------ | 6953| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 6954| callback | AsyncCallback\<[SmoothZoomInfo](arkts-apis-camera-i.md#smoothzoominfo11)\> | 否 | 回调函数,可选,有就是匹配on('smoothZoomInfoAvailable') callback(callback对象不可是匿名函数)。 | 6955 6956**错误码:** 6957 6958以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 6959 6960| 错误码ID | 错误信息 | 6961|---------| --------------- | 6962| 202 | Not System Application. | 6963 6964**示例:** 6965 6966```ts 6967function unregisterSmoothZoomInfo(professionalVideoSession: camera.ProfessionalVideoSession): void { 6968 professionalVideoSession.off('smoothZoomInfoAvailable'); 6969} 6970``` 6971 6972### on('isoInfoChange')<sup>12+</sup> 6973 6974on(type: 'isoInfoChange', callback: AsyncCallback\<IsoInfo\>): void 6975 6976监听自动ISO变化事件,通过注册回调函数获取实时ISO信息。使用callback异步回调。 6977 6978**系统接口:** 此接口为系统接口。 6979 6980**系统能力:** SystemCapability.Multimedia.Camera.Core 6981 6982**参数:** 6983 6984| 参数名 | 类型 | 必填 | 说明 | 6985| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 6986| type | string | 是 | 监听事件,固定为'isoInfoChange'。 | 6987| callback | AsyncCallback\<[IsoInfo](#isoinfo12)\>| 是 | 回调函数,用于获取ISO信息。 | 6988 6989**错误码:** 6990 6991| 错误码ID | 错误信息 | 6992| ------- | ---------------------- | 6993| 202 | Not System Application. | 6994 6995**示例:** 6996 6997```ts 6998import { BusinessError } from '@kit.BasicServicesKit'; 6999 7000function isoInfoCallback(err: BusinessError, info: camera.IsoInfo): void { 7001 if (err !== undefined && err.code !== 0) { 7002 console.error(`Callback Error, errorCode: ${err.code}`); 7003 return; 7004 } 7005 console.log(`ISO value: ${info.iso}`); 7006} 7007 7008function registerIsoInfoEvent(professionalVideoSession: camera.ProfessionalVideoSession): void { 7009 professionalVideoSession.on('isoInfoChange', isoInfoCallback); 7010} 7011``` 7012 7013### off('isoInfoChange')<sup>12+</sup> 7014 7015off(type: 'isoInfoChange', callback?: AsyncCallback\<IsoInfo\>): void 7016 7017注销监听ISO信息事件,通过注册回调函数来注销。 7018 7019**系统接口:** 此接口为系统接口。 7020 7021**系统能力:** SystemCapability.Multimedia.Camera.Core 7022 7023**参数:** 7024 7025| 参数名 | 类型 | 必填 | 说明 | 7026| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 7027| type | string | 是 | 监听事件,固定为'isoInfoChange'。 | 7028| callback | AsyncCallback\<[IsoInfo](#isoinfo12)\>| 否 | 回调函数,可选,用于匹配on('isoInfoChange')的callback。 | 7029 7030**错误码:** 7031 7032| 错误码ID | 错误信息 | 7033| ------- | ---------------------- | 7034| 202 | Not System Application. | 7035 7036**示例:** 7037 7038```ts 7039function unregisterIsoInfoEvent(professionalVideoSession: camera.ProfessionalVideoSession): void { 7040 professionalVideoSession.off('isoInfoChange'); 7041} 7042``` 7043 7044### on('exposureInfoChange')<sup>12+</sup> 7045 7046on(type: 'exposureInfoChange', callback: AsyncCallback\<ExposureInfo\>): void 7047 7048监听曝光信息事件,通过注册回调函数获取曝光信息。使用callback异步回调。 7049 7050**系统接口:** 此接口为系统接口。 7051 7052**系统能力:** SystemCapability.Multimedia.Camera.Core 7053 7054**参数:** 7055 7056| 参数名 | 类型 | 必填 | 说明 | 7057| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 7058| type | string | 是 | 监听事件,固定为'exposureInfoChange'。 | 7059| callback | AsyncCallback\<[ExposureInfo](#exposureinfo12)\>| 是 | 回调函数,用于获取曝光信息。 | 7060 7061**错误码:** 7062 7063| 错误码ID | 错误信息 | 7064| ------- | ---------------------- | 7065| 202 | Not System Application. | 7066 7067**示例:** 7068 7069```ts 7070import { BusinessError } from '@kit.BasicServicesKit'; 7071 7072function exposureInfoCallback(err: BusinessError, info: camera.ExposureInfo): void { 7073 if (err !== undefined && err.code !== 0) { 7074 console.error(`Callback Error, errorCode: ${err.code}`); 7075 return; 7076 } 7077 console.log(`exposureTimeValue: ${info.exposureTime}`); 7078} 7079 7080function registerExposureInfoEvent(professionalVideoSession: camera.ProfessionalVideoSession): void { 7081 professionalVideoSession.on('exposureInfoChange', exposureInfoCallback); 7082} 7083``` 7084 7085### off('exposureInfoChange')<sup>12+</sup> 7086 7087off(type: 'exposureInfoChange', callback?: AsyncCallback\<ExposureInfo\>): void 7088 7089注销监听曝光信息事件,通过注册回调函数来注销。 7090 7091**系统接口:** 此接口为系统接口。 7092 7093**系统能力:** SystemCapability.Multimedia.Camera.Core 7094 7095**参数:** 7096 7097| 参数名 | 类型 | 必填 | 说明 | 7098| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 7099| type | string | 是 | 监听事件,固定为'exposureInfoChange'。 | 7100| callback | AsyncCallback\<[ExposureInfo](#exposureinfo12)\>| 否 | 回调函数,可选,用于匹配on('exposureInfoChange')的callback。 | 7101 7102**错误码:** 7103 7104| 错误码ID | 错误信息 | 7105| ------- | ---------------------- | 7106| 202 | Not System Application. | 7107 7108**示例:** 7109 7110```ts 7111function unregisterExposureInfoEvent(professionalVideoSession: camera.ProfessionalVideoSession): void { 7112 professionalVideoSession.off('exposureInfoChange'); 7113} 7114``` 7115 7116### on('apertureInfoChange')<sup>12+</sup> 7117 7118on(type: 'apertureInfoChange', callback: AsyncCallback\<ApertureInfo\>): void 7119 7120监听物理光圈变化事件,通过注册回调函数获取物理光圈信息。使用callback异步回调。 7121 7122**系统接口:** 此接口为系统接口。 7123 7124**系统能力:** SystemCapability.Multimedia.Camera.Core 7125 7126**参数:** 7127 7128| 参数名 | 类型 | 必填 | 说明 | 7129| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 7130| type | string | 是 | 监听事件,固定为'apertureInfoChange'。 | 7131| callback | AsyncCallback\<[ApertureInfo](#apertureinfo12)\>| 是 | 回调函数,用于获取物理光圈信息。 | 7132 7133**错误码:** 7134 7135| 错误码ID | 错误信息 | 7136| ------- | ---------------------- | 7137| 202 | Not System Application. | 7138 7139**示例:** 7140 7141```ts 7142import { BusinessError } from '@kit.BasicServicesKit'; 7143 7144function apertureInfoCallback(err: BusinessError, info: camera.ApertureInfo): void { 7145 if (err !== undefined && err.code !== 0) { 7146 console.error(`Callback Error, errorCode: ${err.code}`); 7147 return; 7148 } 7149 console.log(`Aperture value: ${info.aperture}`); 7150} 7151 7152function registerApertureInfoEvent(professionalVideoSession: camera.ProfessionalVideoSession): void { 7153 professionalVideoSession.on('apertureInfoChange', apertureInfoCallback); 7154} 7155``` 7156 7157### off('apertureInfoChange')<sup>12+</sup> 7158 7159off(type: 'apertureInfoChange', callback?: AsyncCallback\<ApertureInfo\>): void 7160 7161注销监听物理光圈变化事件,通过注册回调函数来注销。 7162 7163**系统接口:** 此接口为系统接口。 7164 7165**系统能力:** SystemCapability.Multimedia.Camera.Core 7166 7167**参数:** 7168 7169| 参数名 | 类型 | 必填 | 说明 | 7170| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 7171| type | string | 是 | 监听事件,固定为'apertureInfoChange'。 | 7172| callback | AsyncCallback\<[ApertureInfo](#apertureinfo12)\>| 否 | 回调函数,可选,用于匹配on('apertureInfoChange')的callback。 | 7173 7174**错误码:** 7175 7176| 错误码ID | 错误信息 | 7177| ------- | ---------------------- | 7178| 202 | Not System Application. | 7179 7180**示例:** 7181 7182```ts 7183function unregisterApertureInfoEvent(professionalVideoSession: camera.ProfessionalVideoSession): void { 7184 professionalVideoSession.off('apertureInfoChange'); 7185} 7186``` 7187 7188### on('luminationInfoChange')<sup>12+</sup> 7189 7190on(type: 'luminationInfoChange', callback: AsyncCallback\<LuminationInfo\>): void 7191 7192监听光照变化事件,通过注册回调函数获取光照参数。使用callback异步回调。 7193 7194**系统接口:** 此接口为系统接口。 7195 7196**系统能力:** SystemCapability.Multimedia.Camera.Core 7197 7198**参数:** 7199 7200| 参数名 | 类型 | 必填 | 说明 | 7201| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 7202| type | string | 是 | 监听事件,固定为'luminationInfoChange'。 | 7203| callback | AsyncCallback\<[LuminationInfo](#luminationinfo12)\>| 是 | 回调函数,用于获取光照参数。 | 7204 7205**错误码:** 7206 7207| 错误码ID | 错误信息 | 7208| ------- | ---------------------- | 7209| 202 | Not System Application. | 7210 7211**示例:** 7212 7213```ts 7214import { BusinessError } from '@kit.BasicServicesKit'; 7215 7216function luminationInfoCallback(err: BusinessError, info: camera.LuminationInfo): void { 7217 if (err !== undefined && err.code !== 0) { 7218 console.error(`Callback Error, errorCode: ${err.code}`); 7219 return; 7220 } 7221 console.log(`Lumination: ${info.lumination}`); 7222} 7223 7224function registerLuminationInfoEvent(professionalVideoSession: camera.ProfessionalVideoSession): void { 7225 professionalVideoSession.on('luminationInfoChange', luminationInfoCallback); 7226} 7227``` 7228 7229### off('luminationInfoChange')<sup>12+</sup> 7230 7231off(type: 'luminationInfoChange', callback?: AsyncCallback\<LuminationInfo\>): void 7232 7233注销监听光照变化事件,通过注册回调函数来注销。 7234 7235**系统接口:** 此接口为系统接口。 7236 7237**系统能力:** SystemCapability.Multimedia.Camera.Core 7238 7239**参数:** 7240 7241| 参数名 | 类型 | 必填 | 说明 | 7242| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 7243| type | string | 是 | 监听事件,固定为'luminationInfoChange'。 | 7244| callback | AsyncCallback\<[LuminationInfo](#luminationinfo12)\>| 否 | 回调函数,可选,用于匹配on('luminationInfoChange')的callback。 | 7245 7246**错误码:** 7247 7248| 错误码ID | 错误信息 | 7249| ------- | ---------------------- | 7250| 202 | Not System Application. | 7251 7252**示例:** 7253 7254```ts 7255function unregisterLuminationInfoEvent(professionalVideoSession: camera.ProfessionalVideoSession): void { 7256 professionalVideoSession.off('luminationInfoChange'); 7257} 7258``` 7259 7260## MacroPhotoSession<sup>12+</sup> 7261 7262MacroPhotoSession extends Session, Flash, AutoExposure, Focus, Zoom, ColorEffect, ManualFocus 7263 7264微距拍照模式会话类,继承自[Session](arkts-apis-camera-Session.md),用于设置微距拍照模式的参数以及保存所需要的所有资源[CameraInput](arkts-apis-camera-CameraInput.md)、[CameraOutput](arkts-apis-camera-CameraOutput.md)。 7265 7266### on('error')<sup>12+</sup> 7267 7268on(type: 'error', callback: ErrorCallback): void 7269 7270监听微距拍照会话的错误事件,通过注册回调函数获取结果。使用callback异步回调。 7271 7272**系统接口:** 此接口为系统接口。 7273 7274**系统能力:** SystemCapability.Multimedia.Camera.Core 7275 7276**参数:** 7277 7278| 参数名 | 类型 | 必填 | 说明 | 7279|----------|---------------------------------------------------------------------------|-----|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------| 7280| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。session调用相关接口出现错误时会触发该事件,比如调用[beginConfig](arkts-apis-camera-Session.md#beginconfig11),[commitConfig](arkts-apis-camera-Session.md#commitconfig11-1),[addInput](arkts-apis-camera-Session.md#addinput11)等接口发生错误时返回错误信息。 | 7281| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。 | 7282 7283**错误码:** 7284 7285以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7286 7287| 错误码ID | 错误信息 | 7288|-------|----------------------------| 7289| 202 | Not System Application. | 7290 7291**示例:** 7292 7293```ts 7294import { BusinessError } from '@kit.BasicServicesKit'; 7295 7296function callback(err: BusinessError): void { 7297 console.error(`MacroPhotoSession error code: ${err.code}`); 7298} 7299 7300function registerSessionError(macroPhotoSession: camera.MacroPhotoSession): void { 7301 macroPhotoSession.on('error', callback); 7302} 7303``` 7304 7305### off('error')<sup>12+</sup> 7306 7307off(type: 'error', callback?: ErrorCallback): void 7308 7309注销监听微距拍照会话的错误事件,通过注册回调函数获取结果。 7310 7311**系统接口:** 此接口为系统接口。 7312 7313**系统能力:** SystemCapability.Multimedia.Camera.Core 7314 7315**参数:** 7316 7317| 参数名 | 类型 | 必填 | 说明 | 7318|----------|---------------------------------------------------------------------------|----|-------------------------------------------------------------| 7319| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。 | 7320| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | 否 | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 | 7321 7322**错误码:** 7323 7324以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7325 7326| 错误码ID | 错误信息 | 7327|-------|----------------------------| 7328| 202 | Not System Application. | 7329 7330**示例:** 7331 7332```ts 7333function unregisterSessionError(macroPhotoSession: camera.MacroPhotoSession): void { 7334 macroPhotoSession.off('error'); 7335} 7336``` 7337 7338### on('focusStateChange')<sup>12+</sup> 7339 7340on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 7341 7342监听相机对焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 7343 7344**系统接口:** 此接口为系统接口。 7345 7346**系统能力:** SystemCapability.Multimedia.Camera.Core 7347 7348**参数:** 7349 7350| 参数名 | 类型 | 必填 | 说明 | 7351|-----------|---------------------------------------------|----|-------------------------------------------------------------------------| 7352| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。仅当自动对焦模式时,且相机对焦状态发生改变时可触发该事件。 | 7353| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.md#focusstate)\> | 是 | 回调函数,用于获取当前对焦状态。 | 7354 7355**错误码:** 7356 7357以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7358 7359| 错误码ID | 错误信息 | 7360|-------|----------------------------| 7361| 202 | Not System Application. | 7362 7363**示例:** 7364 7365```ts 7366import { BusinessError } from '@kit.BasicServicesKit'; 7367 7368function callback(err: BusinessError, focusState: camera.FocusState): void { 7369 if (err !== undefined && err.code !== 0) { 7370 console.error(`Callback Error, errorCode: ${err.code}`); 7371 return; 7372 } 7373 console.info(`Focus state: ${focusState}`); 7374} 7375 7376function registerFocusStateChange(macroPhotoSession: camera.MacroPhotoSession): void { 7377 macroPhotoSession.on('focusStateChange', callback); 7378} 7379``` 7380 7381### off('focusStateChange')<sup>12+</sup> 7382 7383off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 7384 7385注销监听相机对焦的状态变化。 7386 7387**系统接口:** 此接口为系统接口。 7388 7389**系统能力:** SystemCapability.Multimedia.Camera.Core 7390 7391**参数:** 7392 7393| 参数名 | 类型 | 必填 | 说明 | 7394|-----------|---------------------------------------------|----|--------------------------------------------------------------| 7395| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。 | 7396| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.md#focusstate)\> | 否 | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 | 7397 7398**错误码:** 7399 7400以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7401 7402| 错误码ID | 错误信息 | 7403|-------|----------------------------| 7404| 202 | Not System Application. | 7405 7406**示例:** 7407 7408```ts 7409function unregisterFocusStateChange(macroPhotoSession: camera.MacroPhotoSession): void { 7410 macroPhotoSession.off('focusStateChange'); 7411} 7412``` 7413 7414### on('smoothZoomInfoAvailable')<sup>12+</sup> 7415 7416on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 7417 7418监听相机平滑变焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 7419 7420**系统接口:** 此接口为系统接口。 7421 7422**系统能力:** SystemCapability.Multimedia.Camera.Core 7423 7424**参数:** 7425 7426| 参数名 | 类型 | 必填 | 说明 | 7427| -------- | ----------------------- | ---- | ------------------------ | 7428| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 7429| callback | AsyncCallback\<[SmoothZoomInfo](arkts-apis-camera-i.md#smoothzoominfo11)\> | 是 | 回调函数,用于获取当前平滑变焦状态。 | 7430 7431**错误码:** 7432 7433以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7434 7435| 错误码ID | 错误信息 | 7436|-------|----------------------------| 7437| 202 | Not System Application. | 7438 7439**示例:** 7440 7441```ts 7442import { BusinessError } from '@kit.BasicServicesKit'; 7443 7444function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 7445 if (err !== undefined && err.code !== 0) { 7446 console.error(`Callback Error, errorCode: ${err.code}`); 7447 return; 7448 } 7449 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 7450} 7451 7452function registerSmoothZoomInfo(macroPhotoSession: camera.MacroPhotoSession): void { 7453 macroPhotoSession.on('smoothZoomInfoAvailable', callback); 7454} 7455``` 7456 7457### off('smoothZoomInfoAvailable')<sup>12+</sup> 7458 7459off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 7460 7461注销监听相机平滑变焦的状态变化。 7462 7463**系统接口:** 此接口为系统接口。 7464 7465**系统能力:** SystemCapability.Multimedia.Camera.Core 7466 7467**参数:** 7468 7469| 参数名 | 类型 | 必填 | 说明 | 7470| -------- | ----------------------------------------- | ---- | ------------------------ | 7471| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 7472| callback | AsyncCallback\<[SmoothZoomInfo](arkts-apis-camera-i.md#smoothzoominfo11)\> | 否 | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 | 7473 7474**错误码:** 7475 7476以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7477 7478| 错误码ID | 错误信息 | 7479|-------|----------------------------| 7480| 202 | Not System Application. | 7481 7482**示例:** 7483 7484```ts 7485function unregisterSmoothZoomInfo(macroPhotoSession: camera.MacroPhotoSession): void { 7486 macroPhotoSession.off('smoothZoomInfoAvailable'); 7487} 7488``` 7489 7490## MacroVideoSession<sup>12+</sup> 7491 7492MacroVideoSession extends Session, Flash, AutoExposure, Focus, Zoom, ColorEffect, ManualFocus 7493 7494微距录像模式会话类,继承自[Session](arkts-apis-camera-Session.md),用于设置微距录像模式的参数以及保存所需要的所有资源[CameraInput](arkts-apis-camera-CameraInput.md)、[CameraOutput](arkts-apis-camera-CameraOutput.md)。 7495 7496### on('error')<sup>12+</sup> 7497 7498on(type: 'error', callback: ErrorCallback): void 7499 7500监听微距录像会话的错误事件,通过注册回调函数获取结果。使用callback异步回调。 7501 7502**系统接口:** 此接口为系统接口。 7503 7504**系统能力:** SystemCapability.Multimedia.Camera.Core 7505 7506**参数:** 7507 7508| 参数名 | 类型 | 必填 | 说明 | 7509|----------|---------------------------------------------------------------------------|-----|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------| 7510| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。session调用相关接口出现错误时会触发该事件,比如调用[beginConfig](arkts-apis-camera-Session.md#beginconfig11),[commitConfig](arkts-apis-camera-Session.md#commitconfig11-1),[addInput](arkts-apis-camera-Session.md#addinput11)等接口发生错误时返回错误信息。 | 7511| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。 | 7512 7513**错误码:** 7514 7515以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7516 7517| 错误码ID | 错误信息 | 7518|-------|----------------------------| 7519| 202 | Not System Application. | 7520 7521**示例:** 7522 7523```ts 7524import { BusinessError } from '@kit.BasicServicesKit'; 7525 7526function callback(err: BusinessError): void { 7527 console.error(`MacroPhotoSession error code: ${err.code}`); 7528} 7529 7530function registerSessionError(macroVideoSession: camera.MacroVideoSession): void { 7531 macroVideoSession.on('error', callback); 7532} 7533``` 7534 7535### off('error')<sup>12+</sup> 7536 7537off(type: 'error', callback?: ErrorCallback): void 7538 7539注销监听微距录像会话的错误事件,通过注册回调函数获取结果。 7540 7541**系统接口:** 此接口为系统接口。 7542 7543**系统能力:** SystemCapability.Multimedia.Camera.Core 7544 7545**参数:** 7546 7547| 参数名 | 类型 | 必填 | 说明 | 7548|----------|---------------------------------------------------------------------------|----|-------------------------------------------------------------| 7549| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。 | 7550| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | 否 | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 | 7551 7552**错误码:** 7553 7554以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7555 7556| 错误码ID | 错误信息 | 7557|-------|----------------------------| 7558| 202 | Not System Application. | 7559 7560**示例:** 7561 7562```ts 7563function unregisterSessionError(macroVideoSession: camera.MacroVideoSession): void { 7564 macroVideoSession.off('error'); 7565} 7566``` 7567 7568### on('focusStateChange')<sup>12+</sup> 7569 7570on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 7571 7572监听相机对焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 7573 7574**系统接口:** 此接口为系统接口。 7575 7576**系统能力:** SystemCapability.Multimedia.Camera.Core 7577 7578**参数:** 7579 7580| 参数名 | 类型 | 必填 | 说明 | 7581|-----------|---------------------------------------------|----|-------------------------------------------------------------------------| 7582| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。仅当自动对焦模式时,且相机对焦状态发生改变时可触发该事件。 | 7583| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.md#focusstate)\> | 是 | 回调函数,用于获取当前对焦状态。 | 7584 7585**错误码:** 7586 7587以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7588 7589| 错误码ID | 错误信息 | 7590|-------|----------------------------| 7591| 202 | Not System Application. | 7592 7593**示例:** 7594 7595```ts 7596import { BusinessError } from '@kit.BasicServicesKit'; 7597 7598function callback(err: BusinessError, focusState: camera.FocusState): void { 7599 if (err !== undefined && err.code !== 0) { 7600 console.error(`Callback Error, errorCode: ${err.code}`); 7601 return; 7602 } 7603 console.info(`Focus state: ${focusState}`); 7604} 7605 7606function registerFocusStateChange(macroVideoSession: camera.MacroVideoSession): void { 7607 macroVideoSession.on('focusStateChange', callback); 7608} 7609``` 7610 7611### off('focusStateChange')<sup>12+</sup> 7612 7613off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 7614 7615注销监听相机对焦的状态变化。 7616 7617**系统接口:** 此接口为系统接口。 7618 7619**系统能力:** SystemCapability.Multimedia.Camera.Core 7620 7621**参数:** 7622 7623| 参数名 | 类型 | 必填 | 说明 | 7624|-----------|---------------------------------------------|----|--------------------------------------------------------------| 7625| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。 | 7626| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.md#focusstate)\> | 否 | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 | 7627 7628**错误码:** 7629 7630以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7631 7632| 错误码ID | 错误信息 | 7633|-------|----------------------------| 7634| 202 | Not System Application. | 7635 7636**示例:** 7637 7638```ts 7639function unregisterFocusStateChange(macroVideoSession: camera.MacroVideoSession): void { 7640 macroVideoSession.off('focusStateChange'); 7641} 7642``` 7643 7644### on('smoothZoomInfoAvailable')<sup>12+</sup> 7645 7646on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 7647 7648监听相机平滑变焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 7649 7650**系统接口:** 此接口为系统接口。 7651 7652**系统能力:** SystemCapability.Multimedia.Camera.Core 7653 7654**参数:** 7655 7656| 参数名 | 类型 | 必填 | 说明 | 7657| -------- | ----------------------- | ---- | ------------------------ | 7658| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 7659| callback | AsyncCallback\<[SmoothZoomInfo](arkts-apis-camera-i.md#smoothzoominfo11)\> | 是 | 回调函数,用于获取当前平滑变焦状态。 | 7660 7661**错误码:** 7662 7663以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7664 7665| 错误码ID | 错误信息 | 7666|-------|----------------------------| 7667| 202 | Not System Application. | 7668 7669**示例:** 7670 7671```ts 7672import { BusinessError } from '@kit.BasicServicesKit'; 7673 7674function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 7675 if (err !== undefined && err.code !== 0) { 7676 console.error(`Callback Error, errorCode: ${err.code}`); 7677 return; 7678 } 7679 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 7680} 7681 7682function registerSmoothZoomInfo(macroVideoSession: camera.MacroVideoSession): void { 7683 macroVideoSession.on('smoothZoomInfoAvailable', callback); 7684} 7685``` 7686 7687### off('smoothZoomInfoAvailable')<sup>12+</sup> 7688 7689off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 7690 7691注销监听相机平滑变焦的状态变化。 7692 7693**系统接口:** 此接口为系统接口。 7694 7695**系统能力:** SystemCapability.Multimedia.Camera.Core 7696 7697**参数:** 7698 7699| 参数名 | 类型 | 必填 | 说明 | 7700| -------- | ----------------------------------------- | ---- | ------------------------ | 7701| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 7702| callback | AsyncCallback\<[SmoothZoomInfo](arkts-apis-camera-i.md#smoothzoominfo11)\> | 否 | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 | 7703 7704**错误码:** 7705 7706以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7707 7708| 错误码ID | 错误信息 | 7709|-------|----------------------------| 7710| 202 | Not System Application. | 7711 7712**示例:** 7713 7714```ts 7715function unregisterSmoothZoomInfo(macroVideoSession: camera.MacroVideoSession): void { 7716 macroVideoSession.off('smoothZoomInfoAvailable'); 7717} 7718``` 7719 7720## FlashQuery<sup>12+</sup> 7721 7722此接口提供了查阅设备闪光灯信息相应的方法,包括是否支持lcd闪光灯。 7723 7724### isLcdFlashSupported<sup>12+</sup> 7725 7726isLcdFlashSupported(): boolean 7727 7728查询是否支持lcd闪光灯。 7729 7730**系统接口:** 此接口为系统接口。 7731 7732**系统能力:** SystemCapability.Multimedia.Camera.Core 7733 7734**返回值:** 7735 7736| 类型 | 说明 | 7737| -------------- | ----------------------- | 7738| boolean | 查询是否支持lcd闪光灯,返回true为支持,返回false为不支持。| 7739 7740**错误码:** 7741 7742以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7743 7744| 错误码ID | 错误信息 | 7745| --------------- | --------------- | 7746| 202 | Not System Application. | 7747| 7400103 | Session not config, only throw in session usage. | 7748 7749**示例:** 7750 7751```ts 7752function isLcdFlashSupported(nightPhotoSession: camera.NightPhotoSession): boolean { 7753 return nightPhotoSession.isLcdFlashSupported(); 7754} 7755``` 7756 7757## Flash<sup>11+</sup> 7758 7759Flash extends [FlashQuery](arkts-apis-camera-FlashQuery.md) 7760 7761闪光灯类,对设备闪光灯操作。 7762 7763### enableLcdFlash<sup>13+</sup> 7764 7765enableLcdFlash(enabled: boolean): void 7766 7767使能或去使能LCD闪光灯。 7768 7769进行设置之前,需要先检查:设备是否支持LCD闪光灯,可使用方法[isLcdFlashSupported](#islcdflashsupported12)。 7770 7771**系统能力:** SystemCapability.Multimedia.Camera.Core 7772 7773**参数:** 7774 7775| 参数名 | 类型 | 必填 | 说明 | 7776| --------- | ----------------------- | ---- |--------------------------------------------------| 7777| enabled | boolean | 是 | 使能或去使能LCD闪光灯,true为使能,false为去使能。传参为null或者undefined,作为0处理,去使能LCD闪光灯。 | 7778 7779**错误码:** 7780 7781以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)和[通用错误码说明文档](../errorcode-universal.md)。 7782 7783| 错误码ID | 错误信息 | 7784| --------------- | --------------- | 7785| 202 | Not System Application. | 7786| 7400103 | Session not config. | 7787 7788**示例:** 7789 7790```ts 7791import { BusinessError } from '@kit.BasicServicesKit'; 7792 7793function enableLcdFlash(session: camera.PhotoSessionForSys | camera.VideoSessionForSys | camera.NightPhotoSession): void { 7794 try { 7795 session.enableLcdFlash(true); 7796 } catch (error) { 7797 // 失败返回错误码error.code并处理。 7798 let err = error as BusinessError; 7799 console.error(`The setFlashMode call failed. error code: ${err.code}`); 7800 } 7801} 7802``` 7803 7804## TimeLapseRecordState<sup>12+</sup> 7805 7806枚举,延时摄影录制状态。 7807 7808**系统接口:** 此接口为系统接口。 7809 7810**系统能力:** SystemCapability.Multimedia.Camera.Core 7811 7812| 名称 | 值 | 说明 | 7813| ----------------------------- | ---- | ----------- | 7814| IDLE | 0 | 未录制 | 7815| RECORDING | 1 | 录制中 | 7816 7817## TimeLapsePreviewType<sup>12+</sup> 7818 7819枚举,延时摄影预览类型,影响拍摄算法。 7820 7821**系统接口:** 此接口为系统接口。 7822 7823**系统能力:** SystemCapability.Multimedia.Camera.Core 7824 7825| 名称 | 值 | 说明 | 7826| ----------------------------- | ---- | ----------- | 7827| DARK | 1 | 暗光环境,指光照较差的场景,比如夜晚或暗处。 | 7828| LIGHT | 2 | 亮光环境,指光照较好的场景,比如白天或灯光下。 | 7829 7830## TryAEInfo<sup>12+</sup> 7831 7832TryAE参数信息,TryAE是指延时摄影时硬件会根据环境光照变化上报状态的操作。 7833 7834**系统接口:** 此接口为系统接口。 7835 7836**系统能力:** SystemCapability.Multimedia.Camera.Core 7837 7838| 名称 | 类型 | 只读 | 可选 | 说明 | 7839| ---- | ------- | ---- |--| -------------- | 7840| isTryAEDone | boolean | 是 | 否 | TryAE是否完成。 | 7841| isTryAEHintNeeded | boolean | 是 | 是 | 是否需要TryAE。 | 7842| previewType | [TimeLapsePreviewType](#timelapsepreviewtype12) | 是 | 是 | 预览类型。 | 7843| captureInterval | number | 是 | 是 | 拍摄间隔,单位毫秒(ms)。 | 7844 7845## TimeLapsePhotoSession<sup>12+</sup> 7846 7847TimeLapsePhotoSession extends Session, Focus, ManualFocus, AutoExposure, ManualExposure, ManualIso, WhiteBalance, Zoom, ColorEffect 7848 7849延时摄影会话类,继承自[Session](arkts-apis-camera-Session.md),用于设置延时摄影会话的参数以及保存所需要的所有资源[CameraInput](arkts-apis-camera-CameraInput.md)、[CameraOutput](arkts-apis-camera-CameraOutput.md)。 7850 7851### on('error')<sup>12+</sup> 7852 7853on(type: 'error', callback: ErrorCallback): void 7854 7855监听延时摄影会话的错误事件,通过注册回调函数获取结果。使用callback异步回调。 7856 7857**系统接口:** 此接口为系统接口。 7858 7859**系统能力:** SystemCapability.Multimedia.Camera.Core 7860 7861**参数:** 7862 7863| 参数名 | 类型 | 必填 | 说明 | 7864| -------- | ----------------------------------------------------------- | ---- | ------------------------------ | 7865| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。session调用相关接口出现错误时会触发该事件,比如调用[beginConfig](arkts-apis-camera-Session.md#beginconfig11),[commitConfig](arkts-apis-camera-Session.md#commitconfig11-1),[addInput](arkts-apis-camera-Session.md#addinput11)等接口发生错误时返回错误信息。 | 7866| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。 | 7867 7868**错误码:** 7869 7870以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7871 7872| 错误码ID | 错误信息 | 7873|---------| --------------- | 7874| 202 | Not System Application. | 7875 7876**示例:** 7877 7878```ts 7879import { BusinessError } from '@kit.BasicServicesKit'; 7880 7881function callback(err: BusinessError): void { 7882 console.error(`Time lapse photo session error code: ${err.code}`); 7883} 7884 7885function registerSessionError(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 7886 timeLapsePhotoSession.on('error', callback); 7887} 7888``` 7889 7890### off('error')<sup>12+</sup> 7891 7892off(type: 'error', callback?: ErrorCallback): void 7893 7894注销监听延时摄影会话的错误事件,通过注册回调函数获取结果。 7895 7896**系统接口:** 此接口为系统接口。 7897 7898**系统能力:** SystemCapability.Multimedia.Camera.Core 7899 7900**参数:** 7901 7902| 参数名 | 类型 | 必填 | 说明 | 7903| -------- | ------------------------ | ---- | ------------------------------ | 7904| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。 | 7905| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 否 | 回调函数,可选,有就是匿名函数。 | 7906 7907**错误码:** 7908 7909以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7910 7911| 错误码ID | 错误信息 | 7912|---------| --------------- | 7913| 202 | Not System Application. | 7914 7915**示例:** 7916 7917```ts 7918function unregisterSessionError(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 7919 timeLapsePhotoSession.off('error'); 7920} 7921``` 7922 7923### on('focusStateChange')<sup>12+</sup> 7924 7925on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 7926 7927监听相机对焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 7928 7929**系统接口:** 此接口为系统接口。 7930 7931**系统能力:** SystemCapability.Multimedia.Camera.Core 7932 7933**参数:** 7934 7935| 参数名 | 类型 | 必填 | 说明 | 7936| -------- | ---------------- | ---- | ------------------------ | 7937| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。仅当自动对焦模式时,且相机对焦状态发生改变时可触发该事件。 | 7938| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.md#focusstate)\> | 是 | 回调函数,用于获取当前对焦状态。 | 7939 7940**错误码:** 7941 7942以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7943 7944| 错误码ID | 错误信息 | 7945|---------| --------------- | 7946| 202 | Not System Application. | 7947 7948**示例:** 7949 7950```ts 7951import { BusinessError } from '@kit.BasicServicesKit'; 7952 7953function callback(err: BusinessError, focusState: camera.FocusState): void { 7954 if (err !== undefined && err.code !== 0) { 7955 console.error(`Callback Error, errorCode: ${err.code}`); 7956 return; 7957 } 7958 console.info(`Focus state: ${focusState}`); 7959} 7960 7961function registerFocusStateChange(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 7962 timeLapsePhotoSession.on('focusStateChange', callback); 7963} 7964``` 7965 7966### off('focusStateChange')<sup>12+</sup> 7967 7968off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 7969 7970注销监听相机对焦的状态变化。 7971 7972**系统接口:** 此接口为系统接口。 7973 7974**系统能力:** SystemCapability.Multimedia.Camera.Core 7975 7976**参数:** 7977 7978| 参数名 | 类型 | 必填 | 说明 | 7979| -------- | ----------------------------------------- | ---- | ------------------------ | 7980| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。 | 7981| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.md#focusstate)\> | 否 | 回调函数,可选,有就是匹配on('focusStateChange') callback(callback对象不可是匿名函数)。 | 7982 7983**错误码:** 7984 7985以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 7986 7987| 错误码ID | 错误信息 | 7988|---------| --------------- | 7989| 202 | Not System Application. | 7990 7991**示例:** 7992 7993```ts 7994function unregisterFocusStateChange(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 7995 timeLapsePhotoSession.off('focusStateChange'); 7996} 7997``` 7998 7999### on('isoInfoChange')<sup>12+</sup> 8000 8001on(type: 'isoInfoChange', callback: AsyncCallback\<IsoInfo\>): void 8002 8003监听自动ISO变化事件,通过注册回调函数获取实时ISO信息。使用callback异步回调。 8004 8005**系统接口:** 此接口为系统接口。 8006 8007**系统能力:** SystemCapability.Multimedia.Camera.Core 8008 8009**参数:** 8010 8011| 参数名 | 类型 | 必填 | 说明 | 8012| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 8013| type | string | 是 | 监听事件,固定为'isoInfoChange'。 | 8014| callback | AsyncCallback\<[IsoInfo](#isoinfo12)\>| 是 | 回调函数,用于获取ISO信息。 | 8015 8016**错误码:** 8017 8018| 错误码ID | 错误信息 | 8019| ------- | ---------------------- | 8020| 202 | Not System Application. | 8021 8022**示例:** 8023 8024```ts 8025import { BusinessError } from '@kit.BasicServicesKit'; 8026 8027function isoInfoCallback(err: BusinessError, info: camera.IsoInfo): void { 8028 if (err !== undefined && err.code !== 0) { 8029 console.error(`Callback Error, errorCode: ${err.code}`); 8030 return; 8031 } 8032 console.log(`ISO value: ${info.iso}`); 8033} 8034 8035function registerIsoInfoEvent(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8036 timeLapsePhotoSession.on('isoInfoChange', isoInfoCallback); 8037} 8038``` 8039 8040### off('isoInfoChange')<sup>12+</sup> 8041 8042off(type: 'isoInfoChange', callback?: AsyncCallback\<IsoInfo\>): void 8043 8044注销监听ISO信息事件,通过注册回调函数来注销。 8045 8046**系统接口:** 此接口为系统接口。 8047 8048**系统能力:** SystemCapability.Multimedia.Camera.Core 8049 8050**参数:** 8051 8052| 参数名 | 类型 | 必填 | 说明 | 8053| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 8054| type | string | 是 | 监听事件,固定为'isoInfoChange'。 | 8055| callback | AsyncCallback\<[IsoInfo](#isoinfo12)\>| 否 | 回调函数,可选,用于匹配on('isoInfoChange')的callback。 | 8056 8057**错误码:** 8058 8059| 错误码ID | 错误信息 | 8060| ------- | ---------------------- | 8061| 202 | Not System Application. | 8062 8063**示例:** 8064 8065```ts 8066function unregisterIsoInfoEvent(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8067 timeLapsePhotoSession.off('isoInfoChange'); 8068} 8069``` 8070 8071### on('exposureInfoChange')<sup>12+</sup> 8072 8073on(type: 'exposureInfoChange', callback: AsyncCallback\<ExposureInfo\>): void 8074 8075监听曝光信息事件,通过注册回调函数获取曝光信息。使用callback异步回调。 8076 8077**系统接口:** 此接口为系统接口。 8078 8079**系统能力:** SystemCapability.Multimedia.Camera.Core 8080 8081**参数:** 8082 8083| 参数名 | 类型 | 必填 | 说明 | 8084| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 8085| type | string | 是 | 监听事件,固定为'exposureInfoChange'。 | 8086| callback | AsyncCallback\<[ExposureInfo](#exposureinfo12)\>| 是 | 回调函数,用于获取曝光信息。 | 8087 8088**错误码:** 8089 8090| 错误码ID | 错误信息 | 8091| ------- | ---------------------- | 8092| 202 | Not System Application. | 8093 8094**示例:** 8095 8096```ts 8097import { BusinessError } from '@kit.BasicServicesKit'; 8098 8099function exposureInfoCallback(err: BusinessError, info: camera.ExposureInfo): void { 8100 if (err !== undefined && err.code !== 0) { 8101 console.error(`Callback Error, errorCode: ${err.code}`); 8102 return; 8103 } 8104 console.log(`exposureTimeValue: ${info.exposureTime}`); 8105} 8106 8107function registerExposureInfoEvent(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8108 timeLapsePhotoSession.on('exposureInfoChange', exposureInfoCallback); 8109} 8110``` 8111 8112### off('exposureInfoChange')<sup>12+</sup> 8113 8114off(type: 'exposureInfoChange', callback?: AsyncCallback\<ExposureInfo\>): void 8115 8116注销监听曝光信息事件,通过注册回调函数来注销。 8117 8118**系统接口:** 此接口为系统接口。 8119 8120**系统能力:** SystemCapability.Multimedia.Camera.Core 8121 8122**参数:** 8123 8124| 参数名 | 类型 | 必填 | 说明 | 8125| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 8126| type | string | 是 | 监听事件,固定为'exposureInfoChange'。 | 8127| callback | AsyncCallback\<[ExposureInfo](#exposureinfo12)\>| 否 | 回调函数,可选,用于匹配on('exposureInfoChange')的callback。 | 8128 8129**错误码:** 8130 8131| 错误码ID | 错误信息 | 8132| ------- | ---------------------- | 8133| 202 | Not System Application. | 8134 8135**示例:** 8136 8137```ts 8138function unregisterExposureInfoEvent(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8139 timeLapsePhotoSession.off('exposureInfoChange'); 8140} 8141``` 8142 8143### on('luminationInfoChange')<sup>12+</sup> 8144 8145on(type: 'luminationInfoChange', callback: AsyncCallback\<LuminationInfo\>): void 8146 8147监听光照变化事件,通过注册回调函数获取实时光照参数。使用callback异步回调。 8148 8149**系统接口:** 此接口为系统接口。 8150 8151**系统能力:** SystemCapability.Multimedia.Camera.Core 8152 8153**参数:** 8154 8155| 参数名 | 类型 | 必填 | 说明 | 8156| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 8157| type | string | 是 | 监听事件,固定为'luminationInfoChange'。 | 8158| callback | AsyncCallback\<[LuminationInfo](#luminationinfo12)\>| 是 | 回调函数,用于获取光照参数。 | 8159 8160**错误码:** 8161 8162| 错误码ID | 错误信息 | 8163| ------- | ---------------------- | 8164| 202 | Not System Application. | 8165 8166**示例:** 8167 8168```ts 8169import { BusinessError } from '@kit.BasicServicesKit'; 8170 8171function luminationInfoCallback(err: BusinessError, info: camera.LuminationInfo): void { 8172 if (err !== undefined && err.code !== 0) { 8173 console.error(`Callback Error, errorCode: ${err.code}`); 8174 return; 8175 } 8176 console.log(`Lumination: ${info.lumination}`); 8177} 8178 8179function registerLuminationInfoEvent(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8180 timeLapsePhotoSession.on('luminationInfoChange', luminationInfoCallback); 8181} 8182``` 8183 8184### off('luminationInfoChange')<sup>12+</sup> 8185 8186off(type: 'luminationInfoChange', callback?: AsyncCallback\<LuminationInfo\>): void 8187 8188注销监听光照变化事件,通过注册回调函数来注销。 8189 8190**系统接口:** 此接口为系统接口。 8191 8192**系统能力:** SystemCapability.Multimedia.Camera.Core 8193 8194**参数:** 8195 8196| 参数名 | 类型 | 必填 | 说明 | 8197| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 8198| type | string | 是 | 监听事件,固定为'luminationInfoChange'。 | 8199| callback | AsyncCallback\<[LuminationInfo](#luminationinfo12)\>| 否 | 回调函数,可选,用于匹配on('luminationInfoChange')的callback。 | 8200 8201**错误码:** 8202 8203| 错误码ID | 错误信息 | 8204| ------- | ---------------------- | 8205| 202 | Not System Application. | 8206 8207**示例:** 8208 8209```ts 8210function unregisterLuminationInfoEvent(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8211 timeLapsePhotoSession.off('luminationInfoChange'); 8212} 8213``` 8214 8215### on('tryAEInfoChange')<sup>12+</sup> 8216 8217on(type: 'tryAEInfoChange', callback: AsyncCallback\<TryAEInfo\>): void 8218 8219监听TryAE变化事件,通过注册回调函数获取实时TryAE参数。使用callback异步回调。 8220 8221**系统接口:** 此接口为系统接口。 8222 8223**系统能力:** SystemCapability.Multimedia.Camera.Core 8224 8225**参数:** 8226 8227| 参数名 | 类型 | 必填 | 说明 | 8228| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 8229| type | string | 是 | 监听事件,固定为'tryAEInfoChange'。 | 8230| callback | AsyncCallback\<[TryAEInfo](#tryaeinfo12)\>| 是 | 回调函数,用于获取TryAE参数。 | 8231 8232**错误码:** 8233 8234| 错误码ID | 错误信息 | 8235| ------- | ---------------------- | 8236| 202 | Not System Application. | 8237 8238**示例:** 8239 8240```ts 8241import { BusinessError } from '@kit.BasicServicesKit'; 8242 8243function tryAEInfoCallback(err: BusinessError, info: camera.TryAEInfo): void { 8244 if (err !== undefined && err.code !== 0) { 8245 console.error(`Callback Error, errorCode: ${err.code}`); 8246 return; 8247 } 8248 console.log(`TryAEInfo: ${info.isTryAEDone}, ${info.isTryAEHintNeeded}, ${info.previewType}, ${info.captureInterval}`); 8249} 8250 8251function registerTryAEInfoEvent(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8252 timeLapsePhotoSession.on('tryAEInfoChange', tryAEInfoCallback); 8253} 8254``` 8255 8256### off('tryAEInfoChange')<sup>12+</sup> 8257 8258off(type: 'tryAEInfoChange', callback?: AsyncCallback\<TryAEInfo\>): void 8259 8260注销监听TryAE变化事件,通过注册回调函数来注销。 8261 8262**系统接口:** 此接口为系统接口。 8263 8264**系统能力:** SystemCapability.Multimedia.Camera.Core 8265 8266**参数:** 8267 8268| 参数名 | 类型 | 必填 | 说明 | 8269| -------- | ------------------------------------------------------- | ---- | ---------------------------------- | 8270| type | string | 是 | 监听事件,固定为'tryAEInfoChange'。 | 8271| callback | AsyncCallback\<[TryAEInfo](#tryaeinfo12)\>| 否 | 回调函数,可选,用于匹配on('tryAEInfoChange')的callback。 | 8272 8273**错误码:** 8274 8275| 错误码ID | 错误信息 | 8276| ------- | ---------------------- | 8277| 202 | Not System Application. | 8278 8279**示例:** 8280 8281```ts 8282function unregisterTryAEInfoEvent(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8283 timeLapsePhotoSession.off('tryAEInfoChange'); 8284} 8285``` 8286 8287### isTryAENeeded<sup>12+</sup> 8288 8289isTryAENeeded(): boolean 8290 8291判断是否需要执行TryAE。 8292 8293**系统接口:** 此接口为系统接口。 8294 8295**系统能力:** SystemCapability.Multimedia.Camera.Core 8296 8297**返回值:** 8298 8299| 类型 | 说明 | 8300| ---------- | ----------------------------- | 8301| boolean | 是否需要执行TryAE,返回true为是,返回false为否,错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。 | 8302 8303**错误码:** 8304 8305以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8306 8307| 错误码ID | 错误信息 | 8308| --------------- | --------------- | 8309| 202 | Not System Application. | 8310| 7400103 | Session not config. | 8311 8312**示例:** 8313 8314```ts 8315import { BusinessError } from '@kit.BasicServicesKit'; 8316 8317function isTryAENeeded(timeLapsePhotoSession: camera.TimeLapsePhotoSession): boolean { 8318 let needed = false; 8319 try { 8320 needed = timeLapsePhotoSession.isTryAENeeded(); 8321 } catch (error) { 8322 // 失败返回错误码error.code并处理。 8323 let err = error as BusinessError; 8324 console.error(`The isTryAENeeded call failed. error code: ${err.code}`); 8325 } 8326 return needed; 8327} 8328``` 8329 8330### startTryAE<sup>12+</sup> 8331 8332startTryAE(): void 8333 8334开始执行TryAE。 8335 8336**系统接口:** 此接口为系统接口。 8337 8338**系统能力:** SystemCapability.Multimedia.Camera.Core 8339 8340**错误码:** 8341 8342以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8343 8344| 错误码ID | 错误信息 | 8345| --------------- | --------------- | 8346| 202 | Not System Application. | 8347| 7400103 | Session not config. | 8348 8349**示例:** 8350 8351```ts 8352import { BusinessError } from '@kit.BasicServicesKit'; 8353 8354function startTryAE(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8355 try { 8356 timeLapsePhotoSession.startTryAE(); 8357 } catch (error) { 8358 // 失败返回错误码error.code并处理。 8359 let err = error as BusinessError; 8360 console.error(`The startTryAE call failed. error code: ${err.code}`); 8361 } 8362} 8363``` 8364 8365### stopTryAE<sup>12+</sup> 8366 8367stopTryAE(): void 8368 8369停止执行TryAE。 8370 8371**系统接口:** 此接口为系统接口。 8372 8373**系统能力:** SystemCapability.Multimedia.Camera.Core 8374 8375**错误码:** 8376 8377以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8378 8379| 错误码ID | 错误信息 | 8380| --------------- | --------------- | 8381| 202 | Not System Application. | 8382| 7400103 | Session not config. | 8383 8384**示例:** 8385 8386```ts 8387import { BusinessError } from '@kit.BasicServicesKit'; 8388 8389function stopTryAE(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8390 try { 8391 timeLapsePhotoSession.stopTryAE(); 8392 } catch (error) { 8393 // 失败返回错误码error.code并处理。 8394 let err = error as BusinessError; 8395 console.error(`The stopTryAE call failed. error code: ${err.code}`); 8396 } 8397} 8398``` 8399 8400### getSupportedTimeLapseIntervalRange<sup>12+</sup> 8401 8402getSupportedTimeLapseIntervalRange(): Array\<number\> 8403 8404获取支持的拍摄间隔范围。 8405 8406**系统接口:** 此接口为系统接口。 8407 8408**系统能力:** SystemCapability.Multimedia.Camera.Core 8409 8410**返回值:** 8411 8412| 类型 | 说明 | 8413| ---------- | ----------------------------- | 8414| Array\<number\> | 用于获取拍摄间隔范围,单位毫秒(ms),根据底层能力返回为准,接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。 | 8415 8416**错误码:** 8417 8418以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8419 8420| 错误码ID | 错误信息 | 8421| --------------- | --------------- | 8422| 202 | Not System Application. | 8423| 7400103 | Session not config. | 8424 8425**示例:** 8426 8427```ts 8428import { BusinessError } from '@kit.BasicServicesKit'; 8429 8430function getSupportedTimeLapseIntervalRange(timeLapsePhotoSession: camera.TimeLapsePhotoSession): Array<number> { 8431 let intervalRange: Array<number> = []; 8432 try { 8433 intervalRange = timeLapsePhotoSession.getSupportedTimeLapseIntervalRange(); 8434 } catch (error) { 8435 // 失败返回错误码error.code并处理。 8436 let err = error as BusinessError; 8437 console.error(`The getSupportedTimeLapseIntervalRange call failed. error code: ${err.code}`); 8438 } 8439 return intervalRange; 8440} 8441``` 8442 8443### getTimeLapseInterval<sup>12+</sup> 8444 8445getTimeLapseInterval(): number 8446 8447获取当前的拍摄间隔值。 8448 8449**系统接口:** 此接口为系统接口。 8450 8451**系统能力:** SystemCapability.Multimedia.Camera.Core 8452 8453**返回值:** 8454 8455| 类型 | 说明 | 8456| ---------- | ----------------------------- | 8457| number | 返回当前拍摄间隔值,单位毫秒(ms)。 | 8458 8459**错误码:** 8460 8461以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8462 8463| 错误码ID | 错误信息 | 8464| --------------- | --------------- | 8465| 202 | Not System Application. | 8466| 7400103 | Session not config. | 8467 8468**示例:** 8469 8470```ts 8471import { BusinessError } from '@kit.BasicServicesKit'; 8472 8473function getTimeLapseInterval(timeLapsePhotoSession: camera.TimeLapsePhotoSession): number { 8474 let interval: number = 0; 8475 try { 8476 interval = timeLapsePhotoSession.getTimeLapseInterval(); 8477 } catch (error) { 8478 // 失败返回错误码error.code并处理。 8479 let err = error as BusinessError; 8480 console.error(`The getTimeLapseInterval call failed. error code: ${err.code}`); 8481 } 8482 return interval; 8483} 8484``` 8485 8486### setTimeLapseInterval<sup>12+</sup> 8487setTimeLapseInterval(interval: number): void 8488 8489设置拍摄间隔值。 8490 8491**系统接口:** 此接口为系统接口。 8492 8493**系统能力:** SystemCapability.Multimedia.Camera.Core 8494 8495**参数:** 8496 8497| 参数名 | 类型 | 必填 | 说明 | 8498| -------- | ----------------------- | ---- | ------------------- | 8499| interval | number | 是 | 设置拍摄间隔值,单位毫秒(ms)。 | 8500 8501**错误码:** 8502 8503以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8504 8505| 错误码ID | 错误信息 | 8506| --------------- | --------------- | 8507| 202 | Not System Application. | 8508| 7400101 | Parameter missing or parameter type incorrect. | 8509| 7400103 | Session not config. | 8510 8511**示例:** 8512 8513```ts 8514import { BusinessError } from '@kit.BasicServicesKit'; 8515 8516function setTimeLapseInterval(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8517 try { 8518 let interval: number = 10000; 8519 timeLapsePhotoSession.setTimeLapseInterval(interval); 8520 } catch (error) { 8521 // 失败返回错误码error.code并处理。 8522 let err = error as BusinessError; 8523 console.error(`The setTimeLapseInterval call failed. error code: ${err.code}`); 8524 } 8525} 8526``` 8527 8528### getTimeLapseRecordState<sup>12+</sup> 8529 8530getTimeLapseRecordState(): TimeLapseRecordState 8531 8532获取当前拍摄状态。 8533 8534**系统接口:** 此接口为系统接口。 8535 8536**系统能力:** SystemCapability.Multimedia.Camera.Core 8537 8538**返回值:** 8539 8540| 类型 | 说明 | 8541| ---------- | ----------------------------- | 8542| [TimeLapseRecordState](#timelapserecordstate12) | 获取当前拍摄状态。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。 | 8543 8544**错误码:** 8545 8546以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8547 8548| 错误码ID | 错误信息 | 8549| --------------- | --------------- | 8550| 202 | Not System Application. | 8551| 7400103 | Session not config. | 8552 8553**示例:** 8554 8555```ts 8556import { BusinessError } from '@kit.BasicServicesKit'; 8557 8558function getTimeLapseRecordState(timeLapsePhotoSession: camera.TimeLapsePhotoSession): camera.TimeLapseRecordState { 8559 let state = camera.TimeLapseRecordState.IDLE; 8560 try { 8561 state = timeLapsePhotoSession.getTimeLapseRecordState(); 8562 } catch (error) { 8563 // 失败返回错误码error.code并处理。 8564 let err = error as BusinessError; 8565 console.error(`The getTimeLapseRecordState call failed. error code: ${err.code}`); 8566 } 8567 return state; 8568} 8569``` 8570 8571### setTimeLapseRecordState<sup>12+</sup> 8572 8573setTimeLapseRecordState(state: TimeLapseRecordState): void 8574 8575设置当前拍摄状态。 8576 8577**系统接口:** 此接口为系统接口。 8578 8579**系统能力:** SystemCapability.Multimedia.Camera.Core 8580 8581**参数:** 8582 8583| 参数名 | 类型 | 必填 | 说明 | 8584| -------- | -------------------------------| ---- | ----------------------- | 8585| state | [TimeLapseRecordState](#timelapserecordstate12) | 是 | 拍摄状态。 | 8586 8587**错误码:** 8588 8589以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8590 8591| 错误码ID | 错误信息 | 8592| --------------- | --------------- | 8593| 202 | Not System Application. | 8594| 7400101 | Parameter missing or parameter type incorrect. | 8595| 7400103 | Session not config. | 8596 8597**示例:** 8598 8599```ts 8600import { BusinessError } from '@kit.BasicServicesKit'; 8601 8602function setTimeLapseRecordState(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8603 try { 8604 timeLapsePhotoSession.setTimeLapseRecordState(camera.TimeLapseRecordState.RECORDING); 8605 } catch (error) { 8606 // 失败返回错误码error.code并处理。 8607 let err = error as BusinessError; 8608 console.error(`The setTimeLapseRecordState call failed. error code: ${err.code}`); 8609 } 8610} 8611``` 8612 8613### getTimeLapsePreviewType<sup>12+</sup> 8614 8615getTimeLapsePreviewType(): TimeLapsePreviewType 8616 8617获取当前预览类型。 8618 8619**系统接口:** 此接口为系统接口。 8620 8621**系统能力:** SystemCapability.Multimedia.Camera.Core 8622 8623**返回值:** 8624 8625| 类型 | 说明 | 8626| ---------- | ----------------------------- | 8627| [TimeLapsePreviewType](#timelapsepreviewtype12) | 获取当前预览类型。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。 | 8628 8629**错误码:** 8630 8631以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8632 8633| 错误码ID | 错误信息 | 8634| --------------- | --------------- | 8635| 202 | Not System Application. | 8636| 7400103 | Session not config. | 8637 8638**示例:** 8639 8640```ts 8641import { BusinessError } from '@kit.BasicServicesKit'; 8642 8643function getTimeLapsePreviewType(timeLapsePhotoSession: camera.TimeLapsePhotoSession): camera.TimeLapsePreviewType { 8644 let type = camera.TimeLapsePreviewType.DARK; 8645 try { 8646 type = timeLapsePhotoSession.getTimeLapsePreviewType(); 8647 } catch (error) { 8648 // 失败返回错误码error.code并处理。 8649 let err = error as BusinessError; 8650 console.error(`The getTimeLapsePreviewType call failed. error code: ${err.code}`); 8651 } 8652 return type; 8653} 8654``` 8655 8656### setTimeLapsePreviewType<sup>12+</sup> 8657 8658setTimeLapsePreviewType(type: TimeLapsePreviewType): void 8659 8660设置当前预览类型。 8661 8662**系统接口:** 此接口为系统接口。 8663 8664**系统能力:** SystemCapability.Multimedia.Camera.Core 8665 8666**参数:** 8667 8668| 参数名 | 类型 | 必填 | 说明 | 8669| -------- | -------------------------------| ---- | ----------------------- | 8670| state | [TimeLapsePreviewType](#timelapsepreviewtype12) | 是 | 预览类型。 | 8671 8672**错误码:** 8673 8674以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8675 8676| 错误码ID | 错误信息 | 8677| --------------- | --------------- | 8678| 202 | Not System Application. | 8679| 7400101 | Parameter missing or parameter type incorrect. | 8680| 7400103 | Session not config. | 8681 8682**示例:** 8683 8684```ts 8685import { BusinessError } from '@kit.BasicServicesKit'; 8686 8687function setTimeLapsePreviewType(timeLapsePhotoSession: camera.TimeLapsePhotoSession): void { 8688 try { 8689 timeLapsePhotoSession.setTimeLapsePreviewType(camera.TimeLapsePreviewType.LIGHT); 8690 } catch (error) { 8691 // 失败返回错误码error.code并处理。 8692 let err = error as BusinessError; 8693 console.error(`The setTimeLapsePreviewType call failed. error code: ${err.code}`); 8694 } 8695} 8696``` 8697 8698## LightPaintingPhotoSession<sup>12+</sup> 8699 8700LightPaintingPhotoSession extends Session, Flash, Focus, Zoom, ColorEffect 8701 8702流光快门拍照模式会话类,继承自[Session](arkts-apis-camera-Session.md),用于设置流光快门拍照模式的参数以及保存所需要的所有资源[CameraInput](arkts-apis-camera-CameraInput.md)、[CameraOutput](arkts-apis-camera-CameraOutput.md)。 8703 8704### on('error')<sup>12+</sup> 8705 8706on(type: 'error', callback: ErrorCallback): void 8707 8708监听流光快门拍照会话的错误事件,通过注册回调函数获取结果。使用callback异步回调。 8709 8710**系统接口:** 此接口为系统接口。 8711 8712**系统能力:** SystemCapability.Multimedia.Camera.Core 8713 8714**参数:** 8715 8716| 参数名 | 类型 | 必填 | 说明 | 8717|----------|---------------------------------------------------------------------------|-----|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------| 8718| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。session调用相关接口出现错误时会触发该事件,比如调用[beginConfig](arkts-apis-camera-Session.md#beginconfig11),[commitConfig](arkts-apis-camera-Session.md#commitconfig11-1),[addInput](arkts-apis-camera-Session.md#addinput11)等接口发生错误时返回错误信息。 | 8719| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode)。 | 8720 8721**错误码:** 8722 8723以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8724 8725| 错误码ID | 错误信息 | 8726|-------|----------------------------| 8727| 202 | Not System Application. | 8728 8729**示例:** 8730 8731```ts 8732import { BusinessError } from '@kit.BasicServicesKit'; 8733 8734function callback(err: BusinessError): void { 8735 console.error(`LightPaintingPhotoSession error code: ${err.code}`); 8736} 8737 8738function registerSessionError(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): void { 8739 lightPaintingPhotoSession.on('error', callback); 8740} 8741``` 8742 8743### off('error')<sup>12+</sup> 8744 8745off(type: 'error', callback?: ErrorCallback): void 8746 8747注销监听流光快门拍照会话的错误事件,通过注册回调函数获取结果。 8748 8749**系统接口:** 此接口为系统接口。 8750 8751**系统能力:** SystemCapability.Multimedia.Camera.Core 8752 8753**参数:** 8754 8755| 参数名 | 类型 | 必填 | 说明 | 8756|----------|---------------------------------------------------------------------------|----|-------------------------------------------------------------| 8757| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。 | 8758| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | 否 | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 | 8759 8760**错误码:** 8761 8762以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8763 8764| 错误码ID | 错误信息 | 8765|-------|----------------------------| 8766| 202 | Not System Application. | 8767 8768**示例:** 8769 8770```ts 8771function unregisterSessionError(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): void { 8772 lightPaintingPhotoSession.off('error'); 8773} 8774``` 8775 8776### on('focusStateChange')<sup>12+</sup> 8777 8778on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void 8779 8780监听相机对焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 8781 8782**系统接口:** 此接口为系统接口。 8783 8784**系统能力:** SystemCapability.Multimedia.Camera.Core 8785 8786**参数:** 8787 8788| 参数名 | 类型 | 必填 | 说明 | 8789|-----------|---------------------------------------------|----|-------------------------------------------------------------------------| 8790| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。仅当自动对焦模式时,且相机对焦状态发生改变时可触发该事件。 | 8791| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.md#focusstate)\> | 是 | 回调函数,用于获取当前对焦状态。 | 8792 8793**错误码:** 8794 8795以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8796 8797| 错误码ID | 错误信息 | 8798|-------|----------------------------| 8799| 202 | Not System Application. | 8800 8801**示例:** 8802 8803```ts 8804import { BusinessError } from '@kit.BasicServicesKit'; 8805 8806function callback(err: BusinessError, focusState: camera.FocusState): void { 8807 if (err !== undefined && err.code !== 0) { 8808 console.error(`Callback Error, errorCode: ${err.code}`); 8809 return; 8810 } 8811 console.info(`Focus state: ${focusState}`); 8812} 8813 8814function registerFocusStateChange(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): void { 8815 lightPaintingPhotoSession.on('focusStateChange', callback); 8816} 8817``` 8818 8819### off('focusStateChange')<sup>12+</sup> 8820 8821off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void 8822 8823注销监听相机对焦的状态变化。 8824 8825**系统接口:** 此接口为系统接口。 8826 8827**系统能力:** SystemCapability.Multimedia.Camera.Core 8828 8829**参数:** 8830 8831| 参数名 | 类型 | 必填 | 说明 | 8832|-----------|---------------------------------------------|----|--------------------------------------------------------------| 8833| type | string | 是 | 监听事件,固定为'focusStateChange',session创建成功可监听。 | 8834| callback | AsyncCallback\<[FocusState](arkts-apis-camera-e.md#focusstate)\> | 否 | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 | 8835 8836**错误码:** 8837 8838以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8839 8840| 错误码ID | 错误信息 | 8841|-------|----------------------------| 8842| 202 | Not System Application. | 8843 8844**示例:** 8845 8846```ts 8847function unregisterFocusStateChange(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): void { 8848 lightPaintingPhotoSession.off('focusStateChange'); 8849} 8850``` 8851 8852### on('smoothZoomInfoAvailable')<sup>12+</sup> 8853 8854on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void 8855 8856监听相机平滑变焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。 8857 8858**系统接口:** 此接口为系统接口。 8859 8860**系统能力:** SystemCapability.Multimedia.Camera.Core 8861 8862**参数:** 8863 8864| 参数名 | 类型 | 必填 | 说明 | 8865| -------- | ----------------------- | ---- | ------------------------ | 8866| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 8867| callback | AsyncCallback\<[SmoothZoomInfo](arkts-apis-camera-i.md#smoothzoominfo11)\> | 是 | 回调函数,用于获取当前平滑变焦状态。 | 8868 8869**错误码:** 8870 8871以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8872 8873| 错误码ID | 错误信息 | 8874|-------|----------------------------| 8875| 202 | Not System Application. | 8876 8877**示例:** 8878 8879```ts 8880import { BusinessError } from '@kit.BasicServicesKit'; 8881 8882function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void { 8883 if (err !== undefined && err.code !== 0) { 8884 console.error(`Callback Error, errorCode: ${err.code}`); 8885 return; 8886 } 8887 console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`); 8888} 8889 8890function registerSmoothZoomInfo(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): void { 8891 lightPaintingPhotoSession.on('smoothZoomInfoAvailable', callback); 8892} 8893``` 8894 8895### off('smoothZoomInfoAvailable')<sup>12+</sup> 8896 8897off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void 8898 8899注销监听相机平滑变焦的状态变化。 8900 8901**系统接口:** 此接口为系统接口。 8902 8903**系统能力:** SystemCapability.Multimedia.Camera.Core 8904 8905**参数:** 8906 8907| 参数名 | 类型 | 必填 | 说明 | 8908| -------- | ----------------------------------------- | ---- | ------------------------ | 8909| type | string | 是 | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。| 8910| callback | AsyncCallback\<[SmoothZoomInfo](arkts-apis-camera-i.md#smoothzoominfo11)\> | 否 | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 | 8911 8912**错误码:** 8913 8914以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8915 8916| 错误码ID | 错误信息 | 8917|-------|----------------------------| 8918| 202 | Not System Application. | 8919 8920**示例:** 8921 8922```ts 8923function unregisterSmoothZoomInfo(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): void { 8924 lightPaintingPhotoSession.off('smoothZoomInfoAvailable'); 8925} 8926``` 8927 8928### getLightPaintingType<sup>12+</sup> 8929 8930getLightPaintingType(): LightPaintingType 8931 8932获取当前生效的流光快门模式类型。 8933 8934**系统接口:** 此接口为系统接口。 8935 8936**系统能力:** SystemCapability.Multimedia.Camera.Core 8937 8938**返回值:** 8939| 类型 | 说明 | 8940|------------------------------------------------- | --------------------- | 8941| [LightPaintingType](#lightpaintingtype12) | 流光快门模式类型。 | 8942 8943**错误码:** 8944 8945以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8946 8947| 错误码ID | 错误信息 | 8948| --------------- | --------------- | 8949| 202 | Not System Application. | 8950| 7400103 | Session not config. | 8951 8952**示例:** 8953 8954```ts 8955function getLightPaintingType(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): camera.LightPaintingType { 8956 let type: camera.LightPaintingType = lightPaintingPhotoSession.getLightPaintingType(); 8957 return type; 8958} 8959``` 8960 8961### setLightPaintingType<sup>12+</sup> 8962 8963setLightPaintingType(type: LightPaintingType): void 8964 8965设置当前生效的流光快门模式类型。 8966 8967**系统接口:** 此接口为系统接口。 8968 8969**系统能力:** SystemCapability.Multimedia.Camera.Core 8970 8971**返回值:** 8972| 参数名 | 类型 | 必填 | 说明 | 8973| -------- | ----------------------- | ---- | ------------------- | 8974| type | [LightPaintingType](#lightpaintingtype12) | 是 | 设置流光快门模式的类型。 | 8975 8976**错误码:** 8977 8978以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 8979 8980| 错误码ID | 错误信息 | 8981| --------------- | --------------- | 8982| 202 | Not System Application. | 8983| 7400101 | Parameter missing or parameter type incorrect. | 8984| 7400103 | Session not config. | 8985 8986**示例:** 8987 8988```ts 8989import { BusinessError } from '@kit.BasicServicesKit'; 8990 8991function setLightPaintingType(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): void { 8992 try { 8993 let type: camera.LightPaintingType = camera.LightPaintingType.TRAFFIC_TRAILS; 8994 lightPaintingPhotoSession.setLightPaintingType(type); 8995 } catch (error) { 8996 // 失败返回错误码error.code并处理。 8997 let err = error as BusinessError; 8998 console.error(`The setLightPaintingType call failed. error code: ${err.code}`); 8999 } 9000} 9001``` 9002 9003### getSupportedLightPaintingTypes<sup>12+</sup> 9004 9005getSupportedLightPaintingTypes(): Array\<LightPaintingType\> 9006 9007获取当前支持的流光快门模式类型。 9008 9009**系统接口:** 此接口为系统接口。 9010 9011**系统能力:** SystemCapability.Multimedia.Camera.Core 9012 9013**返回值:** 9014| 类型 | 说明 | 9015|------------------------------------------------- | --------------------- | 9016| Array\<[LightPaintingType](#lightpaintingtype12)\> | 支持的流光快门模式类型。 | 9017 9018**错误码:** 9019 9020以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 9021 9022| 错误码ID | 错误信息 | 9023| --------------- | --------------- | 9024| 202 | Not System Application. | 9025| 7400103 | Session not config. | 9026 9027**示例:** 9028 9029```ts 9030function getSupportedLightPaintingTypes(lightPaintingPhotoSession: camera.LightPaintingPhotoSession): Array<camera.LightPaintingType> { 9031 let types: Array<camera.LightPaintingType> = lightPaintingPhotoSession.getSupportedLightPaintingTypes(); 9032 return types 9033} 9034``` 9035 9036## ColorReservationType<sup>15+</sup> 9037 9038枚举,色彩保留类型。 9039 9040**系统能力**: SystemCapability.Multimedia.Camera.Core 9041 9042| 名称 | 值 | 说明 | 9043| -------- | ---- | ---------------- | 9044| NONE | 0 | 无色彩保留效果。 | 9045| PORTRAIT | 1 | 人像留色。 | 9046 9047## ColorReservationQuery<sup>15+</sup> 9048 9049提供了查询设备支持的色彩保留类型的功能。 9050 9051### getSupportedColorReservationTypes<sup>15+</sup> 9052 9053getSupportedColorReservationTypes(): Array\<ColorReservationType\> 9054 9055获取支持的色彩保留类型列表。 9056 9057**系统接口**: 此接口为系统接口。 9058 9059**系统能力**: SystemCapability.Multimedia.Camera.Core 9060 9061**返回值**: 9062 9063| 类型 | 说明 | 9064| ------------------------------------------------------ | ------------------------ | 9065| Array<[ColorReservationType](#colorreservationtype15)> | 支持的色彩保留类型列表。 | 9066 9067**错误码**: 9068 9069以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 9070 9071| 错误码ID | 错误信息 | 9072| -------- | ----------------------- | 9073| 202 | Not System Application. | 9074| 7400103 | Session not config. | 9075 9076**示例**: 9077 9078```ts 9079import { BusinessError } from '@kit.BasicServicesKit'; 9080 9081function getSupportedColorReservationTypes(session: camera.VideoSessionForSys): Array<camera.ColorReservationType> { 9082 let colorReservationTypes: Array<camera.ColorReservationType> = []; 9083 try { 9084 colorReservationTypes = session.getSupportedColorReservationTypes(); 9085 } catch (error) { 9086 // 失败返回错误码error.code并处理。 9087 let err = error as BusinessError; 9088 console.error(`The getSupportedColorReservationTypes call failed. error code: ${err.code}`); 9089 } 9090 return colorReservationTypes; 9091} 9092``` 9093 9094## ColorReservation<sup>15+</sup> 9095 9096ColorReservation extends [ColorReservationQuery](#colorreservationquery15) 9097 9098提供了获取和设置相机色彩保留类型的方法。 9099 9100### setColorReservation<sup>15+</sup> 9101 9102setColorReservation(type: ColorReservationType): void 9103 9104设置色彩保留类型。可以先通过[getSupportedColorReservationTypes](#getsupportedcolorreservationtypes15)获取当前设备所支持的ColorReservationType。 9105 9106**系统接口**: 此接口为系统接口。 9107 9108**系统能力**: SystemCapability.Multimedia.Camera.Core 9109 9110**参数**: 9111 9112| 参数名 | 类型 | 必填 | 说明 | 9113| ------ | ----------------------------------------------- | ---- | ------------------------------------------------------------ | 9114| type | [ColorReservationType](#colorreservationtype15) | 是 | 色彩保留类型,通过[getSupportedColorReservationTypes](#getsupportedcolorreservationtypes15)接口获取。 | 9115 9116**错误码**: 9117 9118以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 9119 9120| 错误码ID | 错误信息 | 9121| -------- | ------------------------------------------------------------ | 9122| 202 | Not System Application. | 9123| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3.Parameter verification failed. | 9124| 7400102 | Operation not allowed. | 9125| 7400103 | Session not config. | 9126| 7400201 | Camera service fatal error. | 9127 9128**示例**: 9129 9130```ts 9131import { BusinessError } from '@kit.BasicServicesKit'; 9132 9133function setColorReservation(session: camera.VideoSessionForSys, type: camera.ColorReservationType): void { 9134 try { 9135 session.setColorReservation(type); 9136 } catch (error) { 9137 // 失败返回错误码error.code并处理。 9138 let err = error as BusinessError; 9139 console.error(`The setColorReservation call failed. error code: ${err.code}`); 9140 } 9141} 9142``` 9143 9144### getColorReservation<sup>15+</sup> 9145 9146getColorReservation(): ColorReservationType 9147 9148获取当前设置的色彩保留类型。 9149 9150**系统接口**: 此接口为系统接口。 9151 9152**系统能力**: SystemCapability.Multimedia.Camera.Core 9153 9154**返回值**: 9155 9156| 类型 | 说明 | 9157| ----------------------------------------------- | ------------------------ | 9158| [ColorReservationType](#colorreservationtype15) | 当前设置的色彩保留类型。 | 9159 9160**错误码**: 9161 9162以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。 9163 9164| 错误码ID | 错误信息 | 9165| -------- | ----------------------- | 9166| 202 | Not System Application. | 9167| 7400103 | Session not config. | 9168 9169**示例**: 9170 9171```ts 9172import { BusinessError } from '@kit.BasicServicesKit'; 9173 9174function getColorReservation(session: camera.VideoSessionForSys): camera.ColorReservationType | undefined { 9175 let colorReservation: camera.ColorReservationType | undefined = undefined; 9176 try { 9177 colorReservation = session.getColorReservation(); 9178 } catch (error) { 9179 // 失败返回错误码error.code并处理。 9180 let err = error as BusinessError; 9181 console.error(`The setColorReservation call failed. error code: ${err.code}`); 9182 } 9183 return colorReservation; 9184} 9185``` 9186