Skip to main content
Version: 14 Oct 2024

Camera

APIs for accessing Camera Device and to do Camera Capture. More...

Classes

Name
structMLCameraMRConnectInfo
structMLCameraConnectContext
structMLCameraCaptureStreamCaps
A structure to encapsulate stream capabilities.
structMLCameraCaptureStreamConfig
structMLCameraCaptureConfig
structMLCameraPlaneInfo
structMLCameraOutput
structMLCameraIntrinsicCalibrationParameters
Camera intrinsic parameter.
structMLCameraResultExtras
structMLCameraDeviceAvailabilityInfo
structMLCameraDeviceAvailabilityStatusCallbacks
structMLCameraDeviceStatusCallbacks
structMLCameraCaptureCallbacks
Capture callbacks to be implemented by client to receive capture status if callback mechanism is used.

Types

Name
typedef MLHandleMLCameraContext
typedef struct MLCameraMRConnectInfoMLCameraMRConnectInfo
typedef struct MLCameraConnectContextMLCameraConnectContext
typedef struct MLCameraCaptureStreamCapsMLCameraCaptureStreamCaps
A structure to encapsulate stream capabilities.
typedef struct MLCameraCaptureStreamConfigMLCameraCaptureStreamConfig
typedef struct MLCameraCaptureConfigMLCameraCaptureConfig
typedef struct MLCameraPlaneInfoMLCameraPlaneInfo
typedef struct MLCameraOutputMLCameraOutput
typedef struct MLCameraIntrinsicCalibrationParametersMLCameraIntrinsicCalibrationParameters
Camera intrinsic parameter.
typedef struct MLCameraResultExtrasMLCameraResultExtras
typedef struct MLCameraDeviceAvailabilityInfoMLCameraDeviceAvailabilityInfo
typedef struct MLCameraDeviceAvailabilityStatusCallbacksMLCameraDeviceAvailabilityStatusCallbacks
typedef struct MLCameraDeviceStatusCallbacksMLCameraDeviceStatusCallbacks
typedef struct MLCameraCaptureCallbacksMLCameraCaptureCallbacks
Capture callbacks to be implemented by client to receive capture status if callback mechanism is used.

Enums

Name
enumAnonymous Enum 4
{
MLCAMERA_MAXSTREAMS = 2
}
enumMLCameraIdentifier
{
MLCameraIdentifier_MAIN = 0,
MLCameraIdentifier_CV,
MLCameraIdentifier_Ensure32Bits = 0x7FFFFFFF
}
enumMLCameraCaptureType
{
MLCameraCaptureType_Image = 0,
MLCameraCaptureType_Video,
MLCameraCaptureType_Preview,
MLCameraCaptureType_Ensure32Bits = 0x7FFFFFFF
}
Captures operation type.
enumMLCameraCaptureFrameRate
{
MLCameraCaptureFrameRate_None = 0,
MLCameraCaptureFrameRate_15FPS,
MLCameraCaptureFrameRate_30FPS,
MLCameraCaptureFrameRate_60FPS,
MLCameraCaptureFrameRate_Ensure32Bits = 0x7FFFFFFF
}
Captures frame rate.
enumMLCameraMRQuality
{
MLCameraMRQuality_648x720 = 1,
MLCameraMRQuality_972x1080 = 2,
MLCameraMRQuality_1944x2160 = 3,
MLCameraMRQuality_960x720 = 4,
MLCameraMRQuality_1440x1080 = 5,
MLCameraMRQuality_2880x2160 = 6,
MLCameraMRQuality_Ensure32Bits = 0x7FFFFFFF
}
Video Quality enumeration for mixed reality capture.
enumMLCameraConnectFlag
{
MLCameraConnectFlag_CamOnly = 0x0,
MLCameraConnectFlag_VirtualOnly = 0x1,
MLCameraConnectFlag_MR = 0x2,
MLCameraConnectFlag_Ensure32Bits = 0x7FFFFFFF
}
enumMLCameraMRBlendType
{
MLCameraMRBlendType_Additive = 1,
MLCameraMRBlendType_Ensure32Bits = 0x7FFFFFFF
}
enumMLCameraDisconnectReason
{
MLCameraDisconnect_DeviceLost = 0,
MLCameraDisconnect_PriorityLost,
MLCameraDisconnect_Ensure32Bits = 0x7FFFFFFF
}
enumMLCameraError
{
MLCameraError_None = 0,
MLCameraError_Invalid,
MLCameraError_Disabled,
MLCameraError_DeviceFailed,
MLCameraError_ServiceFailed,
MLCameraError_CaptureFailed,
MLCameraError_Ensure32Bits = 0x7FFFFFFF
}
enumMLCameraOutputFormat
{
MLCameraOutputFormat_Unknown,
MLCameraOutputFormat_YUV_420_888,
MLCameraOutputFormat_JPEG,
MLCameraOutputFormat_RGBA_8888,
MLCameraOutputFormat_Ensure32Bits = 0x7FFFFFFF
}
Captured output format. These three parameters determine which formats are supported:
enumMLCameraDeviceStatusFlag
{
MLCameraDeviceStatusFlag_Connected = 1 << 0,
MLCameraDeviceStatusFlag_Idle = 1 << 1,
MLCameraDeviceStatusFlag_Streaming = 1 << 2,
MLCameraDeviceStatusFlag_Disconnected = 1 << 3,
MLCameraDeviceStatusFlag_Error = 1 << 4,
MLCameraDeviceStatusFlag_Ensure32Bits = 0x7FFFFFFF
}
enumAnonymous Enum 5
{
MLCamera_MaxImagePlanes = 3
}
enumAnonymous Enum 6
{
MLCameraIntrinsics_MaxDistortionCoefficients = 5
}
Camera distortion vector size.

Functions

Name
voidMLCameraConnectContextInit(MLCameraConnectContext * inout_context)
Initialize the connect context structure.
voidMLCameraCaptureConfigInit(MLCameraCaptureConfig * inout_config)
Initialize the capture config structure.
voidMLCameraDeviceAvailabilityStatusCallbacksInit(MLCameraDeviceAvailabilityStatusCallbacks * inout_device_availability_status_callbacks)
Initialize the callback structure.
voidMLCameraDeviceStatusCallbacksInit(MLCameraDeviceStatusCallbacks * inout_device_status_callbacks)
Initialize the callback structure.
voidMLCameraCaptureCallbacksInit(MLCameraCaptureCallbacks * inout_capture_callbacks)
Initialize the callback structure.
MLResultMLCameraInit(const MLCameraDeviceAvailabilityStatusCallbacks device_availability_status_callbacks, void user_data)
Initialize ML Camera API, Register callback for device availability. If the user does not want to register device availability listener, MLCameraConnect can be called directly without MLCameraInit(). MLCameraDeInit should be used for unregistering callbacks and releasing resources acquired in MLCameraInit().
MLResultMLCameraConnect(const MLCameraConnectContext input_context, MLCameraContext out_context)
Connect to camera device.
MLResultMLCameraGetNumSupportedStreams(MLCameraContext context, uint32_t * out_num_supported_streams)
Query the no of streams supported by camera device.
MLResultMLCameraGetStreamCaps(MLCameraContext context, const uint32_t stream_index, uint32_t inout_num_stream_caps, MLCameraCaptureStreamCaps inout_stream_caps)
Query the stream capabilities.
MLResultMLCameraDisconnect(MLCameraContext context)
Disconnect from camera device.
MLResultMLCameraDeInit()
Uninitialize ML Camera API, unregister callback for device availability. Should be called after all camera devices are disconnected. After MLCameraDeInit, MLCameraInit can be called or MLCameraConnect can be called.
MLResultMLCameraPreCaptureAEAWB(MLCameraContext context)
Trigger AEAWB Convergence.
MLResultMLCameraPrepareCapture(MLCameraContext context, const MLCameraCaptureConfig config, MLHandle out_request_handle)
Prepare for capture.
MLResultMLCameraUpdateCaptureSettings(MLCameraContext context)
Update capture setting.
MLResultMLCameraSetDeviceStatusCallbacks(MLCameraContext context, const MLCameraDeviceStatusCallbacks device_status_callbacks, void data)
Set the client-implemented callbacks to convey camera device status.
MLResultMLCameraSetCaptureCallbacks(MLCameraContext context, const MLCameraCaptureCallbacks capture_callbacks, void data)
Set the client-implemented callbacks to convey capture status.
MLResultMLCameraCaptureImage(MLCameraContext context, uint32_t num_images)
Capture still image.
MLResultMLCameraCaptureVideoStart(MLCameraContext context)
Start video capture. Capture either encoded video or YUV/RGBA frames.
MLResultMLCameraCapturePreviewStart(MLCameraContext context)
Start preview provide raw frames through callback.
MLResultMLCameraCaptureVideoStop(MLCameraContext context)
Stop video capture.
MLResultMLCameraCapturePreviewStop(MLCameraContext context)
Stop preview.
MLResultMLCameraGetDeviceStatus(MLCameraContext context, uint32_t * out_device_status)
Poll camera device status.
MLResultMLCameraGetDeviceAvailabilityStatus(MLCameraIdentifier cam_id, bool * out_device_availability_status)
Poll camera device availability status.
MLResultMLCameraGetErrorCode(MLCameraContext context, MLCameraError * out_error_code)
Obtain camera device error code.
MLResultMLCameraGetCameraCharacteristics(MLCameraContext context, MLHandle * out_characteristics_handle)
Obtains handle for retrieving camera characteristics.

Detailed Description

APIs for accessing Camera Device and to do Camera Capture.

Supported Camera Modes, Resolutions, Capture Type, Formats and FrameRates

Camera Mode Resolution Capture Type Formats FrameRate
MainCam_Only640x480
1280x720
1280x960
1440x1080
1920x1080
2048x1536
PreviewYUV15/30/60
ImageYUV/JPEG15/30/60
VideoYUV/RGB/Compressed15/30/60

2880x2160
3840x2160
4096x3072

PreviewYUV15/30
ImageYUV/JPEG15/30
VideoYUV/RGB/Compressed15/30

Note:
15Fps only supported in Auto Exposure Mode.
When multiple streams are configured frame rate is constrained by max resolution.
FrameRate_None can be used when only Image capture_type is used.


Camera Mode Resolution Capture Type Formats FrameRate
CVCam_Only640x480
1280x720
1280x960
1440x1080
1920x1080
2048x1536
ImageYUV15/30/60
VideoYUV/RGB15/30/60

2880x2160
3840x2160
4096x3072

ImageYUV15/30
VideoYUV/RGB 15/30

Note:
15Fps only supported in Auto Exposure Mode
FrameRate_None can be used when only Image capture_type is used.


Camera Mode Resolution Capture Type Formats FrameRate
MainMR/Virtual_Only648x720 ImageRBG/JPEG30/60
VideoRGB/Compressed30/60
960x720 ImageRBG/JPEG30/60
VideoRGB/Compressed30/60
972x1080 ImageRBG/JPEG30/60
VideoRGB/Compressed30/60
1440x1080ImageRBG/JPEG30/60
VideoRGB/Compressed30/60
1944x2160ImageRBG/JPEG30
VideoRGB/Compressed30
2880x2160ImageRBG/JPEG30
VideoRGB/Compressed30

Note: Quality and frame rate provided during connection should match the resolution and framerate in PrepareCapture.

Stringify the error codes returned by these APIs, call MLMediaResultGetString.

Warning

THIS API IS DEPRECATED IN FAVOR OF STANDARD ANDROID SDK AND NDK CAMERA APIs: https://developer.android.com/training/camera2https://developer.android.com/ndk/reference/group/camera

Shared Object:

  • camera.magicleap*

Enums Documentation

Anonymous Enum 4

EnumeratorValueDescription
MLCAMERA_MAXSTREAMS2Max No of streams supported by logical camera.

MLCameraIdentifier

EnumeratorValueDescription
MLCameraIdentifier_MAIN0x86 logical camera.
MLCameraIdentifier_CVCV logical camera.
MLCameraIdentifier_Ensure32Bits0x7FFFFFFFEnsure enum is represented as 32 bits.

Logical camera identifiers available for access.


MLCameraCaptureType

EnumeratorValueDescription
MLCameraCaptureType_Image0To capture an image.
MLCameraCaptureType_VideoTo capture a video.
MLCameraCaptureType_PreviewTo capture a video and access the raw buffer of the frames.
MLCameraCaptureType_Ensure32Bits0x7FFFFFFFEnsure enum is represented as 32 bits.

Captures operation type.


MLCameraCaptureFrameRate

EnumeratorValueDescription
MLCameraCaptureFrameRate_None0None, used for still capture.
MLCameraCaptureFrameRate_15FPSSpecified 15FPS.
MLCameraCaptureFrameRate_30FPSSpecified 30FPS.
MLCameraCaptureFrameRate_60FPSSpecified 60FPS.
MLCameraCaptureFrameRate_Ensure32Bits0x7FFFFFFFEnsure enum is represented as 32 bits.

Captures frame rate.

Call MLCameraPrepareCapture() to configure frame rate. Use MLCameraCaptureFrameRate_None when configuring only Image capture. Use MLCameraCaptureFrameRate_60fps only when resolution of captures <= 3MP(2048x1536). Use MLCameraCaptureFrameRate_15FPS only when MLCameraConnectFlag is MLCameraConnectFlag_CamOnly.


MLCameraMRQuality

EnumeratorValueDescription
MLCameraMRQuality_648x7201Specifies 648 x 720 resolution. Aspect ratio: 9x10.
MLCameraMRQuality_972x10802Specifies 972 x 1080 resolution. Aspect ratio: 9x10.
MLCameraMRQuality_1944x21603Specifies 1944 x 2160 resolution. Aspect ratio: 9x10. MLCameraCaptureFrameRate_60FPS is not supported for this quality mode.
MLCameraMRQuality_960x7204Specifies 960 x 720 resolution. Aspect ratio: 4x3.
MLCameraMRQuality_1440x10805Specifies 1440 x 1080 resolution. Aspect ratio: 4x3.
MLCameraMRQuality_2880x21606Specifies 2880 x 2160 resolution. Aspect ratio: 4x3. MLCameraCaptureFrameRate_60FPS is not supported for this quality mode.
MLCameraMRQuality_Ensure32Bits0x7FFFFFFFEnsure enum is represented as 32 bits.

Video Quality enumeration for mixed reality capture.

Use MLCameraGetStreamCaps to get the resolution.


MLCameraConnectFlag

EnumeratorValueDescription
MLCameraConnectFlag_CamOnly0x0Camera only frame capture.
MLCameraConnectFlag_VirtualOnly0x1Virtual only capture. Only supported for MLCameraIdentifier_MAIN.
MLCameraConnectFlag_MR0x2Mixed Reality capture. Only supported for MLCameraIdentifier_MAIN.
MLCameraConnectFlag_Ensure32Bits0x7FFFFFFFEnsure enum is represented as 32 bits.

Flags to describe various modules in camera pipeline.


MLCameraMRBlendType

EnumeratorValueDescription
MLCameraMRBlendType_Additive1Additive blend type. It simply adds pixel values of real world and virtual layer.
MLCameraMRBlendType_Ensure32Bits0x7FFFFFFFEnsure enum is represented as 32 bits.

Virtual and real content blending modes.


MLCameraDisconnectReason

EnumeratorValueDescription
MLCameraDisconnect_DeviceLost0Device lost.
MLCameraDisconnect_PriorityLostPriority lost.
MLCameraDisconnect_Ensure32Bits0x7FFFFFFFEnsure enum is represented as 32 bits.

Camera disconnect reason.


MLCameraError

EnumeratorValueDescription
MLCameraError_None0
MLCameraError_InvalidInvalid/Unknown Error.
MLCameraError_DisabledCamera disabled.
MLCameraError_DeviceFailedCamera device failed.
MLCameraError_ServiceFailedCamera service failed.
MLCameraError_CaptureFailedCapture failed.
MLCameraError_Ensure32Bits0x7FFFFFFFEnsure enum is represented as 32 bits.

Camera errors.


MLCameraOutputFormat

EnumeratorValueDescription
MLCameraOutputFormat_Unknown
MLCameraOutputFormat_YUV_420_888YUV planar format.
MLCameraOutputFormat_JPEGCompressed output stream.
MLCameraOutputFormat_RGBA_8888RGB32 format.
MLCameraOutputFormat_Ensure32Bits0x7FFFFFFFEnsure enum is represented as 32 bits.

Captured output format. These three parameters determine which formats are supported:

  • Camera type: [Main, CV].
  • Mode: [Real, MR, Virtual].
  • Capture type: [Preview, Video, Image]. These are formats supported:
Format Camera Type Mode Capture Type
YUV Main
CV
Real
Real
Preview, Video, Image
Video, Image
RGBA Main
Main
CR
Real
MR, Virtual
Real
Video
Video, Image
Video
JPEG Main Real, MR, Virtual Image

MLCameraDeviceStatusFlag

EnumeratorValueDescription
MLCameraDeviceStatusFlag_Connected1 << 0Connected.
MLCameraDeviceStatusFlag_Idle1 << 1Idle.
MLCameraDeviceStatusFlag_Streaming1 << 2Opened.
MLCameraDeviceStatusFlag_Disconnected1 << 3Disconnected.
MLCameraDeviceStatusFlag_Error1 << 4Error. Call MLCameraGetErrorCode to obtain the error code.
MLCameraDeviceStatusFlag_Ensure32Bits0x7FFFFFFFEnsure enum is represented as 32 bits.

Client can implement polling mechanism to retrieve device status and use these masks to view device status.


Anonymous Enum 5

EnumeratorValueDescription
MLCamera_MaxImagePlanes3Number of planes representing the image color space.

Anonymous Enum 6

EnumeratorValueDescription
MLCameraIntrinsics_MaxDistortionCoefficients5Default distortion vector size.

Camera distortion vector size.

API Level:

  • 20

Types Documentation

MLCameraContext

typedef MLHandle MLCameraContext;

Camera context to be used while connecting to camera.

More Info


MLCameraMRConnectInfo

typedef struct MLCameraMRConnectInfo MLCameraMRConnectInfo;

A structure to encapsulate connection settings for MR capture.

More Info


MLCameraConnectContext

typedef struct MLCameraConnectContext MLCameraConnectContext;

A structure to encapsulate context for a CameraConnect Request.

More Info


MLCameraCaptureStreamCaps

typedef struct MLCameraCaptureStreamCaps MLCameraCaptureStreamCaps;

A structure to encapsulate stream capabilities.

The capabilities for each stream supported by logical camera device can be queried with MLCameraGetStreamCaps.

More Info

Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLCameraCaptureStreamConfig

typedef struct MLCameraCaptureStreamConfig MLCameraCaptureStreamConfig;

A structure to encapsulate stream configurations.

More Info


MLCameraCaptureConfig

typedef struct MLCameraCaptureConfig MLCameraCaptureConfig;

A structure to encapsulate capture configuration.

More Info


MLCameraPlaneInfo

typedef struct MLCameraPlaneInfo MLCameraPlaneInfo;

Per plane info for captured output.

More Info


MLCameraOutput

typedef struct MLCameraOutput MLCameraOutput;

A structure to encapsulate captured output.

More Info


MLCameraIntrinsicCalibrationParameters

typedef struct MLCameraIntrinsicCalibrationParameters MLCameraIntrinsicCalibrationParameters;

Camera intrinsic parameter.

More Info

Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLCameraResultExtras

typedef struct MLCameraResultExtras MLCameraResultExtras;

A structure to encapsulate various indices for a capture result.

More Info


MLCameraDeviceAvailabilityInfo

typedef struct MLCameraDeviceAvailabilityInfo MLCameraDeviceAvailabilityInfo;

A structure to represent info on camera availability.

More Info


MLCameraDeviceAvailabilityStatusCallbacks

typedef struct MLCameraDeviceAvailabilityStatusCallbacks MLCameraDeviceAvailabilityStatusCallbacks;

Device availability status callbacks to be implemented by client to receive device availability status.

More Info


MLCameraDeviceStatusCallbacks

typedef struct MLCameraDeviceStatusCallbacks MLCameraDeviceStatusCallbacks;

Device status callbacks to be implemented by client to receive device status if callback mechanism is used.

More Info


MLCameraCaptureCallbacks

typedef struct MLCameraCaptureCallbacks MLCameraCaptureCallbacks;

Capture callbacks to be implemented by client to receive capture status if callback mechanism is used.

This structure must be initialized by calling MLCameraCaptureCallbacksInit() before use.

More Info

Deprecated

Deprecated since 1.4.0. Scheduled for removal.


Functions Documentation

MLCameraConnectContextInit

static inline void MLCameraConnectContextInit(
MLCameraConnectContext * inout_context
)

Initialize the connect context structure.

Parameters

MLCameraConnectContext *inout_contextMLCameraConnectContext structure to initialize.

Required Permissions:

  • None

Shall be called before calling MLCameraConnect().

Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLCameraCaptureConfigInit

static inline void MLCameraCaptureConfigInit(
MLCameraCaptureConfig * inout_config
)

Initialize the capture config structure.

Parameters

MLCameraCaptureConfig *inout_configMLCameraCaptureConfig structure to initialize.

Required Permissions:

  • None

Shall be called before calling MLCameraPrepareCapture().

Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLCameraDeviceAvailabilityStatusCallbacksInit

static inline void MLCameraDeviceAvailabilityStatusCallbacksInit(
MLCameraDeviceAvailabilityStatusCallbacks * inout_device_availability_status_callbacks
)

Initialize the callback structure.

Parameters

MLCameraDeviceAvailabilityStatusCallbacks *inout_device_availability_status_callbacksDevice availability status callbacks structure to initialize.

Required Permissions:

  • None

Shall be called before calling MLCameraSetDeviceAvailabilityStatusCallbacks().

Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLCameraDeviceStatusCallbacksInit

static inline void MLCameraDeviceStatusCallbacksInit(
MLCameraDeviceStatusCallbacks * inout_device_status_callbacks
)

Initialize the callback structure.

Parameters

MLCameraDeviceStatusCallbacks *inout_device_status_callbacksDevice status callbacks structure to initialize.

Required Permissions:

  • None

Shall be called before calling MLCameraSetDeviceStatusCallbacks().

Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLCameraCaptureCallbacksInit

static inline void MLCameraCaptureCallbacksInit(
MLCameraCaptureCallbacks * inout_capture_callbacks
)

Initialize the callback structure.

Parameters

MLCameraCaptureCallbacks *inout_capture_callbacksCapture status callbacks structure to initialize.

Required Permissions:

  • None

Shall be called before calling MLCameraSetCaptureCallbacks().

Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLCameraInit

MLResult MLCameraInit(
const MLCameraDeviceAvailabilityStatusCallbacks * device_availability_status_callbacks,
void * user_data
)

Initialize ML Camera API, Register callback for device availability. If the user does not want to register device availability listener, MLCameraConnect can be called directly without MLCameraInit(). MLCameraDeInit should be used for unregistering callbacks and releasing resources acquired in MLCameraInit().

Parameters

const MLCameraDeviceAvailabilityStatusCallbacks *device_availability_status_callbacksCallback to notify camera availability status.
void *user_dataPointer to user context data (can be NULL).

Returns

MLResultMLResult_OkCamera is initialized and callbacks registered successfully.
MLResultMLResult_UnspecifiedFailureThe operation failed with an unspecified error.
MLResultMLResult_PermissionDeniedNecessary permission is missing.

Required Permissions:

  • android.permission.CAMERA (protection level: dangerous)
Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLCameraConnect

MLResult MLCameraConnect(
const MLCameraConnectContext * input_context,
MLCameraContext * out_context
)

Connect to camera device.

Parameters

const MLCameraConnectContext *input_contextMLCameraConnectContext structure.
MLCameraContext *out_contextCamera context to be used in later APIs.

Returns

MLResultMLResult_InvalidParamOne of the parameters is invalid.
MLResultMLResult_UnspecifiedFailureThe operation failed with an unspecified error.
MLResultMLResult_OkConnected to camera device successfully.
MLResultMLMediaGenericResult_InvalidOperationcamera device already connected.
MLResultMLResult_PermissionDeniedNecessary permission is missing.

Required Permissions:

  • android.permission.CAMERA (protection level: dangerous)
Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLCameraGetNumSupportedStreams

MLResult MLCameraGetNumSupportedStreams(
MLCameraContext context,
uint32_t * out_num_supported_streams
)

Query the no of streams supported by camera device.

Parameters

MLCameraContextcontextCamera context obtained from MLCameraConnect().
uint32_t *out_num_supported_streamsNumber of streams supported by device.

Returns

MLResultMLResult_InvalidParamOne of the parameters is invalid.
MLResultMLResult_OkAPI call completed successfully.

Required Permissions:

  • None
Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLCameraGetStreamCaps

MLResult MLCameraGetStreamCaps(
MLCameraContext context,
const uint32_t stream_index,
uint32_t * inout_num_stream_caps,
MLCameraCaptureStreamCaps * inout_stream_caps
)

Query the stream capabilities.

Parameters

MLCameraContextcontextCamera context obtained from MLCameraConnect().
const uint32_tstream_indexIndex of the stream for which to query capabilities. The index should be in the range [0 , num_supported_streams) where the num_supported_streams is from MLCameraGetNumSupportedStreams().
uint32_t *inout_num_stream_capsWhen the parameter inout_stream_caps is null, this is an output parameter which will hold the number of capabilities supported by the stream on function return. Otherwise this is an input parameter specifying the number of capabilities to retrieve, namely the size of the array pointed to by inout_stream_caps on return. The value should be in the range of [0, number-of-caps-retrieved].
MLCameraCaptureStreamCaps *inout_stream_capsThis is either null or pointing to an array of MLCameraCaptureStreamCaps() on return. Note that caller is responsible for allocating and releasing the array.

Returns

MLResultMLResult_InvalidParamOne of the parameters is invalid.
MLResultMLResult_OkAPI call completed successfully.

Required Permissions:

  • None

Retrieves either the number of capabilities supported by the given stream or an array of capabilities for the given stream. To get the number of capabilities supported by the given stream, this API should be called with num_stream_caps being valid pointer and out_stream_caps being NULL. To retrieve the array of capabilities for the given stream, this API should be called with a valid num_stream_caps (that contains the size of the out_stream_caps) and out_stream_caps being a preallocated array of MLCameraCaptureStreamCaps of size specified by num_stream_caps.

Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLCameraDisconnect

MLResult MLCameraDisconnect(
MLCameraContext context
)

Disconnect from camera device.

Parameters

MLCameraContextcontextCamera context obtained from MLCameraConnect().

Returns

MLResultMLResult_OkDisconnected Camera device successfully.
MLResultMLMediaGenericResult_InvalidOperationCamera device already disconnected or camera device is streaming.

Required Permissions:

  • None
Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLCameraDeInit

MLResult MLCameraDeInit()

Uninitialize ML Camera API, unregister callback for device availability. Should be called after all camera devices are disconnected. After MLCameraDeInit, MLCameraInit can be called or MLCameraConnect can be called.

Returns

MLResultMLResult_OkDeinitialization completed successfully.
MLResultMLMediaGenericResult_InvalidOperationDeInit called when camera device is connected.

Required Permissions:

  • None
Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLCameraPreCaptureAEAWB

MLResult MLCameraPreCaptureAEAWB(
MLCameraContext context
)

Trigger AEAWB Convergence.

Parameters

MLCameraContextcontextCamera context obtained from MLCameraConnect().

Returns

MLResultMLResult_InvalidParamInvalid camera context.
MLResultMLResult_OkAEAWB convergence done.
MLResultMLResult_UnspecifiedFailureUnspecified failure.
MLResultMLResult_TimeoutTimed out waiting for AEAWB convergence.
MLResultMLMediaGenericResult_InvalidOperationCamera device not configured using MLCameraPrepareCapture() or camera device is streaming.

Required Permissions:

  • None

This API triggers AEAWB sequence and returns when AEAWB convergence has been achieved. The Users can either trigger and converge AEAWB metadata settings or use this API.

Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLCameraPrepareCapture

MLResult MLCameraPrepareCapture(
MLCameraContext context,
const MLCameraCaptureConfig * config,
MLHandle * out_request_handle
)

Prepare for capture.

Parameters

MLCameraContextcontextCamera context obtained from MLCameraConnect().
const MLCameraCaptureConfig *configCapture configuration.
MLHandle *out_request_handleHandle to the capture request metadata. Only valid if result is MLResult_Ok.

Returns

MLResultMLResult_InvalidParamFailed to prepare for capture due to invalid input parameter.
MLResultMLResult_OkPrepared for capture successfully.
MLResultMLResult_UnspecifiedFailureFailed to prepare for capture due to internal error.
MLResultMLMediaGenericResult_InvalidOperationCamera device in streaming state.

Required Permissions:

  • None

This API prepares for capture per specified MLCameraCaptureType by creating a capture request, and a handle to which is returned to the user, who can choose to manipulate the request data (metadata) via APIs defined in ml_camera_metadata_v2.h before performing the capture.

Shall be called after MLCameraConnect().

Note: When preparing capture the width and height parameters should match one of the values returned from MLCameraGetStreamCaps.

Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLCameraUpdateCaptureSettings

MLResult MLCameraUpdateCaptureSettings(
MLCameraContext context
)

Update capture setting.

Parameters

MLCameraContextcontextCamera context obtained from MLCameraConnect().

Returns

MLResultMLResult_InvalidParamInvalid context.
MLResultMLMediaGenericResult_InvalidOperationCamera not streaming video or not in preview.

Required Permissions:

  • None

This API updates the capture settings for an active preview/video stream. The API can be used to update capture settings like exposure compensation manual exposure settings like exposure time, iso setting.The capture settings can be changed in metadata handle returned by MLCameraPrepareCapture() and then this API can be called to apply the capture settings.

Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLCameraSetDeviceStatusCallbacks

MLResult MLCameraSetDeviceStatusCallbacks(
MLCameraContext context,
const MLCameraDeviceStatusCallbacks * device_status_callbacks,
void * data
)

Set the client-implemented callbacks to convey camera device status.

Parameters

MLCameraContextcontextCamera context obtained from MLCameraConnect().
const MLCameraDeviceStatusCallbacks *device_status_callbacksCamera device status callbacks.
void *dataUser metadata.

Returns

MLResultMLResult_InvalidParamInvalid context.
MLResultMLResult_OkSet device status callbacks successfully.

Required Permissions:

  • None

Client needs to implement the callbacks defined by MLCameraDeviceStatusCallbacks. The library passes the camera device status to the client via those callbacks.

Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLCameraSetCaptureCallbacks

MLResult MLCameraSetCaptureCallbacks(
MLCameraContext context,
const MLCameraCaptureCallbacks * capture_callbacks,
void * data
)

Set the client-implemented callbacks to convey capture status.

Parameters

MLCameraContextcontextCamera context obtained from MLCameraConnect().
const MLCameraCaptureCallbacks *capture_callbacksCapture status callbacks.
void *dataUser metadata.

Returns

MLResultMLResult_InvalidParamInvalid context.
MLResultMLResult_OkSet Capture callbacks successfully.
MLResultMLResult_UnspecifiedFailureInternal error occurred.

Required Permissions:

  • None

Client needs to implement the callbacks defined by MLCameraCaptureCallbacks. The library passes the capture status to the client via those callbacks.

Shall be called before capture operation for preview/image/video.

Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLCameraCaptureImage

MLResult MLCameraCaptureImage(
MLCameraContext context,
uint32_t num_images
)

Capture still image.

Parameters

MLCameraContextcontextCamera context obtained from MLCameraConnect().
uint32_tnum_imagesNumber of images to capture valid range is 1-10.

Returns

MLResultMLResult_InvalidParamInvalid context or invalid num_images.
MLResultMLResult_OkTriggered image capture successfully.
MLResultMLMediaGenericResult_InvalidOperationMLMediaGenericResult_InvalidOperation Capture device in invalid state or image stream not configured by MLCameraPrepareCapture().
MLResultMLResult_UnspecifiedFailureInternal error occurred.

Required Permissions:

  • None

The output image will be returned in capture callback on_image_buffer_available.

This is a blocking call, it will return after the end of on_image_buffer_available callback execution.

Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLCameraCaptureVideoStart

MLResult MLCameraCaptureVideoStart(
MLCameraContext context
)

Start video capture. Capture either encoded video or YUV/RGBA frames.

Parameters

MLCameraContextcontextCamera context obtained from MLCameraConnect().

Returns

MLResultMLResult_InvalidParamInvalid context input parameter.
MLResultMLResult_OkStarted video capture successfully.
MLResultMLMediaGenericResult_InvalidOperationCapture device in invalid state or video stream not configured by MLCameraPrepareCapture().
MLResultMLResult_UnspecifiedFailureFailed to start video recording due to internal error.

Required Permissions:

  • None

YUV/RGBA frames are provides through callback.For encoded video capture valid encoder input surface should be configured.The captured video YUV/RGBA frames will be returned to the application via on_video_buffer_available.

MLCameraCaptureVideoStop needs to be called to stop the capture.

Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLCameraCapturePreviewStart

MLResult MLCameraCapturePreviewStart(
MLCameraContext context
)

Start preview provide raw frames through callback.

Parameters

MLCameraContextcontextCamera context obtained from MLCameraConnect().

Returns

MLResultMLResult_InvalidParamInvalid context.
MLResultMLResult_OkStarted preview successfully.
MLResultMLResult_UnspecifiedFailureFailed to start preview due to internal error.
MLResultMLMediaGenericResult_InvalidOperationCapture device in invalid state or preview stream not configured by MLCameraPrepareCapture().

Required Permissions:

  • None

The captured preview YUV frames will be returned to the application via on_preview_buffer_available.

MLCameraCapturePreviewStop needs to be called to stop the capture.

Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLCameraCaptureVideoStop

MLResult MLCameraCaptureVideoStop(
MLCameraContext context
)

Stop video capture.

Parameters

MLCameraContextcontextCamera context obtained from MLCameraConnect().

Returns

MLResultMLResult_InvalidParamInvalid context.
MLResultMLResult_OkStopped video capture successfully.
MLResultMLResult_UnspecifiedFailureFailed to stop video recording due to internal error.
MLResultMLMediaGenericResult_InvalidOperationCapture device in invalid state or video stream not streaming.

Required Permissions:

  • None

User should allow some time, i.e., >500ms, after MLCameraCaptureVideoStart and before calling this API, as captured frames are being encoded. Otherwise, MLResult_UnspecifiedFailure will be returned.

Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLCameraCapturePreviewStop

MLResult MLCameraCapturePreviewStop(
MLCameraContext context
)

Stop preview.

Parameters

MLCameraContextcontextCamera context obtained from MLCameraConnect().

Returns

MLResultMLResult_InvalidParamInvalid context.
MLResultMLResult_OkStopped video capture successfully.
MLResultMLResult_UnspecifiedFailureFailed to stop preview due to internal error.
MLResultMLMediaGenericResult_InvalidOperationCapture device in invalid state or preview stream not streaming.

Required Permissions:

  • None
Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLCameraGetDeviceStatus

MLResult MLCameraGetDeviceStatus(
MLCameraContext context,
uint32_t * out_device_status
)

Poll camera device status.

Parameters

MLCameraContextcontextCamera context obtained from MLCameraConnect().
uint32_t *out_device_statusDevice status.

Returns

MLResultMLResult_InvalidParamFailed to obtain device status due to invalid input parameter.
MLResultMLResult_OkObtained device status successfully.

Required Permissions:

  • None

Use MLCameraDeviceStatusFlag to view specific status bit. Call MLCameraGetErrorCode() to obtain the error code if MLCameraDeviceStatusFlag_Error bit is set.

Note: This API can still be used even if MLCameraSetDeviceStatusCallbacks() has been called.

Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLCameraGetDeviceAvailabilityStatus

MLResult MLCameraGetDeviceAvailabilityStatus(
MLCameraIdentifier cam_id,
bool * out_device_availability_status
)

Poll camera device availability status.

Parameters

MLCameraIdentifiercam_idCamera Id for which the availability status is to be queried.
bool *out_device_availability_statusDevice availability status.

Returns

MLResultMLResult_InvalidParamFailed to obtain device status due to invalid input parameter.
MLResultMLResult_OkObtained device status successfully.

Required Permissions:

  • None

Use MLCameraGetDeviceAvailabilityStatus to view specific status.

Note: This API can still be used even if availability status callback is not registered through MLCameraInit call.

Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLCameraGetErrorCode

MLResult MLCameraGetErrorCode(
MLCameraContext context,
MLCameraError * out_error_code
)

Obtain camera device error code.

Parameters

MLCameraContextcontextCamera context obtained from MLCameraConnect().
MLCameraError *out_error_codeCamera device error code.

Returns

MLResultMLResult_InvalidParamFailed to obtain device error code due to invalid input parameter.
MLResultMLResult_OkObtained camera device error code successfully.

Required Permissions:

  • None
Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLCameraGetCameraCharacteristics

MLResult MLCameraGetCameraCharacteristics(
MLCameraContext context,
MLHandle * out_characteristics_handle
)

Obtains handle for retrieving camera characteristics.

Parameters

MLCameraContextcontextCamera context obtained from MLCameraConnect().
MLHandle *out_characteristics_handleHandle to access camera characteristic metadata. Only valid if result is MLResult_Ok.

Returns

MLResultMLResult_InvalidParamFailed to obtain camera characteristic handle due to invalid input parameter.
MLResultMLResult_OkObtained camera characteristic handle successfully.
MLResultMLResult_UnspecifiedFailureFailed due to internal error.

Required Permissions:

  • None

This API provides the handle for retrieving camera characteristics via APIs defined in ml_camera_metadata_v2.h.

Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20