Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
5d43b046
D
Docs
项目概览
OpenHarmony
/
Docs
1 年多 前同步成功
通知
159
Star
292
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看板
提交
5d43b046
编写于
12月 07, 2022
作者:
M
mali
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Document sample modification-01
Signed-off-by:
N
mali
<
mali81@huawei.com
>
上级
f40b2d35
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
37 addition
and
13 deletion
+37
-13
zh-cn/application-dev/reference/apis/js-apis-camera.md
zh-cn/application-dev/reference/apis/js-apis-camera.md
+37
-13
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-camera.md
浏览文件 @
5d43b046
...
...
@@ -188,13 +188,14 @@ getSupportedOutputCapability(camera:CameraDevice, callback: AsyncCallback<Camera
| 参数名 | 类型 | 必填 | 说明 |
| ------------ |--------------------------------------------------------------- | -- | -------------------------- |
|
C
ameraDevice |
[
CameraDevice
](
#cameradevice
)
| 是 | 相机设备。 |
|
c
ameraDevice |
[
CameraDevice
](
#cameradevice
)
| 是 | 相机设备。 |
| callback | AsyncCallback<
[
CameraOutputCapability
](
#cameraoutputcapability
)
\>
| 是 | 使用callback方式获取相机输出能力。 |
**示例:**
```
js
cameraManager
.
getSupportedOutputCapability
(
cameradevice
,
(
err
,
CameraOutputCapability
)
=>
{
let
cameraDevice
=
cameras
[
0
];
cameraManager
.
getSupportedOutputCapability
(
cameraDevice
,
(
err
,
CameraOutputCapability
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to get the outputCapability.
${
err
.
message
}
`
);
return
;
...
...
@@ -215,7 +216,7 @@ getSupportedOutputCapability(camera:CameraDevice): Promise<CameraOutputCapabilit
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------- | ---- | ---------- |
| camera |
[
CameraDevice
](
#cameradevice
)
| 是 | 相机设备。 |
| camera
device
|
[
CameraDevice
](
#cameradevice
)
| 是 | 相机设备。 |
**返回值:**
...
...
@@ -226,6 +227,7 @@ getSupportedOutputCapability(camera:CameraDevice): Promise<CameraOutputCapabilit
**示例:**
```
js
let
cameraDevice
=
cameras
[
0
];
cameraManager
.
getSupportedOutputCapability
(
cameradevice
).
then
((
cameraoutputcapability
)
=>
{
console
.
log
(
'
Promise returned with an array of supported outputCapability
'
);
})
...
...
@@ -294,6 +296,7 @@ muteCamera(mute: boolean): void
**示例:**
```
js
let
mute
=
true
;
cameraManager
.
muteCamera
(
mute
);
```
...
...
@@ -313,13 +316,14 @@ createCameraInput(camera: CameraDevice, callback: AsyncCallback<CameraInput\>):
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------- | ---- | --------------------------------- |
| camera |
[
CameraDevice
](
#cameradevice
)
| 是 | CameraDevice对象。 |
| camera
Device
|
[
CameraDevice
](
#cameradevice
)
| 是 | CameraDevice对象。 |
| callback | AsyncCallback<
[
CameraInput
](
#camerainput
)
\>
| 是 | 回调函数,用于获取CameraInput实例。 |
**示例:**
```
js
cameraManager
.
createCameraInput
(
camera
,
(
err
,
cameraInput
)
=>
{
let
cameraDevice
=
cameras
[
0
];
cameraManager
.
createCameraInput
(
cameraDevice
,
(
err
,
cameraInput
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to create the CameraInput instance.
${
err
.
message
}
`
);
return
;
...
...
@@ -330,7 +334,7 @@ cameraManager.createCameraInput(camera, (err, cameraInput) => {
### createCameraInput
createCameraInput(camera: CameraDevice): Promise<CameraInput
\>
createCameraInput(camera
Device
: CameraDevice): Promise<CameraInput
\>
使用CameraDevice对象异步创建CameraInput实例,通过Promise获取结果。
...
...
@@ -344,7 +348,7 @@ createCameraInput(camera: CameraDevice): Promise<CameraInput\>
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------- | ---- | ---------- |
| camera |
[
CameraDevice
](
#cameradevice
)
| 是 | CameraDevice对象。 |
| camera
Device
|
[
CameraDevice
](
#cameradevice
)
| 是 | CameraDevice对象。 |
**返回值:**
...
...
@@ -355,7 +359,8 @@ createCameraInput(camera: CameraDevice): Promise<CameraInput\>
**示例:**
```
js
cameraManager
.
createCameraInput
(
camera
).
then
((
cameraInput
)
=>
{
let
cameraDevice
=
cameras
[
0
];
cameraManager
.
createCameraInput
(
cameraDevice
).
then
((
cameraInput
)
=>
{
console
.
log
(
'
Promise returned with the CameraInput instance
'
);
})
```
...
...
@@ -383,7 +388,10 @@ createCameraInput(position: CameraPosition, type: CameraType, callback: AsyncCal
**示例:**
```
js
cameraManager
.
createCameraInput
(
camera
.
CameraPosition
.
CAMERA_POSITION_BACK
,
camera
.
CameraType
.
CAMERA_TYPE_UNSPECIFIED
,
(
err
,
cameraInput
)
=>
{
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
;
...
...
@@ -420,7 +428,10 @@ createCameraInput(position: CameraPosition, type:CameraType ): Promise<CameraInp
**示例:**
```
js
cameraManager
.
createCameraInput
(
camera
.
CameraPosition
.
CAMERA_POSITION_BACK
,
camera
.
CameraType
.
CAMERA_TYPE_UNSPECIFIED
).
then
((
cameraInput
)
=>
{
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
'
);
})
```
...
...
@@ -444,6 +455,7 @@ createPreviewOutput(profile: Profile, surfaceId: string, callback: AsyncCallback
**示例:**
```
js
let
profile
=
cameraoutputcapability
.
previewProfiles
[
0
];
cameraManager
.
createPreviewOutput
(
profile
,
surfaceId
,
(
err
,
previewOutput
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to gcreate previewOutput.
${
err
.
message
}
`
);
...
...
@@ -477,6 +489,7 @@ createPreviewOutput(profile: Profile, surfaceId: string): Promise<PreviewOutput\
**示例:**
```
js
let
profile
=
cameraoutputcapability
.
previewProfiles
[
0
];
cameraManager
.
createPreviewOutput
(
profile
,
surfaceId
).
then
((
previewOutput
)
=>
{
console
.
log
(
'
Promise returned with previewOutput created.
'
);
})
...
...
@@ -501,6 +514,7 @@ createPhotoOutput(profile: Profile, surfaceId: string, callback: AsyncCallback<P
**示例:**
```
js
let
profile
=
cameraoutputcapability
.
photoProfiles
[
0
];
cameraManager
.
createPhotoOutput
(
profile
,
surfaceId
,
(
err
,
photoOutput
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to create photoOutput.
${
err
.
message
}
`
);
...
...
@@ -534,6 +548,7 @@ createPhotoOutput(profile: Profile, surfaceId: string): Promise<PhotoOutput\>
**示例:**
```
js
let
profile
=
cameraoutputcapability
.
photoProfiles
[
0
];
cameraManager
.
createPhotoOutput
(
profile
,
surfaceId
).
then
((
photoOutput
)
=>
{
console
.
log
(
'
Promise returned with photoOutput created.
'
);
})
...
...
@@ -558,6 +573,7 @@ createVideoOutput(profile: VideoProfile, surfaceId: string, callback: AsyncCallb
**示例:**
```
js
let
profile
=
cameraoutputcapability
.
videoProfiles
[
0
];
cameraManager
.
createVideoOutput
(
profile
,
surfaceId
,
(
err
,
videoOutput
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to create videoOutput.
${
err
.
message
}
`
);
...
...
@@ -591,6 +607,7 @@ createVideoOutput(profile: VideoProfile, surfaceId: string): Promise<VideoOutput
**示例:**
```
js
let
profile
=
cameraoutputcapability
.
videoProfiles
[
0
];
cameraManager
.
createVideoOutput
(
profile
,
surfaceId
).
then
((
videoOutput
)
=>
{
console
.
log
(
'
Promise returned with videoOutput created.
'
);
})
...
...
@@ -614,6 +631,7 @@ createMetadataOutput(metadataObjectTypes:Array<MetadataObjectType\>, callback: A
**示例:**
```
js
let
metadataObjectTypes
=
cameraoutputcapability
.
supportedMetadataObjectTypes
;
cameraManager
.
createMetadataOutput
(
metadataObjectTypes
,
(
err
,
metadataOutput
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to create metadataOutput.
${
err
.
message
}
`
);
...
...
@@ -646,6 +664,7 @@ createMetadataOutput(metadataObjectTypes:Array<MetadataObjectType\>): Promise<Me
**示例:**
```
js
let
metadataObjectTypes
=
cameraoutputcapability
.
supportedMetadataObjectTypes
;
cameraManager
.
createMetadataOutput
(
metadataObjectTypes
).
then
((
metadataOutput
)
=>
{
console
.
log
(
'
Promise returned with metadataOutput created.
'
);
})
...
...
@@ -1015,7 +1034,7 @@ cameraInput.release().then(() => {
### on('error')
on(type: 'error', camera:CameraDevice, callback: ErrorCallback<CameraInputError
\>
): void
on(type: 'error', camera
Device
:CameraDevice, callback: ErrorCallback<CameraInputError
\>
): void
监听CameraInput的错误事件,通过注册回调函数获取结果。
...
...
@@ -1026,13 +1045,14 @@ on(type: 'error', camera:CameraDevice, callback: ErrorCallback<CameraInputError\
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | --- | ------------------------------------------- |
| type | string | 是 | 监听事件,固定为'error',即CameraInput错误事件。 |
| camera |
[
CameraDevice
](
#cameradevice
)
| 是 | CameraDevice对象。 |
| camera
Device
|
[
CameraDevice
](
#cameradevice
)
| 是 | CameraDevice对象。 |
| callback | ErrorCallback<
[
CameraInputError
](
#camerainputerror
)
\>
| 是 | 回调函数,用于获取结果。 |
**示例:**
```
js
cameraInput
.
on
(
'
error
'
,
camera
,
(
cameraInputError
)
=>
{
let
cameraDevice
=
cameras
[
0
];
cameraInput
.
on
(
'
error
'
,
cameraDevice
,
(
cameraInputError
)
=>
{
console
.
log
(
`Camera input error code:
${
cameraInputError
.
code
}
`
);
})
```
...
...
@@ -2137,6 +2157,7 @@ setExposureBias(exposureBias: number, callback: AsyncCallback<void\>): void
**示例:**
```
js
let
exposureBias
=
biasRangeArray
[
0
];
captureSession
.
setExposureBias
(
exposureBias
,(
err
)
=>
{
if
(
err
)
{
console
.
log
(
`Failed to set the exposure bias
${
err
.
message
}
`
);
...
...
@@ -2171,6 +2192,7 @@ setExposureBias(exposureBias: number): Promise<void\>
**示例:**
```
js
let
exposureBias
=
biasRangeArray
[
0
];
captureSession
.
setExposureBias
(
exposureBias
).
then
(()
=>
{
console
.
log
(
'
Promise returned with the successful execution of setExposureBias.
'
);
})
...
...
@@ -2607,6 +2629,7 @@ setZoomRatio(zoomRatio: number, callback: AsyncCallback<void\>): void
**示例:**
```
js
let
zoomRatio
=
zoomRatioRange
[
0
];
captureSession
.
setZoomRatio
(
zoomRatio
,
(
err
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to set the zoom ratio value
${
err
.
message
}
`
);
...
...
@@ -2639,6 +2662,7 @@ setZoomRatio(zoomRatio: number): Promise<void\>
**示例:**
```
js
let
zoomRatio
=
zoomRatioRange
[
0
];
captureSession
.
setZoomRatio
(
zoomRatio
).
then
(()
=>
{
console
.
log
(
'
Promise returned with the successful execution of setZoomRatio.
'
);
})
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录