camera.h
Overview
Defines the basic APIs of the camera.
File to include: <ohcamera/camera.h>
Library: libohcamera.so
System capability: SystemCapability.Multimedia.Camera.Core
Since: 11
Related module: OH_Camera
Summary
Structs
| Name | typedef Keyword | Description |
|---|---|---|
| Camera_DeviceQueryInfo | Camera_DeviceQueryInfo | Describes the camera device query information. |
| Camera_Size | Camera_Size | Describes the parameters related to the size. |
| Camera_Profile | Camera_Profile | Describes the profile of a camera stream. |
| Camera_FrameRateRange | Camera_FrameRateRange | Describes the frame rate range. |
| Camera_VideoProfile | Camera_VideoProfile | Describes the video profile. |
| Camera_OutputCapability | Camera_OutputCapability | Describes the camera output capability. |
| Camera_Device | Camera_Device | Describes the camera device. |
| Camera_StatusInfo | Camera_StatusInfo | Describes the camera status information. |
| Camera_Point | Camera_Point | Describes the parameters related to a point. |
| Camera_Location | Camera_Location | Describes the location where the photo is taken. |
| Camera_PhotoCaptureSetting | Camera_PhotoCaptureSetting | Describes the parameters related to photo capture. |
| Camera_FrameShutterInfo | Camera_FrameShutterInfo | Describes the frame shutter information. |
| Camera_CaptureEndInfo | Camera_CaptureEndInfo | Describes the capture end information. |
| Camera_Rect | Camera_Rect | Defines the rectangle. The detection point must be in the coordinate system (0-1), where the top-left corner is (0, 0) and the bottom-right corner is (1, 1). The coordinate system is based on the horizontal device direction with the device's charging port on the right. If the layout of the preview screen of an application is based on the vertical direction with the charging port on the lower side, the layout width and height are {w, h}, and the returned point is {x, y}, then the coordinate point after conversion is (1-y, x). |
| Camera_MetadataObject | Camera_MetadataObject | Describes the camera metadata. |
| Camera_TorchStatusInfo | Camera_TorchStatusInfo | Describes the flashlight status information. |
| Camera_SmoothZoomInfo | Camera_SmoothZoomInfo | Describes the smooth zoom information. |
| Camera_CaptureStartInfo | Camera_CaptureStartInfo | Describes the capture start information. |
| Camera_FrameShutterEndInfo | Camera_FrameShutterEndInfo | Describes the frame shutter end information during capture. |
| Camera_FoldStatusInfo | Camera_FoldStatusInfo | Describes the fold status information of the camera. |
| Camera_AutoDeviceSwitchStatusInfo | Camera_AutoDeviceSwitchStatusInfo | Describes the automatic device switching status information. |
| Camera_ConcurrentInfo | Camera_ConcurrentInfo | Describes the camera's concurrency information. |
| Camera_ControlCenterStatusInfo | Camera_ControlCenterStatusInfo | Describes the effect status information of a camera controller. |
| Camera_OcclusionDetectionResult | Camera_OcclusionDetectionResult | Describes the check result for whether a camera lens is blocked or dirty. |
| Camera_Manager | Camera_Manager | Describes the camera manager. You can call OH_Camera_GetCameraManager to create such an object. |
Enums
| Name | typedef Keyword | Description |
|---|---|---|
| Camera_ErrorCode | Camera_ErrorCode | Enumerates the camera error codes. |
| Camera_Status | Camera_Status | Enumerates the camera statuses. |
| Camera_SceneMode | Camera_SceneMode | Enumerates the camera scene modes. |
| Camera_Position | Camera_Position | Enumerates the camera positions. |
| Camera_Type | Camera_Type | Enumerates the camera types. |
| Camera_Connection | Camera_Connection | Enumerates the camera connection types. |
| Camera_Format | Camera_Format | Enumerates the camera output formats. |
| Camera_FlashMode | Camera_FlashMode | Enumerates the flash modes. |
| Camera_ExposureMode | Camera_ExposureMode | Enumerates the exposure modes. |
| Camera_FocusMode | Camera_FocusMode | Enumerates the focus modes. |
| Camera_FocusState | Camera_FocusState | Enumerates the focus states. |
| Camera_VideoStabilizationMode | Camera_VideoStabilizationMode | Enumerates the video stabilization modes. |
| Camera_ImageRotation | Camera_ImageRotation | Enumerates the image rotation angles. |
| Camera_QualityLevel | Camera_QualityLevel | Enumerates the image quality levels. |
| Camera_MetadataObjectType | Camera_MetadataObjectType | Enumerates the metadata object types. |
| Camera_TorchMode | Camera_TorchMode | Enumerates the flashlight modes. |
| Camera_SmoothZoomMode | Camera_SmoothZoomMode | Enumerates the smooth zoom modes. |
| Camera_SystemPressureLevel | Camera_SystemPressureLevel | Enumerates the system pressure levels. |
| Camera_PreconfigType | Camera_PreconfigType | Enumerates the preconfigured photo resolution types. |
| Camera_PreconfigRatio | Camera_PreconfigRatio | Enumerates the preconfigured photo aspect ratios. |
| Camera_HostDeviceType | Camera_HostDeviceType | Enumerates the remote device types. |
| Camera_FoldStatus | Camera_FoldStatus | Enumerates the fold statuses. |
| Camera_QualityPrioritization | Camera_QualityPrioritization | Enumerates the priority levels for video recording quality. |
| Camera_ConcurrentType | Camera_ConcurrentType | Enumerates the camera's concurrency types. |
| Camera_WhiteBalanceMode | Camera_WhiteBalanceMode | Enumerates the white balance modes. |
| Camera_ControlCenterEffectType | Camera_ControlCenterEffectType | Enumerates the effect types of a camera controller. |
| Camera_PhotoQualityPrioritization | Camera_PhotoQualityPrioritization | Enumerates the photo quality prioritization strategies. |
Functions
| Name | Description |
|---|---|
| Camera_ErrorCode OH_Camera_GetCameraManager(Camera_Manager** cameraManager) | Obtains a Camera_Manager instance. |
| Camera_ErrorCode OH_Camera_DeleteCameraManager(Camera_Manager* cameraManager) | Deletes a Camera_Manager instance. |
Enum Description
Camera_ErrorCode
enum Camera_ErrorCode
Description
Enumerates the camera error codes.
Since: 11
| Enum Item | Description |
|---|---|
| CAMERA_OK = 0 | The camera is normal. |
| CAMERA_INVALID_ARGUMENT = 7400101 | A parameter is missing or the parameter type is incorrect. |
| CAMERA_OPERATION_NOT_ALLOWED = 7400102 | The operation is not allowed. |
| CAMERA_SESSION_NOT_CONFIG = 7400103 | The session is not configured. |
| CAMERA_SESSION_NOT_RUNNING = 7400104 | The session is not running. |
| CAMERA_SESSION_CONFIG_LOCKED = 7400105 | The session configuration is locked. |
| CAMERA_DEVICE_SETTING_LOCKED = 7400106 | The device setting is locked. |
| CAMERA_CONFLICT_CAMERA = 7400107 | The device is already started. |
| CAMERA_DEVICE_DISABLED = 7400108 | The camera is disabled for security reasons. |
| CAMERA_DEVICE_PREEMPTED = 7400109 | The camera is preempted. |
| CAMERA_UNRESOLVED_CONFLICTS_WITH_CURRENT_CONFIGURATIONS = 7400110 | The configuration conflicts with the current configuration. Since: 12 |
| CAMERA_SERVICE_FATAL_ERROR = 7400201 | The camera service is abnormal, for example, no camera permission, camera service restart, or abnormal cross-process invocation. |
Camera_Status
enum Camera_Status
Description
Enumerates the camera statuses.
Since: 11
| Enum Item | Description |
|---|---|
| CAMERA_STATUS_APPEAR = 0 | A camera appears. |
| CAMERA_STATUS_DISAPPEAR = 1 | The camera disappears. |
| CAMERA_STATUS_AVAILABLE = 2 | The camera is available. |
| CAMERA_STATUS_UNAVAILABLE = 3 | The camera is unavailable. |
Camera_SceneMode
enum Camera_SceneMode
Description
Enumerates the camera scene modes.
Since: 12
| Enum Item | Description |
|---|---|
| NORMAL_PHOTO = 1 | Normal photo mode. |
| NORMAL_VIDEO = 2 | Normal video mode. |
| SECURE_PHOTO = 12 | Secure mode, which is mainly provided for high-security applications like banking that require features such as biometric verification. The secure mode requires the encryption algorithm framework and trusted application services. For details, see Device Certificate Kit. |
Camera_Position
enum Camera_Position
Description
Enumerates the camera positions.
Since: 11
| Enum Item | Description |
|---|---|
| CAMERA_POSITION_UNSPECIFIED = 0 | A camera that does not have a fixed orientation relative to the device screen. |
| CAMERA_POSITION_BACK = 1 | Rear camera. |
| CAMERA_POSITION_FRONT = 2 | Front camera. |
Camera_Type
enum Camera_Type
Description
Enumerates the camera types.
Since: 11
| Enum Item | Description |
|---|---|
| CAMERA_TYPE_DEFAULT = 0 | Default camera type. |
| CAMERA_TYPE_WIDE_ANGLE = 1 | Wide camera. |
| CAMERA_TYPE_ULTRA_WIDE = 2 | Ultra-wide camera. |
| CAMERA_TYPE_TELEPHOTO = 3 | Telephoto camera. |
| CAMERA_TYPE_TRUE_DEPTH = 4 | Camera with depth of field information. |
Camera_Connection
enum Camera_Connection
Description
Enumerates the camera connection types.
Since: 11
| Enum Item | Description |
|---|---|
| CAMERA_CONNECTION_BUILT_IN = 0 | Built-in camera. |
| CAMERA_CONNECTION_USB_PLUGIN = 1 | Camera connected using USB. |
| CAMERA_CONNECTION_REMOTE = 2 | Remote camera. |
Camera_Format
enum Camera_Format
Description
Enumerates the camera output formats.
Since: 11
| Enum Item | Description |
|---|---|
| CAMERA_FORMAT_RGBA_8888 = 3 | RGBA 8888. |
| CAMERA_FORMAT_YUV_420_SP = 1003 | YUV 420 SP. |
| CAMERA_FORMAT_JPEG = 2000 | JPEG. |
| CAMERA_FORMAT_YCBCR_P010 = 2001 | YCBCR P010. Since: 12 |
| CAMERA_FORMAT_YCRCB_P010 = 2002 | YCRCB P010. Since: 12 |
| CAMERA_FORMAT_HEIC = 2003 | HEIC. Since: 23 |
Camera_FlashMode
enum Camera_FlashMode
Description
Enumerates the flash modes.
Since: 11
| Enum Item | Description |
|---|---|
| FLASH_MODE_CLOSE = 0 | The flash is off. |
| FLASH_MODE_OPEN = 1 | The flash is on. |
| FLASH_MODE_AUTO = 2 | The flash is auto. |
| FLASH_MODE_ALWAYS_OPEN = 3 | The flash is steady on. |
Camera_ExposureMode
enum Camera_ExposureMode
Description
Enumerates the exposure modes.
Since: 11
| Enum Item | Description |
|---|---|
| EXPOSURE_MODE_UNSPECIFIED = -1 | Unspecified exposure. Since: 24 |
| EXPOSURE_MODE_LOCKED = 0 | Exposure locked. The metering point cannot be set. After this mode is used, the exposure will be locked by default for each photo capture. |
| EXPOSURE_MODE_AUTO = 1 | Auto exposure. The metering point can be set by calling OH_CaptureSession_SetMeteringPoint. After this mode is used, it takes effect only for the first photo capture. |
| EXPOSURE_MODE_CONTINUOUS_AUTO = 2 | Continuous auto exposure. After this mode is used, the camera system automatically adjusts the exposure based on the environment changes each time. |
Camera_FocusMode
enum Camera_FocusMode
Description
Enumerates the focus modes.
Since: 11
| Enum Item | Description |
|---|---|
| FOCUS_MODE_MANUAL = 0 | Manual focus. |
| FOCUS_MODE_CONTINUOUS_AUTO = 1 | Continuous auto focus. |
| FOCUS_MODE_AUTO = 2 | Auto focus. |
| FOCUS_MODE_LOCKED = 3 | Focus locked. |
Camera_FocusState
enum Camera_FocusState
Description
Enumerates the focus states.
Since: 11
| Enum Item | Description |
|---|---|
| FOCUS_STATE_SCAN = 0 | Focusing. |
| FOCUS_STATE_FOCUSED = 1 | Focused. |
| FOCUS_STATE_UNFOCUSED = 2 | Unfocused. |
Camera_VideoStabilizationMode
enum Camera_VideoStabilizationMode
Description
Enumerates the video stabilization modes.
Since: 11
| Enum Item | Description |
|---|---|
| STABILIZATION_MODE_OFF = 0 | Video stabilization is disabled. |
| STABILIZATION_MODE_LOW = 1 | The basic video stabilization algorithm is used. |
| STABILIZATION_MODE_MIDDLE = 2 | A video stabilization algorithm with a stabilization effect better than that of the LOW type is used. |
| STABILIZATION_MODE_HIGH = 3 | A video stabilization algorithm with a stabilization effect better than that of the MIDDLE type is used. |
| STABILIZATION_MODE_AUTO = 4 | Automatic video stabilization is used. This value is available for HDF cameras. |
Camera_ImageRotation
enum Camera_ImageRotation
Description
Enumerates the image rotation angles.
Since: 11
| Enum Item | Description |
|---|---|
| IAMGE_ROTATION_0 = 0 | The image rotates 0 degrees. Since API version 23, you are advised to use the new enum value CAMERA_IMAGE_ROTATION_0 instead. |
| CAMERA_IMAGE_ROTATION_0 = 0 | The image rotates 0 degrees. Since: 23 |
| IAMGE_ROTATION_90 = 90 | The image rotates 90 degrees. Since API version 23, you are advised to use the new enum value CAMERA_IMAGE_ROTATION_90 instead. |
| CAMERA_IMAGE_ROTATION_90 = 90 | The image rotates 90 degrees. Since: 23 |
| IAMGE_ROTATION_180 = 180 | The image rotates 180 degrees. Since API version 23, you are advised to use the new enum value CAMERA_IMAGE_ROTATION_180 instead. |
| CAMERA_IMAGE_ROTATION_180 = 180 | The image rotates 180 degrees. Since: 23 |
| IAMGE_ROTATION_270 = 270 | The image rotates 270 degrees. Since API version 23, you are advised to use the new enum value CAMERA_IMAGE_ROTATION_270 instead. |
| CAMERA_IMAGE_ROTATION_270 = 270 | The image rotates 270 degrees. Since: 23 |
Camera_QualityLevel
enum Camera_QualityLevel
Description
Enumerates the image quality levels.
Since: 11
| Enum Item | Description |
|---|---|
| QUALITY_LEVEL_HIGH = 0 | High image quality. |
| QUALITY_LEVEL_MEDIUM = 1 | Medium image quality. |
| QUALITY_LEVEL_LOW = 2 | Low image quality. |
Camera_MetadataObjectType
enum Camera_MetadataObjectType
Description
Enumerates the metadata object types.
Since: 11
| Enum Item | Description |
|---|---|
| FACE_DETECTION = 0 | Metadata object used for face detection. Since API version 23, you are advised to use the new enum value CAMERA_METADATA_OBJECT_TYPE_FACE_DETECTION instead. |
| CAMERA_METADATA_OBJECT_TYPE_FACE_DETECTION = 0 | Metadata object used for face detection. Since: 23 |
| CAMERA_METADATA_OBJECT_TYPE_HUMAN_BODY = 1 | Metadata object used for body detection. Since: 23 |
Camera_TorchMode
enum Camera_TorchMode
Description
Enumerates the flashlight modes.
Since: 12
| Enum Item | Description |
|---|---|
| OFF = 0 | The flashlight is always off. Since API version 23, you are advised to use the new enum value CAMERA_TORCH_MODE_OFF instead. |
| CAMERA_TORCH_MODE_OFF = 0 | The flashlight is always off. Since: 23 |
| ON = 1 | The flashlight is always on. Since API version 23, you are advised to use the new enum value CAMERA_TORCH_MODE_ON instead. |
| CAMERA_TORCH_MODE_ON = 1 | The flashlight is always on. Since: 23 |
| AUTO = 2 | The flashlight will be turned on automatically based on the ambient lighting level. Since API version 23, you are advised to use the new enum value CAMERA_TORCH_MODE_AUTO instead. |
| CAMERA_TORCH_MODE_AUTO = 2 | The flashlight will be turned on automatically based on the ambient lighting level. Since: 23 |
Camera_SmoothZoomMode
enum Camera_SmoothZoomMode
Description
Enumerates the smooth zoom modes.
Since: 12
| Enum Item | Description |
|---|---|
| NORMAL = 0 | Bessel curve mode. Since API version 23, you are advised to use the new enum value CAMERA_SMOOTH_ZOOM_MODE_NORMAL instead. |
| CAMERA_SMOOTH_ZOOM_MODE_NORMAL = 0 | Bessel curve mode. Since: 23 |
Camera_SystemPressureLevel
enum Camera_SystemPressureLevel
Description
Enumerates the system pressure levels.
Since: 20
| Enum Item | Description |
|---|---|
| SYSTEM_PRESSURE_NORMAL = 0 | The system pressure is normal. |
| SYSTEM_PRESSURE_MILD = 1 | The system pressure is elevated but not actively managed by the system. |
| SYSTEM_PRESSURE_SEVERE = 2 | The system pressure may affect the overall image quality and performance. |
| SYSTEM_PRESSURE_CRITICAL = 3 | The system pressure has a significant impact on the image quality and performance. |
| SYSTEM_PRESSURE_SHUTDOWN = 4 | The system pressure is too high, causing the system to shut down. |
Camera_PreconfigType
enum Camera_PreconfigType
Description
Enumerates the preconfigured photo resolution types.
Since: 12
| Enum Item | Description |
|---|---|
| PRECONFIG_720P = 0 | 720p resolution. |
| PRECONFIG_1080P = 1 | 1080p resolution. |
| PRECONFIG_4K = 2 | 4K resolution. |
| PRECONFIG_HIGH_QUALITY = 3 | High-quality photos. |
| PRECONFIG_HIGH_QUALITY_PHOTOSESSION_BT2020 = 4 | Resolution that supports HDR preview and GIF photography. Since: 23 |
Camera_PreconfigRatio
enum Camera_PreconfigRatio
Description
Enumerates the preconfigured photo aspect ratios.
Since: 12
| Enum Item | Description |
|---|---|
| PRECONFIG_RATIO_1_1 = 0 | 1:1 aspect ratio. |
| PRECONFIG_RATIO_4_3 = 1 | 4:3 aspect ratio. |
| PRECONFIG_RATIO_16_9 = 2 | 16:9 aspect ratio. |
Camera_HostDeviceType
enum Camera_HostDeviceType
Description
Enumerates the remote device types.
Since: 15
| Enum Item | Description |
|---|---|
| HOST_DEVICE_TYPE_UNKNOWN_TYPE = 0 | Unknown type. |
| HOST_DEVICE_TYPE_PHONE = 0x0E | Mobile phone. |
| HOST_DEVICE_TYPE_TABLET = 0x11 | Tablet. |
Camera_FoldStatus
enum Camera_FoldStatus
Description
Enumerates the fold statuses.
Since: 13
| Enum Item | Description |
|---|---|
| NON_FOLDABLE = 0 | Unfoldable. Since API version 23, you are advised to use the new enum value CAMERA_FOLD_STATUS_NON_FOLDABLE instead. |
| CAMERA_FOLD_STATUS_NON_FOLDABLE = 0 | Unfoldable. Since: 23 |
| EXPANDED = 1 | Unfolded. Since API version 23, you are advised to use the new enum value CAMERA_FOLD_STATUS_EXPANDED instead. |
| CAMERA_FOLD_STATUS_EXPANDED = 1 | Unfolded. Since: 23 |
| FOLDED = 2 | Folded. Since API version 23, you are advised to use the new enum value CAMERA_FOLD_STATUS_FOLDED instead. |
| CAMERA_FOLD_STATUS_FOLDED = 2 | Folded. Since: 23 |
Camera_QualityPrioritization
enum Camera_QualityPrioritization
Description
Enumerates the priority levels for video recording quality.
Since: 14
| Enum Item | Description |
|---|---|
| HIGH_QUALITY = 0 | Prioritizes high-quality video recording. |
| POWER_BALANCE = 1 | Prioritizes video recording quality while balancing power consumption. |
Camera_ConcurrentType
enum Camera_ConcurrentType
Description
Enumerates the camera's concurrency types.
Since: 18
| Enum Item | Description |
|---|---|
| CAMERA_CONCURRENT_TYPE_LIMITED_CAPABILITY = 0 | Limited camera concurrency. |
| CAMERA_CONCURRENT_TYPE_FULL_CAPABILITY = 1 | Full camera concurrency. |
Camera_WhiteBalanceMode
enum Camera_WhiteBalanceMode
Description
Enumerates the white balance modes.
Since: 20
| Enum Item | Description |
|---|---|
| CAMERA_WHITE_BALANCE_MODE_AUTO = 0 | Automatic. |
| CAMERA_WHITE_BALANCE_MODE_CLOUDY = 1 | Cloudy. |
| CAMERA_WHITE_BALANCE_MODE_INCANDESCENT = 2 | Incandescent light. |
| CAMERA_WHITE_BALANCE_MODE_FLUORESCENT = 3 | Fluorescence light. |
| CAMERA_WHITE_BALANCE_MODE_DAYLIGHT = 4 | Daylight. |
| CAMERA_WHITE_BALANCE_MODE_MANUAL = 5 | Manual. |
| CAMERA_WHITE_BALANCE_MODE_LOCKED = 6 | Locked. |
Camera_ControlCenterEffectType
enum Camera_ControlCenterEffectType
Description
Enumerates the effect types of a camera controller.
Since: 20
| Enum Item | Description |
|---|---|
| CONTROL_CENTER_EFFECT_TYPE_BEAUTY = 0 | Beauty effect. |
| CONTROL_CENTER_EFFECT_TYPE_PORTRAIT = 1 | Portrait blur effect. |
Camera_PhotoQualityPrioritization
enum Camera_PhotoQualityPrioritization
Description
Enumerates the photo quality prioritization strategies.
Since: 21
| Enum Item | Description |
|---|---|
| CAMERA_PHOTO_QUALITY_PRIORITIZATION_HIGH_QUALITY = 0 | Focuses on image quality, which may increase the time required for capturing photos to ensure high-quality output. |
| CAMERA_PHOTO_QUALITY_PRIORITIZATION_SPEED = 1 | Focuses on performance, trading off image quality for faster capture times. |
Function Description
OH_Camera_GetCameraManager()
Camera_ErrorCode OH_Camera_GetCameraManager(Camera_Manager** cameraManager)
Description
Obtains a Camera_Manager instance.
Since: 11
Parameters
| Name | Description |
|---|---|
| Camera_Manager** cameraManager | Double pointer to the Camera_Manager instance created, if the function is successfully called. |
Returns
| Type | Description |
|---|---|
| Camera_ErrorCode | CAMERA_OK: The operation is successful. CAMERA_INVALID_ARGUMENT: A parameter is missing or the parameter type is incorrect. CAMERA_SERVICE_FATAL_ERROR: The camera service is abnormal. |
OH_Camera_DeleteCameraManager()
Camera_ErrorCode OH_Camera_DeleteCameraManager(Camera_Manager* cameraManager)
Description
Deletes a Camera_Manager instance.
Since: 11
Parameters
| Name | Description |
|---|---|
| Camera_Manager* cameraManager | Pointer to the target Camera_Manager instance. |
Returns
| Type | Description |
|---|---|
| Camera_ErrorCode | CAMERA_OK: The operation is successful. CAMERA_INVALID_ARGUMENT: A parameter is missing or the parameter type is incorrect. CAMERA_SERVICE_FATAL_ERROR: The camera service is abnormal. |