Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
bb4f9eb7
D
Docs
项目概览
OpenHarmony
/
Docs
接近 2 年 前同步成功
通知
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看板
未验证
提交
bb4f9eb7
编写于
8月 25, 2023
作者:
O
openharmony_ci
提交者:
Gitee
8月 25, 2023
浏览文件
操作
浏览文件
下载
差异文件
!22955 文档一致性同步d.ts文件
Merge pull request !22955 from 马利/master
上级
23e539b5
7c80be8d
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
543 addition
and
44 deletion
+543
-44
zh-cn/application-dev/reference/apis/js-apis-camera.md
zh-cn/application-dev/reference/apis/js-apis-camera.md
+543
-44
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-camera.md
浏览文件 @
bb4f9eb7
...
...
@@ -164,60 +164,62 @@ let modeManager = camera.getModeManager(context);
相机模式。
**系统接口:**
此接口为系统接口。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
| 名称 | 值 | 说明 |
| ----------------| ---- | ---------|
| NORMAL | 0 | 普通模式 |
| CAPTURE | 1 | 拍照模式 |
| VIDEO | 2 | 录像模式 |
| PORTRAIT | 3 | 人像模式 |
| NIGHT | 4 | 夜景模式 |
| PROFESSIONAL | 5 | 专业模式 |
| SLOW_MOTION | 6 | 慢动作模式|
| PORTRAIT | 1 | 人像模式 |
## FilterType
滤镜类型。
**系统接口:**
此接口为系统接口。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
| 名称 | 值 | 说明 |
| ----------------| ---- | ---------|
| NONE | 0 | 原图 |
| CLASSIC | 1 | 经典 |
| DAWN | 2 | 晨光 |
| PURE | 3 | 清纯 |
| GREY | 4 | 灰调 |
| NATURAL | 5 | 自然 |
| MORI | 6 | 森系 |
| FAIR | 7 | 白皙 |
| PINK | 8 | 粉调 |
| NONE | 0 | 原图
。
|
| CLASSIC | 1 | 经典
。
|
| DAWN | 2 | 晨光
。
|
| PURE | 3 | 清纯
。
|
| GREY | 4 | 灰调
。
|
| NATURAL | 5 | 自然
。
|
| MORI | 6 | 森系
。
|
| FAIR | 7 | 白皙
。
|
| PINK | 8 | 粉调
。
|
## PortraitEffect
人像效果类型。
**系统接口:**
此接口为系统接口。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
| 名称 | 值 | 说明 |
| ----------------| ---- | ---------|
| OFF | 0 | 关闭 |
| CIRCLES | 1 | 圆形 |
| OFF | 0 | 关闭
。
|
| CIRCLES | 1 | 圆形
。
|
## BeautyType
美颜类型。
**系统接口:**
此接口为系统接口。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
| 名称 | 值 | 说明 |
| ----------------| ---- | ---------|
| AUTO
_TYPE | 0 | 自动
|
| SKIN_SMOOTH | 1 | 光滑 |
| FACE_SLENDER | 2 | 瘦脸 |
| SKIN_TONE | 3 | 肤色 |
| AUTO
| 0 | 自动。
|
| SKIN_SMOOTH | 1 | 光滑
。
|
| FACE_SLENDER | 2 | 瘦脸
。
|
| SKIN_TONE | 3 | 肤色
。
|
## CameraManager
...
...
@@ -654,6 +656,27 @@ cameraManager.on('cameraStatus', (err, cameraStatusInfo) => {
})
```
### off('cameraStatus')
off(type: 'cameraStatus', callback?: AsyncCallback
\<
CameraStatusInfo
\>
): void
相机设备状态注销回调,通过注销回调函数取消获取相机的状态变化。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -----------------| ---- | --------- |
| type | string | 是 | 监听事件,固定为'cameraStatus'。cameraManager对象获取成功后可监听。 |
| callback | AsyncCallback
\<
[
CameraStatusInfo
](
#camerastatusinfo
)
\>
| 否 | 可选参数,有表明匹配on接口callback。 | |
**示例:**
```
js
cameraManager
.
off
(
'
cameraStatus
'
)
```
### on('cameraMute')
on(type: 'cameraMute', callback: AsyncCallback
\<
boolean
\>
): void
...
...
@@ -679,6 +702,33 @@ cameraManager.on('cameraMute', (err, curMuetd) => {
})
```
### off('cameraMute')
off(type: 'cameraMute', callback?: AsyncCallback
\<
boolean
\>
): void
禁用回调,通过注销注册回调函数获取相机禁用状态变化。
**系统接口:**
此接口为系统接口。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------- | ---- | --------- |
| type | string | 是 | 监听事件,固定为'cameraMute',系统相机摄像头开关,cameraManager对象获取成功后可监听。 |
| callback | AsyncCallback
\<
boolean> | 否 | 回调函数,可选参数,有表明匹配on接口callback。 |
**示例:**
```
js
func
(
err
,
curMuetd
)
{
let
isMuted
=
curMuetd
;
}
cameraManager
.
on
(
'
cameraMute
'
,
func
)
cameraManager
.
off
(
'
cameraMute
'
,
func
)
```
### isPrelaunchSupported
isPrelaunchSupported(camera: CameraDevice): boolean
...
...
@@ -824,7 +874,7 @@ function getDeferredPreviewOutput(context: Context, previewProfile: camera.Profi
### getSupportedModes
getSupportedModes(
camera
: CameraDevice): Array
\<
CameraMode
\>
getSupportedModes(
device
: CameraDevice): Array
\<
CameraMode
\>
获取指定相机设备支持的模式列表,同步返回结果。
...
...
@@ -836,7 +886,7 @@ getSupportedModes(camera: CameraDevice): Array\<CameraMode\>
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------- | ---- | ------------------- |
|
camera |
\<
[
CameraDevice
](
#cameradevice
)
>
| 是 | 相机设备实例,通过
[
getSupportedCameras
](
#getsupportedcameras
)
接口获取。 |
|
device |
[
CameraDevice
](
#cameradevice
)
| 是 | 相机设备实例,通过
[
getSupportedCameras
](
#getsupportedcameras
)
接口获取。 |
**返回值:**
...
...
@@ -853,7 +903,7 @@ let cameraModes = cameraManager.getSupportedModes(cameraDevices[0]);
### getSupportedOutputCapability
getSupportedOutputCapability(
camera
:CameraDevice, mode: CameraMode): CameraOutputCapability
getSupportedOutputCapability(
device
:CameraDevice, mode: CameraMode): CameraOutputCapability
获取指定模式下相机设备支持的输出能力,同步返回结果。
...
...
@@ -865,7 +915,7 @@ getSupportedOutputCapability(camera:CameraDevice, mode: CameraMode): CameraOutpu
| 参数名 | 类型 | 必填 | 说明 |
| ------------ |--------------------------------------------------------------- | -- | -------------------------- |
|
cameraDevice
|
[
CameraDevice
](
#cameradevice
)
| 是 | 相机设备,通过
[
getSupportedCameras
](
#getsupportedcameras
)
接口获取。 |
|
device
|
[
CameraDevice
](
#cameradevice
)
| 是 | 相机设备,通过
[
getSupportedCameras
](
#getsupportedcameras
)
接口获取。 |
| mode |
[
CameraMode
](
#cameramode
)
| 是 | 指定模式,通过
[
getSupportedModes
](
#getsupportedmodes
)
接口获取。 |
**返回值:**
...
...
@@ -1207,6 +1257,28 @@ cameraInput.on('error', cameraDevice, (error) => {
})
```
### off('error')
off(type: 'error', camera:CameraDevice, callback?: ErrorCallback): void
注销监听CameraInput的错误事件。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | --- | ------------------------------------------- |
| type | string | 是 | 监听事件,固定为'error',CameraInput对象创建成功可监听。相机设备出错情况下可触发该事件并返回结果,比如(设备不可用或者冲突等返回对应错误信息) |
| cameraDevice |
[
CameraDevice
](
#cameradevice
)
| 是 | CameraDevice对象。 |
| callback | ErrorCallback | 否 | 回调函数,可选,有就是匹配on('error') callback |
**示例:**
```
js
cameraInput
.
off
(
'
error
'
,
cameraDevice
)
```
## FlashMode
枚举,闪光灯模式。
...
...
@@ -2615,7 +2687,7 @@ try {
```
### getSupportedFilters
getSupportedFilters(): Array
\<
FilterType
>
getSupportedFilters(): Array
\<
number
>
获取当前支持的滤镜效果列表。
...
...
@@ -2629,6 +2701,14 @@ getSupportedFilters(): Array\<FilterType>
| ---------- | ----------------------------- |
| Array
\<
FilterType
\>
| 返回支持的滤镜效果列表。 |
**错误码:**
以下错误码的详细介绍请参见
[
Camera错误码
](
../errorcodes/errorcode-camera.md
)
。
| 错误码ID | 错误信息 |
| --------------- | --------------- |
| 7400103 | Session not config. |
**示例:**
```
js
...
...
@@ -2636,7 +2716,7 @@ let FilterTypes = captureSession.getSupportedFilters();
```
### setFilter
setFilter(filter:
FilterType
): void
setFilter(filter:
number
): void
设置滤镜效果。
...
...
@@ -2648,7 +2728,16 @@ setFilter(filter: FilterType): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------| ---- | ---------------------|
| filter |
[
FilterType
](
#filtertype
)
| 是 | 当前用户设置的滤镜类型。 |
| filter |
[
number
](
#filtertype
)
| 是 | 当前用户设置的滤镜类型。 |
**错误码:**
以下错误码的详细介绍请参见
[
Camera错误码
](
../errorcodes/errorcode-camera.md
)
。
| 错误码ID | 错误信息 |
| --------------- | --------------- |
| 7400101 | Parameter missing or parameter type incorrect. |
| 7400103 | Session not config. |
**示例:**
...
...
@@ -2673,7 +2762,15 @@ if (!FilterTypes.empty()) {
| 类型 | 说明 |
| ---------- | ----------------------------|
|
[
FilterType
](
#filtertype
)
| 已设置的滤镜效果。可查阅
[
FilterType
](
#filtertype
)
。|
|
[
number
](
#filtertype
)
| 已设置的滤镜效果。可查阅
[
FilterType
](
#filtertype
)
。|
**错误码:**
以下错误码的详细介绍请参见
[
Camera错误码
](
../errorcodes/errorcode-camera.md
)
。
| 错误码ID | 错误信息 |
| --------------- | --------------- |
| 7400103 | Session not config. |
**示例:**
...
...
@@ -2682,7 +2779,7 @@ let FilterType = captureSession.getFilter();
```
### getSupportedBeautyTypes
getSupportedBeautyTypes(): Array
<
BeautyType
>
getSupportedBeautyTypes(): Array
<
[
BeautyType
](
#beautytype
)
>
获取当前支持的美颜效果列表。
...
...
@@ -2694,19 +2791,29 @@ getSupportedBeautyTypes(): Array<BeautyType>
| 类型 | 说明 |
| ---------- | ----------------------------- |
| Array
\<
BeautyType
\>
| 返回当前支持的美颜效果列表。 |
| Array
\<
[
BeautyType
](
#beautytype
)
\>
| 返回当前支持的美颜效果列表。 |
**错误码:**
以下错误码的详细介绍请参见
[
Camera错误码
](
../errorcodes/errorcode-camera.md
)
。
| 错误码ID | 错误信息 |
| --------------- | --------------- |
| 7400103 | Session not config. |
**示例:**
```
js
let
FilterTypes
=
captureSession
.
getSupportedBeautyTypes
();
```
### getSupportedBeautyRange
s
### getSupportedBeautyRange
getSupportedBeautyRange
s
(type: BeautyType): Array
<number>
getSupportedBeautyRange(type: BeautyType): Array
<number>
获取指定美颜效果的范围值。
**系统接口:**
此接口为系统接口。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
**参数:**
...
...
@@ -2721,12 +2828,20 @@ getSupportedBeautyRanges(type: BeautyType): Array<number>
| ---------- | ----------------------------- |
| Array
\<
number
\>
| 当前美颜类型所支持的美颜强度。 |
**错误码:**
以下错误码的详细介绍请参见
[
Camera错误码
](
../errorcodes/errorcode-camera.md
)
。
| 错误码ID | 错误信息 |
| --------------- | --------------- |
| 7400103 | Session not config. |
**示例:**
```
js
let
beautyTypes
=
captureSession
.
getSupportedBeautyTypes
();
if
(
!
beautyTypes
.
empty
())
{
let
nums
=
captureSession
.
getSupportedBeautyRange
s
(
beautyTypes
[
0
]);
let
nums
=
captureSession
.
getSupportedBeautyRange
(
beautyTypes
[
0
]);
}
```
...
...
@@ -2745,7 +2860,15 @@ setBeauty(type: BeautyType, value: number): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------| ---- | --------------------- |
| type |
[
BeautyType
](
#beautytype
)
| 是 | 美颜类型 |
| value |
[
number] | 是 | 美颜强度,通过[getSupportedBeautyRanges
](
#getsupportedbeautyranges
)
接口获取。|
| value | number | 是 | 美颜强度,通过
[
getSupportedBeautyRange
](
#getsupportedbeautyrange
)
接口获取。|
**错误码:**
以下错误码的详细介绍请参见
[
Camera错误码
](
../errorcodes/errorcode-camera.md
)
。
| 错误码ID | 错误信息 |
| --------------- | --------------- |
| 7400103 | Session not config. |
**示例:**
...
...
@@ -2753,7 +2876,7 @@ setBeauty(type: BeautyType, value: number): void
let
beautyTypes
=
captureSession
.
getSupportedBeautyTypes
();
let
beautyLevels
;
if
(
!
beautyTypes
.
empty
())
{
beautyLevels
=
captureSession
.
getSupportedBeautyRange
s
(
beautyTypes
[
0
]);
beautyLevels
=
captureSession
.
getSupportedBeautyRange
(
beautyTypes
[
0
]);
}
if
(
!
beautyTypes
.
empty
()
&&
beautyLevels
.
empty
())
{
captureSession
.
setBeauty
(
beautyTypes
[
0
],
beautyLevels
[
0
]);
...
...
@@ -2779,7 +2902,15 @@ getBeauty(type: BeautyType): number
**返回值:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------- | ---- | --------------------- |
| value | [number] | 是 | 美颜强度 |
| value | number | 是 | 美颜强度 |
**错误码:**
以下错误码的详细介绍请参见
[
Camera错误码
](
../errorcodes/errorcode-camera.md
)
。
| 错误码ID | 错误信息 |
| --------------- | --------------- |
| 7400103 | Session not config. |
**示例:**
...
...
@@ -2787,7 +2918,7 @@ getBeauty(type: BeautyType): number
let
BeautyTypes
=
captureSession
.
getSupportedBeautyTypes
();
let
beautyLevels
;
if
(
!
BeautyTypes
.
empty
())
{
beautyLevels
=
captureSession
.
getSupportedBeautyRange
s
(
BeautyTypes
[
0
]);
beautyLevels
=
captureSession
.
getSupportedBeautyRange
(
BeautyTypes
[
0
]);
}
if
(
!
BeautyTypes
.
empty
()
&&
beautyLevels
.
empty
())
{
captureSession
.
setBeauty
(
BeautyTypes
[
0
],
beautyLevels
[
0
]);
...
...
@@ -2818,6 +2949,27 @@ captureSession.on('focusStateChange', (err, focusState) => {
})
```
### off('focusStateChange')
off(type: 'focusStateChange', callback?: AsyncCallback
\<
FocusState
\>
): void
注销监听相机聚焦的状态变化。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------------------- | ---- | ------------------------ |
| type | string | 是 | 监听事件,固定为'focusStateChange',session 创建成功可监听。|
| callback | AsyncCallback
\<
[
FocusState
](
#focusstate
)
\>
| 否 | 回调函数,可选 |
**示例:**
```
js
captureSession
.
off
(
'
focusStateChange
'
)
```
### on('error')
on(type: 'error', callback: ErrorCallback): void
...
...
@@ -2840,13 +2992,34 @@ captureSession.on('error', (error) => {
console
.
log
(
`Capture session error code:
${
error
.
code
}
`
);
})
```
### off('error')
off(type: 'error', callback?: ErrorCallback): void
监听拍照会话的错误事件,通过注册回调函数获取结果。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------------------------------------- | ---- | ------------------------------ |
| type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。 |
| callback | ErrorCallback| 否 | 回调函数,可选 |
**示例:**
```
js
captureSession
.
off
(
'
error
'
)
```
## PortraitSession
继承自
[
CaptureSession
](
#capturesession
)
,用于设置人像模式的参数。
### getSupportedPortraitEffects
getSupportedPortraitEffects(): Array
<
PortraitEffect
>
getSupportedPortraitEffects(): Array
<
[
PortraitEffect
](
#portraiteffect
)
>
获取支持的人像虚化效果列表。
...
...
@@ -2860,6 +3033,14 @@ getSupportedPortraitEffects(): Array<PortraitEffect>
| ----------------------------------------------- | ---------------------------- |
| Array
<
[
PortraitEffect
](
#portraiteffect
)
>
| 支持的人像虚化效果列表。 |
**错误码:**
以下错误码的详细介绍请参见
[
Camera错误码
](
../errorcodes/errorcode-camera.md
)
。
| 错误码ID | 错误信息 |
| --------------- | --------------- |
| 7400103 | Session not config. |
**示例:**
```
js
...
...
@@ -2881,6 +3062,14 @@ setPortraitEffect(effect: PortraitEffect): void
| ------------ |--------------------------------------------------------------- | -- | -------------------------- |
| effect |
[
PortraitEffect
](
#portraiteffect
)
| 是 | 人像虚化效果,通过
[
getSupportedPortraitEffects
](
#getsupportedportraiteffects
)
接口获取。 |
**错误码:**
以下错误码的详细介绍请参见
[
Camera错误码
](
../errorcodes/errorcode-camera.md
)
。
| 错误码ID | 错误信息 |
| --------------- | --------------- |
| 7400103 | Session not config. |
**示例:**
```
js
...
...
@@ -2905,6 +3094,13 @@ getPortraitEffect(): PortraitEffect
| ----------------------------------------------- | ---------------------------- |
|
[
PortraitEffect
](
#portraiteffect
)
| 当前设置的人像虚化效果。 |
**错误码:**
以下错误码的详细介绍请参见
[
Camera错误码
](
../errorcodes/errorcode-camera.md
)
。
| 错误码ID | 错误信息 |
| --------------- | --------------- |
| 7400103 | Session not config. |
**示例:**
...
...
@@ -3128,6 +3324,27 @@ previewOutput.on('frameStart', () => {
})
```
### off('frameStart')
off(type: 'frameStart', callback?: AsyncCallback
\<
void
\>
): void
注销监听预览帧启动。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | --------------------------------------- |
| type | string | 是 | 监听事件,固定为'frameStart',previewOutput创建成功可监听。 |
| callback | AsyncCallback
\<
void
\>
| 否 | 回调函数,可选 |
**示例:**
```
js
previewOutput
.
off
(
'
frameStart
'
)
```
### on('frameEnd')
on(type: 'frameEnd', callback: AsyncCallback
\<
void
\>
): void
...
...
@@ -3151,6 +3368,27 @@ previewOutput.on('frameEnd', () => {
})
```
### off('frameEnd')
off(type: 'frameEnd', callback?: AsyncCallback
\<
void
\>
): void
注销监听预览帧结束。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | ------------------------------------- |
| type | string | 是 | 监听事件,固定为'frameEnd',previewOutput创建成功可监听。 |
| callback | AsyncCallback
\<
void
\>
| 否 | 回调函数,可选 |
**示例:**
```
js
previewOutput
.
off
(
'
frameEnd
'
)
```
### on('error')
on(type: 'error', callback: ErrorCallback): void
...
...
@@ -3174,6 +3412,27 @@ previewOutput.on('error', (previewOutputError) => {
})
```
### off('error')
off(type: 'error', callback?: ErrorCallback): void
注销监听预览输出的错误事件。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------| ---- | ------------------------ |
| type | string | 是 | 监听事件,固定为'error',previewOutput创建成功可监听。|
| callback | ErrorCallback | 否 | 回调函数,可选 |
**示例:**
```
js
previewOutput
.
off
(
'
error
'
)
```
### addDeferredSurface
addDeferredSurface(surfaceId: string): void
...
...
@@ -3548,6 +3807,27 @@ photoOutput.on('captureStart', (err, captureId) => {
})
```
### off('captureStart')
off(type: 'captureStart', callback?: AsyncCallback
\<
number
\>
): void
注销监听拍照开始。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------- | ---- | ------------------------------------------ |
| type | string | 是 | 监听事件,固定为'captureStart',photoOutput创建成功后可监听 |
| callback | AsyncCallback
\<
number
\>
| 否 | 可选。 |
**示例:**
```
js
photoOutput
.
off
(
'
captureStart
'
)
```
### on('frameShutter')
on(type: 'frameShutter', callback: AsyncCallback
\<
FrameShutterInfo
\>
): void
...
...
@@ -3572,6 +3852,27 @@ photoOutput.on('frameShutter', (err, frameShutterInfo) => {
})
```
### off('frameShutter')
off(type: 'frameShutter', callback?: AsyncCallback
\<
FrameShutterInfo
\>
): void
注销监听拍照帧输出捕获。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------- | --- | ------------------------------------ |
| type | string | 是 | 监听事件,固定为'frameShutter',photoOutput创建成功后可监听。 |
| callback | AsyncCallback
\<
[
FrameShutterInfo
](
#frameshutterinfo
)
\>
| 否 | 回调函数,可选。 |
**示例:**
```
js
photoOutput
.
off
(
'
frameShutter
'
)
```
### on('captureEnd')
on(type: 'captureEnd', callback: AsyncCallback
\<
CaptureEndInfo
\>
): void
...
...
@@ -3596,6 +3897,27 @@ photoOutput.on('captureEnd', (err, captureEndInfo) => {
})
```
### off('captureEnd')
off(type: 'captureEnd', callback?: AsyncCallback
\<
CaptureEndInfo
\>
): void
注销监听拍照结束。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------- | ---- | ---------------------------------------- |
| type | string | 是 | 监听事件,固定为'captureEnd',photoOutput创建成功后可监听。 |
| callback | AsyncCallback
\<
[
CaptureEndInfo
](
#captureendinfo
)
\>
| 否 | 回调函数,可选。 |
**示例:**
```
js
photoOutput
.
off
(
'
captureEnd
'
)
```
### on('error')
on(type: 'error', callback: ErrorCallback): void
...
...
@@ -3619,6 +3941,27 @@ photoOutput.on('error', (error) => {
})
```
### off('error')
off(type: 'error', callback?: ErrorCallback): void
注销监听拍照输出发生错误。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------- | ---- | ----------------------------------- |
| type | string | 是 | 监听事件,固定为'error',photoOutput创建成功后可监听。 |
| callback | ErrorCallback | 否 | 回调函数,可选 |
**示例:**
```
js
photoOutput
.
off
(
'
error
'
)
```
### isQuickThumbnailSupported
isQuickThumbnailSupported(): boolean
...
...
@@ -3643,7 +3986,7 @@ isQuickThumbnailSupported(): boolean
| 错误码ID | 错误信息 |
| --------------- | --------------- |
| 740010
1 | Parameter missing or parameter type incorrect
|
| 740010
4 | session is not running
|
**示例:**
...
...
@@ -3689,7 +4032,7 @@ enableQuickThumbnail(enabled: boolean): void
| 错误码ID | 错误信息 |
| --------------- | --------------- |
| 740010
1 | Parameter missing or parameter type incorrect
|
| 740010
4 | session is not running
|
**示例:**
...
...
@@ -3731,7 +4074,57 @@ on(type: 'quickThumbnail', callback: AsyncCallback\<image.PixelMap>): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------- | ---- | ----------------------------------- |
| type | string | 是 | 监听事件,固定为'quickThumbnail'。 |
| callback | AsyncCallback
\<
[
image.PixelMap
](
js-apis-image.md#pixelmap7
)
> | 回调返回PixelMap。 |
| callback | AsyncCallback
\<
[
image.PixelMap
](
js-apis-image.md#pixelmap7
)
> | 是 | 回调返回PixelMap。 |
**示例:**
```
js
import
camera
from
'
@ohos.multimedia.camera
'
this
.
cameraManager
=
camera
.
getCameraManager
(
globalThis
.
abilityContext
);
let
cameras
=
this
.
cameraManager
.
getSupportedCameras
()
// 创建CaptureSession实例
this
.
captureSession
=
await
this
.
cameraManager
.
createCaptureSession
()
// 开始配置会话
await
this
.
captureSession
.
beginConfig
()
// 把CameraInput加入到会话
this
.
cameraInput
=
await
this
.
cameraManager
.
createCameraInput
(
cameras
[
0
])
await
this
.
cameraInput
.
open
()
await
this
.
captureSession
.
addInput
(
this
.
cameraInput
)
// 把PhotoOutPut加入到会话
this
.
photoOutPut
=
await
this
.
cameraManager
.
createPhotoOutput
(
photoProfile
,
surfaceId
)
await
this
.
captureSession
.
addOutput
(
this
.
photoOutPut
)
boolean
isSupported
=
this
.
photoOutPut
.
isQuickThumbnailSupported
()
if
(
isSupported
)
{
// 使能快速缩略图
this
.
photoOutPut
.
enableQuickThumbnail
(
true
)
}
this
.
photoOutPut
.
on
(
'
quickThumbnail
'
,
(
err
,
pixelmap
)
=>
{
if
(
err
||
pixelmap
===
undefined
)
{
Logger
.
error
(
this
.
tag
,
'
photoOutPut on thumbnail failed
'
)
return
}
// 显示或保存pixelmap
this
.
showOrSavePicture
(
pixelmap
)
})
```
### off('quickThumbnail')
off(type: 'quickThumbnail', callback?: AsyncCallback
\<
image.PixelMap>): void
注销监听快速缩略图输出事件。
**系统接口:**
此接口为系统接口。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------- | ---- | ----------------------------------- |
| type | string | 是 | 监听事件,固定为'quickThumbnail'。 |
| callback | AsyncCallback
\<
[
image.PixelMap
](
js-apis-image.md#pixelmap7
)
> | 否 | 可选。 |
**示例:**
...
...
@@ -3764,6 +4157,7 @@ this.photoOutPut.on('quickThumbnail', (err, pixelmap) => {
// 显示或保存pixelmap
this
.
showOrSavePicture
(
pixelmap
)
})
this
.
photoOutPut
.
off
(
'
quickThumbnail
'
)
```
## FrameShutterInfo
...
...
@@ -3999,6 +4393,27 @@ videoOutput.on('frameStart', () => {
})
```
### off('frameStart')
off(type: 'frameStart', callback?: AsyncCallback
\<
void
\>
): void
注销监听录像开始。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | ----------------------------------------- |
| type | string | 是 | 监听事件,固定为'frameStart',videoOutput创建成功后可监听。 |
| callback | AsyncCallback
\<
void
\>
| 否 | 回调函数,可选 |
**示例:**
```
js
videoOutput
.
off
(
'
frameStart
'
)
```
### on('frameEnd')
on(type: 'frameEnd', callback: AsyncCallback
\<
void
\>
): void
...
...
@@ -4022,6 +4437,27 @@ videoOutput.on('frameEnd', () => {
})
```
### off('frameEnd')
off(type: 'frameEnd', callback?: AsyncCallback
\<
void
\>
): void
注销监听录像结束。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | ------------------------------------------ |
| type | string | 是 | 监听事件,固定为'frameEnd',videoOutput创建成功后可监听 。 |
| callback | AsyncCallback
\<
void
\>
| 否 | 回调函数,可选 |
**示例:**
```
js
videoOutput
.
off
(
'
frameEnd
'
)
```
### on('error')
on(type: 'error', callback: ErrorCallback): void
...
...
@@ -4045,6 +4481,27 @@ videoOutput.on('error', (error) => {
})
```
### off('error')
off(type: 'error', callback?: ErrorCallback): void
注销监听录像输出发生错误。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------- | ---- | -------------------------------------- |
| type | string | 是 | 监听事件,固定为'error',videoOutput创建成功后可监听。 |
| callback | ErrorCallback | 否 | 回调函数,可选 |
**示例:**
```
js
videoOutput
.
off
(
'
error
'
)
```
## MetadataOutput
metadata流。继承
[
CameraOutput
](
#cameraoutput
)
...
...
@@ -4190,6 +4647,27 @@ metadataOutput.on('metadataObjectsAvailable', (err, metadataObjectArr) => {
})
```
### off('metadataObjectsAvailable')
off(type: 'metadataObjectsAvailable', callback?: AsyncCallback
\<
Array
\<
MetadataObject
\>\>
): void
注销监听检测到的metadata对象。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------- | ---- | ------------------------------------ |
| type | string | 是 | 监听事件,固定为'metadataObjectsAvailable',metadataOutput创建成功后可监听。 |
| callback | Callback
\<
Array
\<
[
MetadataObject
](
#metadataobject
)
\>\>
| 否 | 回调函数,可选。 |
**示例:**
```
js
metadataOutput
.
off
(
'
metadataObjectsAvailable
'
)
```
### on('error')
on(type: 'error', callback: ErrorCallback): void
...
...
@@ -4213,6 +4691,27 @@ metadataOutput.on('error', (metadataOutputError) => {
})
```
### off('error')
off(type: 'error', callback?: ErrorCallback): void
注销监听metadata流的错误。
**系统能力:**
SystemCapability.Multimedia.Camera.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------- | ---- | --------------------------------------- |
| type | string | 是 | 监听事件,固定为'error',metadataOutput创建成功后可监听。 |
| callback | ErrorCallback | 否 | 回调函数,可选 |
**示例:**
```
js
metadataOutput
.
off
(
'
error
'
)
```
## MetadataObjectType
枚举,metadata流。
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录