Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
f2a43b77
D
Docs
项目概览
OpenHarmony
/
Docs
大约 2 年 前同步成功
通知
161
Star
293
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f2a43b77
编写于
1月 12, 2023
作者:
M
mali
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Camera development and interface document update
Signed-off-by:
N
mali
<
mali81@huawei.com
>
上级
a0f765fa
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
578 addition
and
1927 deletion
+578
-1927
zh-cn/application-dev/media/camera.md
zh-cn/application-dev/media/camera.md
+116
-80
zh-cn/application-dev/reference/apis/js-apis-camera.md
zh-cn/application-dev/reference/apis/js-apis-camera.md
+462
-1847
未找到文件。
zh-cn/application-dev/media/camera.md
浏览文件 @
f2a43b77
...
...
@@ -8,7 +8,7 @@ OpenHarmony相机模块支持相机业务的开发,开发者可以通过已开
-
**相机静态能力**
:用于描述相机的固有能力的一系列参数,比如朝向、支持的分辨率等信息。
-
**物理相机**
:物理相机就是独立的实体摄像头设备。物理相机ID是用于标志每个物理摄像头的唯一字串。
-
**异步操作**
:为保证UI线程不被阻塞,
大部分Camera调用都是异步的。对于每个
API均提供了callback函数和Promise函数。
-
**异步操作**
:为保证UI线程不被阻塞,
部分Camera接口采用异步调用方式。异步方式
API均提供了callback函数和Promise函数。
## 开发步骤
...
...
@@ -60,36 +60,46 @@ import media from '@ohos.multimedia.media'
// 创建CameraManager对象
context
:
any
=
getContext
(
this
)
let
cameraManager
=
await
camera
.
getCameraManager
(
this
.
context
)
if
(
!
cameraManager
)
{
let
cameraManager
try
{
cameraManager
=
camera
.
getCameraManager
(
this
.
context
);
}
catch
(
error
)
{
console
.
error
(
'
Failed to get the CameraManager instance
'
);
}
// 获取相机列表
let
cameraArray
=
await
cameraManager
.
getSupportedCameras
()
if
(
!
cameraArray
)
{
console
.
error
(
'
Failed to get the cameras
'
);
let
cameraArray
try
{
cameraArray
=
cameraManager
.
getSupportedCameras
();
}
catch
(
error
)
{
console
.
error
(
'
Failed to get the cameras errorCode =
'
+
error
.
code
);
}
for
(
let
index
=
0
;
index
<
cameraArray
.
length
;
index
++
)
{
console
.
log
(
'
cameraId :
'
+
cameraArray
[
index
].
cameraId
)
// 获取相机ID
console
.
log
(
'
cameraPosition :
'
+
cameraArray
[
index
].
cameraPosition
)
// 获取相机位置
console
.
log
(
'
cameraType :
'
+
cameraArray
[
index
].
cameraType
)
// 获取相机类型
console
.
log
(
'
connectionType :
'
+
cameraArray
[
index
].
connectionType
)
// 获取相机连接类型
console
.
log
(
'
cameraId :
'
+
cameraArray
[
index
].
cameraId
)
;
// 获取相机ID
console
.
log
(
'
cameraPosition :
'
+
cameraArray
[
index
].
cameraPosition
)
;
// 获取相机位置
console
.
log
(
'
cameraType :
'
+
cameraArray
[
index
].
cameraType
)
;
// 获取相机类型
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
();
// 获取相机设备支持的输出流能力
let
cameraOutputCap
=
await
cameraManager
.
getSupportedOutputCapability
(
cameraArray
[
0
]);
if
(
!
cameraOutputCap
)
{
console
.
error
(
"
outputCapability outputCapability == null || undefined
"
)
}
else
{
let
cameraOutputCap
try
{
cameraOutputCap
=
cameraManager
.
getSupportedOutputCapability
(
cameraArray
[
0
]);
console
.
info
(
"
outputCapability:
"
+
JSON
.
stringify
(
cameraOutputCap
));
}
catch
(
error
)
{
console
.
error
(
"
outputCapability outputCapability == null || undefined
"
)
}
let
previewProfilesArray
=
cameraOutputCap
.
GetPreviewProfiles
();
...
...
@@ -113,8 +123,10 @@ if (!metadataObjectTypesArray) {
}
// 创建预览输出流,其中参数 surfaceId 参考下面 XComponent 组件,预览流为XComponent组件提供的surface
let
previewOutput
=
await
cameraManager
.
createPreviewOutput
(
previewProfilesArray
[
0
],
surfaceId
)
if
(
!
previewOutput
)
{
let
previewOutput
try
{
previewOutput
=
cameraManager
.
createPreviewOutput
(
previewProfilesArray
[
0
],
surfaceId
)
}
catch
(
error
)
{
console
.
error
(
"
Failed to create the PreviewOutput instance.
"
)
}
...
...
@@ -123,10 +135,11 @@ let imageReceiver = await image.createImageReceiver(1920, 1080, 4, 8)
// 获取照片显示SurfaceId
let
photoSurfaceId
=
await
imageReceiver
.
getReceivingSurfaceId
()
// 创建拍照输出流
let
photoOutput
=
await
cameraManager
.
createPhotoOutput
(
photoProfilesArray
[
0
],
photoSurfaceId
)
if
(
!
photoOutput
)
{
console
.
error
(
'
Failed to create the PhotoOutput instance.
'
);
return
;
let
photoOutput
try
{
photoOutput
=
cameraManager
.
createPhotoOutput
(
photoProfilesArray
[
0
],
photoSurfaceId
)
}
catch
(
error
)
{
console
.
error
(
'
Failed to createPhotoOutput errorCode =
'
+
error
.
code
);
}
// 创建视频录制的参数
...
...
@@ -169,10 +182,11 @@ videoRecorder.getInputSurface().then((id) => {
})
// 创建VideoOutput对象
let
videoOutput
=
await
cameraManager
.
createVideoOutput
(
videoProfilesArray
[
0
],
videoSurfaceId
)
if
(
!
videoOutput
)
{
console
.
error
(
'
Failed to create the videoOutput instance.
'
);
return
;
let
videoOutput
try
{
videoOutput
=
cameraManager
.
createVideoOutput
(
videoProfilesArray
[
0
],
videoSurfaceId
)
}
catch
(
error
)
{
console
.
error
(
'
Failed to create the videoOutput instance. errorCode =
'
+
error
.
code
);
}
```
预览流、拍照流和录像流的输入均需要提前创建surface,其中预览流为XComponent组件提供的surface,拍照流为ImageReceiver提供的surface,录像流为VideoRecorder的surface。
...
...
@@ -247,24 +261,40 @@ function getVideoRecorderSurface() {
```
typescript
//创建会话
let
captureSession
=
await
camera
.
createCaptureSession
()
if
(
!
captureSession
)
{
console
.
error
(
'
Failed to create the CaptureSession instance.
'
);
return
;
let
captureSession
try
{
captureSession
=
cameraManager
.
createCaptureSession
()
}
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
()
...
...
@@ -282,13 +312,25 @@ await captureSession.start().then(() => {
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
()
...
...
@@ -303,71 +345,65 @@ await captureSession.start().then(() => {
```
typescript
// 判断设备是否支持闪光灯
let
flashStatus
=
await
captureSession
.
hasFlash
()
if
(
!
flashStatus
)
{
console
.
error
(
'
Failed to check whether the device has the flash mode.
'
);
let
flashStatus
try
{
flashStatus
=
captureSession
.
hasFlash
()
}
catch
(
error
)
{
console
.
error
(
'
Failed to hasFlash. errorCode =
'
+
error
.
code
);
}
console
.
log
(
'
Promise returned with the flash light support status:
'
+
flashStatus
);
if
(
flashStatus
)
{
// 判断是否支持自动闪光灯模式
let
flashModeStatus
captureSession
.
isFlashModeSupported
(
camera
.
FlashMode
.
FLASH_MODE_AUTO
,
async
(
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
);
try
{
let
status
=
captureSession
.
isFlashModeSupported
(
camera
.
FlashMode
.
FLASH_MODE_AUTO
)
flashModeStatus
=
status
})
}
catch
(
error
)
{
console
.
error
(
'
Failed to check whether the flash mode is supported. errorCode =
'
+
error
.
code
);
}
if
(
flashModeStatus
)
{
// 设置自动闪光灯模式
captureSession
.
setFlashMode
(
camera
.
FlashMode
.
FLASH_MODE_AUTO
,
async
(
err
)
=>
{
if
(
err
)
{
console
.
error
(
'
Failed to set the flash mode ${err.message}
'
);
return
;
}
console
.
log
(
'
Callback returned with the successful execution of setFlashMode.
'
);
})
try
{
captureSession
.
setFlashMode
(
camera
.
FlashMode
.
FLASH_MODE_AUTO
)
}
catch
(
error
)
{
console
.
error
(
'
Failed to set the flash mode. errorCode =
'
+
error
.
code
);
}
}
}
// 判断是否支持连续自动变焦模式
let
focusModeStatus
captureSession
.
isFocusModeSupported
(
camera
.
FocusMode
.
FOCUS_MODE_CONTINUOUS_AUTO
,
async
(
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
);
try
{
let
status
=
captureSession
.
isFocusModeSupported
(
camera
.
FocusMode
.
FOCUS_MODE_CONTINUOUS_AUTO
)
focusModeStatus
=
status
})
}
catch
(
error
)
{
console
.
error
(
'
Failed to check whether the focus mode is supported. errorCode =
'
+
error
.
code
);
}
if
(
focusModeStatus
)
{
// 设置连续自动变焦模式
captureSession
.
setFocusMode
(
camera
.
FocusMode
.
FOCUS_MODE_CONTINUOUS_AUTO
,
async
(
err
)
=>
{
if
(
err
)
{
console
.
error
(
'
Failed to set the focus mode ${err.message}
'
);
return
;
}
console
.
log
(
'
Callback returned with the successful execution of setFocusMode.
'
);
})
try
{
captureSession
.
setFocusMode
(
camera
.
FocusMode
.
FOCUS_MODE_CONTINUOUS_AUTO
)
}
catch
(
error
)
{
console
.
error
(
'
Failed to set the focus mode. errorCode =
'
+
error
.
code
);
}
}
// 获取相机支持的可变焦距比范围
let
zoomRatioRange
=
await
captureSession
.
getZoomRatioRange
()
if
(
!
zoomRatioRange
)
{
console
.
error
(
'
Failed to get the zoom ratio range.
'
);
return
;
let
zoomRatioRange
try
{
zoomRatioRange
=
captureSession
.
getZoomRatioRange
()
}
catch
(
error
)
{
console
.
error
(
'
Failed to get the zoom ratio range. errorCode =
'
+
error
.
code
);
}
// 设置可变焦距比
captureSession
.
setZoomRatio
(
zoomRatioRange
[
0
],
async
(
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.
'
);
})
try
{
captureSession
.
setZoomRatio
(
zoomRatioRange
[
0
])
}
catch
(
error
)
{
console
.
error
(
'
Failed to set the zoom ratio value. errorCode =
'
+
error
.
code
);
}
```
#### 拍照
...
...
@@ -428,7 +464,7 @@ videoOutput.stop((err) => {
captureSession
.
stop
()
// 释放相机输入流
cameraInput
.
relea
se
()
cameraInput
.
clo
se
()
// 释放预览输出流
previewOutput
.
release
()
...
...
zh-cn/application-dev/reference/apis/js-apis-camera.md
浏览文件 @
f2a43b77
...
...
@@ -12,9 +12,9 @@ import camera from '@ohos.multimedia.camera';
## camera.getCameraManager
getCameraManager(context: Context
, callback: AsyncCallback<CameraManager
\>
): void
getCameraManager(context: Context
): CameraManager
获取相机管理器实例,
通过注册回调函数获取
结果。
获取相机管理器实例,
同步返回
结果。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
...
...
@@ -23,46 +23,17 @@ getCameraManager(context: Context, callback: AsyncCallback<CameraManager\>): voi
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------------------------- | ---- | ---------------------------- |
| 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
camera
.
getCameraManager
(
context
).
then
((
cameraManager
)
=>
{
console
.
log
(
'
Promise returned with the CameraManager instance.
'
);
})
let
cameraManager
=
camera
.
getCameraManager
(
context
);
```
## CameraStatus
...
...
@@ -71,12 +42,12 @@ camera.getCameraManager(context).then((cameraManager) => {
**系统能力:**
SystemCapability.Multimedia.Camera.Core
| 名称
| 值 | 说明
|
| ------------------------- | ---- | ------------ |
| 名称
| 值 | 说明
|
| ------------------------- | ---- | ------------
|
| CAMERA_STATUS_APPEAR | 0 | 新的相机出现。 |
| CAMERA_STATUS_DISAPPEAR | 1 | 相机被移除。 |
| CAMERA_STATUS_AVAILABLE | 2 | 相机可用。 |
| CAMERA_STATUS_UNAVAILABLE | 3 | 相机不可用。 |
| CAMERA_STATUS_DISAPPEAR | 1 | 相机被移除。
|
| CAMERA_STATUS_AVAILABLE | 2 | 相机可用。
|
| CAMERA_STATUS_UNAVAILABLE | 3 | 相机不可用。
|
## Profile
...
...
@@ -123,64 +94,58 @@ camera.getCameraManager(context).then((cameraManager) => {
| videoProfiles | Array<
[
VideoProfile
](
#videoprofile
)
\>
| 是 | 支持的录像配置信息。 |
| supportedMetadataObjectTypes | Array<
[
MetadataObjectType
](
#metadataobjecttype
)
\>
| 是 | 支持的metadata流类型信息。|
## CameraManager
相机管理器类,使用前需要通过getCameraManager获取相机管理实例。
### getSupportedCameras
getSupportedCameras(callback: AsyncCallback<Array<CameraDevice
\>\>
): void
## CameraErrorCode
获取支持指定的相机设备对象,通过注册回调函数获取结果
。
相机错误码
。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------------------------------- | ---- | ------------------------------- |
| callback | AsyncCallback<Array<
[
CameraDevice
](
#cameradevice
)
\>\>
| 是 | 使用callback方式获取支持的相机列表。 |
| 名称 | 值 | 说明 |
| ------------------------- | ---- | ------------ |
| INVALID_ARGUMENT | 7400101 | 参数缺失或者参数类型不对。 |
| OPERATION_NOT_ALLOWED | 7400102 | 操作流程不对,不允许。 |
| 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
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
}
`
);
})
```
相机管理器类,使用前需要通过getCameraManager获取相机管理实例。
### getSupportedCameras
getSupportedCameras():
Promise<Array<CameraDevice
\>
\>
getSupportedCameras():
Array<CameraDevice
\>
获取支持指定的相机设备对象,
通过Promise获取
结果。
获取支持指定的相机设备对象,
同步返回
结果。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
**返回值:**
| 类型 | 说明 |
| ----------------------------------------------- | ------------------------- |
| Promise<Array<
[
CameraDevice
](
#cameradevice
)
\>\>
| 使用promise获取支持相机列表。 |
| 类型 | 说明 |
| ----------------------------------------------- | ---------------------------- |
| Array
<
[
CameraDevice
](
#cameradevice
)
>
| 相机设备列表。 |
**示例:**
```
js
cameraManager
.
getSupportedCameras
().
then
((
cameras
)
=>
{
console
.
log
(
`Promise returned with an array of supported cameras:
${
cameras
.
length
}
`
);
})
let
cameras
;
try
{
cameras
=
cameraManager
.
getSupportedCameras
();
}
catch
(
error
)
{
console
.
log
(
error
.
code
);
}
```
### getSupportedOutputCapability
getSupportedOutputCapability(camera
:CameraDevice, callback: AsyncCallback<CameraOutputCapability
\>
): void
getSupportedOutputCapability(camera
Device:CameraDevice): CameraOutputCapability
查询相机设备在模式下支持的输出能力,
通过注册回调函数获取
结果。
查询相机设备在模式下支持的输出能力,
同步返回
结果。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
...
...
@@ -189,52 +154,23 @@ getSupportedOutputCapability(camera:CameraDevice, callback: AsyncCallback<Camera
| 参数名 | 类型 | 必填 | 说明 |
| ------------ |--------------------------------------------------------------- | -- | -------------------------- |
| 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
cameraManager
.
getSupportedCameras
().
then
((
cameras
)
=>
{
let
cameraDevice
=
cameras
[
0
];
cameraManager
.
getSupportedOutputCapability
(
cameraDevice
).
then
((
cameraoutputcapability
)
=>
{
console
.
log
(
'
Promise returned with an array of supported outputCapability
'
);
})
})
let
cameraDevice
=
cameras
[
0
];
let
cameraOutputCapability
;
try
{
cameraOutputCapability
=
cameraManager
.
getSupportedOutputCapability
(
cameraDevice
);
}
catch
(
error
)
{
console
.
log
(
error
.
code
);
}
```
### isCameraMuted
...
...
@@ -306,9 +242,9 @@ cameraManager.muteCamera(mute);
### createCameraInput
createCameraInput(camera: CameraDevice
, callback: AsyncCallback<CameraInput
\>
): void
createCameraInput(camera: CameraDevice
): CameraInput
使用CameraDevice对象
异步创建CameraInput实例,通过注册回调函数获取
结果。
使用CameraDevice对象
创建CameraInput实例,同步返回
结果。
**需要权限:**
ohos.permission.CAMERA
...
...
@@ -319,57 +255,30 @@ createCameraInput(camera: CameraDevice, callback: AsyncCallback<CameraInput\>):
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------- | ---- | --------------------------------- |
| 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
let
cameraDevice
=
cameras
[
0
];
cameraManager
.
createCameraInput
(
cameraDevice
).
then
((
cameraInput
)
=>
{
console
.
log
(
'
Promise returned with the CameraInput instance
'
);
})
let
cameraInput
;
try
{
cameraInput
=
cameraManager
.
createCameraInput
(
cameraDevice
);
}
catch
(
error
)
{
console
.
log
(
error
.
code
);
}
```
### createCameraInput
createCameraInput(position: CameraPosition, type: CameraType
, callback: AsyncCallback<CameraInput
\>
): void
createCameraInput(position: CameraPosition, type: CameraType
): CameraInput
根据相机位置和类型创建CameraInput实例,
通过注册回调函数获取
结果。
根据相机位置和类型创建CameraInput实例,
同步返回
结果。
**需要权限:**
ohos.permission.CAMERA
...
...
@@ -381,45 +290,12 @@ createCameraInput(position: CameraPosition, type: CameraType, callback: AsyncCal
| -------- | ------------------------------------------- | ---- | --------------------------------- |
| position |
[
CameraPosition
](
#cameraposition
)
| 是 | 相机位置,通过 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
let
cameraDevice
=
cameras
[
0
];
let
position
=
cameraDevice
.
cameraPosition
;
let
type
=
cameraDevice
.
cameraType
;
cameraManager
.
createCameraInput
(
position
,
type
).
then
((
cameraInput
)
=>
{
console
.
log
(
'
Promise returned with the CameraInput instance
'
);
})
let
cameraInput
;
try
{
cameraInput
=
cameraManager
.
createCameraInput
(
position
,
type
);
}
catch
(
error
)
{
console
.
log
(
error
.
code
);
}
```
### createPreviewOutput
createPreviewOutput(profile: Profile, surfaceId: string
, callback: AsyncCallback<PreviewOutput
\>
): void
createPreviewOutput(profile: Profile, surfaceId: string
): PreviewOutput
创建预览输出对象,
通过注册回调函数获取
结果。
创建预览输出对象,
同步返回
结果。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
...
...
@@ -446,56 +325,30 @@ createPreviewOutput(profile: Profile, surfaceId: string, callback: AsyncCallback
| -------- | ----------------------------------------------- | ---- | ------------------------------- |
| profile |
[
Profile
](
#profile
)
| 是 | 支持的预览配置信息,通过getSupportedOutputCapability接口获取。|
| 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
let
profile
=
cameraoutputcapability
.
previewProfiles
[
0
];
cameraManager
.
createPreviewOutput
(
profile
,
surfaceId
).
then
((
previewOutput
)
=>
{
console
.
log
(
'
Promise returned with previewOutput created.
'
);
})
let
previewOutput
;
try
{
previewOutput
=
cameraManager
.
createPreviewOutput
(
profile
,
surfaceId
);
}
catch
(
error
)
{
console
.
log
(
error
.
code
);
}
```
### createPhotoOutput
createPhotoOutput(profile: Profile, surfaceId: string
, callback: AsyncCallback<PhotoOutput
\>
): void
createPhotoOutput(profile: Profile, surfaceId: string
): PhotoOutput
创建拍照输出对象,
通过注册回调函数获取
结果。
创建拍照输出对象,
同步返回
结果。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
...
...
@@ -505,56 +358,25 @@ createPhotoOutput(profile: Profile, surfaceId: string, callback: AsyncCallback<P
| -------- | ------------------------------------------- | ---- | ----------------------------------- |
| profile |
[
Profile
](
#profile
)
| 是 | 支持的拍照配置信息,通过getSupportedOutputCapability接口获取。|
| 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
let
profile
=
cameraoutputcapability
.
photoProfiles
[
0
];
cameraManager
.
createPhotoOutput
(
profile
,
surfaceId
).
then
((
photoOutput
)
=>
{
console
.
log
(
'
Promise returned with photoOutput created.
'
);
})
let
photoOutput
=
cameraManager
.
createPhotoOutput
(
profile
,
surfaceId
);
```
### createVideoOutput
createVideoOutput(profile: VideoProfile, surfaceId: string
, callback: AsyncCallback<VideoOutput
\>
): void
createVideoOutput(profile: VideoProfile, surfaceId: string
): VideoOutput
创建录像输出对象,
通过注册回调函数获取
结果。
创建录像输出对象,
同步返回
结果。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
...
...
@@ -564,56 +386,30 @@ createVideoOutput(profile: VideoProfile, surfaceId: string, callback: AsyncCallb
| -------- | ------------------------------------------- | ---- | ------------------------------ |
| profile |
[
VideoProfile
](
#videoprofile
)
| 是 | 支持的录像配置信息,通过getSupportedOutputCapability接口获取。 |
| 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
let
profile
=
cameraoutputcapability
.
videoProfiles
[
0
];
cameraManager
.
createVideoOutput
(
profile
,
surfaceId
).
then
((
videoOutput
)
=>
{
console
.
log
(
'
Promise returned with videoOutput created.
'
);
})
let
videoOutput
;
try
{
videoOutput
=
cameraManager
.
createVideoOutput
(
profile
,
surfaceId
);
}
catch
(
error
)
{
console
.
log
(
error
.
code
);
}
```
### createMetadataOutput
createMetadataOutput(metadataObjectTypes:Array<MetadataObjectType
\>
, callback: AsyncCallback<MetadataOutput
\>
): void
createMetadataOutput(metadataObjectTypes:Array<MetadataObjectType
\>
): MetadataOutput
创建metadata流输出对象,
通过注册回调函数获取
结果。
创建metadata流输出对象,
同步返回
结果。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
...
...
@@ -622,96 +418,48 @@ createMetadataOutput(metadataObjectTypes:Array<MetadataObjectType\>, callback: A
| 参数名 | 类型 | 必填 | 说明 |
| -------------------- | -------------------------------------------------- | --- | ---------------------------- |
| 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
let
metadataObjectTypes
=
cameraoutputcapability
.
supportedMetadataObjectTypes
;
cameraManager
.
createMetadataOutput
(
metadataObjectTypes
).
then
((
metadataOutput
)
=>
{
console
.
log
(
'
Promise returned with metadataOutput created.
'
);
})
let
metadataOutput
;
try
{
metadataOutput
=
cameraManager
.
createMetadataOutput
(
metadataObjectTypes
);
}
catch
(
error
)
{
console
.
log
(
error
.
code
);
}
```
### createCaptureSession
createCaptureSession(
callback: AsyncCallback<CaptureSession
\>
): void
createCaptureSession(
): CaptureSession
创建CaptureSession实例,通过注册回调函数获取结果。
**系统能力:**
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
cameraManager
.
createCaptureSession
().
then
((
captureSession
)
=>
{
console
.
log
(
'
Promise returned with captureSession created.
'
);
})
let
captureSession
;
try
{
captureSession
=
cameraManager
.
createCaptureSession
();
}
catch
(
error
)
{
console
.
log
(
error
.
code
);
}
```
### on('cameraStatus')
...
...
@@ -801,7 +549,7 @@ cameraManager.on('cameraMute', (err, curMuetd) => {
| 名称 | 值 | 说明 |
| ----------------------- | ---- | -------------- |
| CAMERA_TYPE_
UNSPECIFIED
| 0 | 相机类型未指定。 |
| CAMERA_TYPE_
DEFAULT
| 0 | 相机类型未指定。 |
| CAMERA_TYPE_WIDE_ANGLE | 1 | 广角相机。 |
| CAMERA_TYPE_ULTRA_WIDE | 2 | 超广角相机。 |
| CAMERA_TYPE_TELEPHOTO | 3 | 长焦相机。 |
...
...
@@ -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
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | ------------------- |
| callback | AsyncCallback<void
\>
| 是 | 回调函数,用于获取结果。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | --- | ------------------------------------------- |
| type | string | 是 | 监听事件,固定为'error',即CameraInput错误事件。 |
| cameraDevice |
[
CameraDevice
](
#cameradevice
)
| 是 | CameraDevice对象。 |
| callback | ErrorCallback<BusinessError
\>
| 是 | 回调函数,用于获取结果。 |
**示例:**
```
js
cameraInput
.
release
((
err
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to release the CameraInput instance
${
err
.
message
}
`
);
return
;
}
console
.
log
(
'
Callback invoked to indicate that the CameraInput instance is released successfully.
'
);
});
let
cameraDevice
=
cameras
[
0
];
cameraInput
.
on
(
'
error
'
,
cameraDevice
,
(
error
)
=>
{
console
.
log
(
`Camera input error code:
${
error
.
code
}
`
);
})
```
##
# releas
e
##
FlashMod
e
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 | 闪光灯常亮。 |
**返回值:**
| 类型 | 说明 |
| -------------- | ----------------------- |
| 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
## ExposureMode
枚举,曝光模式。
...
...
@@ -1135,56 +809,25 @@ cameraInput.on('error', cameraDevice, (cameraInputError) => {
### beginConfig
beginConfig
\(
callback: AsyncCallback<void
\>\)
: 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
\>
beginConfig(): void
开始配置会话
,通过Promise获取结果
。
开始配置会话。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
**返回值:**
| 类型 | 说明 |
| -------------- | ------------------------ |
| Promise<void
\>
| 使用Promise的方式获取结果。 |
**示例:**
```
js
captureSession
.
beginConfig
().
then
(()
=>
{
console
.
log
(
'
Promise returned to indicate the begin config success.
'
);
})
try
{
captureSession
.
beginConfig
();
}
catch
(
error
)
{
console
.
log
(
error
.
code
);
}
```
### commitConfig
commitConfig
\(
callback: AsyncCallback<void
\>\
)
: void
commitConfig
(callback: AsyncCallback<void
\>
): void
提交配置信息,通过注册回调函数获取结果。
...
...
@@ -1210,7 +853,7 @@ captureSession.commitConfig((err) => {
### commitConfig
commitConfig
\(\
)
: Promise<void
\>
commitConfig
(
): Promise<void
\>
提交配置信息,通过Promise获取结果。
...
...
@@ -1232,36 +875,9 @@ captureSession.commitConfig().then(() => {
### addInput
addInput
\(
cameraInput: CameraInput, callback: AsyncCallback<void
\>\)
: 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
\>
addInput(cameraInput: CameraInput): void
把
[
CameraInput
](
#camerainput
)
加入到会话
,通过Promise获取结果
。
把
[
CameraInput
](
#camerainput
)
加入到会话。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
...
...
@@ -1271,52 +887,21 @@ addInput\(cameraInput: CameraInput\): Promise<void\>
| ----------- | --------------------------- | ---- | ------------------------ |
| 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
captureSession
.
removeInput
(
cameraInput
,
(
err
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to remove the CameraInput instance.
${
err
.
message
}
`
);
return
;
}
console
.
log
(
'
Callback invoked to indicate that the cameraInput instance is removed.
'
);
});
try
{
captureSession
.
addInput
(
cameraInput
);
}
catch
(
error
)
{
console
.
log
(
error
.
code
);
}
```
### removeInput
removeInput
\(
cameraInput: CameraInput
\)
: Promise<void
\>
removeInput
(cameraInput: CameraInput): void
移除
[
CameraInput
](
#camerainput
)
,通过Promise获取结果
。
移除
[
CameraInput
](
#camerainput
)
。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
...
...
@@ -1326,25 +911,21 @@ removeInput\(cameraInput: CameraInput\): Promise<void\>
| ----------- | --------------------------- | ---- | ------------------------ |
| cameraInput |
[
CameraInput
](
#camerainput
)
| 是 | 需要移除的CameraInput实例。 |
**返回值:**
| 类型 | 说明 |
| -------------- | ------------------------- |
| Promise
\<
void
\>
| 使用Promise的方式获取结果。 |
**示例:**
```
js
captureSession
.
removeInput
(
cameraInput
).
then
(()
=>
{
console
.
log
(
'
Promise returned to indicate that the cameraInput instance is removed.
'
);
})
try
{
captureSession
.
removeInput
(
cameraInput
);
}
catch
(
error
)
{
console
.
log
(
error
.
code
);
}
```
### addOutput
addOutput
\(
previewOutput: CameraOutput, callback: AsyncCallback<void
\>\
)
: void
addOutput
(previewOutput: CameraOutput
): void
把
[
CameraOutput
](
#cameraoutput
)
加入到会话
,通过注册回调函数获取结果
。
把
[
CameraOutput
](
#cameraoutput
)
加入到会话。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
...
...
@@ -1353,53 +934,22 @@ addOutput\(previewOutput: CameraOutput, callback: AsyncCallback<void\>\): void
| 参数名 | 类型 | 必填 | 说明 |
| ------------- | ------------------------------- | ---- | ------------------------ |
| 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
captureSession
.
addOutput
(
previewOutput
).
then
(()
=>
{
console
.
log
(
'
Promise returned with cameraOutput added.
'
);
})
try
{
captureSession
.
addOutput
(
previewOutput
);
}
catch
(
error
)
{
console
.
log
(
error
.
code
);
}
```
### removeOutput
removeOutput
\(
previewOutput: CameraOutput, callback: AsyncCallback<void
\>\
)
: void
removeOutput
(previewOutput: CameraOutput
): void
从会话中移除
[
CameraOutput
](
#cameraoutput
)
,通过注册回调函数获取结果
。
从会话中移除
[
CameraOutput
](
#cameraoutput
)
。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
...
...
@@ -1408,48 +958,15 @@ removeOutput\(previewOutput: CameraOutput, callback: AsyncCallback<void\>\): voi
| 参数名 | 类型 | 必填 | 说明 |
| ------------- | ------------------------------- | ---- | ------------------------ |
| 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
captureSession
.
removeOutput
(
previewOutput
).
then
(()
=>
{
console
.
log
(
'
Promise returned to indicate that the CameraOutput instance is removed.
'
);
})
try
{
captureSession
.
removeOutput
(
previewOutput
);
}
catch
(
error
)
{
console
.
log
(
error
.
code
);
}
```
### start
...
...
@@ -1598,57 +1115,33 @@ captureSession.release().then(() => {
### hasFlash
hasFlash(
callback: AsyncCallback<boolean
\>
): void
hasFlash(
): boolean
检测是否有闪光灯,通过注册回调函数获取结果。
**系统能力:**
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
captureSession
.
hasFlash
().
then
((
status
)
=>
{
console
.
log
(
`Promise returned with the flash light support status:
${
status
}
`
);
})
try
{
let
status
=
captureSession
.
hasFlash
();
}
catch
(
error
)
{
console
.
log
(
error
.
code
);
}
```
### isFlashModeSupported
isFlashModeSupported(flashMode: FlashMode
, callback: AsyncCallback<boolean
\>
): void
isFlashModeSupported(flashMode: FlashMode
): boolean
检测闪光灯模式是否支持
,通过注册回调函数获取结果
。
检测闪光灯模式是否支持。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
...
...
@@ -1657,53 +1150,28 @@ isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback<boolean\>): v
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ----------------------- | ---- | --------------------------------- |
| 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
captureSession
.
isFlashModeSupported
(
camera
.
FlashMode
.
FLASH_MODE_AUTO
).
then
((
status
)
=>
{
console
.
log
(
`Promise returned with flash mode support status.
${
status
}
`
);
})
try
{
let
status
=
captureSession
.
isFlashModeSupported
(
camera
.
FlashMode
.
FLASH_MODE_AUTO
);
}
catch
(
error
)
{
console
.
log
(
error
.
code
);
}
```
### setFlashMode
setFlashMode(flashMode: FlashMode
, callback: AsyncCallback<void
\>
): void
setFlashMode(flashMode: FlashMode): void
设置闪光灯模式
,通过注册回调函数获取结果
。
设置闪光灯模式。
进行设置之前,需要先检查:
...
...
@@ -1717,133 +1185,46 @@ setFlashMode(flashMode: FlashMode, callback: AsyncCallback<void\>): void
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ----------------------- | ---- | --------------------- |
| flashMode |
[
FlashMode
](
#flashmode
)
| 是 | 指定闪光灯模式。 |
| callback | AsyncCallback<void
\>
| 是 | 回调函数,用于获取结果。 |
**示例:**
```
js
captureSession
.
setFlashMode
(
camera
.
FlashMode
.
FLASH_MODE_AUTO
,
(
err
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to set the flash mode
${
err
.
message
}
`
);
return
;
}
console
.
log
(
'
Callback returned with the successful execution of setFlashMode.
'
);
})
try
{
captureSession
.
setFlashMode
(
camera
.
FlashMode
.
FLASH_MODE_AUTO
);
}
catch
(
error
)
{
console
.
log
(
error
.
code
);
}
```
### setFlashMode
setFlashMode(flashMode: FlashMode): Promise<void
\>
设置闪光灯模式,通过Promise获取结果。
### getFlashMode
进行设置之前,需要先检查:
getFlashMode(): FlashMode
1.
设备是否支持闪光灯,可使用方法
[
hasFlash
](
#hasflash
)
。
2.
设备是否支持指定的闪光灯模式,可使用方法
[
isFlashModeSupported
](
#isflashmodesupported
)
。
获取当前设备的闪光灯模式。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ----------------------- | ---- | ------------- |
| flashMode |
[
FlashMode
](
#flashmode
)
| 是 | 指定闪光灯模式。 |
**返回值:**
| 类型 | 说明 |
| -------------- | ------------------------ |
| Promise<void
\>
| 使用Promise的方式获取结果。 |
**示例:**
```
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
\>
| 是 | 回调函数,用于获取是否支持曝光模式。 |
| 类型 | 说明 |
| ---------- | ----------------------------- |
|
[
FlashMode
](
#flashmode
)
| 获取当前设备的闪光灯模式。 |
**示例:**
```
js
captureSession
.
isExposureModeSupported
(
camera
.
ExposureMode
.
EXPOSURE_MODE_LOCKED
,(
err
)
=>
{
if
(
err
)
{
console
.
log
(
`Failed to check exposure mode supported
${
err
.
message
}
`
);
return
;
}
console
.
log
(
'
Callback returned with the successful execution of isExposureModeSupported
'
);
})
try
{
let
flashMode
=
captureSession
.
getFlashMode
();
}
catch
(
error
)
{
console
.
log
(
error
.
code
);
}
```
### isExposureModeSupported
isExposureModeSupported(aeMode: ExposureMode):
Promise<boolean
\>
isExposureModeSupported(aeMode: ExposureMode):
boolean;
检测曝光模式是否支持
,通过Promise获取结果
。
检测曝光模式是否支持。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
...
...
@@ -1855,71 +1236,49 @@ isExposureModeSupported(aeMode: ExposureMode): Promise<boolean\>
**返回值:**
| 名称 | 说明 |
| ----------------- |--------------------------------- |
| Promise<boolean
\>
| 使用Promise的方式获取支持的曝光模式。 |
**示例:**
```
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
)
\>
| 是 | 回调函数,用于获取当前曝光模式。 |
| 类型 | 说明 |
| ---------- | ----------------------------- |
| boolean | 获取是否支持曝光模式。 |
**示例:**
```
js
captureSession
.
getExposureMode
((
err
,
exposureMode
)
=>
{
if
(
err
)
{
console
.
log
(
`Failed to get the exposure mode
${
err
.
message
}
`
);
return
;
}
console
.
log
(
`Callback returned with current exposure mode:
${
exposureMode
}
`
);
})
try
{
let
isSupported
=
captureSession
.
isExposureModeSupported
(
camera
.
ExposureMode
.
EXPOSURE_MODE_LOCKED
);
}
catch
(
error
)
{
console
.
log
(
error
.
code
);
}
```
### getExposureMode
getExposureMode():
Promise<ExposureMode
\>
getExposureMode():
ExposureMode
获取当前曝光模式
,通过Promise获取结果
。
获取当前曝光模式。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
**返回值:**
|
名称 | 说明
|
| ----------
----------------------------- |--
----------------------------- |
|
Promise<
[
ExposureMode
](
#exposuremode
)
\>
| 使用Promise的方式
获取当前曝光模式。 |
|
类型 | 说明
|
| ----------
|
----------------------------- |
|
[
ExposureMode
](
#exposuremode
)
|
获取当前曝光模式。 |
**示例:**
```
js
captureSession
.
getExposureMode
().
then
((
exposureMode
)
=>
{
console
.
log
(
`Promise returned with current exposure mode :
${
exposureMode
}
`
);
})
try
{
let
exposureMode
=
captureSession
.
getExposureMode
();
}
catch
(
error
)
{
console
.
log
(
error
.
code
);
}
```
### setExposureMode
setExposureMode(aeMode: ExposureMode
, callback: AsyncCallback<void
\>
): void
setExposureMode(aeMode: ExposureMode): void
设置曝光模式
,通过注册回调函数获取结果
。
设置曝光模式。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
...
...
@@ -1928,124 +1287,46 @@ setExposureMode(aeMode: ExposureMode, callback: AsyncCallback<void\>): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------| ---- | ----------------------- |
| 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
captureSession
.
getMeteringPoint
((
err
,
exposurePoint
)
=>
{
if
(
err
)
{
console
.
log
(
`Failed to get the current exposure point
${
err
.
message
}
`
);
return
;
}
console
.
log
(
`Callback returned with current exposure point:
${
exposurePoint
}
`
);
})
try
{
captureSession
.
setExposureMode
(
camera
.
ExposureMode
.
EXPOSURE_MODE_LOCKED
);
}
catch
(
error
)
{
console
.
log
(
error
.
code
);
}
```
### getMeteringPoint
getMeteringPoint(): P
romise<Point
\>
getMeteringPoint(): P
oint
查询曝光区域中心点
,通过Promise获取结果
。(该接口目前为预留,将在3.2版本开放)
查询曝光区域中心点。(该接口目前为预留,将在3.2版本开放)
**系统能力:**
SystemCapability.Multimedia.Camera.Core
**返回值:**
| 名称 | 说明 |
| ------------------------- |----------------------------- |
| Promise<
[
Point
](
#point
)
\>
| 使用Promise的方式获取当前曝光点。 |
**示例:**
```
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
\>
| 是 | 回调函数,用于获取结果。 |
| 类型 | 说明 |
| ---------- | ----------------------------- |
|
[
Point
](
#point
)
| 获取当前曝光点。 |
**示例:**
```
js
const
Point1
=
{
x
:
1
,
y
:
1
};
captureSession
.
setMeteringPoint
(
Point1
,(
err
)
=>
{
if
(
err
)
{
console
.
log
(
`Failed to set the exposure point
${
err
.
message
}
`
);
return
;
}
console
.
log
(
'
Callback returned with the successful execution of setMeteringPoint
'
);
})
try
{
let
exposurePoint
=
captureSession
.
getMeteringPoint
();
}
catch
(
error
)
{
console
.
log
(
error
.
code
);
}
```
### setMeteringPoint
setMeteringPoint(point: Point):
Promise<void
\>
setMeteringPoint(point: Point):
void
设置曝光区域中心点
,通过Promise获取结果
。(该接口目前为预留,将在3.2版本开放)
设置曝光区域中心点。(该接口目前为预留,将在3.2版本开放)
**系统能力:**
SystemCapability.Multimedia.Camera.Core
...
...
@@ -2055,75 +1336,46 @@ setMeteringPoint(point: Point): Promise<void\>
| ------------- | -------------------------------| ---- | ------------------- |
| exposurePoint |
[
Point
](
#point
)
| 是 | 曝光点。 |
**返回值:**
| 名称 | 说明 |
| ----------------- |------------------------ |
| Promise<void
\>
| 使用Promise的方式返回结果。 |
**示例:**
```
js
const
Point2
=
{
x
:
2
,
y
:
2
};
captureSession
.
setMeteringPoint
(
Point2
).
then
(()
=>
{
console
.
log
(
'
Promise returned with the successful execution of setMeteringPoint
'
);
})
```
### 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
));
})
const
exposurePoint
=
{
x
:
1
,
y
:
1
};
try
{
captureSession
.
setMeteringPoint
(
exposurePoint
);
}
catch
(
error
)
{
console
.
log
(
error
.
code
);
}
```
### getExposureBiasRange
getExposureBiasRange():
Promise<Array<number
\>
\>
getExposureBiasRange():
Array<number
\>
查询曝光补偿范围
,通过Promise获取结果
。
查询曝光补偿范围。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
**返回值:**
|
名称 | 说明
|
| ----------
------- |---------
----------------------------- |
|
Promise<Array<number
\>\>
| 使用Promise的方式获取曝光补偿范围
。 |
|
类型 | 说明
|
| ----------
|
----------------------------- |
|
Array<number
\>
| 获取补偿范围的数组
。 |
**示例:**
```
js
captureSession
.
getExposureBiasRange
().
then
((
biasRangeArray
)
=>
{
console
.
log
(
'
Promise returned with the array of compenstation range:
'
+
JSON
.
stringify
(
biasRangeArray
));
})
try
{
let
biasRangeArray
=
captureSession
.
getExposureBiasRange
();
}
catch
(
error
)
{
console
.
log
(
error
.
code
);
}
```
### setExposureBias
setExposureBias(exposureBias: number
, callback: AsyncCallback<void
\>
): void
setExposureBias(exposureBias: number): void
设置曝光补偿
,通过注册回调函数获取结果
。
设置曝光补偿。
进行设置之前,建议先通过方法
[
getExposureBiasRange
](
#getexposurebiasrange
)
查询支持的范围。
...
...
@@ -2134,105 +1386,47 @@ setExposureBias(exposureBias: number, callback: AsyncCallback<void\>): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------| ---- | ------------------- |
| exposureBias | number | 是 | 曝光补偿,getExposureBiasRange查询支持的范围 |
| callback | AsyncCallback<void
\>
| 是 | 回调函数,用于获取结果。 |
**示例:**
```
js
let
exposureBias
=
biasRangeArray
[
0
];
captureSession
.
setExposureBias
(
exposureBias
,(
err
)
=>
{
if
(
err
)
{
console
.
log
(
`Failed to set the exposure bias
${
err
.
message
}
`
);
return
;
}
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
}
`
);
})
try
{
captureSession
.
setExposureBias
(
exposureBias
);
}
catch
(
error
)
{
console
.
log
(
error
.
code
);
}
```
### getExposureValue
getExposureValue():
Promise<number
\>
getExposureValue():
number
查询当前曝光值
,通过Promise获取结果
。
查询当前曝光值。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
**返回值:**
|
名称 | 说明
|
| ----------
------- |
-------------------------- |
|
Promise<number
\>
| 使用Promise的方式
获取曝光值。 |
|
类型 | 说明
|
| ----------
| ---
-------------------------- |
|
number |
获取曝光值。 |
**示例:**
```
js
captureSession
.
getExposureValue
().
then
((
exposureValue
)
=>
{
console
.
log
(
`Promise returned with exposure value:
${
exposureValude
}
`
);
})
try
{
let
exposureValue
=
captureSession
.
getExposureValue
();
}
catch
(
error
)
{
console
.
log
(
error
.
code
);
}
```
### isFocusModeSupported
isFocusModeSupported(afMode: FocusMode
, callback: AsyncCallback<boolean
\>
): void
isFocusModeSupported(afMode: FocusMode
): boolean
检测对焦模式是否支持
,通过注册回调函数获取结果
。
检测对焦模式是否支持。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
...
...
@@ -2241,53 +1435,28 @@ isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback<boolean\>): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------- | ---- | -------------------------------- |
| 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
captureSession
.
isFocusModeSupported
(
camera
.
FocusMode
.
FOCUS_MODE_AUTO
).
then
((
status
)
=>
{
console
.
log
(
`Promise returned with focus mode support status
${
status
}
.`
);
})
try
{
let
status
=
captureSession
.
isFocusModeSupported
(
camera
.
FocusMode
.
FOCUS_MODE_AUTO
);
}
catch
(
error
)
{
console
.
log
(
error
.
code
);
}
```
### setFocusMode
setFocusMode(afMode: FocusMode
, callback: AsyncCallback<void
\>
): void
setFocusMode(afMode: FocusMode): void
设置对焦模式
,通过注册回调函数获取结果
。
设置对焦模式。
进行设置之前,需要先检查设备是否支持指定的焦距模式,可使用方法
[
isFocusModeSupported
](
#isfocusmodesupported
)
。
...
...
@@ -2298,103 +1467,46 @@ setFocusMode(afMode: FocusMode, callback: AsyncCallback<void\>): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------- | ---- | ------------------- |
| 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
captureSession
.
setFocusMode
(
camera
.
FocusMode
.
FOCUS_MODE_AUTO
).
then
(()
=>
{
console
.
log
(
'
Promise returned with the successful execution of setFocusMode.
'
);
})
```
### 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
}
`
);
})
try
{
captureSession
.
setFocusMode
(
camera
.
FocusMode
.
FOCUS_MODE_AUTO
);
}
catch
(
error
)
{
console
.
log
(
error
.
code
);
}
```
### getFocusMode
getFocusMode():
Promise<FocusMode
\>
getFocusMode():
FocusMode
获取当前的对焦模式
,通过Promise获取结果
。
获取当前的对焦模式。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
**返回值:**
| 类型
| 说明
|
| ----------
--------- | ---
----------------------------- |
|
Promise<FocusMode
\>
| 使用Promise的方式获取当前
的焦距模式。 |
| 类型
| 说明
|
| ----------
|
----------------------------- |
|
[
FocusMode
](
#focusmode
)
| 获取当前设备
的焦距模式。 |
**示例:**
```
js
captureSession
.
getFocusMode
().
then
((
afMode
)
=>
{
console
.
log
(
`Promise returned with current focus mode :
${
afMode
}
`
);
})
try
{
let
afMode
=
captureSession
.
getFocusMode
();
}
catch
(
error
)
{
console
.
log
(
error
.
code
);
}
```
### setFocusPoint
setFocusPoint(point: Point
, callback: AsyncCallback<void
\>
): void
setFocusPoint(point: Point): void
设置焦点
,通过注册回调函数获取结果
。
设置焦点。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
...
...
@@ -2402,431 +1514,199 @@ setFocusPoint(point: Point, callback: AsyncCallback<void\>): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------- | ---- | ------------------- |
| point |
[
Point
](
#point
)
| 是 | 焦点。 |
| callback | AsyncCallback<void
\>
| 是 | 回调函数,用于获取结果。 |
| Point1 |
[
Point
](
#point
)
| 是 | 焦点。 |
**示例:**
```
js
const
Point1
=
{
x
:
1
,
y
:
1
};
captureSession
.
setFocusPoint
(
Point1
,
(
err
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to set the focus point
${
err
.
message
}
`
);
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
));
})
try
{
captureSession
.
setFocusPoint
(
Point1
);
}
catch
(
error
)
{
console
.
log
(
error
.
code
);
}
```
### getFocusPoint
getFocusPoint(): P
romise<Point
\>
getFocusPoint(): P
oint
查询焦点
,通过Promise获取结果
。
查询焦点。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
**返回值:**
| 类型 | 说明 |
| --------------- | --------------------------- |
| Promise<Point
\>
| 使用Promise的方式获取当前焦点。 |
**示例:**
```
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
\>
| 是 | 回调函数,用于获取当前焦距。 |
| 类型 | 说明 |
| ---------- | ----------------------------- |
|
[
Point
](
#point
)
| 用于获取当前焦点。 |
**示例:**
```
js
captureSession
.
getFocalLength
((
err
,
focalLength
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to get the current focal length
${
err
.
message
}
`
);
return
;
}
console
.
log
(
`Callback returned with the current focal length:
${
focalLength
}
`
);
})
try
{
let
point
=
captureSession
.
getFocusPoint
();
}
catch
(
error
)
{
console
.
log
(
error
.
code
);
}
```
### getFocalLength
getFocalLength():
Promise<number
\>
getFocalLength():
number
查询焦距值
,通过Promise获取结果
。
查询焦距值。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
**返回值:**
| 类型 | 说明 |
| ---------------- | ----------------------- |
| Promise<number
\>
| 使用Promise的方式获取焦距。 |
**示例:**
```
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
\>\>
| 是 | 回调函数,用于获取可变焦距比范围,返回的数组包括其最小值和最大值。 |
| 类型 | 说明 |
| ---------- | ----------------------------- |
| number | 用于获取当前焦距。 |
**示例:**
```
js
captureSession
.
getZoomRatioRange
((
err
,
zoomRatioRange
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to get the zoom ratio range.
${
err
.
message
}
`
);
return
;
}
console
.
log
(
`Callback returned with zoom ratio range:
${
zoomRatioRange
.
length
}
`
);
})
try
{
let
focalLength
=
captureSession
.
getFocalLength
();
}
catch
(
error
)
{
console
.
log
(
error
.
code
);
}
```
### getZoomRatioRange
getZoomRatioRange
\(\)
: Promise<Array<number
\>\>
获取支持的变焦范围,通过Promise获取结果。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
**返回值:**
| 类型 | 说明 |
| ------------------------ | --------------------------- |
| Promise<Array<number
\>\>
| 使用Promise的方式获取当前的可变焦距比范围,返回的数组包括其最小值和最大值。 |
**示例:**
getZoomRatioRange(): Array<number
\>
```
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
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------- | -------------------- | ---- | ------------------- |
| 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
)
| 是 | 视频防抖模式。 |
| callback | AsyncCallback<boolean
\>
| 是 | 回调函数,返回视频防抖模式是否支持。 |
| 类型 | 说明 |
| ---------- | ----------------------------- |
| Array<number
\>
| 用于获取可变焦距比范围,返回的数组包括其最小值和最大值。 |
**示例:**
```
js
captureSession
.
isVideoStabilizationModeSupported
(
camera
.
VideoStabilizationMode
.
OFF
,
(
err
,
isSupported
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to check whether video stabilization mode supported.
${
err
.
message
}
`
);
return
;
}
console
.
log
(
`Callback returned with the successful execution of isVideoStabilizationModeSupported`
);
})
try
{
let
zoomRatioRange
=
captureSession
.
getZoomRatioRange
();
}
catch
(
error
)
{
console
.
log
(
error
.
code
);
}
```
###
isVideoStabilizationModeSupported
###
setZoomRatio
isVideoStabilizationModeSupported(vsMode: VideoStabilizationMode): Promise<boolean
\>
setZoomRatio(zoomRatio: number): void
查询是否支持指定的视频防抖模式,通过Promise获取结果
。
设置变焦比
。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
**
返回值
:**
**
参数
:**
|
类型 | 说明
|
| ---------
-------- | --------------------------
------------------- |
|
Promise<boolean
\>
| 使用Promise的方式获取结果,返回视频防抖模式是否支持。
|
|
参数名 | 类型 | 必填 | 说明
|
| ---------
| -------------------- | ---- |
------------------- |
|
zoomRatio | number | 是 | 可变焦距比,通过getZoomRatioRange获取支持的变焦范围
|
**示例:**
```
js
captureSession
.
isVideoStabilizationModeSupported
(
camera
.
VideoStabilizationMode
.
OFF
).
then
((
isSupported
)
=>
{
console
.
log
(
`Promise returned with video stabilization mode supported:
${
isSupported
}
`
);
})
let
zoomRatio
=
zoomRatioRange
[
0
];
try
{
captureSession
.
setZoomRatio
(
zoomRatio
);
}
catch
(
error
)
{
console
.
log
(
error
.
code
);
}
```
### get
ActiveVideoStabilizationMode
### get
ZoomRatio
get
ActiveVideoStabilizationMode(callback: AsyncCallback<VideoStabilizationMode
\>
): void
get
ZoomRatio(): number
查询当前正在使用的视频防抖模式,通过注册回调函数获取结果
。
获取当前的变焦比
。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
**
参数
:**
**
返回值
:**
|
参数名 | 类型 | 必填 | 说明
|
| --------
| ----------------------------------------- | ---- | -
----------------------------- |
|
callback | AsyncCallback<VideoStabilizationMode
\>
| 是 | 回调函数,返回视频防抖是否正在使用。
|
|
类型 | 说明
|
| --------
-- |
----------------------------- |
|
number | 获取当前的变焦比结果。
|
**示例:**
```
js
captureSession
.
getActiveVideoStabilizationMode
((
err
,
vsMode
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to get active video stabilization mode
${
err
.
message
}
`
);
return
;
}
console
.
log
(
'
Callback returned with the successful execution of getActiveVideoStabilizationMode.
'
);
})
try
{
let
zoomRatio
=
captureSession
.
getZoomRatio
();
}
catch
(
error
)
{
console
.
log
(
error
.
code
);
}
```
###
getActiveVideoStabilizationMode
###
isVideoStabilizationModeSupported
getActiveVideoStabilizationMode(): Promise<VideoStabilizationMode
\>
isVideoStabilizationModeSupported(vsMode: VideoStabilizationMode): boolean
查询
当前正在使用的视频防抖模式,通过Promise获取结果
。
查询
是否支持指定的视频防抖模式
。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------- | ---- | ------------------------------ |
| vsMode |
[
VideoStabilizationMode
](
#videostabilizationmode
)
| 是 | 视频防抖模式。 |
**返回值:**
| 类型
| 说明
|
| ----------
---------------------- | --------------------
----------------------------- |
|
Promise<VideoStabilizationMode
\>
| 使用Promise的方式获取结果,返回视频防抖当前是否正在使用。
|
| 类型
| 说明
|
| ----------
|
----------------------------- |
|
boolean | 返回视频防抖模式是否支持。
|
**示例:**
```
js
captureSession
.
getActiveVideoStabilizationMode
().
then
((
vsMode
)
=>
{
console
.
log
(
`Promise returned with the current video stabilization mode:
${
vsMode
}
`
);
})
try
{
let
isSupported
=
captureSession
.
isVideoStabilizationModeSupported
(
camera
.
VideoStabilizationMode
.
OFF
);
}
catch
(
error
)
{
console
.
log
(
error
.
code
);
}
```
###
set
VideoStabilizationMode
###
getActive
VideoStabilizationMode
setVideoStabilizationMode(mode: VideoStabilizationMode, callback: AsyncCallback<void
\>
): void
getActiveVideoStabilizationMode(): VideoStabilizationMode
设置视频防抖模式,通过注册回调函数获取结果
。
查询当前正在使用的视频防抖模式
。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
**
参数
:**
**
返回值
:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------- | ---- | --------------------- |
| mode |
[
VideoStabilizationMode
](
#videostabilizationmode
)
| 是 | 需要设置的视频防抖模式。 |
| callback | AsyncCallback<void
\>
| 是 | 回调函数。 |
| 类型 | 说明 |
| ---------- | ----------------------------- |
| VideoStabilizationMode | 视频防抖是否正在使用。 |
**示例:**
```
js
captureSession
.
setVideoStabilizationMode
(
camera
.
VideoStabilizationMode
.
OFF
,
(
err
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to set the video stabilization mode
${
err
.
message
}
`
);
return
;
}
console
.
log
(
'
Callback returned with the successful execution of setVideoStabilizationMode.
'
);
})
try
{
let
vsMode
=
captureSession
.
getActiveVideoStabilizationMode
();
}
catch
(
error
)
{
console
.
log
(
error
.
code
);
}
```
### setVideoStabilizationMode
setVideoStabilizationMode(mode: VideoStabilizationMode):
Promise<void
\>
setVideoStabilizationMode(mode: VideoStabilizationMode):
void
设置视频防抖
,通过Promise获取结果
。
设置视频防抖
模式
。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
...
...
@@ -2836,18 +1716,14 @@ setVideoStabilizationMode(mode: VideoStabilizationMode): Promise<void\>
| -------- | ------------------------------------------------- | ---- | --------------------- |
| mode |
[
VideoStabilizationMode
](
#videostabilizationmode
)
| 是 | 需要设置的视频防抖模式。 |
**返回值:**
| 类型 | 说明 |
| -------------- | ------------------------------------------------- |
| Promise<void
\>
| 使用Promise的方式获取结果,返回设置的视频防抖模式的结果。 |
**示例:**
```
js
captureSession
.
setVideoStabilizationMode
(
camera
.
VideoStabilizationMode
.
OFF
).
then
(()
=>
{
console
.
log
(
'
Promise returned with the successful execution of setVideoStabilizationMode.
'
);
})
try
{
captureSession
.
setVideoStabilizationMode
(
camera
.
VideoStabilizationMode
.
OFF
);
}
catch
(
error
)
{
console
.
log
(
error
.
code
);
}
```
### on('focusStateChange')
...
...
@@ -2875,7 +1751,7 @@ captureSession.on('focusStateChange', (focusState) => {
### on('error')
on(type: 'error', callback: ErrorCallback<
CaptureSession
Error
\>
): void
on(type: 'error', callback: ErrorCallback<
Business
Error
\>
): void
监听拍照会话的错误事件,通过注册回调函数获取结果。
...
...
@@ -2886,7 +1762,7 @@ on(type: 'error', callback: ErrorCallback<CaptureSessionError\>): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------------------------------------- | ---- | ------------------------------ |
| type | string | 是 | 监听事件,固定为'error',即拍照会话错误事件。 |
| callback | ErrorCallback<
[
CaptureSessionError
](
#capturesessionerror
)
\>
| 是 | 回调函数,用于获取错误信息。 |
| callback | ErrorCallback<
BusinessError
\>
| 是 | 回调函数,用于获取错误信息。 |
**示例:**
...
...
@@ -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
会话中
[
CaptureSession
](
#capturesession
)
使用的输出信息,output的基类。
...
...
@@ -3118,7 +1972,7 @@ previewOutput.on('frameEnd', () => {
### on('error')
on(type: 'error', callback: ErrorCallback<
PreviewOutput
Error
\>
): void
on(type: 'error', callback: ErrorCallback<
Business
Error
\>
): void
监听预览输出的错误事件,通过注册回调函数获取结果。
...
...
@@ -3129,7 +1983,7 @@ on(type: 'error', callback: ErrorCallback<PreviewOutputError\>): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------------------------------------------- | ---- | ------------------------ |
| type | string | 是 | 监听事件,固定为'error',即预览输出错误事件。|
| callback | ErrorCallback<
[
PreviewOutputErrorCode
](
#previewoutputerrorcode
)
\>
| 是 | 回调函数,用于获取错误信息。 |
| callback | ErrorCallback<
BusinessError
\>
| 是 | 回调函数,用于获取错误信息。 |
**示例:**
...
...
@@ -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
枚举,图片旋转角度。
...
...
@@ -3242,6 +2076,28 @@ photoOutput.capture((err) => {
### 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
以指定参数触发一次拍照,通过注册回调函数获取结果。
...
...
@@ -3302,35 +2158,29 @@ capture(setting?: PhotoCaptureSetting): Promise<void\>
**示例:**
```
js
photoOutput
.
capture
().
then
(()
=>
{
photoOutput
.
capture
(
settings
).
then
(()
=>
{
console
.
log
(
'
Promise returned to indicate that photo capture request success.
'
);
})
```
### isMirrorSupported
isMirrorSupported(
callback: AsyncCallback<boolean
\>
): void
isMirrorSupported(
): boolean
查询是否支持镜像拍照
,通过注册回调函数获取结果
。
查询是否支持镜像拍照。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
**
参数
:**
**
返回值
:**
|
参数名 | 类型 | 必填 | 说明
|
| --------
| ------------------------------------------------- | ---- | ---
----------------------- |
|
callback | AsyncCallback<boolean
\>
| 是 | 回调函数,返回是否支持镜像拍照。
|
|
类型 | 说明
|
| --------
------ |
----------------------- |
|
boolean | 回是否支持镜像拍照。
|
**示例:**
```
js
photoOutput
.
isMirrorSupported
((
err
,
isSupported
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to check mirror is supported
${
err
.
message
}
`
);
return
;
}
console
.
log
(
'
Callback returned with the successful execution of isMirrorSupported.
'
);
})
let
isSupported
=
photoOutput
.
isMirrorSupported
();
```
### release
...
...
@@ -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(type: 'captureStart', callback: AsyncCallback<number
\>
): void
...
...
@@ -3476,7 +2304,7 @@ photoOutput.on('captureEnd', (err, captureEndInfo) => {
### on('error')
on(type: 'error', callback: ErrorCallback<
PhotoOutput
Error
\>
): void
on(type: 'error', callback: ErrorCallback<
Business
Error
\>
): void
监听拍照输出发生错误,通过注册回调函数获取结果。
...
...
@@ -3487,7 +2315,7 @@ on(type: 'error', callback: ErrorCallback<PhotoOutputError\>): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------------------------------- | ---- | ----------------------------------- |
| type | string | 是 | 监听事件,固定为'error',即拍照错误事件。 |
| callback | ErrorCallback<
[
PhotoOutputError
](
#photooutputerror
)
\>
| 是 | 回调函数,用于获取错误信息。 |
| callback | ErrorCallback<
BusinessError
\>
| 是 | 回调函数,用于获取错误信息。 |
**示例:**
...
...
@@ -3519,29 +2347,6 @@ photoOutput.on('error', (err, photoOutputError) => {
| captureId | number | 是 | 拍照的ID。 |
| 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
录像会话中使用的输出信息,继承
[
CameraOutput
](
#cameraoutput
)
...
...
@@ -3641,7 +2446,7 @@ stop(): Promise<void\>
videoOutput
.
stop
().
then
(()
=>
{
console
.
log
(
'
Promise returned to indicate that stop method execution success.
'
);
})
```
```
### release
...
...
@@ -3739,7 +2544,7 @@ videoOutput.on('frameEnd', () => {
### on('error')
on(type: 'error', callback: ErrorCallback<
VideoOutput
Error
\>
): void
on(type: 'error', callback: ErrorCallback<
Business
Error
\>
): void
监听录像输出发生错误,通过注册回调函数获取结果。
...
...
@@ -3750,7 +2555,7 @@ on(type: 'error', callback: ErrorCallback<VideoOutputError\>): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------ | ---- | -------------------------------------- |
| type | string | 是 | 监听事件,固定为'error',即视频输出错误事件。 |
| callback | Callback<
[
VideoOutputError
](
#videooutputerror
)
\>
| 是 | 回调函数,用于获取错误信息。 |
| callback | Callback<
BusinessError
\>
| 是 | 回调函数,用于获取错误信息。 |
**示例:**
...
...
@@ -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
metadata流。继承
[
CameraOutput
](
#cameraoutput
)
...
...
@@ -3906,7 +2690,7 @@ metadataOutput.on('metadataObjectsAvailable', (metadataObjectArr) => {
### on('error')
on(type: 'error', callback: ErrorCallback<
MetadataOutput
Error
\>
): void
on(type: 'error', callback: ErrorCallback<
Business
Error
\>
): void
监听metadata流的错误,通过注册回调函数获取结果。
...
...
@@ -3917,7 +2701,7 @@ on(type: 'error', callback: ErrorCallback<MetadataOutputError\>): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------ | ---- | --------------------------------------- |
| type | string | 是 | 监听事件,固定为'error',即metadata流的错误。 |
| callback | Callback<
[
MetadataOutputError
](
#metadataoutputerror
)
\>
| 是 | 回调函数,用于获取错误信息。 |
| callback | Callback<
BusinessError
\>
| 是 | 回调函数,用于获取错误信息。 |
**示例:**
...
...
@@ -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
枚举,metadata流。
...
...
@@ -3975,156 +2738,8 @@ metadata输出错误码。
相机元能力信息,
[
CameraInput
](
#camerainput
)
相机信息中的数据来源,通过metadataOutput.on('metadataObjectsAvailable')接口获取
### getType
getType(callback: AsyncCallback<MetadataObjectType
\>
): void
查询metadata对象类型,通过注册回调函数获取结果。
**系统能力:**
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
| 名称 | 类型 | 必填 | 说明 |
| -------- | ------------------------------- | ---- | -----------------|
| type |
[
MetadataObjectType
](
#metadataobjecttype
)
| 否 | 图片质量。 |
| timestamp | number | 否 | 图片旋转角度。 |
| boundingBox |
[
Rect
](
#rect
)
| 否 | 图片地理位置信息。 |
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录