openharmony 鸿蒙 capi-camera-h

2026-08-25 浏览 (1)

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

Nametypedef KeywordDescription
Camera_DeviceQueryInfoCamera_DeviceQueryInfoDescribes the camera device query information.
Camera_SizeCamera_SizeDescribes the parameters related to the size.
Camera_ProfileCamera_ProfileDescribes the profile of a camera stream.
Camera_FrameRateRangeCamera_FrameRateRangeDescribes the frame rate range.
Camera_VideoProfileCamera_VideoProfileDescribes the video profile.
Camera_OutputCapabilityCamera_OutputCapabilityDescribes the camera output capability.
Camera_DeviceCamera_DeviceDescribes the camera device.
Camera_StatusInfoCamera_StatusInfoDescribes the camera status information.
Camera_PointCamera_PointDescribes the parameters related to a point.
Camera_LocationCamera_LocationDescribes the location where the photo is taken.
Camera_PhotoCaptureSettingCamera_PhotoCaptureSettingDescribes the parameters related to photo capture.
Camera_FrameShutterInfoCamera_FrameShutterInfoDescribes the frame shutter information.
Camera_CaptureEndInfoCamera_CaptureEndInfoDescribes the capture end information.
Camera_RectCamera_RectDefines 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_MetadataObjectCamera_MetadataObjectDescribes the camera metadata.
Camera_TorchStatusInfoCamera_TorchStatusInfoDescribes the flashlight status information.
Camera_SmoothZoomInfoCamera_SmoothZoomInfoDescribes the smooth zoom information.
Camera_CaptureStartInfoCamera_CaptureStartInfoDescribes the capture start information.
Camera_FrameShutterEndInfoCamera_FrameShutterEndInfoDescribes the frame shutter end information during capture.
Camera_FoldStatusInfoCamera_FoldStatusInfoDescribes the fold status information of the camera.
Camera_AutoDeviceSwitchStatusInfoCamera_AutoDeviceSwitchStatusInfoDescribes the automatic device switching status information.
Camera_ConcurrentInfoCamera_ConcurrentInfoDescribes the camera's concurrency information.
Camera_ControlCenterStatusInfoCamera_ControlCenterStatusInfoDescribes the effect status information of a camera controller.
Camera_OcclusionDetectionResultCamera_OcclusionDetectionResultDescribes the check result for whether a camera lens is blocked or dirty.
Camera_ManagerCamera_ManagerDescribes the camera manager.
You can call OH_Camera_GetCameraManager to create such an object.

Enums

Nametypedef KeywordDescription
Camera_ErrorCodeCamera_ErrorCodeEnumerates the camera error codes.
Camera_StatusCamera_StatusEnumerates the camera statuses.
Camera_SceneModeCamera_SceneModeEnumerates the camera scene modes.
Camera_PositionCamera_PositionEnumerates the camera positions.
Camera_TypeCamera_TypeEnumerates the camera types.
Camera_ConnectionCamera_ConnectionEnumerates the camera connection types.
Camera_FormatCamera_FormatEnumerates the camera output formats.
Camera_FlashModeCamera_FlashModeEnumerates the flash modes.
Camera_ExposureModeCamera_ExposureModeEnumerates the exposure modes.
Camera_FocusModeCamera_FocusModeEnumerates the focus modes.
Camera_FocusStateCamera_FocusStateEnumerates the focus states.
Camera_VideoStabilizationModeCamera_VideoStabilizationModeEnumerates the video stabilization modes.
Camera_ImageRotationCamera_ImageRotationEnumerates the image rotation angles.
Camera_QualityLevelCamera_QualityLevelEnumerates the image quality levels.
Camera_MetadataObjectTypeCamera_MetadataObjectTypeEnumerates the metadata object types.
Camera_TorchModeCamera_TorchModeEnumerates the flashlight modes.
Camera_SmoothZoomModeCamera_SmoothZoomModeEnumerates the smooth zoom modes.
Camera_SystemPressureLevelCamera_SystemPressureLevelEnumerates the system pressure levels.
Camera_PreconfigTypeCamera_PreconfigTypeEnumerates the preconfigured photo resolution types.
Camera_PreconfigRatioCamera_PreconfigRatioEnumerates the preconfigured photo aspect ratios.
Camera_HostDeviceTypeCamera_HostDeviceTypeEnumerates the remote device types.
Camera_FoldStatusCamera_FoldStatusEnumerates the fold statuses.
Camera_QualityPrioritizationCamera_QualityPrioritizationEnumerates the priority levels for video recording quality.
Camera_ConcurrentTypeCamera_ConcurrentTypeEnumerates the camera's concurrency types.
Camera_WhiteBalanceModeCamera_WhiteBalanceModeEnumerates the white balance modes.
Camera_ControlCenterEffectTypeCamera_ControlCenterEffectTypeEnumerates the effect types of a camera controller.
Camera_PhotoQualityPrioritizationCamera_PhotoQualityPrioritizationEnumerates the photo quality prioritization strategies.

Functions

NameDescription
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 ItemDescription
CAMERA_OK = 0The camera is normal.
CAMERA_INVALID_ARGUMENT = 7400101A parameter is missing or the parameter type is incorrect.
CAMERA_OPERATION_NOT_ALLOWED = 7400102The operation is not allowed.
CAMERA_SESSION_NOT_CONFIG = 7400103The session is not configured.
CAMERA_SESSION_NOT_RUNNING = 7400104The session is not running.
CAMERA_SESSION_CONFIG_LOCKED = 7400105The session configuration is locked.
CAMERA_DEVICE_SETTING_LOCKED = 7400106The device setting is locked.
CAMERA_CONFLICT_CAMERA = 7400107The device is already started.
CAMERA_DEVICE_DISABLED = 7400108The camera is disabled for security reasons.
CAMERA_DEVICE_PREEMPTED = 7400109The camera is preempted.
CAMERA_UNRESOLVED_CONFLICTS_WITH_CURRENT_CONFIGURATIONS = 7400110The configuration conflicts with the current configuration.
Since: 12
CAMERA_SERVICE_FATAL_ERROR = 7400201The 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 ItemDescription
CAMERA_STATUS_APPEAR = 0A camera appears.
CAMERA_STATUS_DISAPPEAR = 1The camera disappears.
CAMERA_STATUS_AVAILABLE = 2The camera is available.
CAMERA_STATUS_UNAVAILABLE = 3The camera is unavailable.

Camera_SceneMode

enum Camera_SceneMode

Description

Enumerates the camera scene modes.

Since: 12

Enum ItemDescription
NORMAL_PHOTO = 1Normal photo mode.
NORMAL_VIDEO = 2Normal video mode.
SECURE_PHOTO = 12Secure 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 ItemDescription
CAMERA_POSITION_UNSPECIFIED = 0A camera that does not have a fixed orientation relative to the device screen.
CAMERA_POSITION_BACK = 1Rear camera.
CAMERA_POSITION_FRONT = 2Front camera.

Camera_Type

enum Camera_Type

Description

Enumerates the camera types.

Since: 11

Enum ItemDescription
CAMERA_TYPE_DEFAULT = 0Default camera type.
CAMERA_TYPE_WIDE_ANGLE = 1Wide camera.
CAMERA_TYPE_ULTRA_WIDE = 2Ultra-wide camera.
CAMERA_TYPE_TELEPHOTO = 3Telephoto camera.
CAMERA_TYPE_TRUE_DEPTH = 4Camera with depth of field information.

Camera_Connection

enum Camera_Connection

Description

Enumerates the camera connection types.

Since: 11

Enum ItemDescription
CAMERA_CONNECTION_BUILT_IN = 0Built-in camera.
CAMERA_CONNECTION_USB_PLUGIN = 1Camera connected using USB.
CAMERA_CONNECTION_REMOTE = 2Remote camera.

Camera_Format

enum Camera_Format

Description

Enumerates the camera output formats.

Since: 11

Enum ItemDescription
CAMERA_FORMAT_RGBA_8888 = 3RGBA 8888.
CAMERA_FORMAT_YUV_420_SP = 1003YUV 420 SP.
CAMERA_FORMAT_JPEG = 2000JPEG.
CAMERA_FORMAT_YCBCR_P010 = 2001YCBCR P010.
Since: 12
CAMERA_FORMAT_YCRCB_P010 = 2002YCRCB P010.
Since: 12
CAMERA_FORMAT_HEIC = 2003HEIC.
Since: 23

Camera_FlashMode

enum Camera_FlashMode

Description

Enumerates the flash modes.

Since: 11

Enum ItemDescription
FLASH_MODE_CLOSE = 0The flash is off.
FLASH_MODE_OPEN = 1The flash is on.
FLASH_MODE_AUTO = 2The flash is auto.
FLASH_MODE_ALWAYS_OPEN = 3The flash is steady on.

Camera_ExposureMode

enum Camera_ExposureMode

Description

Enumerates the exposure modes.

Since: 11

Enum ItemDescription
EXPOSURE_MODE_UNSPECIFIED = -1Unspecified exposure.
Since: 24
EXPOSURE_MODE_LOCKED = 0Exposure 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 = 1Auto 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 = 2Continuous 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 ItemDescription
FOCUS_MODE_MANUAL = 0Manual focus.
FOCUS_MODE_CONTINUOUS_AUTO = 1Continuous auto focus.
FOCUS_MODE_AUTO = 2Auto focus.
FOCUS_MODE_LOCKED = 3Focus locked.

Camera_FocusState

enum Camera_FocusState

Description

Enumerates the focus states.

Since: 11

Enum ItemDescription
FOCUS_STATE_SCAN = 0Focusing.
FOCUS_STATE_FOCUSED = 1Focused.
FOCUS_STATE_UNFOCUSED = 2Unfocused.

Camera_VideoStabilizationMode

enum Camera_VideoStabilizationMode

Description

Enumerates the video stabilization modes.

Since: 11

Enum ItemDescription
STABILIZATION_MODE_OFF = 0Video stabilization is disabled.
STABILIZATION_MODE_LOW = 1The basic video stabilization algorithm is used.
STABILIZATION_MODE_MIDDLE = 2A video stabilization algorithm with a stabilization effect better than that of the LOW type is used.
STABILIZATION_MODE_HIGH = 3A video stabilization algorithm with a stabilization effect better than that of the MIDDLE type is used.
STABILIZATION_MODE_AUTO = 4Automatic 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 ItemDescription
IAMGE_ROTATION_0 = 0The 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 = 0The image rotates 0 degrees.
Since: 23
IAMGE_ROTATION_90 = 90The 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 = 90The image rotates 90 degrees.
Since: 23
IAMGE_ROTATION_180 = 180The 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 = 180The image rotates 180 degrees.
Since: 23
IAMGE_ROTATION_270 = 270The 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 = 270The image rotates 270 degrees.
Since: 23

Camera_QualityLevel

enum Camera_QualityLevel

Description

Enumerates the image quality levels.

Since: 11

Enum ItemDescription
QUALITY_LEVEL_HIGH = 0High image quality.
QUALITY_LEVEL_MEDIUM = 1Medium image quality.
QUALITY_LEVEL_LOW = 2Low image quality.

Camera_MetadataObjectType

enum Camera_MetadataObjectType

Description

Enumerates the metadata object types.

Since: 11

Enum ItemDescription
FACE_DETECTION = 0Metadata 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 = 0Metadata object used for face detection.
Since: 23
CAMERA_METADATA_OBJECT_TYPE_HUMAN_BODY = 1Metadata object used for body detection.
Since: 23

Camera_TorchMode

enum Camera_TorchMode

Description

Enumerates the flashlight modes.

Since: 12

Enum ItemDescription
OFF = 0The 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 = 0The flashlight is always off.
Since: 23
ON = 1The 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 = 1The flashlight is always on.
Since: 23
AUTO = 2The 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 = 2The 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 ItemDescription
NORMAL = 0Bessel 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 = 0Bessel curve mode.
Since: 23

Camera_SystemPressureLevel

enum Camera_SystemPressureLevel

Description

Enumerates the system pressure levels.

Since: 20

Enum ItemDescription
SYSTEM_PRESSURE_NORMAL = 0The system pressure is normal.
SYSTEM_PRESSURE_MILD = 1The system pressure is elevated but not actively managed by the system.
SYSTEM_PRESSURE_SEVERE = 2The system pressure may affect the overall image quality and performance.
SYSTEM_PRESSURE_CRITICAL = 3The system pressure has a significant impact on the image quality and performance.
SYSTEM_PRESSURE_SHUTDOWN = 4The 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 ItemDescription
PRECONFIG_720P = 0720p resolution.
PRECONFIG_1080P = 11080p resolution.
PRECONFIG_4K = 24K resolution.
PRECONFIG_HIGH_QUALITY = 3High-quality photos.
PRECONFIG_HIGH_QUALITY_PHOTOSESSION_BT2020 = 4Resolution that supports HDR preview and GIF photography.
Since: 23

Camera_PreconfigRatio

enum Camera_PreconfigRatio

Description

Enumerates the preconfigured photo aspect ratios.

Since: 12

Enum ItemDescription
PRECONFIG_RATIO_1_1 = 01:1 aspect ratio.
PRECONFIG_RATIO_4_3 = 14:3 aspect ratio.
PRECONFIG_RATIO_16_9 = 216:9 aspect ratio.

Camera_HostDeviceType

enum Camera_HostDeviceType

Description

Enumerates the remote device types.

Since: 15

Enum ItemDescription
HOST_DEVICE_TYPE_UNKNOWN_TYPE = 0Unknown type.
HOST_DEVICE_TYPE_PHONE = 0x0EMobile phone.
HOST_DEVICE_TYPE_TABLET = 0x11Tablet.

Camera_FoldStatus

enum Camera_FoldStatus

Description

Enumerates the fold statuses.

Since: 13

Enum ItemDescription
NON_FOLDABLE = 0Unfoldable.
Since API version 23, you are advised to use the new enum value CAMERA_FOLD_STATUS_NON_FOLDABLE instead.
CAMERA_FOLD_STATUS_NON_FOLDABLE = 0Unfoldable.
Since: 23
EXPANDED = 1Unfolded.
Since API version 23, you are advised to use the new enum value CAMERA_FOLD_STATUS_EXPANDED instead.
CAMERA_FOLD_STATUS_EXPANDED = 1Unfolded.
Since: 23
FOLDED = 2Folded.
Since API version 23, you are advised to use the new enum value CAMERA_FOLD_STATUS_FOLDED instead.
CAMERA_FOLD_STATUS_FOLDED = 2Folded.
Since: 23

Camera_QualityPrioritization

enum Camera_QualityPrioritization

Description

Enumerates the priority levels for video recording quality.

Since: 14

Enum ItemDescription
HIGH_QUALITY = 0Prioritizes high-quality video recording.
POWER_BALANCE = 1Prioritizes video recording quality while balancing power consumption.

Camera_ConcurrentType

enum Camera_ConcurrentType

Description

Enumerates the camera's concurrency types.

Since: 18

Enum ItemDescription
CAMERA_CONCURRENT_TYPE_LIMITED_CAPABILITY = 0Limited camera concurrency.
CAMERA_CONCURRENT_TYPE_FULL_CAPABILITY = 1Full camera concurrency.

Camera_WhiteBalanceMode

enum Camera_WhiteBalanceMode

Description

Enumerates the white balance modes.

Since: 20

Enum ItemDescription
CAMERA_WHITE_BALANCE_MODE_AUTO = 0Automatic.
CAMERA_WHITE_BALANCE_MODE_CLOUDY = 1Cloudy.
CAMERA_WHITE_BALANCE_MODE_INCANDESCENT = 2Incandescent light.
CAMERA_WHITE_BALANCE_MODE_FLUORESCENT = 3Fluorescence light.
CAMERA_WHITE_BALANCE_MODE_DAYLIGHT = 4Daylight.
CAMERA_WHITE_BALANCE_MODE_MANUAL = 5Manual.
CAMERA_WHITE_BALANCE_MODE_LOCKED = 6Locked.

Camera_ControlCenterEffectType

enum Camera_ControlCenterEffectType

Description

Enumerates the effect types of a camera controller.

Since: 20

Enum ItemDescription
CONTROL_CENTER_EFFECT_TYPE_BEAUTY = 0Beauty effect.
CONTROL_CENTER_EFFECT_TYPE_PORTRAIT = 1Portrait blur effect.

Camera_PhotoQualityPrioritization

enum Camera_PhotoQualityPrioritization

Description

Enumerates the photo quality prioritization strategies.

Since: 21

Enum ItemDescription
CAMERA_PHOTO_QUALITY_PRIORITIZATION_HIGH_QUALITY = 0Focuses on image quality, which may increase the time required for capturing photos to ensure high-quality output.
CAMERA_PHOTO_QUALITY_PRIORITIZATION_SPEED = 1Focuses 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

NameDescription
Camera_Manager** cameraManagerDouble pointer to the Camera_Manager instance created, if the function is successfully called.

Returns

TypeDescription
Camera_ErrorCodeCAMERA_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

NameDescription
Camera_Manager* cameraManagerPointer to the target Camera_Manager instance.

Returns

TypeDescription
Camera_ErrorCodeCAMERA_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.

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 capi-oh-camera-capturesession-callbacks

openharmony 鸿蒙 arkts-apis-camera-OIS

openharmony 鸿蒙 capi-oh-camera-camera-devicequeryinfo

openharmony 鸿蒙 capi-oh-camera-camera-frameraterange

openharmony 鸿蒙 capi-oh-camera-camera-outputcapability

openharmony 鸿蒙 arkts-apis-camera-Photo

openharmony 鸿蒙 capi-oh-camera-camera-profile

openharmony 鸿蒙 capi-oh-camera-camera-manager

openharmony 鸿蒙 capi-oh-camera-previewoutput-callbacks

openharmony 鸿蒙 arkts-apis-camera-ManualExposureQuery

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/qwf4Vz2m