• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Interface (Stabilization)
2<!--Kit: Camera Kit-->
3<!--Subsystem: Multimedia-->
4<!--Owner: @qano-->
5<!--SE: @leo_ysl-->
6<!--TSE: @xchaosioda-->
7
8> **NOTE**
9>
10> - The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
11> - The initial APIs of this interface are supported since API version 11.
12
13Stabilization inherits from [StabilizationQuery](arkts-apis-camera-StabilizationQuery.md).
14
15It provides APIs to set video stabilization.
16
17 > **NOTE**
18 >
19 > You can set video stabilization only when a [VideoOutput](arkts-apis-camera-VideoOutput.md) stream exists in the session.
20 > The enumerated value **HIGH** of [VideoStabilizationMode](arkts-apis-camera-e.md#videostabilizationmode) takes effect only when the resolution of [Profile](arkts-apis-camera-i.md#profile) is 1920 x 1080.
21
22## Modules to Import
23
24```ts
25import { camera } from '@kit.CameraKit';
26```
27
28## getActiveVideoStabilizationMode<sup>11+</sup>
29
30getActiveVideoStabilizationMode(): VideoStabilizationMode
31
32Obtains the video stabilization mode in use.
33
34**Atomic service API**: This API can be used in atomic services since API version 19.
35
36**System capability**: SystemCapability.Multimedia.Camera.Core
37
38**Return value**
39
40| Type       | Description         |
41| ---------- |-------------|
42| [VideoStabilizationMode](arkts-apis-camera-e.md#videostabilizationmode)    | Video stabilization mode obtained.|
43
44**Error codes**
45
46For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
47
48| ID        | Error Message       |
49| --------------- | --------------- |
50| 7400103                |  Session not config.                                   |
51
52**Example**
53
54```ts
55import { BusinessError } from '@kit.BasicServicesKit';
56
57function getActiveVideoStabilizationMode(videoSession: camera.VideoSession): camera.VideoStabilizationMode | undefined {
58  let vsMode: camera.VideoStabilizationMode | undefined = undefined;
59  try {
60    vsMode = videoSession.getActiveVideoStabilizationMode();
61  } catch (error) {
62    // If the operation fails, error.code is returned and processed.
63    let err = error as BusinessError;
64    console.error(`The getActiveVideoStabilizationMode call failed. error code: ${err.code}`);
65  }
66  return vsMode;
67}
68```
69
70## setVideoStabilizationMode<sup>11+</sup>
71
72setVideoStabilizationMode(mode: VideoStabilizationMode): void
73
74Sets a video stabilization mode. Before the setting, call [isVideoStabilizationModeSupported](arkts-apis-camera-StabilizationQuery.md#isvideostabilizationmodesupported11) to check whether the target video stabilization mode is supported.
75
76**Atomic service API**: This API can be used in atomic services since API version 19.
77
78**System capability**: SystemCapability.Multimedia.Camera.Core
79
80**Parameters**
81
82| Name     | Type                                             | Mandatory| Description                   |
83| -------- | ------------------------------------------------- | ---- | --------------------- |
84| mode     | [VideoStabilizationMode](arkts-apis-camera-e.md#videostabilizationmode) | Yes  | Video stabilization mode.  |
85
86**Error codes**
87
88For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
89
90| ID        | Error Message       |
91| --------------- | --------------- |
92| 7400103                |  Session not config.                                   |
93
94**Example**
95
96```ts
97import { BusinessError } from '@kit.BasicServicesKit';
98
99function setVideoStabilizationMode(videoSession: camera.VideoSession): void {
100  try {
101    videoSession.setVideoStabilizationMode(camera.VideoStabilizationMode.OFF);
102  } catch (error) {
103    // If the operation fails, error.code is returned and processed.
104    let err = error as BusinessError;
105    console.error(`The setVideoStabilizationMode call failed. error code: ${err.code}`);
106  }
107}
108```
109