未验证 提交 507a0196 编写于 作者: O openharmony_ci 提交者: Gitee

!21344 camera API新增性能相关接口文档

Merge pull request !21344 from zengyawen/camera
......@@ -61,6 +61,7 @@
- 相机最佳实践
- [拍照实现方案](camera-shooting-case.md)
- [录像实现方案](camera-recording-case.md)
- [性能提升方案(仅对系统应用开放)](camera-preformance-imporvement.md)
- 图片
- [图片开发概述](image-overview.md)
- [图片解码](image-decoding.md)
......
# 性能提升方案(仅对系统应用开放)
相机启动性能受限于底层器件上电、流程Pipeline初始化等耗时操作影响,本文档将为开发者提供更进一步的指导,提升相机启动速度以及拍照返回缩略图速度。相关能力与底层器件相关,请开发者在使用前需确认是否支持相关特性。
​相关特性分别在打开相机设备过程、配流过程以及拍照过程中。本文档针对三个场景分别进行介绍。
## 延时配流
经典的相机启动过程经过“相机设备打开”、“配置数据流”、“启动数据流”等流程,而配流启流之前需要得到XComponent组件的surfaceId。
延时配流方案是把配流启流与surface解耦,在组件尚未给应用surface之前,可以先进行配流启流,只需要在启流结束之前提供surface,可以提升启动速度,防止影响其他启动优化方案的落地。
![deferred-surface-scene](figures/deferred-surface-scene.png)
优化前:配流动作依赖surface对象,surface对象依赖于UI加载完成。也就是在UI加载完成后,才可以创建Session、配置输入输出流、启动Session,由相机HDI进行配流。
优化后:配流动作不依赖surface对象,界面加载和配流并行执行。完成参数准备后,即可开始创建Session。
### 接口说明
详细的API参考说明,请参考[Camera API文档](../reference/apis/js-apis-camera.md)
| 接口 | 说明 |
| ---- | ---- |
| createDeferredPreviewOutput(profile: Profile): Promise\<PreviewOutput> | 创建延迟预览输出对象,在配流时替代普通的预览输出对象加入数据流。 |
| addDeferredSurface(surfaceId: string): Promise\<void> | 配置延迟预览的Surface,可以在session.commitConfig()配流和session.start()启流之后运行。 |
### 开发示例
接口调用流程建议如下图所示:
![](figures/deferred-surface-sequence-diagram.png)
```js
import camera from '@ohos.multimedia.camera';
function async preview(context: Context, cameraInfo: camera.Device, previewProfile: camera.Profile, photoProfile: camera.Profile, surfaceId: string): Promise<void> {
const cameraManager: camera.CameraManager = camera.getCameraManager(context);
const cameraInput camera.CameraInput = await cameraManager.createCameraInput(cameraInfo)
const previewOutput: camera.PreviewOutput = await cameraManager.createDeferredPreviewOutput(previewProfile);
const photoOutput: camera.PhotoOutput = await cameraManager.createPhotoOutput(photoProfile);
const session: camera.CaptureSession = await this.mCameraManager.createCaptureSession();
await session.beginConfig();
await session.addInput(cameraInput);
await session.addOutput(previewOutput);
await session.addOutput(photoOutput);
await session.commitConfig();
await session.start();
await previewOutput.addDeferredSurface(surfaceId);
}
```
## 快速缩略图
相机拍照性能依赖算法处理的速度,算法链越复杂、效果就越好,但同时处理时间就越长。
通过相机快速缩略图,相机拍照可单独输出拇指缩略图,在真图没有上报之前,可以提前上报一张缩略图给应用去做显示,提升shot2see用户感知拍照速度。
这样从拍照流程上进行优化,既可以满足后处理算法处理的要求,又不会阻塞前台的拍照速度。
### 接口说明
详细的API参考说明,请参考[Camera API文档](../reference/apis/js-apis-camera.md)
| 接口 | 说明 |
| ---- | ---- |
| isQuickThumbnailSupported() : boolean | 是否支持快速缩略图。 |
| enableQuickThumbnail(enabled:bool): void | 使能/去使能快速缩略图。 |
| on(type: 'quickThumbnail', callback: AsyncCallback\<image.PixelMap>): void | 相机缩略图监听回调。 |
> **说明:**
>
> - isQuickThumbnailSupported及enableQuickThumbnail接口的调用需要在CaptureSession.addOutput、CaptureSession.addInput后,CaptureSession.commitConfig()之前。
> - on接口需要在enableQuickThumbnail(true)之后生效。
### 开发示例
接口调用流程建议如下图所示:
![](figures/quick-thumbnail-sequence-diagram.png)
```js
import camera from '@ohos.multimedia.camera'
this.cameraManager = camera.getCameraManager(globalThis.abilityContext);
let cameras = this.cameraManager.getSupportedCameras()
// 创建CaptureSession实例
this.captureSession = await this.cameraManager.createCaptureSession()
// 开始配置会话
await this.captureSession.beginConfig()
// 把CameraInput加入到会话
this.cameraInput = await this.cameraManager.createCameraInput(cameras[0])
await this.cameraInput.open()
await this.captureSession.addInput(this.cameraInput)
// 把PhotoOutPut加入到会话
this.photoOutPut = await this.cameraManager.createPhotoOutput(photoProfile, surfaceId)
await this.captureSession.addOutput(this.photoOutPut)
boolean isSupported = this.photoOutPut.isQuickThumbnailSupported()
if (isSupported) {
// 使能快速缩略图
this.photoOutPut.enableQuickThumbnail(true)
this.photoOutPut.on('quickThumbnail', (err, pixelmap) => {
if (err || pixelmap === undefined) {
Logger.error(this.tag, 'photoOutPut on thumbnail failed ')
return
}
// 显示或保存pixelmap
this.showOrSavePicture(pixelmap)
})
}
```
## 预热启动
普通情况下相机应用的启动是用户通过点击桌面相机图标触发的。桌面应用感知用户点击相机图标,然后通知应用管理器启动对应的相机应用(进程),这个过程是耗时较长。进入相机应用后,开始进入相机启动流程。经典的相机启动过程会经过,“相机设备打开”,“配置数据流”,“启动数据流等”,这个过程也较为耗时。
​相机启动方案是把“相机设备打开”这个动作提前到相机应用启动之前,即在用户点击相机图标,
还没等相机应用启动的时候,触发相机设备打开的动作,从而缩短相机应用内启动相机的流程,加速相机启动。使用预热启动前后的相机应用流程对比如下:
![prelaunch-scene](figures/prelaunch-scene.png)
### 接口说明
详细的API参考说明,请参考[Camera API文档](../reference/apis/js-apis-camera.md)
| 接口 | 说明 |
| ---- | ---- |
| isPreLaunchSupported(camera: CameraDevice) : boolean | 判断指定cameraDevice是否支持预热启动。 |
| setPreLaunchConfig(preLaunchConfig: PreLaunchConfig) : void | 配置相机预热参数。 |
| preLaunch() : void | 用户点击系统相机图标,拉起相机应用的同时调用,下发预热请求,使能相机预热启动。 |
### 开发示例
接口调用流程建议如下图所示:
![](figures/prelaunch-sequence-diagram.png)
- **桌面应用**
```js
import camera from '@ohos.multimedia.camera'
this.cameraManager = camera.getCameraManager(globalThis.abilityContext);
try {
this.cameraManager.preLaunch();
} catch (error) {
console.error(`catch error: Code: ${error.code}, message: ${error.message}`)
}
```
- **相机应用**
使用该功能前,应用需要**申请权限**:ohos.permission.CAMERA
具体申请方式及校验方式,请参考[访问控制授权申请指导](../security/accesstoken-guidelines.md)
```js
import camera from '@ohos.multimedia.camera'
this.cameraManager = camera.getCameraManager(globalThis.abilityContext);
let cameras = this.cameraManager.getSupportedCameras()
if(this.cameraManager.isPreLaunchSupported(cameras[0])) {
try {
this.cameraManager.setPreLaunchConfig({cameraDevice: cameras[0]});
} catch (error) {
console.error(`catch error: Code: ${error.code}, message: ${error.message}`)
}
}
```
......@@ -2,7 +2,7 @@
> **说明:**
>
> - 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块
......@@ -582,6 +582,148 @@ cameraManager.on('cameraMute', (err, curMuetd) => {
})
```
### isPreLaunchSupported
isPreLaunchSupported(camera: CameraDevice): boolean
在setPreLaunchConfig接口使用前调用,用于判断指定cameraDevice是否支持预热启动。
**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------- | ---- | --------- |
| camera | [CameraDevice](#cameradevice) | 是 | 相机信息。|
**返回值:**
| 类型 | 说明 |
| -------- | --------------- |
| boolean | 返回指定cameraDevice是否支持预热启动。|
**错误码:**
以下错误码的详细介绍请参见相机错误码。
| 错误码ID | 错误信息 |
| --------------- | --------------- |
| 7400101 | Parameter missing or parameter type incorrect. |
**示例:**
```js
this.cameraManager = camera.getCameraManager(globalThis.abilityContext);
let cameras = this.cameraManager.getSupportedCameras()
if(this.cameraManager.isPreLaunchSupported(cameras[0])) {
this.cameraManager.setPreLaunchConfig({cameraDevice: cameras[0]});
}
```
### setPreLaunchConfig
setPreLaunchConfig(preLaunchConfig: PreLaunchConfig): void
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.CAMERA
**系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------- | ---- | --------- |
| preLaunchConfig | [PreLaunchConfig](#prelaunchconfig) | 是 | 预启动配置参数。|
**错误码:**
以下错误码的详细介绍请参见相机错误码。
| 错误码ID | 错误信息 |
| --------------- | --------------- |
| 7400101 | Parameter missing or parameter type incorrect. |
| 7400102 | Operation not allow. |
**示例:**
```js
this.cameraManager = camera.getCameraManager(globalThis.abilityContext);
let cameras = this.cameraManager.getSupportedCameras()
```
### preLaunch
preLaunch(): void
用户点击系统相机图标,拉起相机应用同时调用,下发预热请求,使能相机预热启动。
**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Multimedia.Camera.Core
**示例:**
```js
this.cameraManager = camera.getCameraManager(globalThis.abilityContext);
```
### createDeferredPreviewOutput
createDeferredPreviewOutput(profile: Profile): PreviewOutput
创建延迟预览输出对象,在配流时替代普通的预览输出对象加入数据流。
**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------- | ---- | --------- |
| profile | [Profile](#profile) | 是 | 相机预览流的配置文件。 |
**返回值:**
| 类型 | 说明 |
| -------- | --------------- |
| [PreviewOutput](#previewoutput) | 返回预览输出对象。 |
**错误码:**
以下错误码的详细介绍请参见相机错误码。
| 错误码ID | 错误信息 |
| --------------- | --------------- |
| 7400101 | Parameter missing or parameter type incorrect. |
**示例:**
```js
function getDeferredPreviewOutput(context: Context, previewProfile: camera.Profile): Promise<PreviewOutput> {
const cameraManager = camera.getCameraManager(context);
const output: Promise<PreviewOutput> = cameraManager.createDeferredPreviewOutput(previewProfile);
return output;
}
```
## PreLaunchConfig
相机预启动配置参数。
当前sensor级别预热,待扩展流预热参数。
**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Multimedia.Camera.Core
| 名称 | 类型 | 必填 | 说明 |
| ------ | ----------------------------- | -------------- | ---------- |
| cameraDevice | [CameraDevice](#cameradevice) | 是 | 相机信息。 |
## CameraStatusInfo
相机管理器回调返回的接口实例,表示相机状态信息。
......@@ -836,7 +978,7 @@ cameraInput.close().then(() => {
### on('error')
on(type: 'error', camera:CameraDevice, callback: ErrorCallback\<BusinessError\>): void
on(type: 'error', camera:CameraDevice, callback: ErrorCallback): void
监听CameraInput的错误事件,通过注册回调函数获取结果。
......@@ -848,7 +990,7 @@ on(type: 'error', camera:CameraDevice, callback: ErrorCallback\<BusinessError\>)
| -------- | -------------------------------- | --- | ------------------------------------------- |
| type | string | 是 | 监听事件,固定为'error',CameraInput对象创建成功可监听。相机设备出错情况下可触发该事件并返回结果,比如(设备不可用或者冲突等返回对应错误信息) |
| cameraDevice | [CameraDevice](#cameradevice) | 是 | CameraDevice对象。 |
| callback | ErrorCallback\<BusinessError\> | 是 | 回调函数,用于获取结果。返回错误码,错误码类型[CameraErrorCode](#cameraerrorcode) |
| callback | ErrorCallback | 是 | 回调函数,用于获取结果。返回错误码,错误码类型[CameraErrorCode](#cameraerrorcode) |
**示例:**
......@@ -883,7 +1025,7 @@ cameraInput.on('error', cameraDevice, (error) => {
| EXPOSURE_MODE_AUTO | 1 | 自动曝光模式。支持曝光区域中心点设置,可以使用[setMeteringPoint](#setmeteringpoint)设置曝光区域中心点。 |
| EXPOSURE_MODE_CONTINUOUS_AUTO | 2 | 连续自动曝光。不支持曝光区域中心点设置。 |
## FocusMode
## FocusMode
枚举,焦距模式。
......@@ -2290,7 +2432,7 @@ captureSession.on('focusStateChange', (err, focusState) => {
### on('error')
on(type: 'error', callback: ErrorCallback\<BusinessError\>): void
on(type: 'error', callback: ErrorCallback): void
监听拍照会话的错误事件,通过注册回调函数获取结果。
......@@ -2301,7 +2443,7 @@ on(type: 'error', callback: ErrorCallback\<BusinessError\>): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------------------------------------- | ---- | ------------------------------ |
| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。session调用相关接口出现错误时会触发该事件,比如调用(beginConfig(),commitConfig(),addInput)等接口发生错误时返回错误信息。 |
| callback | ErrorCallback\<BusinessError\> | 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](#cameraerrorcode) |
| callback | ErrorCallback| 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](#cameraerrorcode) |
**示例:**
......@@ -2549,7 +2691,7 @@ previewOutput.on('frameEnd', () => {
### on('error')
on(type: 'error', callback: ErrorCallback\<BusinessError\>): void
on(type: 'error', callback: ErrorCallback): void
监听预览输出的错误事件,通过注册回调函数获取结果。
......@@ -2560,7 +2702,7 @@ on(type: 'error', callback: ErrorCallback\<BusinessError\>): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------| ---- | ------------------------ |
| type | string | 是 | 监听事件,固定为'error',previewOutput创建成功可监听。预览接口使用错误时触发该事件,比如调用(start(),release())等接口发生错误时返回对应错误信息。|
| callback | ErrorCallback\<BusinessError\> | 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](#cameraerrorcode) |
| callback | ErrorCallback | 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](#cameraerrorcode) |
**示例:**
......@@ -2570,6 +2712,49 @@ previewOutput.on('error', (previewOutputError) => {
})
```
### addDeferredSurface
addDeferredSurface(surfaceId: string): void
配置延迟预览的Surface,可以在session.commitConfig()配流和session.start()启流之后运行。
**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------| ---- | ------------------------ |
| surfaceId | string | 是 | 从[XComponent](../arkui-ts/ts-basic-components-xcomponent.md)组件获取的surfaceId。|
**错误码:**
以下错误码的详细介绍请参见相机错误码
| 错误码ID | 错误信息 |
| --------------- | --------------- |
| 7400101 | Parameter missing or parameter type incorrect |
**示例:**
```js
function async preview(context: Context, cameraInfo: camera.Device, previewProfile: camera.Profile, photoProfile: camera.Profile, surfaceId: string): Promise<void> {
const cameraManager: camera.CameraManager = camera.getCameraManager(context);
const cameraInput camera.CameraInput = await cameraManager.createCameraInput(cameraInfo)
const previewOutput: camera.PreviewOutput = await cameraManager.createDeferredPreviewOutput(previewProfile);
const photoOutput: camera.PhotoOutput = await cameraManager.createPhotoOutput(photoProfile);
const session: camera.CaptureSession = await this.mCameraManager.createCaptureSession();
await session.beginConfig();
await session.addInput(cameraInput);
await session.addOutput(previewOutput);
await session.addOutput(photoOutput);
await session.commitConfig();
await session.start();
await previewOutput.addDeferredSurface(surfaceId);
}
```
## ImageRotation
枚举,图片旋转角度。
......@@ -2951,7 +3136,7 @@ photoOutput.on('captureEnd', (err, captureEndInfo) => {
### on('error')
on(type: 'error', callback: ErrorCallback\<BusinessError\>): void
on(type: 'error', callback: ErrorCallback): void
监听拍照输出发生错误,通过注册回调函数获取结果。
......@@ -2962,7 +3147,7 @@ on(type: 'error', callback: ErrorCallback\<BusinessError\>): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------- | ---- | ----------------------------------- |
| type | string | 是 | 监听事件,固定为'error',photoOutput创建成功后可监听。拍照接口调用时出现错误触发该事件并返回错误信息。 |
| callback | ErrorCallback\<BusinessError\> | 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](#cameraerrorcode) |
| callback | ErrorCallback | 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](#cameraerrorcode) |
**示例:**
......@@ -2972,6 +3157,153 @@ photoOutput.on('error', (error) => {
})
```
### isQuickThumbnailSupported
isQuickThumbnailSupported(): boolean
是否支持输出快速缩略图。
在CaptureSession.addOutput、CaptureSession.addInput之后,CaptureSession.commitConfig之前生效。
**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Multimedia.Camera.Core
**返回值:**
| 类型 | 说明 |
| --------- | ------ |
| boolean | 返回支持情况,如果返回true表示支持,否则不支持。 |
**错误码:**
以下错误码的详细介绍请参见相机错误码
| 错误码ID | 错误信息 |
| --------------- | --------------- |
| 7400101 | Parameter missing or parameter type incorrect |
**示例:**
```js
this.cameraManager = camera.getCameraManager(globalThis.abilityContext);
let cameras = this.cameraManager.getSupportedCameras()
// 创建CaptureSession实例
this.captureSession = await this.cameraManager.createCaptureSession()
// 开始配置会话
await this.captureSession.beginConfig()
// 把CameraInput加入到会话
this.mCameraInput = await this.cameraManager.createCameraInput(cameras[0])
await this.cameraInput.open()
await this.captureSession.addInput(this.cameraInput)
// 把PhotoOutPut加入到会话
this.photoOutPut = await this.cameraManager.createPhotoOutput(photoProfile, surfaceId)
await this.captureSession.addOutput(this.photoOutPut)
boolean isSupported = this.photoOutPut.isQuickThumbnailSupported()
```
### enableQuickThumbnail
enableQuickThumbnail(enabled: boolean): void
使能/去使能快速缩略图。
在CaptureSession.addOutput、CaptureSession.addInput之后,CaptureSession.commitConfig之前生效。
**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------- | ---- | ----------------------------------- |
| enabled | boolean | 是 | true:使能快速缩略图;false:去使能快速缩略图。 |
**错误码:**
以下错误码的详细介绍请参见相机错误码
| 错误码ID | 错误信息 |
| --------------- | --------------- |
| 7400101 | Parameter missing or parameter type incorrect |
**示例:**
```js
this.cameraManager = camera.getCameraManager(globalThis.abilityContext);
let cameras = this.cameraManager.getSupportedCameras()
// 创建CaptureSession实例
this.captureSession = await this.cameraManager.createCaptureSession()
// 开始配置会话
await this.captureSession.beginConfig()
// 把CameraInput加入到会话
this.cameraInput = await this.cameraManager.createCameraInput(cameras[0])
await this.cameraInput.open()
await this.captureSession.addInput(this.cameraInput)
// 把PhotoOutPut加入到会话
this.photoOutPut = await this.cameraManager.createPhotoOutput(photoProfile, surfaceId)
await this.captureSession.addOutput(this.photoOutPut)
boolean isSupported = this.photoOutPut.isQuickThumbnailSupported()
if (isSupported) {
// 使能快速缩略图
this.photoOutPut.enableQuickThumbnail(true)
}
```
### on('quickThumbnail')
on(type: 'quickThumbnail', callback: AsyncCallback\<image.PixelMap>): void
监听快速缩略图输出事件。
在enableQuickThumbnail(true)使能快速缩略图之后监听生效。
**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------- | ---- | ----------------------------------- |
| type | string | 是 | 监听事件,固定为'quickThumbnail'。 |
| callback | AsyncCallback\<[image.PixelMap](js-apis-image.md#pixelmap7)> | 回调返回PixelMap。 |
**示例:**
```js
import camera from '@ohos.multimedia.camera'
this.cameraManager = camera.getCameraManager(globalThis.abilityContext);
let cameras = this.cameraManager.getSupportedCameras()
// 创建CaptureSession实例
this.captureSession = await this.cameraManager.createCaptureSession()
// 开始配置会话
await this.captureSession.beginConfig()
// 把CameraInput加入到会话
this.cameraInput = await this.cameraManager.createCameraInput(cameras[0])
await this.cameraInput.open()
await this.captureSession.addInput(this.cameraInput)
// 把PhotoOutPut加入到会话
this.photoOutPut = await this.cameraManager.createPhotoOutput(photoProfile, surfaceId)
await this.captureSession.addOutput(this.photoOutPut)
boolean isSupported = this.photoOutPut.isQuickThumbnailSupported()
if (isSupported) {
// 使能快速缩略图
this.photoOutPut.enableQuickThumbnail(true)
}
this.photoOutPut.on('quickThumbnail', (err, pixelmap) => {
if (err || pixelmap === undefined) {
Logger.error(this.tag, 'photoOutPut on thumbnail failed ')
return
}
// 显示或保存pixelmap
this.showOrSavePicture(pixelmap)
})
```
## FrameShutterInfo
拍照帧输出信息。
......@@ -3230,7 +3562,7 @@ videoOutput.on('frameEnd', () => {
### on('error')
on(type: 'error', callback: ErrorCallback\<BusinessError\>): void
on(type: 'error', callback: ErrorCallback): void
监听录像输出发生错误,通过注册回调函数获取结果。
......@@ -3241,7 +3573,7 @@ on(type: 'error', callback: ErrorCallback\<BusinessError\>): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------- | ---- | -------------------------------------- |
| type | string | 是 | 监听事件,固定为'error',videoOutput创建成功后可监听。录像接口调用出现错误时触发该事件并返回对应错误码,比如调用(start(),release())接口时出现错误返回对应错误信息。 |
| callback | Callback\<BusinessError\> | 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](#cameraerrorcode) |
| callback | ErrorCallback | 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](#cameraerrorcode) |
**示例:**
......@@ -3398,7 +3730,7 @@ metadataOutput.on('metadataObjectsAvailable', (err, metadataObjectArr) => {
### on('error')
on(type: 'error', callback: ErrorCallback\<BusinessError\>): void
on(type: 'error', callback: ErrorCallback): void
监听metadata流的错误,通过注册回调函数获取结果。
......@@ -3409,7 +3741,7 @@ on(type: 'error', callback: ErrorCallback\<BusinessError\>): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------- | ---- | --------------------------------------- |
| type | string | 是 | 监听事件,固定为'error',metadataOutput创建成功后可监听。metadata接口使用错误时触发该事件并返回对应错误码,比如调用(start(),release())接口时发生错误返回对应错误信息。 |
| callback | Callback\<BusinessError\> | 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](#cameraerrorcode) |
| callback | ErrorCallback | 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](#cameraerrorcode) |
**示例:**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册