提交 f2a43b77 编写于 作者: M mali

Camera development and interface document update

Signed-off-by: Nmali <mali81@huawei.com>
上级 a0f765fa
...@@ -8,7 +8,7 @@ OpenHarmony相机模块支持相机业务的开发,开发者可以通过已开 ...@@ -8,7 +8,7 @@ OpenHarmony相机模块支持相机业务的开发,开发者可以通过已开
- **相机静态能力**:用于描述相机的固有能力的一系列参数,比如朝向、支持的分辨率等信息。 - **相机静态能力**:用于描述相机的固有能力的一系列参数,比如朝向、支持的分辨率等信息。
- **物理相机**:物理相机就是独立的实体摄像头设备。物理相机ID是用于标志每个物理摄像头的唯一字串。 - **物理相机**:物理相机就是独立的实体摄像头设备。物理相机ID是用于标志每个物理摄像头的唯一字串。
- **异步操作**:为保证UI线程不被阻塞,大部分Camera调用都是异步的。对于每个API均提供了callback函数和Promise函数。 - **异步操作**:为保证UI线程不被阻塞,部分Camera接口采用异步调用方式。异步方式API均提供了callback函数和Promise函数。
## 开发步骤 ## 开发步骤
...@@ -60,36 +60,46 @@ import media from '@ohos.multimedia.media' ...@@ -60,36 +60,46 @@ import media from '@ohos.multimedia.media'
// 创建CameraManager对象 // 创建CameraManager对象
context: any = getContext(this) context: any = getContext(this)
let cameraManager = await camera.getCameraManager(this.context) let cameraManager
if (!cameraManager) { try {
cameraManager = camera.getCameraManager(this.context);
} catch (error) {
console.error('Failed to get the CameraManager instance'); console.error('Failed to get the CameraManager instance');
} }
// 获取相机列表 // 获取相机列表
let cameraArray = await cameraManager.getSupportedCameras() let cameraArray
if (!cameraArray) { try {
console.error('Failed to get the cameras'); cameraArray = cameraManager.getSupportedCameras();
} catch (error) {
console.error('Failed to get the cameras errorCode = ' + error.code);
} }
for (let index = 0; index < cameraArray.length; index++) { for (let index = 0; index < cameraArray.length; index++) {
console.log('cameraId : ' + cameraArray[index].cameraId) // 获取相机ID console.log('cameraId : ' + cameraArray[index].cameraId); // 获取相机ID
console.log('cameraPosition : ' + cameraArray[index].cameraPosition) // 获取相机位置 console.log('cameraPosition : ' + cameraArray[index].cameraPosition); // 获取相机位置
console.log('cameraType : ' + cameraArray[index].cameraType) // 获取相机类型 console.log('cameraType : ' + cameraArray[index].cameraType); // 获取相机类型
console.log('connectionType : ' + cameraArray[index].connectionType) // 获取相机连接类型 console.log('connectionType : ' + cameraArray[index].connectionType); // 获取相机连接类型
} }
// 创建相机输入流 // 创建相机输入流
let cameraInput = await cameraManager.createCameraInput(cameraArray[0]) let cameraInput
try {
cameraInput = cameraManager.createCameraInput(cameraArray[0]);
} catch () {
console.error('Failed to createCameraInput errorCode = ' + error.code);
}
// 打开相机 // 打开相机
await cameraInput.open(); await cameraInput.open();
// 获取相机设备支持的输出流能力 // 获取相机设备支持的输出流能力
let cameraOutputCap = await cameraManager.getSupportedOutputCapability(cameraArray[0]); let cameraOutputCap
if (!cameraOutputCap) { try {
console.error("outputCapability outputCapability == null || undefined") cameraOutputCap = cameraManager.getSupportedOutputCapability(cameraArray[0]);
} else {
console.info("outputCapability: " + JSON.stringify(cameraOutputCap)); console.info("outputCapability: " + JSON.stringify(cameraOutputCap));
} catch (error) {
console.error("outputCapability outputCapability == null || undefined")
} }
let previewProfilesArray = cameraOutputCap.GetPreviewProfiles(); let previewProfilesArray = cameraOutputCap.GetPreviewProfiles();
...@@ -113,8 +123,10 @@ if (!metadataObjectTypesArray) { ...@@ -113,8 +123,10 @@ if (!metadataObjectTypesArray) {
} }
// 创建预览输出流,其中参数 surfaceId 参考下面 XComponent 组件,预览流为XComponent组件提供的surface // 创建预览输出流,其中参数 surfaceId 参考下面 XComponent 组件,预览流为XComponent组件提供的surface
let previewOutput = await cameraManager.createPreviewOutput(previewProfilesArray[0], surfaceId) let previewOutput
if (!previewOutput) { try {
previewOutput = cameraManager.createPreviewOutput(previewProfilesArray[0], surfaceId)
} catch (error) {
console.error("Failed to create the PreviewOutput instance.") console.error("Failed to create the PreviewOutput instance.")
} }
...@@ -123,10 +135,11 @@ let imageReceiver = await image.createImageReceiver(1920, 1080, 4, 8) ...@@ -123,10 +135,11 @@ let imageReceiver = await image.createImageReceiver(1920, 1080, 4, 8)
// 获取照片显示SurfaceId // 获取照片显示SurfaceId
let photoSurfaceId = await imageReceiver.getReceivingSurfaceId() let photoSurfaceId = await imageReceiver.getReceivingSurfaceId()
// 创建拍照输出流 // 创建拍照输出流
let photoOutput = await cameraManager.createPhotoOutput(photoProfilesArray[0], photoSurfaceId) let photoOutput
if (!photoOutput) { try {
console.error('Failed to create the PhotoOutput instance.'); photoOutput = cameraManager.createPhotoOutput(photoProfilesArray[0], photoSurfaceId)
return; } catch (error) {
console.error('Failed to createPhotoOutput errorCode = ' + error.code);
} }
// 创建视频录制的参数 // 创建视频录制的参数
...@@ -169,10 +182,11 @@ videoRecorder.getInputSurface().then((id) => { ...@@ -169,10 +182,11 @@ videoRecorder.getInputSurface().then((id) => {
}) })
// 创建VideoOutput对象 // 创建VideoOutput对象
let videoOutput = await cameraManager.createVideoOutput(videoProfilesArray[0], videoSurfaceId) let videoOutput
if (!videoOutput) { try {
console.error('Failed to create the videoOutput instance.'); videoOutput = cameraManager.createVideoOutput(videoProfilesArray[0], videoSurfaceId)
return; } catch (error) {
console.error('Failed to create the videoOutput instance. errorCode = ' + error.code);
} }
``` ```
预览流、拍照流和录像流的输入均需要提前创建surface,其中预览流为XComponent组件提供的surface,拍照流为ImageReceiver提供的surface,录像流为VideoRecorder的surface。 预览流、拍照流和录像流的输入均需要提前创建surface,其中预览流为XComponent组件提供的surface,拍照流为ImageReceiver提供的surface,录像流为VideoRecorder的surface。
...@@ -247,24 +261,40 @@ function getVideoRecorderSurface() { ...@@ -247,24 +261,40 @@ function getVideoRecorderSurface() {
```typescript ```typescript
//创建会话 //创建会话
let captureSession = await camera.createCaptureSession() let captureSession
if (!captureSession) { try {
console.error('Failed to create the CaptureSession instance.'); captureSession = cameraManager.createCaptureSession()
return; } catch (error) {
console.error('Failed to create the CaptureSession instance. errorCode = ' + error.code);
} }
console.log('Callback returned with the CaptureSession instance.' + session);
// 开始配置会话 // 开始配置会话
await captureSession.beginConfig() try {
captureSession.beginConfig()
} catch (error) {
console.error('Failed to beginConfig. errorCode = ' + error.code);
}
// 向会话中添加相机输入流 // 向会话中添加相机输入流
await captureSession.addInput(cameraInput) try {
captureSession.addInput(cameraInput)
} catch (error) {
console.error('Failed to addInput. errorCode = ' + error.code);
}
// 向会话中添加预览输入流 // 向会话中添加预览输入流
await captureSession.addOutput(previewOutput) try {
captureSession.addOutput(previewOutput)
} catch (error) {
console.error('Failed to addOutput(previewOutput). errorCode = ' + error.code);
}
// 向会话中添加拍照输出流 // 向会话中添加拍照输出流
await captureSession.addOutput(photoOutput) try {
captureSession.addOutput(photoOutput)
} catch (error) {
console.error('Failed to addOutput(photoOutput). errorCode = ' + error.code);
}
// 提交会话配置 // 提交会话配置
await captureSession.commitConfig() await captureSession.commitConfig()
...@@ -282,13 +312,25 @@ await captureSession.start().then(() => { ...@@ -282,13 +312,25 @@ await captureSession.start().then(() => {
await captureSession.stop() await captureSession.stop()
// 开始配置会话 // 开始配置会话
await captureSession.beginConfig() try {
captureSession.beginConfig()
} catch (error) {
console.error('Failed to beginConfig. errorCode = ' + error.code);
}
// 从会话中移除拍照输出流 // 从会话中移除拍照输出流
await captureSession.removeOutput(photoOutput) try {
captureSession.removeOutput(photoOutput)
} catch (error) {
console.error('Failed to removeOutput(photoOutput). errorCode = ' + error.code);
}
// 向会话中添加录像输出流 // 向会话中添加录像输出流
await captureSession.addOutput(videoOutput) try {
captureSession.addOutput(videoOutput)
} catch (error) {
console.error('Failed to addOutput(videoOutput). errorCode = ' + error.code);
}
// 提交会话配置 // 提交会话配置
await captureSession.commitConfig() await captureSession.commitConfig()
...@@ -303,71 +345,65 @@ await captureSession.start().then(() => { ...@@ -303,71 +345,65 @@ await captureSession.start().then(() => {
```typescript ```typescript
// 判断设备是否支持闪光灯 // 判断设备是否支持闪光灯
let flashStatus = await captureSession.hasFlash() let flashStatus
if (!flashStatus) { try {
console.error('Failed to check whether the device has the flash mode.'); flashStatus = captureSession.hasFlash()
} catch (error) {
console.error('Failed to hasFlash. errorCode = ' + error.code);
} }
console.log('Promise returned with the flash light support status:' + flashStatus); console.log('Promise returned with the flash light support status:' + flashStatus);
if (flashStatus) { if (flashStatus) {
// 判断是否支持自动闪光灯模式 // 判断是否支持自动闪光灯模式
let flashModeStatus let flashModeStatus
captureSession.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO, async (err, status) => { try {
if (err) { let status = captureSession.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO)
console.error('Failed to check whether the flash mode is supported. ${err.message}');
return;
}
console.log('Callback returned with the flash mode support status: ' + status);
flashModeStatus = status flashModeStatus = status
}) } catch (error) {
console.error('Failed to check whether the flash mode is supported. errorCode = ' + error.code);
}
if(flashModeStatus) { if(flashModeStatus) {
// 设置自动闪光灯模式 // 设置自动闪光灯模式
captureSession.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO, async (err) => { try {
if (err) { captureSession.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO)
console.error('Failed to set the flash mode ${err.message}'); } catch (error) {
return; console.error('Failed to set the flash mode. errorCode = ' + error.code);
} }
console.log('Callback returned with the successful execution of setFlashMode.');
})
} }
} }
// 判断是否支持连续自动变焦模式 // 判断是否支持连续自动变焦模式
let focusModeStatus let focusModeStatus
captureSession.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_CONTINUOUS_AUTO, async (err, status) => { try {
if (err) { let status = captureSession.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_CONTINUOUS_AUTO)
console.error('Failed to check whether the focus mode is supported. ${err.message}');
return;
}
console.log('Callback returned with the focus mode support status: ' + status);
focusModeStatus = status focusModeStatus = status
}) } catch (error) {
console.error('Failed to check whether the focus mode is supported. errorCode = ' + error.code);
}
if (focusModeStatus) { if (focusModeStatus) {
// 设置连续自动变焦模式 // 设置连续自动变焦模式
captureSession.setFocusMode(camera.FocusMode.FOCUS_MODE_CONTINUOUS_AUTO, async (err) => { try {
if (err) { captureSession.setFocusMode(camera.FocusMode.FOCUS_MODE_CONTINUOUS_AUTO)
console.error('Failed to set the focus mode ${err.message}'); } catch (error) {
return; console.error('Failed to set the focus mode. errorCode = ' + error.code);
} }
console.log('Callback returned with the successful execution of setFocusMode.');
})
} }
// 获取相机支持的可变焦距比范围 // 获取相机支持的可变焦距比范围
let zoomRatioRange = await captureSession.getZoomRatioRange() let zoomRatioRange
if (!zoomRatioRange) { try {
console.error('Failed to get the zoom ratio range.'); zoomRatioRange = captureSession.getZoomRatioRange()
return; } catch (error) {
console.error('Failed to get the zoom ratio range. errorCode = ' + error.code);
} }
// 设置可变焦距比 // 设置可变焦距比
captureSession.setZoomRatio(zoomRatioRange[0], async (err) => { try {
if (err) { captureSession.setZoomRatio(zoomRatioRange[0])
console.error('Failed to set the zoom ratio value ${err.message}'); } catch (error) {
return; console.error('Failed to set the zoom ratio value. errorCode = ' + error.code);
} }
console.log('Callback returned with the successful execution of setZoomRatio.');
})
``` ```
#### 拍照 #### 拍照
...@@ -428,7 +464,7 @@ videoOutput.stop((err) => { ...@@ -428,7 +464,7 @@ videoOutput.stop((err) => {
captureSession.stop() captureSession.stop()
// 释放相机输入流 // 释放相机输入流
cameraInput.release() cameraInput.close()
// 释放预览输出流 // 释放预览输出流
previewOutput.release() previewOutput.release()
......
...@@ -12,9 +12,9 @@ import camera from '@ohos.multimedia.camera'; ...@@ -12,9 +12,9 @@ import camera from '@ohos.multimedia.camera';
## camera.getCameraManager ## camera.getCameraManager
getCameraManager(context: Context, callback: AsyncCallback<CameraManager\>): void getCameraManager(context: Context): CameraManager
获取相机管理器实例,通过注册回调函数获取结果。 获取相机管理器实例,同步返回结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core **系统能力:** SystemCapability.Multimedia.Camera.Core
...@@ -23,46 +23,17 @@ getCameraManager(context: Context, callback: AsyncCallback<CameraManager\>): voi ...@@ -23,46 +23,17 @@ getCameraManager(context: Context, callback: AsyncCallback<CameraManager\>): voi
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------------------------- | ---- | ---------------------------- | | -------- | ----------------------------------------------- | ---- | ---------------------------- |
| context | [Context](js-apis-inner-app-context.md) | 是 | 应用上下文。 | | context | [Context](js-apis-inner-app-context.md) | 是 | 应用上下文。 |
| callback | AsyncCallback<[CameraManager](#cameramanager)\> | 是 | 回调函数,用于获取相机管理器实例。 |
**示例:**
```js
camera.getCameraManager(context, (err, cameraManager) => {
if (err) {
console.error(`Failed to get the CameraManager instance ${err.message}`);
return;
}
console.log('Callback returned with the CameraManager instance');
});
```
## camera.getCameraManager
getCameraManager(context: Context): Promise<CameraManager\>
获取相机管理器实例,通过Promise获取结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------- | ---- | ------------ |
| context | [Context](js-apis-inner-app-context.md) | 是 | 应用上下文。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ----------------------------------------- | ----------------------------------- | | ----------------------------------------------- | ---------------------------- |
| Promise<[CameraManager](#cameramanager)\> | 使用Promise的方式获取一个相机管理器实例。 | | [CameraManager](#cameramanager) | 相机管理器。 |
**示例:** **示例:**
```js ```js
camera.getCameraManager(context).then((cameraManager) => { let cameraManager = camera.getCameraManager(context);
console.log('Promise returned with the CameraManager instance.');
})
``` ```
## CameraStatus ## CameraStatus
...@@ -71,12 +42,12 @@ camera.getCameraManager(context).then((cameraManager) => { ...@@ -71,12 +42,12 @@ camera.getCameraManager(context).then((cameraManager) => {
**系统能力:** SystemCapability.Multimedia.Camera.Core **系统能力:** SystemCapability.Multimedia.Camera.Core
| 名称 | 值 | 说明 | | 名称 | 值 | 说明 |
| ------------------------- | ---- | ------------ | | ------------------------- | ---- | ------------ |
| CAMERA_STATUS_APPEAR | 0 | 新的相机出现。 | | CAMERA_STATUS_APPEAR | 0 | 新的相机出现。 |
| CAMERA_STATUS_DISAPPEAR | 1 | 相机被移除。 | | CAMERA_STATUS_DISAPPEAR | 1 | 相机被移除。 |
| CAMERA_STATUS_AVAILABLE | 2 | 相机可用。 | | CAMERA_STATUS_AVAILABLE | 2 | 相机可用。 |
| CAMERA_STATUS_UNAVAILABLE | 3 | 相机不可用。 | | CAMERA_STATUS_UNAVAILABLE | 3 | 相机不可用。 |
## Profile ## Profile
...@@ -123,64 +94,58 @@ camera.getCameraManager(context).then((cameraManager) => { ...@@ -123,64 +94,58 @@ camera.getCameraManager(context).then((cameraManager) => {
| videoProfiles | Array<[VideoProfile](#videoprofile)\> | 是 | 支持的录像配置信息。 | | videoProfiles | Array<[VideoProfile](#videoprofile)\> | 是 | 支持的录像配置信息。 |
| supportedMetadataObjectTypes | Array<[MetadataObjectType](#metadataobjecttype)\> | 是 | 支持的metadata流类型信息。| | supportedMetadataObjectTypes | Array<[MetadataObjectType](#metadataobjecttype)\> | 是 | 支持的metadata流类型信息。|
## CameraManager ## CameraErrorCode
相机管理器类,使用前需要通过getCameraManager获取相机管理实例。
### getSupportedCameras
getSupportedCameras(callback: AsyncCallback<Array<CameraDevice\>\>): void
获取支持指定的相机设备对象,通过注册回调函数获取结果 相机错误码
**系统能力:** SystemCapability.Multimedia.Camera.Core **系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:** | 名称 | 值 | 说明 |
| ------------------------- | ---- | ------------ |
| 参数名 | 类型 | 必填 | 说明 | | INVALID_ARGUMENT | 7400101 | 参数缺失或者参数类型不对。 |
| -------- | ----------------------------------------------------- | ---- | ------------------------------- | | OPERATION_NOT_ALLOWED | 7400102 | 操作流程不对,不允许。 |
| callback | AsyncCallback<Array<[CameraDevice](#cameradevice)\>\> | 是 | 使用callback方式获取支持的相机列表。 | | SESSION_NOT_CONFIG | 7400103 | session 未配置返回。 |
| SESSION_NOT_RUNNING | 7400104 | session 未运行返回。 |
| SESSION_CONFIG_LOCKED | 7400105 | session 配置已锁定返回。 |
| DEVICE_SETTING_LOCKED | 7400106 | 设备设置已锁定返回。 |
| CONFILICT_CAMERA | 7400107 | 设备重复打开返回。 |
| DEVICE_DISABLED | 7400108 | 安全原因摄像头被禁用。 |
| SERVICE_FATAL_ERROR | 7400201 | 相机服务错误返回。 |
**示例:** ## CameraManager
```js 相机管理器类,使用前需要通过getCameraManager获取相机管理实例。
cameraManager.getSupportedCameras((err, cameras) => {
if (err) {
console.error(`Failed to get the cameras. ${err.message}`);
return;
}
console.log(`Callback returned with an array of supported cameras: ${cameras.length}`);
})
```
### getSupportedCameras ### getSupportedCameras
getSupportedCameras(): Promise<Array<CameraDevice\>\> getSupportedCameras(): Array<CameraDevice\>
获取支持指定的相机设备对象,通过Promise获取结果。 获取支持指定的相机设备对象,同步返回结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core **系统能力:** SystemCapability.Multimedia.Camera.Core
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ----------------------------------------------- | ------------------------- | | ----------------------------------------------- | ---------------------------- |
| Promise<Array<[CameraDevice](#cameradevice)\>\> | 使用promise获取支持相机列表。 | | Array<[CameraDevice](#cameradevice)> | 相机设备列表。 |
**示例:** **示例:**
```js ```js
cameraManager.getSupportedCameras().then((cameras) => { let cameras;
console.log(`Promise returned with an array of supported cameras: ${cameras.length}`); try{
}) cameras = cameraManager.getSupportedCameras();
} catch (error) {
console.log(error.code);
}
``` ```
### getSupportedOutputCapability ### getSupportedOutputCapability
getSupportedOutputCapability(camera:CameraDevice, callback: AsyncCallback<CameraOutputCapability\>): void getSupportedOutputCapability(cameraDevice:CameraDevice): CameraOutputCapability
查询相机设备在模式下支持的输出能力,通过注册回调函数获取结果。 查询相机设备在模式下支持的输出能力,同步返回结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core **系统能力:** SystemCapability.Multimedia.Camera.Core
...@@ -189,52 +154,23 @@ getSupportedOutputCapability(camera:CameraDevice, callback: AsyncCallback<Camera ...@@ -189,52 +154,23 @@ getSupportedOutputCapability(camera:CameraDevice, callback: AsyncCallback<Camera
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------------ |--------------------------------------------------------------- | -- | -------------------------- | | ------------ |--------------------------------------------------------------- | -- | -------------------------- |
| cameraDevice | [CameraDevice](#cameradevice) | 是 | 相机设备,通过 getSupportedCameras 接口获取 | | cameraDevice | [CameraDevice](#cameradevice) | 是 | 相机设备,通过 getSupportedCameras 接口获取 |
| callback | AsyncCallback<[CameraOutputCapability](#cameraoutputcapability)\> | 是 | 使用callback方式获取相机输出能力。 |
**示例:**
```js
cameraManager.getSupportedCameras().then((cameras) => {
let cameraDevice = cameras[0];
cameraManager.getSupportedOutputCapability(cameraDevice, (err, CameraOutputCapability) => {
if (err) {
console.error(`Failed to get the outputCapability. ${err.message}`);
return;
}
console.log('Callback returned with an array of supported outputCapability');
})
})
```
### getSupportedOutputCapability
getSupportedOutputCapability(camera:CameraDevice): Promise<CameraOutputCapability\>
查询相机设备在模式下支持的输出能力,通过Promise获取结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------- | ---- | ---------- |
| cameradevice | [CameraDevice](#cameradevice) | 是 | 相机设备,通过 getSupportedCameras 接口获取 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------------------------------------------------------------- | ----------------------------- | | ----------------------------------------------- | ---------------------------- |
| Promise<[CameraOutputCapability](#cameraoutputcapability)\> | 使用Promise的方式获取结果,返回相机输出能力。 | | [CameraOutputCapability](#cameraoutputcapability) | 相机输出能力。 |
**示例:** **示例:**
```js ```js
cameraManager.getSupportedCameras().then((cameras) => { let cameraDevice = cameras[0];
let cameraDevice = cameras[0]; let cameraOutputCapability;
cameraManager.getSupportedOutputCapability(cameraDevice).then((cameraoutputcapability) => { try{
console.log('Promise returned with an array of supported outputCapability'); cameraOutputCapability = cameraManager.getSupportedOutputCapability(cameraDevice);
}) } catch (error) {
}) console.log(error.code);
}
``` ```
### isCameraMuted ### isCameraMuted
...@@ -306,9 +242,9 @@ cameraManager.muteCamera(mute); ...@@ -306,9 +242,9 @@ cameraManager.muteCamera(mute);
### createCameraInput ### createCameraInput
createCameraInput(camera: CameraDevice, callback: AsyncCallback<CameraInput\>): void createCameraInput(camera: CameraDevice): CameraInput
使用CameraDevice对象异步创建CameraInput实例,通过注册回调函数获取结果。 使用CameraDevice对象创建CameraInput实例,同步返回结果。
**需要权限:** ohos.permission.CAMERA **需要权限:** ohos.permission.CAMERA
...@@ -319,57 +255,30 @@ createCameraInput(camera: CameraDevice, callback: AsyncCallback<CameraInput\>): ...@@ -319,57 +255,30 @@ createCameraInput(camera: CameraDevice, callback: AsyncCallback<CameraInput\>):
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------- | ---- | --------------------------------- | | -------- | ------------------------------------------- | ---- | --------------------------------- |
| cameraDevice | [CameraDevice](#cameradevice) | 是 | CameraDevice对象,通过 getSupportedCameras 接口获取 | | cameraDevice | [CameraDevice](#cameradevice) | 是 | CameraDevice对象,通过 getSupportedCameras 接口获取 |
| callback | AsyncCallback<[CameraInput](#camerainput)\> | 是 | 回调函数,用于获取CameraInput实例。 |
**示例:**
```js
let cameraDevice = cameras[0];
cameraManager.createCameraInput(cameraDevice, (err, cameraInput) => {
if (err) {
console.error(`Failed to create the CameraInput instance. ${err.message}`);
return;
}
console.log('Callback returned with the CameraInput instance.');
})
```
### createCameraInput
createCameraInput(cameraDevice: CameraDevice): Promise<CameraInput\>
使用CameraDevice对象异步创建CameraInput实例,通过Promise获取结果。
**需要权限:** ohos.permission.CAMERA
**系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------- | ---- | ---------- |
| cameraDevice | [CameraDevice](#cameradevice) | 是 | CameraDevice对象,通过 getSupportedCameras 接口获取 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ------------------------------------- | ------------------------------------ | | ---------- | ----------------------------- |
| Promise<[CameraInput](#camerainput)\> | 使用Promise的方式获取CameraInput的实例。 | | [CameraInput](#camerainput) | CameraInput实例。 |
**示例:** **示例:**
```js ```js
let cameraDevice = cameras[0]; let cameraDevice = cameras[0];
cameraManager.createCameraInput(cameraDevice).then((cameraInput) => { let cameraInput;
console.log('Promise returned with the CameraInput instance'); try {
}) cameraInput = cameraManager.createCameraInput(cameraDevice);
} catch (error) {
console.log(error.code);
}
``` ```
### createCameraInput ### createCameraInput
createCameraInput(position: CameraPosition, type: CameraType, callback: AsyncCallback<CameraInput\>): void createCameraInput(position: CameraPosition, type: CameraType): CameraInput
根据相机位置和类型创建CameraInput实例,通过注册回调函数获取结果。 根据相机位置和类型创建CameraInput实例,同步返回结果。
**需要权限:** ohos.permission.CAMERA **需要权限:** ohos.permission.CAMERA
...@@ -381,45 +290,12 @@ createCameraInput(position: CameraPosition, type: CameraType, callback: AsyncCal ...@@ -381,45 +290,12 @@ createCameraInput(position: CameraPosition, type: CameraType, callback: AsyncCal
| -------- | ------------------------------------------- | ---- | --------------------------------- | | -------- | ------------------------------------------- | ---- | --------------------------------- |
| position | [CameraPosition](#cameraposition) | 是 | 相机位置,通过 getSupportedCameras 接口获取设备,然后获取设备位置信息 | | position | [CameraPosition](#cameraposition) | 是 | 相机位置,通过 getSupportedCameras 接口获取设备,然后获取设备位置信息 |
| type | [CameraType](#cameratype) | 是 | 相机类型,通过 getSupportedCameras 接口获取设备,然后获取设备类型信息 | | type | [CameraType](#cameratype) | 是 | 相机类型,通过 getSupportedCameras 接口获取设备,然后获取设备类型信息 |
| callback | AsyncCallback<[CameraInput](#camerainput)\> | 是 | 回调函数,用于获取CameraInput实例。 |
**示例:**
```js
let cameraDevice = cameras[0];
let position = cameraDevice.cameraPosition;
let type = cameraDevice.cameraType;
cameraManager.createCameraInput(position, type, (err, cameraInput) => {
if (err) {
console.error(`Failed to create the CameraInput instance. ${err.message}`);
return;
}
console.log('Callback returned with the CameraInput instance');
})
```
### createCameraInput
createCameraInput(position: CameraPosition, type:CameraType ): Promise<CameraInput\>
根据相机位置和类型创建CameraInput实例,通过Promise获取结果。
**需要权限:** ohos.permission.CAMERA
**系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------- | ---- | ------------ |
| position | [CameraPosition](#cameraposition) | 是 | 相机位置,通过 getSupportedCameras 接口获取设备,然后获取设备位置信息 |
| type | [CameraType](#cameratype) | 是 | 相机类型,通过 getSupportedCameras 接口获取设备,然后获取设备类型信息 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ------------------------------------- | ------------------------------------ | | ---------- | ----------------------------- |
| Promise<[CameraInput](#camerainput)\> | 使用Promise的方式获取CameraInput的实例。 | | [CameraInput](#camerainput) | CameraInput实例。 |
**示例:** **示例:**
...@@ -427,16 +303,19 @@ createCameraInput(position: CameraPosition, type:CameraType ): Promise<CameraInp ...@@ -427,16 +303,19 @@ createCameraInput(position: CameraPosition, type:CameraType ): Promise<CameraInp
let cameraDevice = cameras[0]; let cameraDevice = cameras[0];
let position = cameraDevice.cameraPosition; let position = cameraDevice.cameraPosition;
let type = cameraDevice.cameraType; let type = cameraDevice.cameraType;
cameraManager.createCameraInput(position, type).then((cameraInput) => { let cameraInput;
console.log('Promise returned with the CameraInput instance'); try {
}) cameraInput = cameraManager.createCameraInput(position, type);
} catch (error) {
console.log(error.code);
}
``` ```
### createPreviewOutput ### createPreviewOutput
createPreviewOutput(profile: Profile, surfaceId: string, callback: AsyncCallback<PreviewOutput\>): void createPreviewOutput(profile: Profile, surfaceId: string): PreviewOutput
创建预览输出对象,通过注册回调函数获取结果。 创建预览输出对象,同步返回结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core **系统能力:** SystemCapability.Multimedia.Camera.Core
...@@ -446,56 +325,30 @@ createPreviewOutput(profile: Profile, surfaceId: string, callback: AsyncCallback ...@@ -446,56 +325,30 @@ createPreviewOutput(profile: Profile, surfaceId: string, callback: AsyncCallback
| -------- | ----------------------------------------------- | ---- | ------------------------------- | | -------- | ----------------------------------------------- | ---- | ------------------------------- |
| profile | [Profile](#profile) | 是 | 支持的预览配置信息,通过getSupportedOutputCapability接口获取。| | profile | [Profile](#profile) | 是 | 支持的预览配置信息,通过getSupportedOutputCapability接口获取。|
| surfaceId| string | 是 | 从[XComponent](../arkui-ts/ts-basic-components-xcomponent.md)或者[ImageReceiver](js-apis-image.md#imagereceiver9)组件获取的surfaceId。| | surfaceId| string | 是 | 从[XComponent](../arkui-ts/ts-basic-components-xcomponent.md)或者[ImageReceiver](js-apis-image.md#imagereceiver9)组件获取的surfaceId。|
| callback | AsyncCallback<[PreviewOutput](#previewoutput)\> | 是 | 回调函数,用于获取PreviewOutput实例。|
**示例:**
```js
let profile = cameraoutputcapability.previewProfiles[0];
cameraManager.createPreviewOutput(profile, surfaceId, (err, previewOutput) => {
if (err) {
console.error(`Failed to gcreate previewOutput. ${err.message}`);
return;
}
console.log('Callback returned with previewOutput created.');
})
```
### createPreviewOutput
createPreviewOutput(profile: Profile, surfaceId: string): Promise<PreviewOutput\>
创建预览输出对象,通过Promise获取结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------| ---- | ----------------- |
| profile | [Profile](#profile) | 是 | 支持的预览配置信息,通过getSupportedOutputCapability接口获取。|
| surfaceId| string | 是 | 从[XComponent](../arkui-ts/ts-basic-components-xcomponent.md)或者[ImageReceiver](js-apis-image.md#imagereceiver9)组件获取的surfaceId。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ---------------------------------------- | ---------------------------------------- | | ---------- | ----------------------------- |
| Promise<[PreviewOutput](#previewoutput)\> | 使用Promise的方式获取PreviewOutput的实例。 | | [PreviewOutput](#previewoutput) | PreviewOutput实例。 |
**示例:** **示例:**
```js ```js
let profile = cameraoutputcapability.previewProfiles[0]; let profile = cameraoutputcapability.previewProfiles[0];
cameraManager.createPreviewOutput(profile, surfaceId).then((previewOutput) => { let previewOutput;
console.log('Promise returned with previewOutput created.'); try {
}) previewOutput = cameraManager.createPreviewOutput(profile, surfaceId);
} catch (error) {
console.log(error.code);
}
``` ```
### createPhotoOutput ### createPhotoOutput
createPhotoOutput(profile: Profile, surfaceId: string, callback: AsyncCallback<PhotoOutput\>): void createPhotoOutput(profile: Profile, surfaceId: string): PhotoOutput
创建拍照输出对象,通过注册回调函数获取结果。 创建拍照输出对象,同步返回结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core **系统能力:** SystemCapability.Multimedia.Camera.Core
...@@ -505,56 +358,25 @@ createPhotoOutput(profile: Profile, surfaceId: string, callback: AsyncCallback<P ...@@ -505,56 +358,25 @@ createPhotoOutput(profile: Profile, surfaceId: string, callback: AsyncCallback<P
| -------- | ------------------------------------------- | ---- | ----------------------------------- | | -------- | ------------------------------------------- | ---- | ----------------------------------- |
| profile | [Profile](#profile) | 是 | 支持的拍照配置信息,通过getSupportedOutputCapability接口获取。| | profile | [Profile](#profile) | 是 | 支持的拍照配置信息,通过getSupportedOutputCapability接口获取。|
| surfaceId| string | 是 | 从[ImageReceiver](js-apis-image.md#imagereceiver9)获取的surfaceId。| | surfaceId| string | 是 | 从[ImageReceiver](js-apis-image.md#imagereceiver9)获取的surfaceId。|
| callback | AsyncCallback<[PhotoOutput](#photooutput)\> | 是 | 回调函数,用于获取PhotoOutput实例。 |
**示例:**
```js
let profile = cameraoutputcapability.photoProfiles[0];
cameraManager.createPhotoOutput(profile, surfaceId, (err, photoOutput) => {
if (err) {
console.error(`Failed to create photoOutput. ${err.message}`);
return;
}
console.log('Callback returned with photoOutput created.');
})
```
### createPhotoOutput
createPhotoOutput(profile: Profile, surfaceId: string): Promise<PhotoOutput\>
创建拍照输出对象,通过Promise获取结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------| ---- | ----------- |
| profile | [Profile](#profile) | 是 | 支持的拍照配置信息,通过getSupportedOutputCapability接口获取。 |
| surfaceId| string | 是 | 从[ImageReceiver](js-apis-image.md#imagereceiver9)获取的surfaceId。|
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ------------------------------------- | -------------------------------------- | | ---------- | ----------------------------- |
| Promise<[PhotoOutput](#photooutput)\> | 使用Promise的方式获取PhotoOutput的实例。 | | [PhotoOutput](#photooutput) | PhotoOutput实例。 |
**示例:** **示例:**
```js ```js
let profile = cameraoutputcapability.photoProfiles[0]; let profile = cameraoutputcapability.photoProfiles[0];
cameraManager.createPhotoOutput(profile, surfaceId).then((photoOutput) => { let photoOutput = cameraManager.createPhotoOutput(profile, surfaceId);
console.log('Promise returned with photoOutput created.');
})
``` ```
### createVideoOutput ### createVideoOutput
createVideoOutput(profile: VideoProfile, surfaceId: string, callback: AsyncCallback<VideoOutput\>): void createVideoOutput(profile: VideoProfile, surfaceId: string): VideoOutput
创建录像输出对象,通过注册回调函数获取结果。 创建录像输出对象,同步返回结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core **系统能力:** SystemCapability.Multimedia.Camera.Core
...@@ -564,56 +386,30 @@ createVideoOutput(profile: VideoProfile, surfaceId: string, callback: AsyncCallb ...@@ -564,56 +386,30 @@ createVideoOutput(profile: VideoProfile, surfaceId: string, callback: AsyncCallb
| -------- | ------------------------------------------- | ---- | ------------------------------ | | -------- | ------------------------------------------- | ---- | ------------------------------ |
| profile | [VideoProfile](#videoprofile) | 是 | 支持的录像配置信息,通过getSupportedOutputCapability接口获取。 | | profile | [VideoProfile](#videoprofile) | 是 | 支持的录像配置信息,通过getSupportedOutputCapability接口获取。 |
| surfaceId| string | 是 | 从[VideoRecorder](js-apis-media.md#videorecorder9)获取的surfaceId。| | surfaceId| string | 是 | 从[VideoRecorder](js-apis-media.md#videorecorder9)获取的surfaceId。|
| callback | AsyncCallback<[VideoOutput](#videooutput)\> | 是 | 回调函数,用于获取VideoOutput实例。 |
**示例:**
```js
let profile = cameraoutputcapability.videoProfiles[0];
cameraManager.createVideoOutput(profile, surfaceId, (err, videoOutput) => {
if (err) {
console.error(`Failed to create videoOutput. ${err.message}`);
return;
}
console.log('Callback returned with an array of supported outputCapability' );
})
```
### createVideoOutput
createVideoOutput(profile: VideoProfile, surfaceId: string): Promise<VideoOutput\>
创建录像输出对象,通过Promise获取结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------| ---- | ---------- |
| profile | [VideoProfile](#videoprofile) | 是 | 支持的录像配置信息,通过getSupportedOutputCapability接口获取。 |
| surfaceId| string | 是 | 从[VideoRecorder](js-apis-media.md#videorecorder9)获取的surfaceId。|
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ------------------------------------- | -------------------------------------- | | ---------- | ----------------------------- |
| Promise<[VideoOutput](#videooutput)\> | 使用Promise的方式获取videoOutput的实例。 | | [VideoOutput](#videooutput) | VideoOutput实例。 |
**示例:** **示例:**
```js ```js
let profile = cameraoutputcapability.videoProfiles[0]; let profile = cameraoutputcapability.videoProfiles[0];
cameraManager.createVideoOutput(profile, surfaceId).then((videoOutput) => { let videoOutput;
console.log('Promise returned with videoOutput created.'); try {
}) videoOutput = cameraManager.createVideoOutput(profile, surfaceId);
} catch (error) {
console.log(error.code);
}
``` ```
### createMetadataOutput ### createMetadataOutput
createMetadataOutput(metadataObjectTypes:Array<MetadataObjectType\>, callback: AsyncCallback<MetadataOutput\>): void createMetadataOutput(metadataObjectTypes:Array<MetadataObjectType\>): MetadataOutput
创建metadata流输出对象,通过注册回调函数获取结果。 创建metadata流输出对象,同步返回结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core **系统能力:** SystemCapability.Multimedia.Camera.Core
...@@ -622,96 +418,48 @@ createMetadataOutput(metadataObjectTypes:Array<MetadataObjectType\>, callback: A ...@@ -622,96 +418,48 @@ createMetadataOutput(metadataObjectTypes:Array<MetadataObjectType\>, callback: A
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------------------- | -------------------------------------------------- | --- | ---------------------------- | | -------------------- | -------------------------------------------------- | --- | ---------------------------- |
| metadataObjectTypes | Array<[MetadataObjectType](#metadataobjecttype)\> | 是 | metadata流类型信息,通过getSupportedOutputCapability接口获取。 | | metadataObjectTypes | Array<[MetadataObjectType](#metadataobjecttype)\> | 是 | metadata流类型信息,通过getSupportedOutputCapability接口获取。 |
| callback | AsyncCallback<[MetadataOutput](#metadataoutput)\> | 是 | 回调函数,用于获取MetadataOutput实例。 |
**示例:**
```js
let metadataObjectTypes = cameraoutputcapability.supportedMetadataObjectTypes;
cameraManager.createMetadataOutput(metadataObjectTypes, (err, metadataOutput) => {
if (err) {
console.error(`Failed to create metadataOutput. ${err.message}`);
return;
}
console.log('Callback returned with metadataOutput created.');
})
```
### createMetadataOutput
createMetadataOutput(metadataObjectTypes:Array<MetadataObjectType\>): Promise<MetadataOutput\>
创建metadata流输出对象,通过Promise获取结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------------------- | -------------------------------------------------- | --- | -------------------- |
| metadataObjectTypes | Array<[MetadataObjectType](#metadataobjecttype)\> | 是 | metadata流类型信息,通过getSupportedOutputCapability接口获取。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ------------------------------------------ | ----------------------------------------- | | ---------- | ----------------------------- |
| Promise<[MetadataOutput](#metadataoutput)\> | 使用Promise的方式获取MetadataOutput的实例。 | | [MetadataOutput](#metadataoutput) | MetadataOutput实例。 |
**示例:** **示例:**
```js ```js
let metadataObjectTypes = cameraoutputcapability.supportedMetadataObjectTypes; let metadataObjectTypes = cameraoutputcapability.supportedMetadataObjectTypes;
cameraManager.createMetadataOutput(metadataObjectTypes).then((metadataOutput) => { let metadataOutput;
console.log('Promise returned with metadataOutput created.'); try {
}) metadataOutput = cameraManager.createMetadataOutput(metadataObjectTypes);
} catch (error) {
console.log(error.code);
}
``` ```
### createCaptureSession ### createCaptureSession
createCaptureSession(callback: AsyncCallback<CaptureSession\>): void createCaptureSession(): CaptureSession
创建CaptureSession实例,通过注册回调函数获取结果。 创建CaptureSession实例,通过注册回调函数获取结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core **系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------------------- | ----------------------------------------- | ----------- | ---------------------------- |
| callback | AsyncCallback<[CaptureSession](#capturesession)\> | 是 | 回调函数,用于获取拍照会话实例。 |
**示例:**
```js
cameraManager.createCaptureSession((err, captureSession) => {
if (err) {
console.error(`Failed to create captureSession. ${err.message}`);
return;
}
console.log('Callback returned with captureSession created.');
})
```
### createCaptureSession
createCaptureSession(): Promise<CaptureSession\>
创建CaptureSession实例,通过Promise获取结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ------------------------------------------- | ---------------------------------------- | | ---------- | ----------------------------- |
| Promise<[CaptureSession](#capturesession)\> | 使用Promise的方式获取CaptureSession的实例。 | | [CaptureSession](#capturesession) | CaptureSession实例。 |
**示例:** **示例:**
```js ```js
cameraManager.createCaptureSession().then((captureSession) => { let captureSession;
console.log('Promise returned with captureSession created.'); try {
}) captureSession = cameraManager.createCaptureSession();
} catch (error) {
console.log(error.code);
}
``` ```
### on('cameraStatus') ### on('cameraStatus')
...@@ -801,7 +549,7 @@ cameraManager.on('cameraMute', (err, curMuetd) => { ...@@ -801,7 +549,7 @@ cameraManager.on('cameraMute', (err, curMuetd) => {
| 名称 | 值 | 说明 | | 名称 | 值 | 说明 |
| ----------------------- | ---- | -------------- | | ----------------------- | ---- | -------------- |
| CAMERA_TYPE_UNSPECIFIED | 0 | 相机类型未指定。 | | CAMERA_TYPE_DEFAULT | 0 | 相机类型未指定。 |
| CAMERA_TYPE_WIDE_ANGLE | 1 | 广角相机。 | | CAMERA_TYPE_WIDE_ANGLE | 1 | 广角相机。 |
| CAMERA_TYPE_ULTRA_WIDE | 2 | 超广角相机。 | | CAMERA_TYPE_ULTRA_WIDE | 2 | 超广角相机。 |
| CAMERA_TYPE_TELEPHOTO | 3 | 长焦相机。 | | CAMERA_TYPE_TELEPHOTO | 3 | 长焦相机。 |
...@@ -966,119 +714,45 @@ cameraInput.close().then(() => { ...@@ -966,119 +714,45 @@ cameraInput.close().then(() => {
}) })
``` ```
### release ### on('error')
release\(callback: AsyncCallback<void\>\): void on(type: 'error', cameraDevice:CameraDevice, callback: ErrorCallback<BusinessError\>): void
释放资源,通过注册回调函数获取结果。 监听CameraInput的错误事件,通过注册回调函数获取结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core **系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | ------------------- | | -------- | -------------------------------- | --- | ------------------------------------------- |
| callback | AsyncCallback<void\> | 是 | 回调函数,用于获取结果。 | | type | string | 是 | 监听事件,固定为'error',即CameraInput错误事件。 |
| cameraDevice | [CameraDevice](#cameradevice) | 是 | CameraDevice对象。 |
| callback | ErrorCallback<BusinessError\> | 是 | 回调函数,用于获取结果。 |
**示例:** **示例:**
```js ```js
cameraInput.release((err) => { let cameraDevice = cameras[0];
if (err) { cameraInput.on('error', cameraDevice, (error) => {
console.error(`Failed to release the CameraInput instance ${err.message}`); console.log(`Camera input error code: ${error.code}`);
return; })
}
console.log('Callback invoked to indicate that the CameraInput instance is released successfully.');
});
``` ```
### release ## FlashMode
release(): Promise<void\> 枚举,闪光灯模式。
释放资源,通过Promise获取结果 **系统能力:** SystemCapability.Multimedia.Camera.Core
**系统能力:** SystemCapability.Multimedia.Camera.Core | 名称 | 值 | 说明 |
| ---------------------- | ---- | ---------- |
| FLASH_MODE_CLOSE | 0 | 闪光灯关闭。 |
| FLASH_MODE_OPEN | 1 | 闪光灯打开。 |
| FLASH_MODE_AUTO | 2 | 自动闪光灯。 |
| FLASH_MODE_ALWAYS_OPEN | 3 | 闪光灯常亮。 |
**返回值:** ## ExposureMode
| 类型 | 说明 |
| -------------- | ----------------------- |
| Promise<void\> | 使用Promise的方式获取结果。 |
**示例:**
```js
cameraInput.release().then(() => {
console.log('Promise returned to indicate that the CameraInput instance is released successfully.');
})
```
### on('error')
on(type: 'error', cameraDevice:CameraDevice, callback: ErrorCallback<CameraInputError\>): void
监听CameraInput的错误事件,通过注册回调函数获取结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | --- | ------------------------------------------- |
| type | string | 是 | 监听事件,固定为'error',即CameraInput错误事件。 |
| cameraDevice | [CameraDevice](#cameradevice) | 是 | CameraDevice对象。 |
| callback | ErrorCallback<[CameraInputError](#camerainputerror)\> | 是 | 回调函数,用于获取结果。 |
**示例:**
```js
let cameraDevice = cameras[0];
cameraInput.on('error', cameraDevice, (cameraInputError) => {
console.log(`Camera input error code: ${cameraInputError.code}`);
})
```
## CameraInputErrorCode
枚举,[CameraInput](#camerainput)错误类型。
**系统能力:** SystemCapability.Multimedia.Camera.Core
| 名称 | 值 | 说明 |
| ------------------------- | ---- | ---------- |
| ERROR_UNKNOWN | -1 | 未知错误。 |
| ERROR_NO_PERMISSION | 0 | 没有权限。 |
| ERROR_DEVICE_PREEMPTED | 1 | 相机被抢占。 |
| ERROR_DEVICE_DISCONNECTED | 2 | 相机断开连接。 |
| ERROR_DEVICE_IN_USE | 3 | 相机正在使用。 |
| ERROR_DRIVER_ERROR | 4 | 驱动错误。 |
## CameraInputError
[CameraInput](#camerainput)错误码。
**系统能力:** SystemCapability.Multimedia.Camera.Core
| 名称 | 类型 | 必填 | 说明 |
| ---- | --------------------------------------------- | ------------ |--------------------- |
| code | [CameraInputErrorCode](#camerainputerrorcode) | 是 |CameraInput中的错误码。 |
## FlashMode
枚举,闪光灯模式。
**系统能力:** SystemCapability.Multimedia.Camera.Core。
| 名称 | 值 | 说明 |
| ---------------------- | ---- | ---------- |
| FLASH_MODE_CLOSE | 0 | 闪光灯关闭。 |
| FLASH_MODE_OPEN | 1 | 闪光灯打开。 |
| FLASH_MODE_AUTO | 2 | 自动闪光灯。 |
| FLASH_MODE_ALWAYS_OPEN | 3 | 闪光灯常亮。 |
## ExposureMode
枚举,曝光模式。 枚举,曝光模式。
...@@ -1135,56 +809,25 @@ cameraInput.on('error', cameraDevice, (cameraInputError) => { ...@@ -1135,56 +809,25 @@ cameraInput.on('error', cameraDevice, (cameraInputError) => {
### beginConfig ### beginConfig
beginConfig\(callback: AsyncCallback<void\>\): void beginConfig(): void
开始配置会话,通过注册回调函数获取结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | ------------------- |
| callback | AsyncCallback<void\> | 是 | 回调函数,用于获取结果。 |
**示例:**
```js
captureSession.beginConfig((err) => {
if (err) {
console.error(`Failed to start the configuration. ${err.message}`);
return;
}
console.log('Callback invoked to indicate the begin config success.');
});
```
### beginConfig
beginConfig\(\): Promise<void\>
开始配置会话,通过Promise获取结果 开始配置会话。
**系统能力:** SystemCapability.Multimedia.Camera.Core **系统能力:** SystemCapability.Multimedia.Camera.Core
**返回值:**
| 类型 | 说明 |
| -------------- | ------------------------ |
| Promise<void\> | 使用Promise的方式获取结果。 |
**示例:** **示例:**
```js ```js
captureSession.beginConfig().then(() => { try {
console.log('Promise returned to indicate the begin config success.'); captureSession.beginConfig();
}) } catch (error) {
console.log(error.code);
}
``` ```
### commitConfig ### commitConfig
commitConfig\(callback: AsyncCallback<void\>\): void commitConfig(callback: AsyncCallback<void\>): void
提交配置信息,通过注册回调函数获取结果。 提交配置信息,通过注册回调函数获取结果。
...@@ -1210,7 +853,7 @@ captureSession.commitConfig((err) => { ...@@ -1210,7 +853,7 @@ captureSession.commitConfig((err) => {
### commitConfig ### commitConfig
commitConfig\(\): Promise<void\> commitConfig(): Promise<void\>
提交配置信息,通过Promise获取结果。 提交配置信息,通过Promise获取结果。
...@@ -1232,36 +875,9 @@ captureSession.commitConfig().then(() => { ...@@ -1232,36 +875,9 @@ captureSession.commitConfig().then(() => {
### addInput ### addInput
addInput\(cameraInput: CameraInput, callback: AsyncCallback<void\>\): void addInput(cameraInput: CameraInput): void
[CameraInput](#camerainput)加入到会话,通过注册回调函数获取结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----------- | --------------------------- | ---- | ------------------------ |
| cameraInput | [CameraInput](#camerainput) | 是 | 需要添加的CameraInput实例。 |
| callback | AsyncCallback<void\> | 是 | 回调函数,用于获取结果。 |
**示例:**
```js
captureSession.addInput(cameraInput, (err) => {
if (err) {
console.error(`Failed to add the CameraInput instance. ${err.message}`);
return;
}
console.log('Callback invoked to indicate that the CameraInput instance is added.');
});
```
### addInput
addInput\(cameraInput: CameraInput\): Promise<void\>
[CameraInput](#camerainput)加入到会话,通过Promise获取结果 [CameraInput](#camerainput)加入到会话。
**系统能力:** SystemCapability.Multimedia.Camera.Core **系统能力:** SystemCapability.Multimedia.Camera.Core
...@@ -1271,52 +887,21 @@ addInput\(cameraInput: CameraInput\): Promise<void\> ...@@ -1271,52 +887,21 @@ addInput\(cameraInput: CameraInput\): Promise<void\>
| ----------- | --------------------------- | ---- | ------------------------ | | ----------- | --------------------------- | ---- | ------------------------ |
| cameraInput | [CameraInput](#camerainput) | 是 | 需要添加的CameraInput实例。 | | cameraInput | [CameraInput](#camerainput) | 是 | 需要添加的CameraInput实例。 |
**返回值:**
| 类型 | 说明 |
| -------------- | ------------------------ |
| Promise<void\> | 使用Promise的方式获取结果。 |
**示例:**
```js
captureSession.addInput(cameraInput).then(() => {
console.log('Promise used to indicate that the CameraInput instance is added.');
})
```
### removeInput
removeInput\(cameraInput: CameraInput, callback: AsyncCallback<void\>\): void
移除[CameraInput](#camerainput),通过注册回调函数获取结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----------- | --------------------------- | ---- | ------------------------ |
| cameraInput | [CameraInput](#camerainput) | 是 | 需要移除的CameraInput实例。 |
| callback | AsyncCallback<void\> | 是 | 回调函数,用于获取结果。 |
**示例:** **示例:**
```js ```js
captureSession.removeInput(cameraInput, (err) => { try {
if (err) { captureSession.addInput(cameraInput);
console.error(`Failed to remove the CameraInput instance. ${err.message}`); } catch (error) {
return; console.log(error.code);
} }
console.log('Callback invoked to indicate that the cameraInput instance is removed.');
});
``` ```
### removeInput ### removeInput
removeInput\(cameraInput: CameraInput\): Promise<void\> removeInput(cameraInput: CameraInput): void
移除[CameraInput](#camerainput),通过Promise获取结果 移除[CameraInput](#camerainput)
**系统能力:** SystemCapability.Multimedia.Camera.Core **系统能力:** SystemCapability.Multimedia.Camera.Core
...@@ -1326,25 +911,21 @@ removeInput\(cameraInput: CameraInput\): Promise<void\> ...@@ -1326,25 +911,21 @@ removeInput\(cameraInput: CameraInput\): Promise<void\>
| ----------- | --------------------------- | ---- | ------------------------ | | ----------- | --------------------------- | ---- | ------------------------ |
| cameraInput | [CameraInput](#camerainput) | 是 | 需要移除的CameraInput实例。 | | cameraInput | [CameraInput](#camerainput) | 是 | 需要移除的CameraInput实例。 |
**返回值:**
| 类型 | 说明 |
| -------------- | ------------------------- |
| Promise\<void\> | 使用Promise的方式获取结果。 |
**示例:** **示例:**
```js ```js
captureSession.removeInput(cameraInput).then(() => { try {
console.log('Promise returned to indicate that the cameraInput instance is removed.'); captureSession.removeInput(cameraInput);
}) } catch (error) {
console.log(error.code);
}
``` ```
### addOutput ### addOutput
addOutput\(previewOutput: CameraOutput, callback: AsyncCallback<void\>\): void addOutput(previewOutput: CameraOutput): void
[CameraOutput](#cameraoutput)加入到会话,通过注册回调函数获取结果 [CameraOutput](#cameraoutput)加入到会话。
**系统能力:** SystemCapability.Multimedia.Camera.Core **系统能力:** SystemCapability.Multimedia.Camera.Core
...@@ -1353,53 +934,22 @@ addOutput\(previewOutput: CameraOutput, callback: AsyncCallback<void\>\): void ...@@ -1353,53 +934,22 @@ addOutput\(previewOutput: CameraOutput, callback: AsyncCallback<void\>\): void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------------- | ------------------------------- | ---- | ------------------------ | | ------------- | ------------------------------- | ---- | ------------------------ |
| previewOutput | [PreviewOutput](#previewoutput) | 是 | 需要添加的previewoutput实例。 | | previewOutput | [PreviewOutput](#previewoutput) | 是 | 需要添加的previewoutput实例。 |
| callback | AsyncCallback<void\> | 是 | 回调函数,用于获取结果。 |
**示例:**
```js
captureSession.addOutput(previewOutput, (err) => {
if (err) {
console.error(`Failed to add output. ${err.message}`);
return;
}
console.log('Callback returned with output added.');
})
```
### addOutput
addOutput\(previewOutput: CameraOutput\): Promise<void\>
[CameraOutput](#cameraoutput)加入到会话,通过Promise获取结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------------- | ------------------------------- | ---- | ------------------------- |
| previewOutput | [PreviewOutput](#previewoutput) | 是 | 需要添加的previewOutput实例。 |
**返回值:**
| 类型 | 说明 |
| -------------- | ----------------------- |
| Promise<void\> | 使用Promise的方式获取结果。 |
**示例:** **示例:**
```js ```js
captureSession.addOutput(previewOutput).then(() => { try {
console.log('Promise returned with cameraOutput added.'); captureSession.addOutput(previewOutput);
}) } catch (error) {
console.log(error.code);
}
``` ```
### removeOutput ### removeOutput
removeOutput\(previewOutput: CameraOutput, callback: AsyncCallback<void\>\): void removeOutput(previewOutput: CameraOutput): void
从会话中移除[CameraOutput](#cameraoutput),通过注册回调函数获取结果 从会话中移除[CameraOutput](#cameraoutput)
**系统能力:** SystemCapability.Multimedia.Camera.Core **系统能力:** SystemCapability.Multimedia.Camera.Core
...@@ -1408,48 +958,15 @@ removeOutput\(previewOutput: CameraOutput, callback: AsyncCallback<void\>\): voi ...@@ -1408,48 +958,15 @@ removeOutput\(previewOutput: CameraOutput, callback: AsyncCallback<void\>\): voi
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------------- | ------------------------------- | ---- | ------------------------ | | ------------- | ------------------------------- | ---- | ------------------------ |
| previewOutput | [PreviewOutput](#previewoutput) | 是 | 需要移除的previewoutput实例。 | | previewOutput | [PreviewOutput](#previewoutput) | 是 | 需要移除的previewoutput实例。 |
| callback | AsyncCallback<void\> | 是 | 回调函数,用于获取结果。 |
**示例:**
```js
captureSession.removeOutput(previewOutput, (err) => {
if (err) {
console.error(`Failed to remove the CameraOutput instance. ${err.message}`);
return;
}
console.log('Callback invoked to indicate that the CameraOutput instance is removed.');
});
```
### removeOutput
removeOutput(previewOutput: CameraOutput): Promise<void\>
从会话中移除[CameraOutput](#cameraoutput),通过Promise获取结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------------- | ------------------------------- | ---- | ------------------------- |
| previewOutput | [PreviewOutput](#previewoutput) | 是 | 需要移除的previewoutput实例。 |
**返回值:**
| 类型 | 说明 |
| -------------- | ------------------------ |
| Promise<void\> | 使用Promise的方式获取结果。 |
**示例:** **示例:**
```js ```js
captureSession.removeOutput(previewOutput).then(() => { try {
console.log('Promise returned to indicate that the CameraOutput instance is removed.'); captureSession.removeOutput(previewOutput);
}) } catch (error) {
console.log(error.code);
}
``` ```
### start ### start
...@@ -1598,57 +1115,33 @@ captureSession.release().then(() => { ...@@ -1598,57 +1115,33 @@ captureSession.release().then(() => {
### hasFlash ### hasFlash
hasFlash(callback: AsyncCallback<boolean\>): void hasFlash(): boolean
检测是否有闪光灯,通过注册回调函数获取结果。 检测是否有闪光灯,通过注册回调函数获取结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core **系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------- | ---- | -------------------------------- |
| callback | AsyncCallback<boolean\> | 是 | 回调函数,返回true表示设备支持闪光灯。 |
**示例:**
```js
captureSession.hasFlash((err, status) => {
if (err) {
console.error(`Failed to check whether the device has flash light. ${err.message}`);
return;
}
console.log(`Callback returned with flash light support status: ${status}`);
})
```
### hasFlash
hasFlash(): Promise<boolean\>
检测是否有闪光灯,通过Promise获取结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ----------------- | ----------------------------------------------- | | ---------- | ----------------------------- |
| Promise<boolean\> | 使用Promise的方式获取结果,返回true表示设备支持闪光灯。 | | boolean | 返回true表示设备支持闪光灯。 |
**示例:** **示例:**
```js ```js
captureSession.hasFlash().then((status) => { try {
console.log(`Promise returned with the flash light support status: ${status}`); let status = captureSession.hasFlash();
}) } catch (error) {
console.log(error.code);
}
``` ```
### isFlashModeSupported ### isFlashModeSupported
isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback<boolean\>): void isFlashModeSupported(flashMode: FlashMode): boolean
检测闪光灯模式是否支持,通过注册回调函数获取结果 检测闪光灯模式是否支持。
**系统能力:** SystemCapability.Multimedia.Camera.Core **系统能力:** SystemCapability.Multimedia.Camera.Core
...@@ -1657,53 +1150,28 @@ isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback<boolean\>): v ...@@ -1657,53 +1150,28 @@ isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback<boolean\>): v
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| --------- | ----------------------- | ---- | --------------------------------- | | --------- | ----------------------- | ---- | --------------------------------- |
| flashMode | [FlashMode](#flashmode) | 是 | 指定闪光灯模式。 | | flashMode | [FlashMode](#flashmode) | 是 | 指定闪光灯模式。 |
| callback | AsyncCallback<boolean\> | 是 | 回调函数,返回true表示支持该闪光灯模式。 |
**示例:**
```js
captureSession.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO, (err, status) => {
if (err) {
console.error(`Failed to check whether the flash mode is supported. ${err.message}`);
return;
}
console.log(`Callback returned with the flash mode support status: ${status}`);
})
```
### isFlashModeSupported
isFlashModeSupported(flashMode: FlashMode): Promise<boolean\>
检测闪光灯模式是否支持,通过Promise获取结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ----------------------- | ---- | ------------- |
| flashMode | [FlashMode](#flashmode) | 是 | 指定闪光灯模式。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ----------------- | ---------------------------------------------------- | | ---------- | ----------------------------- |
| Promise<boolean\> | 使用Promise的方式获取结果,返回true表示设备支持该闪光灯模式。 | | boolean | 返回true表示支持该闪光灯模式。 |
**示例:** **示例:**
```js ```js
captureSession.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO).then((status) => { try {
console.log(`Promise returned with flash mode support status.${status}`); let status = captureSession.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO);
}) } catch (error) {
console.log(error.code);
}
``` ```
### setFlashMode ### setFlashMode
setFlashMode(flashMode: FlashMode, callback: AsyncCallback<void\>): void setFlashMode(flashMode: FlashMode): void
设置闪光灯模式,通过注册回调函数获取结果 设置闪光灯模式。
进行设置之前,需要先检查: 进行设置之前,需要先检查:
...@@ -1717,133 +1185,46 @@ setFlashMode(flashMode: FlashMode, callback: AsyncCallback<void\>): void ...@@ -1717,133 +1185,46 @@ setFlashMode(flashMode: FlashMode, callback: AsyncCallback<void\>): void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| --------- | ----------------------- | ---- | --------------------- | | --------- | ----------------------- | ---- | --------------------- |
| flashMode | [FlashMode](#flashmode) | 是 | 指定闪光灯模式。 | | flashMode | [FlashMode](#flashmode) | 是 | 指定闪光灯模式。 |
| callback | AsyncCallback<void\> | 是 | 回调函数,用于获取结果。 |
**示例:** **示例:**
```js ```js
captureSession.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO, (err) => { try {
if (err) { captureSession.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO);
console.error(`Failed to set the flash mode ${err.message}`); } catch (error) {
return; console.log(error.code);
} }
console.log('Callback returned with the successful execution of setFlashMode.');
})
``` ```
### setFlashMode ### getFlashMode
setFlashMode(flashMode: FlashMode): Promise<void\>
设置闪光灯模式,通过Promise获取结果。
进行设置之前,需要先检查: getFlashMode(): FlashMode
1. 设备是否支持闪光灯,可使用方法[hasFlash](#hasflash) 获取当前设备的闪光灯模式。
2. 设备是否支持指定的闪光灯模式,可使用方法[isFlashModeSupported](#isflashmodesupported)
**系统能力:** SystemCapability.Multimedia.Camera.Core **系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ----------------------- | ---- | ------------- |
| flashMode | [FlashMode](#flashmode) | 是 | 指定闪光灯模式。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------------- | ------------------------ | | ---------- | ----------------------------- |
| Promise<void\> | 使用Promise的方式获取结果。 | | [FlashMode](#flashmode) | 获取当前设备的闪光灯模式。 |
**示例:**
```js
captureSession.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO).then(() => {
console.log('Promise returned with the successful execution of setFlashMode.');
})
```
### getFlashMode
getFlashMode(callback: AsyncCallback<FlashMode\>): void
获取当前设备的闪光灯模式,通过注册回调函数获取结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------------- | ---- | --------------------------------- |
| callback | AsyncCallback<[FlashMode](#flashmode)\> | 是 | 回调函数,用于获取当前设备的闪光灯模式。 |
**示例:**
```js
captureSession.getFlashMode((err, flashMode) => {
if (err) {
console.error(`Failed to get the flash mode ${err.message}`);
return;
}
console.log(`Callback returned with current flash mode: ${flashMode}`);
})
```
### getFlashMode
getFlashMode(): Promise<FlashMode\>
获取当前设备的闪光灯模式,通过Promise获取结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core
**返回值:**
| 类型 | 说明 |
| --------------------------------- | --------------------------------- |
| Promise<[FlashMode](#flashmode)\> | 使用Promise的方式获取当前的闪光灯模式。 |
**示例:**
```js
captureSession.getFlashMode().then((flashMode) => {
console.log(`Promise returned with current flash mode : ${flashMode}`);
})
```
### isExposureModeSupported
isExposureModeSupported(aeMode: ExposureMode, callback: AsyncCallback<boolean\>): void;
检测曝光模式是否支持,通过注册回调函数获取结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------| ---- | ----------------------------- |
| aeMode | [ExposureMode](#exposuremode) | 是 | 曝光模式。 |
| callback | AsyncCallback<boolean\> | 是 | 回调函数,用于获取是否支持曝光模式。 |
**示例:** **示例:**
```js ```js
captureSession.isExposureModeSupported(camera.ExposureMode.EXPOSURE_MODE_LOCKED,(err) => { try {
if (err) { let flashMode = captureSession.getFlashMode();
console.log(`Failed to check exposure mode supported ${err.message}`); } catch (error) {
return ; console.log(error.code);
} }
console.log('Callback returned with the successful execution of isExposureModeSupported');
})
``` ```
### isExposureModeSupported ### isExposureModeSupported
isExposureModeSupported(aeMode: ExposureMode): Promise<boolean\> isExposureModeSupported(aeMode: ExposureMode): boolean;
检测曝光模式是否支持,通过Promise获取结果 检测曝光模式是否支持。
**系统能力:** SystemCapability.Multimedia.Camera.Core **系统能力:** SystemCapability.Multimedia.Camera.Core
...@@ -1855,71 +1236,49 @@ isExposureModeSupported(aeMode: ExposureMode): Promise<boolean\> ...@@ -1855,71 +1236,49 @@ isExposureModeSupported(aeMode: ExposureMode): Promise<boolean\>
**返回值:** **返回值:**
| 名称 | 说明 | | 类型 | 说明 |
| ----------------- |--------------------------------- | | ---------- | ----------------------------- |
| Promise<boolean\> | 使用Promise的方式获取支持的曝光模式。 | | boolean | 获取是否支持曝光模式。 |
**示例:**
```js
captureSession.isExposureModeSupported(camera.ExposureMode.EXPOSURE_MODE_LOCKED).then((isSupported) => {
console.log(`Promise returned with exposure mode supported : ${isSupported}`);
})
```
### getExposureMode
getExposureMode(callback: AsyncCallback<ExposureMode\>): void
获取当前曝光模式,通过注册回调函数获取结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------| ---- | ---------------------------------------- |
| callback | AsyncCallback<[ExposureMode](#exposuremode)\> | 是 | 回调函数,用于获取当前曝光模式。 |
**示例:** **示例:**
```js ```js
captureSession.getExposureMode((err, exposureMode) => { try {
if (err) { let isSupported = captureSession.isExposureModeSupported(camera.ExposureMode.EXPOSURE_MODE_LOCKED);
console.log(`Failed to get the exposure mode ${err.message}`); } catch (error) {
return ; console.log(error.code);
} }
console.log(`Callback returned with current exposure mode: ${exposureMode}`);
})
``` ```
### getExposureMode ### getExposureMode
getExposureMode(): Promise<ExposureMode\> getExposureMode(): ExposureMode
获取当前曝光模式,通过Promise获取结果 获取当前曝光模式。
**系统能力:** SystemCapability.Multimedia.Camera.Core **系统能力:** SystemCapability.Multimedia.Camera.Core
**返回值:** **返回值:**
| 名称 | 说明 | | 类型 | 说明 |
| --------------------------------------- |------------------------------- | | ---------- | ----------------------------- |
| Promise<[ExposureMode](#exposuremode)\> | 使用Promise的方式获取当前曝光模式。 | | [ExposureMode](#exposuremode) | 获取当前曝光模式。 |
**示例:** **示例:**
```js ```js
captureSession.getExposureMode().then((exposureMode) => { try {
console.log(`Promise returned with current exposure mode : ${exposureMode}`); let exposureMode = captureSession.getExposureMode();
}) } catch (error) {
console.log(error.code);
}
``` ```
### setExposureMode ### setExposureMode
setExposureMode(aeMode: ExposureMode, callback: AsyncCallback<void\>): void setExposureMode(aeMode: ExposureMode): void
设置曝光模式,通过注册回调函数获取结果 设置曝光模式。
**系统能力:** SystemCapability.Multimedia.Camera.Core **系统能力:** SystemCapability.Multimedia.Camera.Core
...@@ -1928,124 +1287,46 @@ setExposureMode(aeMode: ExposureMode, callback: AsyncCallback<void\>): void ...@@ -1928,124 +1287,46 @@ setExposureMode(aeMode: ExposureMode, callback: AsyncCallback<void\>): void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------| ---- | ----------------------- | | -------- | -------------------------------| ---- | ----------------------- |
| aeMode | [ExposureMode](#exposuremode) | 是 | 曝光模式。 | | aeMode | [ExposureMode](#exposuremode) | 是 | 曝光模式。 |
| callback | AsyncCallback<void\> | 是 | 回调函数,用于获取设置结果。 |
**示例:**
```js
captureSession.setExposureMode(camera.ExposureMode.EXPOSURE_MODE_LOCKED,(err) => {
if (err) {
console.log(`Failed to set the exposure mode ${err.message}`);
return ;
}
console.log('Callback returned with the successful execution of setExposureMode');
})
```
### setExposureMode
setExposureMode(aeMode: ExposureMode): Promise<void\>
设置曝光模式,通过Promise获取结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core
**返回值:**
| 名称 | 说明 |
| ----------------- |---------------------------- |
| Promise<void\> | 使用Promise的方式获取设置结果。 |
**示例:**
```js
captureSession.setExposureMode(camera.ExposureMode.EXPOSURE_MODE_LOCKED).then(() => {
console.log('Promise returned with the successful execution of setExposureMode.');
})
```
### getMeteringPoint
getMeteringPoint(callback: AsyncCallback<Point\>): void
查询曝光区域中心点,通过注册回调函数获取结果。(该接口目前为预留,将在3.2版本开放)
**系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------| ---- | ------------------------ |
| callback | AsyncCallback<[Point](#point)\>| 是 | 回调函数,用于获取当前曝光点。 |
**示例:** **示例:**
```js ```js
captureSession.getMeteringPoint((err, exposurePoint) => { try {
if (err) { captureSession.setExposureMode(camera.ExposureMode.EXPOSURE_MODE_LOCKED);
console.log(`Failed to get the current exposure point ${err.message}`); } catch (error) {
return ; console.log(error.code);
} }
console.log(`Callback returned with current exposure point: ${exposurePoint}`);
})
``` ```
### getMeteringPoint ### getMeteringPoint
getMeteringPoint(): Promise<Point\> getMeteringPoint(): Point
查询曝光区域中心点,通过Promise获取结果。(该接口目前为预留,将在3.2版本开放) 查询曝光区域中心点。(该接口目前为预留,将在3.2版本开放)
**系统能力:** SystemCapability.Multimedia.Camera.Core **系统能力:** SystemCapability.Multimedia.Camera.Core
**返回值:** **返回值:**
| 名称 | 说明 | | 类型 | 说明 |
| ------------------------- |----------------------------- | | ---------- | ----------------------------- |
| Promise<[Point](#point)\> | 使用Promise的方式获取当前曝光点。 | | [Point](#point) | 获取当前曝光点。 |
**示例:**
```js
captureSession.getMeteringPoint().then((exposurePoint) => {
console.log(`Promise returned with current exposure point : ${exposurePoint}`);
})
```
### setMeteringPoint
setMeteringPoint(point: Point, callback: AsyncCallback<void\>): void
设置曝光区域中心点,通过注册回调函数获取结果。(该接口目前为预留,将在3.2版本开放)
**系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------------- | -------------------------------| ---- | ------------------- |
| exposurePoint | [Point](#point) | 是 | 曝光点。 |
| callback | AsyncCallback<void\> | 是 | 回调函数,用于获取结果。 |
**示例:** **示例:**
```js ```js
const Point1 = {x: 1, y: 1}; try {
let exposurePoint = captureSession.getMeteringPoint();
captureSession.setMeteringPoint(Point1,(err) => { } catch (error) {
if (err) { console.log(error.code);
console.log(`Failed to set the exposure point ${err.message}`); }
return ;
}
console.log('Callback returned with the successful execution of setMeteringPoint');
})
``` ```
### setMeteringPoint ### setMeteringPoint
setMeteringPoint(point: Point): Promise<void\> setMeteringPoint(point: Point): void
设置曝光区域中心点,通过Promise获取结果。(该接口目前为预留,将在3.2版本开放) 设置曝光区域中心点。(该接口目前为预留,将在3.2版本开放)
**系统能力:** SystemCapability.Multimedia.Camera.Core **系统能力:** SystemCapability.Multimedia.Camera.Core
...@@ -2055,75 +1336,46 @@ setMeteringPoint(point: Point): Promise<void\> ...@@ -2055,75 +1336,46 @@ setMeteringPoint(point: Point): Promise<void\>
| ------------- | -------------------------------| ---- | ------------------- | | ------------- | -------------------------------| ---- | ------------------- |
| exposurePoint | [Point](#point) | 是 | 曝光点。 | | exposurePoint | [Point](#point) | 是 | 曝光点。 |
**返回值:**
| 名称 | 说明 |
| ----------------- |------------------------ |
| Promise<void\> | 使用Promise的方式返回结果。 |
**示例:** **示例:**
```js ```js
const Point2 = {x: 2, y: 2}; const exposurePoint = {x: 1, y: 1};
try {
captureSession.setMeteringPoint(Point2).then(() => { captureSession.setMeteringPoint(exposurePoint);
console.log('Promise returned with the successful execution of setMeteringPoint'); } catch (error) {
}) console.log(error.code);
``` }
### getExposureBiasRange
getExposureBiasRange(callback: AsyncCallback<Array<number\>\>): void
查询曝光补偿范围,通过注册回调函数获取结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------| ---- | ----------------------------- |
| callback | AsyncCallback<Array<number\>\> | 是 | 回调函数,用于获取补偿范围的数组。 |
**示例:**
```js
captureSession.getExposureBiasRange((err, biasRangeArray) => {
if (err) {
console.log(`Failed to get the array of compenstation range ${err.message}`);
return ;
}
console.log('Callback returned with the array of compenstation range: ' + JSON.stringify(biasRangeArray));
})
``` ```
### getExposureBiasRange ### getExposureBiasRange
getExposureBiasRange(): Promise<Array<number\>\> getExposureBiasRange(): Array<number\>
查询曝光补偿范围,通过Promise获取结果 查询曝光补偿范围。
**系统能力:** SystemCapability.Multimedia.Camera.Core **系统能力:** SystemCapability.Multimedia.Camera.Core
**返回值:** **返回值:**
| 名称 | 说明 | | 类型 | 说明 |
| ----------------- |-------------------------------------- | | ---------- | ----------------------------- |
| Promise<Array<number\>\> | 使用Promise的方式获取曝光补偿范围。 | | Array<number\> | 获取补偿范围的数组。 |
**示例:** **示例:**
```js ```js
captureSession.getExposureBiasRange().then((biasRangeArray) => { try {
console.log('Promise returned with the array of compenstation range: ' + JSON.stringify(biasRangeArray)); let biasRangeArray = captureSession.getExposureBiasRange();
}) } catch (error) {
console.log(error.code);
}
``` ```
### setExposureBias ### setExposureBias
setExposureBias(exposureBias: number, callback: AsyncCallback<void\>): void setExposureBias(exposureBias: number): void
设置曝光补偿,通过注册回调函数获取结果 设置曝光补偿。
进行设置之前,建议先通过方法[getExposureBiasRange](#getexposurebiasrange)查询支持的范围。 进行设置之前,建议先通过方法[getExposureBiasRange](#getexposurebiasrange)查询支持的范围。
...@@ -2134,105 +1386,47 @@ setExposureBias(exposureBias: number, callback: AsyncCallback<void\>): void ...@@ -2134,105 +1386,47 @@ setExposureBias(exposureBias: number, callback: AsyncCallback<void\>): void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------| ---- | ------------------- | | -------- | -------------------------------| ---- | ------------------- |
| exposureBias | number | 是 | 曝光补偿,getExposureBiasRange查询支持的范围 | | exposureBias | number | 是 | 曝光补偿,getExposureBiasRange查询支持的范围 |
| callback | AsyncCallback<void\> | 是 | 回调函数,用于获取结果。 |
**示例:** **示例:**
```js ```js
let exposureBias = biasRangeArray[0]; let exposureBias = biasRangeArray[0];
captureSession.setExposureBias(exposureBias,(err) => { try {
if (err) { captureSession.setExposureBias(exposureBias);
console.log(`Failed to set the exposure bias ${err.message}`); } catch (error) {
return ; console.log(error.code);
} }
console.log('Callback returned with the successful execution of setExposureBias');
})
```
### setExposureBias
setExposureBias(exposureBias: number): Promise<void\>
设置曝光补偿,通过Promise获取结果。
进行设置之前,建议先通过方法[getExposureBiasRange](#getexposurebiasrange)查询支持的范围。
**系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------------- | --------- | ---- | --------- |
| exposureBias | number | 是 | 曝光补偿,getExposureBiasRange查询支持的范围 |
**返回值:**
| 名称 | 说明 |
| ----------------- |------------------------- |
| Promise<void\> | 使用Promise的方式获取结果。 |
**示例:**
```js
let exposureBias = biasRangeArray[0];
captureSession.setExposureBias(exposureBias).then(() => {
console.log('Promise returned with the successful execution of setExposureBias.');
})
```
### getExposureValue
getExposureValue(callback: AsyncCallback<number\>): void
查询当前曝光值,通过注册回调函数获取结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------| ---- | --------------------- |
| callback | AsyncCallback<number\> | 是 | 回调函数,用于获取曝光值。 |
**示例:**
```js
captureSession.getExposureValue((err, exposureValue) => {
if (err) {
console.log(`Failed to get the exposure value ${err.message}`);
return ;
}
console.log(`Callback returned with the exposure value: ${exposureValue}`);
})
``` ```
### getExposureValue ### getExposureValue
getExposureValue(): Promise<number\> getExposureValue(): number
查询当前曝光值,通过Promise获取结果 查询当前曝光值。
**系统能力:** SystemCapability.Multimedia.Camera.Core **系统能力:** SystemCapability.Multimedia.Camera.Core
**返回值:** **返回值:**
| 名称 | 说明 | | 类型 | 说明 |
| ----------------- |-------------------------- | | ---------- | ----------------------------- |
| Promise<number\> | 使用Promise的方式获取曝光值。 | | number | 获取曝光值。 |
**示例:** **示例:**
```js ```js
captureSession.getExposureValue().then((exposureValue) => { try {
console.log(`Promise returned with exposure value: ${exposureValude}`); let exposureValue = captureSession.getExposureValue();
}) } catch (error) {
console.log(error.code);
}
``` ```
### isFocusModeSupported ### isFocusModeSupported
isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback<boolean\>): void isFocusModeSupported(afMode: FocusMode): boolean
检测对焦模式是否支持,通过注册回调函数获取结果 检测对焦模式是否支持。
**系统能力:** SystemCapability.Multimedia.Camera.Core **系统能力:** SystemCapability.Multimedia.Camera.Core
...@@ -2241,53 +1435,28 @@ isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback<boolean\>): void ...@@ -2241,53 +1435,28 @@ isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback<boolean\>): void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------- | ---- | -------------------------------- | | -------- | ----------------------- | ---- | -------------------------------- |
| afMode | [FocusMode](#focusmode) | 是 | 指定的焦距模式。 | | afMode | [FocusMode](#focusmode) | 是 | 指定的焦距模式。 |
| callback | AsyncCallback<boolean\> | 是 | 回调函数,返回true表示支持该焦距模式。 |
**示例:**
```js
captureSession.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_AUTO, (err, status) => {
if (err) {
console.error(`Failed to check whether the focus mode is supported. ${err.message}`);
return;
}
console.log(`Callback returned with the focus mode support status: ${status}`);
})
```
### isFocusModeSupported
isFocusModeSupported(afMode: FocusMode): Promise<boolean\>
检测对焦模式是否支持,通过Promise获取结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ----------------------- | ---- | ------------- |
| afMode | [FocusMode](#focusmode) | 是 | 指定的焦距模式。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ----------------- | --------------------------------------------------- | | ---------- | ----------------------------- |
| Promise<boolean\> | 使用Promise的方式获取结果,返回true表示设备支持该焦距模式。 | | boolean | 返回true表示支持该焦距模式。 |
**示例:** **示例:**
```js ```js
captureSession.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_AUTO).then((status) => { try {
console.log(`Promise returned with focus mode support status ${status}.`); let status = captureSession.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_AUTO);
}) } catch (error) {
console.log(error.code);
}
``` ```
### setFocusMode ### setFocusMode
setFocusMode(afMode: FocusMode, callback: AsyncCallback<void\>): void setFocusMode(afMode: FocusMode): void
设置对焦模式,通过注册回调函数获取结果 设置对焦模式。
进行设置之前,需要先检查设备是否支持指定的焦距模式,可使用方法[isFocusModeSupported](#isfocusmodesupported) 进行设置之前,需要先检查设备是否支持指定的焦距模式,可使用方法[isFocusModeSupported](#isfocusmodesupported)
...@@ -2298,103 +1467,46 @@ setFocusMode(afMode: FocusMode, callback: AsyncCallback<void\>): void ...@@ -2298,103 +1467,46 @@ setFocusMode(afMode: FocusMode, callback: AsyncCallback<void\>): void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------- | ---- | ------------------- | | -------- | ----------------------- | ---- | ------------------- |
| afMode | [FocusMode](#focusmode) | 是 | 指定的焦距模式。 | | afMode | [FocusMode](#focusmode) | 是 | 指定的焦距模式。 |
| callback | AsyncCallback<void\> | 是 | 回调函数,用于获取结果。 |
**示例:**
```js
captureSession.setFocusMode(camera.FocusMode.FOCUS_MODE_AUTO, (err) => {
if (err) {
console.error(`Failed to set the focus mode ${err.message}`);
return;
}
console.log('Callback returned with the successful execution of setFocusMode.');
})
```
### setFocusMode
setFocusMode(afMode: FocusMode): Promise<void\>
设置对焦模式,通过Promise获取结果。
进行设置之前,需要先检查设备是否支持指定的焦距模式,可使用方法[isFocusModeSupported](#isfocusmodesupported)
**系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ----------------------- | ---- | ------------- |
| afMode | [FocusMode](#focusmode) | 是 | 指定的焦距模式。 |
**返回值:**
| 类型 | 说明 |
| -------------- | ------------------------ |
| Promise<void\> | 使用Promise的方式获取结果。 |
**示例:** **示例:**
```js ```js
captureSession.setFocusMode(camera.FocusMode.FOCUS_MODE_AUTO).then(() => { try {
console.log('Promise returned with the successful execution of setFocusMode.'); captureSession.setFocusMode(camera.FocusMode.FOCUS_MODE_AUTO);
}) } catch (error) {
``` console.log(error.code);
}
### getFocusMode
getFocusMode(callback: AsyncCallback<FocusMode\>): void
获取当前的对焦模式,通过注册回调函数获取结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------------- | ---- | ------------------------------- |
| callback | AsyncCallback<[FocusMode](#focusmode)\> | 是 | 回调函数,用于获取当前设备的焦距模式。 |
**示例:**
```js
captureSession.getFocusMode((err, afMode) => {
if (err) {
console.error(`Failed to get the focus mode ${err.message}`);
return;
}
console.log(`Callback returned with current focus mode: ${afMode}`);
})
``` ```
### getFocusMode ### getFocusMode
getFocusMode(): Promise<FocusMode\> getFocusMode(): FocusMode
获取当前的对焦模式,通过Promise获取结果 获取当前的对焦模式。
**系统能力:** SystemCapability.Multimedia.Camera.Core **系统能力:** SystemCapability.Multimedia.Camera.Core
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ------------------- | -------------------------------- | | ---------- | ----------------------------- |
| Promise<FocusMode\> | 使用Promise的方式获取当前的焦距模式。 | | [FocusMode](#focusmode) | 获取当前设备的焦距模式。 |
**示例:** **示例:**
```js ```js
captureSession.getFocusMode().then((afMode) => { try {
console.log(`Promise returned with current focus mode : ${afMode}`); let afMode = captureSession.getFocusMode();
}) } catch (error) {
console.log(error.code);
}
``` ```
### setFocusPoint ### setFocusPoint
setFocusPoint(point: Point, callback: AsyncCallback<void\>): void setFocusPoint(point: Point): void
设置焦点,通过注册回调函数获取结果 设置焦点。
**系统能力:** SystemCapability.Multimedia.Camera.Core **系统能力:** SystemCapability.Multimedia.Camera.Core
...@@ -2402,431 +1514,199 @@ setFocusPoint(point: Point, callback: AsyncCallback<void\>): void ...@@ -2402,431 +1514,199 @@ setFocusPoint(point: Point, callback: AsyncCallback<void\>): void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------- | ---- | ------------------- | | -------- | ----------------------- | ---- | ------------------- |
| point | [Point](#point) | 是 | 焦点。 | | Point1 | [Point](#point) | 是 | 焦点。 |
| callback | AsyncCallback<void\> | 是 | 回调函数,用于获取结果。 |
**示例:** **示例:**
```js ```js
const Point1 = {x: 1, y: 1}; const Point1 = {x: 1, y: 1};
try {
captureSession.setFocusPoint(Point1, (err) => { captureSession.setFocusPoint(Point1);
if (err) { } catch (error) {
console.error(`Failed to set the focus point ${err.message}`); console.log(error.code);
return; }
}
console.log('Callback returned with the successful execution of setFocusPoint.');
})
```
### setFocusPoint
setFocusPoint(point: Point): Promise<void\>
设置焦点,通过Promise获取结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------- | ---- | ------------------- |
| point | [Point](#point) | 是 | 焦点。 |
**返回值:**
| 类型 | 说明 |
| -------------- | ----------------------- |
| Promise<void\> | 使用Promise的方式获取结果。 |
**示例:**
```js
const Point2 = {x: 2, y: 2};
captureSession.setFocusPoint(Point2).then(() => {
console.log('Promise returned with the successful execution of setFocusPoint.');
})
```
### getFocusPoint
getFocusPoint(callback: AsyncCallback<Point\>): void
查询焦点,通过注册回调函数获取结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------- | ---- | ----------------------- |
| callback | AsyncCallback<[Point](#point)\> | 是 | 回调函数,用于获取当前焦点。 |
**示例:**
```js
captureSession.getFocusPoint((err, point) => {
if (err) {
console.error(`Failed to get the current focus point ${err.message}`);
return;
}
console.log('Callback returned with the current focus point: ' + JSON.stringify(point));
})
``` ```
### getFocusPoint ### getFocusPoint
getFocusPoint(): Promise<Point\> getFocusPoint(): Point
查询焦点,通过Promise获取结果 查询焦点。
**系统能力:** SystemCapability.Multimedia.Camera.Core **系统能力:** SystemCapability.Multimedia.Camera.Core
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| --------------- | --------------------------- | | ---------- | ----------------------------- |
| Promise<Point\> | 使用Promise的方式获取当前焦点。 | | [Point](#point) | 用于获取当前焦点。 |
**示例:**
```js
captureSession.getFocusPoint().then((point) => {
console.log('Promise returned with the current focus point: ' + JSON.stringify(point));
})
```
### getFocalLength
getFocalLength(callback: AsyncCallback<number\>): void
查询焦距值,通过注册回调函数获取结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ----------------------- |
| callback | AsyncCallback<number\> | 是 | 回调函数,用于获取当前焦距。 |
**示例:** **示例:**
```js ```js
captureSession.getFocalLength((err, focalLength) => { try {
if (err) { let point = captureSession.getFocusPoint();
console.error(`Failed to get the current focal length ${err.message}`); } catch (error) {
return; console.log(error.code);
} }
console.log(`Callback returned with the current focal length: ${focalLength}`);
})
``` ```
### getFocalLength ### getFocalLength
getFocalLength(): Promise<number\> getFocalLength(): number
查询焦距值,通过Promise获取结果 查询焦距值。
**系统能力:** SystemCapability.Multimedia.Camera.Core **系统能力:** SystemCapability.Multimedia.Camera.Core
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ---------------- | ----------------------- | | ---------- | ----------------------------- |
| Promise<number\> | 使用Promise的方式获取焦距。 | | number | 用于获取当前焦距。 |
**示例:**
```js
captureSession.getFocalLength().then((focalLength) => {
console.log(`Promise returned with the current focal length: ${focalLength}`);
})
```
### getZoomRatioRange
getZoomRatioRange\(callback: AsyncCallback<Array<number\>\>\): void
获取支持的变焦范围,通过注册回调函数获取结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------ | ---- | ------------------- |
| callback | AsyncCallback<Array<number\>\> | 是 | 回调函数,用于获取可变焦距比范围,返回的数组包括其最小值和最大值。 |
**示例:** **示例:**
```js ```js
captureSession.getZoomRatioRange((err, zoomRatioRange) => { try {
if (err) { let focalLength = captureSession.getFocalLength();
console.error(`Failed to get the zoom ratio range. ${err.message}`); } catch (error) {
return; console.log(error.code);
} }
console.log(`Callback returned with zoom ratio range: ${zoomRatioRange.length}`);
})
``` ```
### getZoomRatioRange ### getZoomRatioRange
getZoomRatioRange\(\): Promise<Array<number\>\> getZoomRatioRange(): Array<number\>
获取支持的变焦范围,通过Promise获取结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core
**返回值:**
| 类型 | 说明 |
| ------------------------ | --------------------------- |
| Promise<Array<number\>\> | 使用Promise的方式获取当前的可变焦距比范围,返回的数组包括其最小值和最大值。 |
**示例:**
```js 获取支持的变焦范围。
captureSession.getZoomRatioRange().then((zoomRatioRange) => {
console.log(`Promise returned with zoom ratio range: ${zoomRatioRange.length}`);
})
```
### setZoomRatio
setZoomRatio(zoomRatio: number, callback: AsyncCallback<void\>): void
设置变焦比,通过注册回调函数获取结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core **系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:** **返回值:**
| 参数名 | 类型 | 必填 | 说明 |
| --------- | -------------------- | ---- | ------------------- |
| zoomRatio | number | 是 | 可变焦距比,通过getZoomRatioRange获取支持的变焦范围 |
| callback | AsyncCallback<void\> | 是 | 回调函数,用于获取结果。 |
**示例:**
```js
let zoomRatio = zoomRatioRange[0];
captureSession.setZoomRatio(zoomRatio, (err) => {
if (err) {
console.error(`Failed to set the zoom ratio value ${err.message}`);
return;
}
console.log('Callback returned with the successful execution of setZoomRatio.');
})
```
### setZoomRatio
setZoomRatio(zoomRatio: number): Promise<void\>
设置变焦比,通过Promise获取结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------ | ---- | --------- |
| zoomRatio | number | 是 | 可变焦距比,通过getZoomRatioRange获取支持的变焦范围|
**返回值:**
| 类型 | 说明 |
| -------------- | ----------------------- |
| Promise<void\> | 使用Promise的方式获取结果。 |
**示例:**
```js
let zoomRatio = zoomRatioRange[0];
captureSession.setZoomRatio(zoomRatio).then(() => {
console.log('Promise returned with the successful execution of setZoomRatio.');
})
```
### getZoomRatio
getZoomRatio(callback: AsyncCallback<number\>): void
获取当前的变焦比,通过注册回调函数获取结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------- | ---- | ------------------- |
| callback | AsyncCallback<number\> | 是 | 回调函数,用于获取结果。 |
**示例:**
```js
captureSession.getZoomRatio((err, zoomRatio) => {
if (err) {
console.error(`Failed to get the zoom ratio ${err.message}`);
return;
}
console.log(`Callback returned with current zoom ratio: ${zoomRatio}`);
})
```
### getZoomRatio
getZoomRatio(): Promise<number\>
获取当前的变焦比,通过Promise获取结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core
**返回值:**
| 类型 | 说明 |
| ---------------- | ----------------------- |
| Promise<number\> | 使用Promise的方式获取结果。 |
**示例:**
```js
captureSession.getZoomRatio().then((zoomRatio) => {
console.log(`Promise returned with current zoom ratio : ${zoomRatio}`);
})
```
### isVideoStabilizationModeSupported
isVideoStabilizationModeSupported(vsMode: VideoStabilizationMode, callback: AsyncCallback<boolean\>): void
查询是否支持指定的视频防抖模式,通过注册回调函数获取结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 | | 类型 | 说明 |
| -------- | ------------------------------------------------- | ---- | ------------------------------ | | ---------- | ----------------------------- |
| vsMode | [VideoStabilizationMode](#videostabilizationmode) | 是 | 视频防抖模式。 | | Array<number\> | 用于获取可变焦距比范围,返回的数组包括其最小值和最大值。 |
| callback | AsyncCallback<boolean\> | 是 | 回调函数,返回视频防抖模式是否支持。 |
**示例:** **示例:**
```js ```js
captureSession.isVideoStabilizationModeSupported(camera.VideoStabilizationMode.OFF, (err, isSupported) => { try {
if (err) { let zoomRatioRange = captureSession.getZoomRatioRange();
console.error(`Failed to check whether video stabilization mode supported. ${err.message}`); } catch (error) {
return; console.log(error.code);
} }
console.log(`Callback returned with the successful execution of isVideoStabilizationModeSupported`);
})
``` ```
### isVideoStabilizationModeSupported ### setZoomRatio
isVideoStabilizationModeSupported(vsMode: VideoStabilizationMode): Promise<boolean\> setZoomRatio(zoomRatio: number): void
查询是否支持指定的视频防抖模式,通过Promise获取结果 设置变焦比
**系统能力:** SystemCapability.Multimedia.Camera.Core **系统能力:** SystemCapability.Multimedia.Camera.Core
**返回值:** **参数:**
| 类型 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ----------------- | --------------------------------------------- | | --------- | -------------------- | ---- | ------------------- |
| Promise<boolean\> | 使用Promise的方式获取结果,返回视频防抖模式是否支持。 | | zoomRatio | number | 是 | 可变焦距比,通过getZoomRatioRange获取支持的变焦范围 |
**示例:** **示例:**
```js ```js
captureSession.isVideoStabilizationModeSupported(camera.VideoStabilizationMode.OFF).then((isSupported) => { let zoomRatio = zoomRatioRange[0];
console.log(`Promise returned with video stabilization mode supported: ${isSupported}`); try {
}) captureSession.setZoomRatio(zoomRatio);
} catch (error) {
console.log(error.code);
}
``` ```
### getActiveVideoStabilizationMode ### getZoomRatio
getActiveVideoStabilizationMode(callback: AsyncCallback<VideoStabilizationMode\>): void getZoomRatio(): number
查询当前正在使用的视频防抖模式,通过注册回调函数获取结果 获取当前的变焦比
**系统能力:** SystemCapability.Multimedia.Camera.Core **系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:** **返回值:**
| 参数名 | 类型 | 必填 | 说明 | | 类型 | 说明 |
| -------- | ----------------------------------------- | ---- | ------------------------------ | | ---------- | ----------------------------- |
| callback | AsyncCallback<VideoStabilizationMode\> | 是 | 回调函数,返回视频防抖是否正在使用。 | | number | 获取当前的变焦比结果。 |
**示例:** **示例:**
```js ```js
captureSession.getActiveVideoStabilizationMode((err, vsMode) => { try {
if (err) { let zoomRatio = captureSession.getZoomRatio();
console.error(`Failed to get active video stabilization mode ${err.message}`); } catch (error) {
return; console.log(error.code);
} }
console.log('Callback returned with the successful execution of getActiveVideoStabilizationMode.');
})
``` ```
### getActiveVideoStabilizationMode ### isVideoStabilizationModeSupported
getActiveVideoStabilizationMode(): Promise<VideoStabilizationMode\> isVideoStabilizationModeSupported(vsMode: VideoStabilizationMode): boolean
查询当前正在使用的视频防抖模式,通过Promise获取结果 查询是否支持指定的视频防抖模式
**系统能力:** SystemCapability.Multimedia.Camera.Core **系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------- | ---- | ------------------------------ |
| vsMode | [VideoStabilizationMode](#videostabilizationmode) | 是 | 视频防抖模式。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------------------------------- | ------------------------------------------------- | | ---------- | ----------------------------- |
| Promise<VideoStabilizationMode\> | 使用Promise的方式获取结果,返回视频防抖当前是否正在使用。 | | boolean | 返回视频防抖模式是否支持。 |
**示例:** **示例:**
```js ```js
captureSession.getActiveVideoStabilizationMode().then((vsMode) => { try {
console.log(`Promise returned with the current video stabilization mode: ${vsMode}`); let isSupported = captureSession.isVideoStabilizationModeSupported(camera.VideoStabilizationMode.OFF);
}) } catch (error) {
console.log(error.code);
}
``` ```
### setVideoStabilizationMode ### getActiveVideoStabilizationMode
setVideoStabilizationMode(mode: VideoStabilizationMode, callback: AsyncCallback<void\>): void getActiveVideoStabilizationMode(): VideoStabilizationMode
设置视频防抖模式,通过注册回调函数获取结果 查询当前正在使用的视频防抖模式
**系统能力:** SystemCapability.Multimedia.Camera.Core **系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:** **返回值:**
| 参数名 | 类型 | 必填 | 说明 | | 类型 | 说明 |
| -------- | ------------------------------------------------- | ---- | --------------------- | | ---------- | ----------------------------- |
| mode | [VideoStabilizationMode](#videostabilizationmode) | 是 | 需要设置的视频防抖模式。 | | VideoStabilizationMode | 视频防抖是否正在使用。 |
| callback | AsyncCallback<void\> | 是 | 回调函数。 |
**示例:** **示例:**
```js ```js
captureSession.setVideoStabilizationMode(camera.VideoStabilizationMode.OFF, (err) => { try {
if (err) { let vsMode = captureSession.getActiveVideoStabilizationMode();
console.error(`Failed to set the video stabilization mode ${err.message}`); } catch (error) {
return; console.log(error.code);
} }
console.log('Callback returned with the successful execution of setVideoStabilizationMode.');
})
``` ```
### setVideoStabilizationMode ### setVideoStabilizationMode
setVideoStabilizationMode(mode: VideoStabilizationMode): Promise<void\> setVideoStabilizationMode(mode: VideoStabilizationMode): void
设置视频防抖,通过Promise获取结果 设置视频防抖模式
**系统能力:** SystemCapability.Multimedia.Camera.Core **系统能力:** SystemCapability.Multimedia.Camera.Core
...@@ -2836,18 +1716,14 @@ setVideoStabilizationMode(mode: VideoStabilizationMode): Promise<void\> ...@@ -2836,18 +1716,14 @@ setVideoStabilizationMode(mode: VideoStabilizationMode): Promise<void\>
| -------- | ------------------------------------------------- | ---- | --------------------- | | -------- | ------------------------------------------------- | ---- | --------------------- |
| mode | [VideoStabilizationMode](#videostabilizationmode) | 是 | 需要设置的视频防抖模式。 | | mode | [VideoStabilizationMode](#videostabilizationmode) | 是 | 需要设置的视频防抖模式。 |
**返回值:**
| 类型 | 说明 |
| -------------- | ------------------------------------------------- |
| Promise<void\> | 使用Promise的方式获取结果,返回设置的视频防抖模式的结果。 |
**示例:** **示例:**
```js ```js
captureSession.setVideoStabilizationMode(camera.VideoStabilizationMode.OFF).then(() => { try {
console.log('Promise returned with the successful execution of setVideoStabilizationMode.'); captureSession.setVideoStabilizationMode(camera.VideoStabilizationMode.OFF);
}) } catch (error) {
console.log(error.code);
}
``` ```
### on('focusStateChange') ### on('focusStateChange')
...@@ -2875,7 +1751,7 @@ captureSession.on('focusStateChange', (focusState) => { ...@@ -2875,7 +1751,7 @@ captureSession.on('focusStateChange', (focusState) => {
### on('error') ### on('error')
on(type: 'error', callback: ErrorCallback<CaptureSessionError\>): void on(type: 'error', callback: ErrorCallback<BusinessError\>): void
监听拍照会话的错误事件,通过注册回调函数获取结果。 监听拍照会话的错误事件,通过注册回调函数获取结果。
...@@ -2886,7 +1762,7 @@ on(type: 'error', callback: ErrorCallback<CaptureSessionError\>): void ...@@ -2886,7 +1762,7 @@ on(type: 'error', callback: ErrorCallback<CaptureSessionError\>): void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------------------------------------- | ---- | ------------------------------ | | -------- | ----------------------------------------------------------- | ---- | ------------------------------ |
| type | string | 是 | 监听事件,固定为'error',即拍照会话错误事件。 | | type | string | 是 | 监听事件,固定为'error',即拍照会话错误事件。 |
| callback | ErrorCallback<[CaptureSessionError](#capturesessionerror)\> | 是 | 回调函数,用于获取错误信息。 | | callback | ErrorCallback<BusinessError\> | 是 | 回调函数,用于获取错误信息。 |
**示例:** **示例:**
...@@ -2896,28 +1772,6 @@ captureSession.on('error', (captureSessionError) => { ...@@ -2896,28 +1772,6 @@ captureSession.on('error', (captureSessionError) => {
}) })
``` ```
## CaptureSessionErrorCode
枚举,会话错误类型。
**系统能力:** SystemCapability.Multimedia.Camera.Core
| 名称 | 值 | 说明 |
| ----------------------------- | ---- | -------- |
| ERROR_UNKNOWN | -1 | 未知错误。 |
| ERROR_INSUFFICIENT_RESOURCES | 0 | 资源不足。 |
| ERROR_TIMEOUT | 1 | 超时。 |
## CaptureSessionError
会话错误码。
**系统能力:** SystemCapability.Multimedia.Camera.Core
| 名称 | 类型 | 必填 | 说明 |
| ---- | ------------------------------------------- | -------------------------- |-------------------------- |
| code | [CaptureSessionError](#capturesessionerror) | 是 |CaptureSession中的错误码。 |
## CameraOutput ## CameraOutput
会话中[CaptureSession](#capturesession)使用的输出信息,output的基类。 会话中[CaptureSession](#capturesession)使用的输出信息,output的基类。
...@@ -3118,7 +1972,7 @@ previewOutput.on('frameEnd', () => { ...@@ -3118,7 +1972,7 @@ previewOutput.on('frameEnd', () => {
### on('error') ### on('error')
on(type: 'error', callback: ErrorCallback<PreviewOutputError\>): void on(type: 'error', callback: ErrorCallback<BusinessError\>): void
监听预览输出的错误事件,通过注册回调函数获取结果。 监听预览输出的错误事件,通过注册回调函数获取结果。
...@@ -3129,7 +1983,7 @@ on(type: 'error', callback: ErrorCallback<PreviewOutputError\>): void ...@@ -3129,7 +1983,7 @@ on(type: 'error', callback: ErrorCallback<PreviewOutputError\>): void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------------------------------------------- | ---- | ------------------------ | | -------- | ----------------------------------------------------------------- | ---- | ------------------------ |
| type | string | 是 | 监听事件,固定为'error',即预览输出错误事件。| | type | string | 是 | 监听事件,固定为'error',即预览输出错误事件。|
| callback | ErrorCallback<[PreviewOutputErrorCode](#previewoutputerrorcode)\> | 是 | 回调函数,用于获取错误信息。 | | callback | ErrorCallback<BusinessError\> | 是 | 回调函数,用于获取错误信息。 |
**示例:** **示例:**
...@@ -3139,26 +1993,6 @@ previewOutput.on('error', (previewOutputError) => { ...@@ -3139,26 +1993,6 @@ previewOutput.on('error', (previewOutputError) => {
}) })
``` ```
## PreviewOutputErrorCode
枚举,预览输出错误类型。
**系统能力:** SystemCapability.Multimedia.Camera.Core
| 名称 | 值 | 说明 |
| ------------- | ---- | -------- |
| ERROR_UNKNOWN | -1 | 未知错误。 |
## PreviewOutputError
预览输出错误码。
**系统能力:** SystemCapability.Multimedia.Camera.Core
| 名称 | 类型 | 必填 | 说明 |
| ---- | ------------------------------------------------- | ---------------- |---------------------- |
| code | [PreviewOutputErrorCode](#previewoutputerrorcode) | 是 |PreviewOutput中的错误码。 |
## ImageRotation ## ImageRotation
枚举,图片旋转角度。 枚举,图片旋转角度。
...@@ -3242,6 +2076,28 @@ photoOutput.capture((err) => { ...@@ -3242,6 +2076,28 @@ photoOutput.capture((err) => {
### capture ### capture
capture(): Promise<void\>
以默认设置触发一次拍照,通过Promise获取结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core
**返回值:**
| 类型 | 说明 |
| -------------- | ------------------------ |
| Promise<void\> | 使用Promise的方式获取结果。 |
**示例:**
```js
photoOutput.capture().then(() => {
console.log('Promise returned to indicate that photo capture request success.');
})
```
### capture
capture(setting: PhotoCaptureSetting, callback: AsyncCallback<void\>): void capture(setting: PhotoCaptureSetting, callback: AsyncCallback<void\>): void
以指定参数触发一次拍照,通过注册回调函数获取结果。 以指定参数触发一次拍照,通过注册回调函数获取结果。
...@@ -3302,35 +2158,29 @@ capture(setting?: PhotoCaptureSetting): Promise<void\> ...@@ -3302,35 +2158,29 @@ capture(setting?: PhotoCaptureSetting): Promise<void\>
**示例:** **示例:**
```js ```js
photoOutput.capture().then(() => { photoOutput.capture(settings).then(() => {
console.log('Promise returned to indicate that photo capture request success.'); console.log('Promise returned to indicate that photo capture request success.');
}) })
``` ```
### isMirrorSupported ### isMirrorSupported
isMirrorSupported(callback: AsyncCallback<boolean\>): void isMirrorSupported(): boolean
查询是否支持镜像拍照,通过注册回调函数获取结果 查询是否支持镜像拍照。
**系统能力:** SystemCapability.Multimedia.Camera.Core **系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:** **返回值:**
| 参数名 | 类型 | 必填 | 说明 | | 类型 | 说明 |
| -------- | ------------------------------------------------- | ---- | -------------------------- | | -------------- | ----------------------- |
| callback | AsyncCallback<boolean\> | 是 | 回调函数,返回是否支持镜像拍照。 | | boolean | 回是否支持镜像拍照。 |
**示例:** **示例:**
```js ```js
photoOutput.isMirrorSupported((err, isSupported) => { let isSupported = photoOutput.isMirrorSupported();
if (err) {
console.error(`Failed to check mirror is supported ${err.message}`);
return;
}
console.log('Callback returned with the successful execution of isMirrorSupported.');
})
``` ```
### release ### release
...@@ -3381,28 +2231,6 @@ photoOutput.release().then(() => { ...@@ -3381,28 +2231,6 @@ photoOutput.release().then(() => {
}) })
``` ```
### isMirrorSupported
isMirrorSupported(): Promise<boolean\>
查询是否支持镜像拍照,通过Promise获取结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core
**返回值:**
| 类型 | 说明 |
| ----------------- | ------------------------------------------- |
| Promise<boolean\> | 使用Promise的方式获取结果,返回是否支持自拍结果。 |
**示例:**
```js
photoOutput.isMirrorSupported().then((isSupported) => {
console.log(`Promise returned with mirror supported: ${isSupported}`);
})
```
### on('captureStart') ### on('captureStart')
on(type: 'captureStart', callback: AsyncCallback<number\>): void on(type: 'captureStart', callback: AsyncCallback<number\>): void
...@@ -3476,7 +2304,7 @@ photoOutput.on('captureEnd', (err, captureEndInfo) => { ...@@ -3476,7 +2304,7 @@ photoOutput.on('captureEnd', (err, captureEndInfo) => {
### on('error') ### on('error')
on(type: 'error', callback: ErrorCallback<PhotoOutputError\>): void on(type: 'error', callback: ErrorCallback<BusinessError\>): void
监听拍照输出发生错误,通过注册回调函数获取结果。 监听拍照输出发生错误,通过注册回调函数获取结果。
...@@ -3487,7 +2315,7 @@ on(type: 'error', callback: ErrorCallback<PhotoOutputError\>): void ...@@ -3487,7 +2315,7 @@ on(type: 'error', callback: ErrorCallback<PhotoOutputError\>): void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------------------------------- | ---- | ----------------------------------- | | -------- | ----------------------------------------------------- | ---- | ----------------------------------- |
| type | string | 是 | 监听事件,固定为'error',即拍照错误事件。 | | type | string | 是 | 监听事件,固定为'error',即拍照错误事件。 |
| callback | ErrorCallback<[PhotoOutputError](#photooutputerror)\> | 是 | 回调函数,用于获取错误信息。 | | callback | ErrorCallback<BusinessError\> | 是 | 回调函数,用于获取错误信息。 |
**示例:** **示例:**
...@@ -3519,29 +2347,6 @@ photoOutput.on('error', (err, photoOutputError) => { ...@@ -3519,29 +2347,6 @@ photoOutput.on('error', (err, photoOutputError) => {
| captureId | number | 是 | 拍照的ID。 | | captureId | number | 是 | 拍照的ID。 |
| frameCount | number | 是 | 帧数。 | | frameCount | number | 是 | 帧数。 |
## PhotoOutputErrorCode
枚举,拍照输出错误类型。
**系统能力:** SystemCapability.Multimedia.Camera.Core
| 名称 | 值 | 说明 |
| ----------------------------- | ---- | --------------- |
| ERROR_UNKNOWN | -1 | 未知错误。 |
| ERROR_DRIVER_ERROR | 0 | 驱动或者硬件错误。 |
| ERROR_INSUFFICIENT_RESOURCES | 1 | 资源不足。 |
| ERROR_TIMEOUT | 2 | 超时。 |
## PhotoOutputError
拍照输出错误码。
**系统能力:** SystemCapability.Multimedia.Camera.Core
| 名称 | 类型 | 必填 |说明 |
| ---- | ------------------------------------- | --------- | ----------------------- |
| code | [PhotoOutputErrorCode](#photooutputerrorcode) | 是 | PhotoOutput中的错误码。 |
## VideoOutput ## VideoOutput
录像会话中使用的输出信息,继承[CameraOutput](#cameraoutput) 录像会话中使用的输出信息,继承[CameraOutput](#cameraoutput)
...@@ -3641,7 +2446,7 @@ stop(): Promise<void\> ...@@ -3641,7 +2446,7 @@ stop(): Promise<void\>
videoOutput.stop().then(() => { videoOutput.stop().then(() => {
console.log('Promise returned to indicate that stop method execution success.'); console.log('Promise returned to indicate that stop method execution success.');
}) })
``` ```
### release ### release
...@@ -3739,7 +2544,7 @@ videoOutput.on('frameEnd', () => { ...@@ -3739,7 +2544,7 @@ videoOutput.on('frameEnd', () => {
### on('error') ### on('error')
on(type: 'error', callback: ErrorCallback<VideoOutputError\>): void on(type: 'error', callback: ErrorCallback<BusinessError\>): void
监听录像输出发生错误,通过注册回调函数获取结果。 监听录像输出发生错误,通过注册回调函数获取结果。
...@@ -3750,7 +2555,7 @@ on(type: 'error', callback: ErrorCallback<VideoOutputError\>): void ...@@ -3750,7 +2555,7 @@ on(type: 'error', callback: ErrorCallback<VideoOutputError\>): void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------ | ---- | -------------------------------------- | | -------- | ------------------------------------------------ | ---- | -------------------------------------- |
| type | string | 是 | 监听事件,固定为'error',即视频输出错误事件。 | | type | string | 是 | 监听事件,固定为'error',即视频输出错误事件。 |
| callback | Callback<[VideoOutputError](#videooutputerror)\> | 是 | 回调函数,用于获取错误信息。 | | callback | Callback<BusinessError\> | 是 | 回调函数,用于获取错误信息。 |
**示例:** **示例:**
...@@ -3760,27 +2565,6 @@ videoOutput.on('error', (VideoOutputError) => { ...@@ -3760,27 +2565,6 @@ videoOutput.on('error', (VideoOutputError) => {
}) })
``` ```
## VideoOutputErrorCode
枚举,录像输出错误类型。
**系统能力:** SystemCapability.Multimedia.Camera.Core
| 名称 | 值 | 说明 |
| --------------------- | ---- | ------------ |
| ERROR_UNKNOWN | -1 | 未知错误。 |
| ERROR_DRIVER_ERROR | 0 | 驱动或者硬件错误。|
## VideoOutputError
录像输出错误码。
**系统能力:** SystemCapability.Multimedia.Camera.Core
| 名称 | 类型 | 必填 | 说明 |
| ---- | ------------------------------------- | ----------------- | ----------------------- |
| code | [PhotoOutputErrorCode](#photooutputerrorcode) | 是 | VideoOutput中的错误码。 |
## MetadataOutput ## MetadataOutput
metadata流。继承[CameraOutput](#cameraoutput) metadata流。继承[CameraOutput](#cameraoutput)
...@@ -3906,7 +2690,7 @@ metadataOutput.on('metadataObjectsAvailable', (metadataObjectArr) => { ...@@ -3906,7 +2690,7 @@ metadataOutput.on('metadataObjectsAvailable', (metadataObjectArr) => {
### on('error') ### on('error')
on(type: 'error', callback: ErrorCallback<MetadataOutputError\>): void on(type: 'error', callback: ErrorCallback<BusinessError\>): void
监听metadata流的错误,通过注册回调函数获取结果。 监听metadata流的错误,通过注册回调函数获取结果。
...@@ -3917,7 +2701,7 @@ on(type: 'error', callback: ErrorCallback<MetadataOutputError\>): void ...@@ -3917,7 +2701,7 @@ on(type: 'error', callback: ErrorCallback<MetadataOutputError\>): void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------ | ---- | --------------------------------------- | | -------- | ------------------------------------------------ | ---- | --------------------------------------- |
| type | string | 是 | 监听事件,固定为'error',即metadata流的错误。 | | type | string | 是 | 监听事件,固定为'error',即metadata流的错误。 |
| callback | Callback<[MetadataOutputError](#metadataoutputerror)\> | 是 | 回调函数,用于获取错误信息。 | | callback | Callback<BusinessError\> | 是 | 回调函数,用于获取错误信息。 |
**示例:** **示例:**
...@@ -3927,27 +2711,6 @@ metadataOutput.on('error', (metadataOutputError) => { ...@@ -3927,27 +2711,6 @@ metadataOutput.on('error', (metadataOutputError) => {
}) })
``` ```
## MetadataOutputErrorCode
枚举,metadata输出错误类型。
**系统能力:** SystemCapability.Multimedia.Camera.Core
| 名称 | 值 | 说明 |
| ------------------------------- | ---- | -------- |
| ERROR_UNKNOWN | -1 | 未知错误。 |
| ERROR_INSUFFICIENT_RESOURCES | 0 | 资源不足。 |
## MetadataOutputError
metadata输出错误码。
**系统能力:** SystemCapability.Multimedia.Camera.Core
| 名称 | 类型 | 必填 | 说明 |
| ---- | ------------------------------------- | ----------------- | ----------------------- |
| code | [MetadataOutputErrorCode](#metadataoutputerrorcode) | 是 | MetadataOutput中的错误码。 |
## MetadataObjectType ## MetadataObjectType
枚举,metadata流。 枚举,metadata流。
...@@ -3975,156 +2738,8 @@ metadata输出错误码。 ...@@ -3975,156 +2738,8 @@ metadata输出错误码。
相机元能力信息,[CameraInput](#camerainput)相机信息中的数据来源,通过metadataOutput.on('metadataObjectsAvailable')接口获取 相机元能力信息,[CameraInput](#camerainput)相机信息中的数据来源,通过metadataOutput.on('metadataObjectsAvailable')接口获取
### getType | 名称 | 类型 | 必填 | 说明 |
| -------- | ------------------------------- | ---- | -----------------|
getType(callback: AsyncCallback<MetadataObjectType\>): void | type | [MetadataObjectType](#metadataobjecttype) | 否 | 图片质量。 |
| timestamp | number | 否 | 图片旋转角度。 |
查询metadata对象类型,通过注册回调函数获取结果。 | boundingBox | [Rect](#rect) | 否 | 图片地理位置信息。 |
\ No newline at end of file
**系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------------------------------- | --- | -------------------- |
| callback | AsyncCallback<[MetadataObjectType](#metadataobjecttype)\> | 是 | 回调函数,用于获取结果。 |
**示例:**
```js
let metadataObject = metadataObjectArr[0];
metadataObject.getType((err, metadataObjectType) => {
if (err) {
console.error(`Failed to get type. ${err.message}`);
return;
}
console.log('Callback returned with an array of metadataObjectType.');
})
```
### getType
getType(): Promise<MetadataObjectType\>
查询metadata对象类型,通过Promise获取结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core
**返回值:**
| 类型 | 说明 |
| --------------------------------------------------- | --------------------------- |
| Promise<[MetadataObjectType](#metadataobjecttype)\> | 使用Promise的方式获取结果。 |
**示例:**
```js
let metadataObject = metadataObjectArr[0];
metadataObject.getType().then((metadataObjectType) => {
console.log('Callback returned with an array of metadataObjectType.');
})
```
### getTimestamp
getTimestamp(callback: AsyncCallback<number\>): void
查询metadata时间戳,通过注册回调函数获取结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------------------------------------- | ---- | ------------------------ |
| callback | AsyncCallback<number\> | 是 | 回调函数,用于获取结果。 |
**示例:**
```js
let metadataObject = metadataObjectArr[0];
metadataObject.getTimestamp((err,timestamp) => {
if (err) {
console.error(`Failed to get timestamp. ${err.message}`);
return;
}
console.log('Callback returned with timestamp getted timestamp : ${timestamp}');
})
```
### getTimestamp
getTimestamp(): Promise<number\>
查询metadata时间戳,通过Promise获取结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core
**返回值:**
| 类型 | 说明 |
| ---------------- | --------------------------- |
| Promise<number)\> | 使用Promise的方式获取结果。 |
**示例:**
```js
let metadataObject = metadataObjectArr[0];
metadataObject.getTimestamp().then((timestamp) => {
console.log('Callback returned with timestamp getted timestamp : ${timestamp}');
})
```
### getBoundingBox
getBoundingBox(callback: AsyncCallback<Rect\>): void
查询metadata的边界框,通过注册回调函数获取结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------------------------------------- | ---- | ------------------------ |
| callback | AsyncCallback<[Rect](#rect)\> | 是 | 回调函数,用于获取结果。 |
**示例:**
```js
let metadataObject = metadataObjectArr[0];
metadataObject.getBoundingBox((err, rect) => {
if (err) {
console.error(`Failed to get boundingBox. ${err.message}`);
return;
}
console.log('Callback returned with boundingBox getted.');
})
```
### getBoundingBox
getBoundingBox(): Promise<Rect\>
查询metadata的边界框,通过Promise获取结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core
**返回值:**
| 类型 | 说明 |
| ---------------------- | --------------------------- |
| Promise<[Rect](#rect)\> | 使用Promise的方式获取结果。 |
**示例:**
```js
let metadataObject = metadataObjectArr[0];
metadataObject.getBoundingBox().then((rect) => {
console.log('Callback returned with boundingBox getted.');
})
```
## MetadataFaceObject
metadata的人脸对象。继承[MetadataObject](#metadataobject)
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册