NativeBindings
This class defines the C# interface to the C functions/structures in "ml_camera.h".
Inherits from:
MagicLeapNativeBindings
Public Methods
delegate void DeviceAvailabilityStatusDelegate
public delegate void DeviceAvailabilityStatusDelegate(
ref MLCameraDeviceAvailabilityInfo info
)
Parameters
Type | Name | Description |
---|---|---|
ref MLCameraDeviceAvailabilityInfo | info |
MLResult.Code MLCameraCaptureImage
The output image will be returned in capture callback on_image_buffer_available
public MLResult.Code MLCameraCaptureImage(
ulong contextHandle,
uint numImages
)
Parameters
Type | Name | Description |
---|---|---|
ulong | contextHandle | Context obtained from MLCameraConnect. |
uint | numImages | no of images to capture valid range is 1-10. |
Returns: MLResult.Result will be MLResult.Code.Ok if image was captured successfully. MLResult.Result will be MLResult.Code.MediaGenericInvalidOperation if failed to capture image due to on-going video recording. MLResult.Result will be MLResult.Code.MediaGenericUnexpectedNull if failed to capture image due to null pointer. MLResult.Result will be MLResult.Code.InvalidParam if failed to capture image due to an invalid parameter. MLResult.Result will be MLResult.Code.Timeout if failed to capture image due to timeout. MLResult.Result will be MLResult.Code.PermissionDenied if a required permission is missing.
MLResult.Code MLCameraCaptureVideoStart
Start video capture and save output to a file. The captured video and audio streams will be encoded with AVC and AAC codecs and packed in mp4 container format and stored into the file specified by the file path.The library is responsible for opening and closing the file.The current supported video resolution is 1080p. If this function is invoked before the camera sensor has locked AE and AWB, it will be blocked till AE, AWB is locked and then starts to capture. MLCameraCaptureVideoStop() needs to be called to stop the capture.
public MLResult.Code MLCameraCaptureVideoStart(
ulong contextHandle
)
Parameters
Type | Name | Description |
---|---|---|
ulong | path | File path to store the output video. |
Returns: MLResult.Result will be MLResult.Code.Ok if started video recording successfully. MLResult.Result will be MLResult.Code.MediaGenericUnexpectedNull if failed to start video recording due to null pointer. MLResult.Result will be MLResult.Code.InvalidParam if failed to start video recording due to invalid input parameter. MLResult.Result will be MLResult.Code.Timeout if failed to start video recording image due to timeout. MLResult.Result will be MLResult.Code.AllocFailed if failed to allocate memory. MLResult.Result will be MLResult.Code.PermissionDenied if a required permission is missing.
MLResult.Code MLCameraCaptureVideoStop
Stop video capture. 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.
public MLResult.Code MLCameraCaptureVideoStop(
ulong contextHandle
)
Parameters
Type | Name | Description |
---|---|---|
ulong | contextHandle |
Returns: MLResult.Result will be MLResult.Code.Ok if stopped video recording successfully. MLResult.Result will be MLResult.Code.MediaGenericUnexpectedNull if failed to stop video recording due to null pointer. MLResult.Result will be MLResult.Code.UnspecifiedFailure if failed due to internal error. MLResult.Result will be MLResult.Code.PermissionDenied if a required permission is missing.
MLResult.Code MLCameraConnect
public MLResult.Code MLCameraConnect(
ref MLCameraConnectContext inputContext,
out ulong handle
)
Parameters
Type | Name | Description |
---|---|---|
ref MLCameraConnectContext | inputContext | Structure to encapsulate context for a CameraConnect Request. |
out ulong | handle |
MLResult.Code MLCameraDeInit
public MLResult.Code MLCameraDeInit()
MLResult.Code MLCameraDisconnect
Disconnect from camera device.
public MLResult.Code MLCameraDisconnect(
ulong contextHandle
)
Parameters
Type | Name | Description |
---|---|---|
ulong | contextHandle | Capture operation type. |
Returns: MLResult.Result will be MLResult.Code.Ok if disconnected from camera device successfully. MLResult.Result will be MLResult.Code.PermissionDenied if a required permission is missing.
MLResult.Code MLCameraGetCameraCharacteristics
Obtain handle for retrieving camera characteristics. This API provides the handle for retrieving camera characteristics via APIs defined in ml_camera_metadata.h.
public MLResult.Code MLCameraGetCameraCharacteristics(
ulong contextHandle,
out ulong outMetadataHandle
)
Parameters
Type | Name | Description |
---|---|---|
ulong | outHandle | Handle to access camera characteristic metadata. |
out ulong | outMetadataHandle |
Returns: MLResult.Result will be MLResult.Code.Ok if obtained camera characteristic handle successfully. MLResult.Result will be MLResult.Code.InvalidParam if failed to obtain camera characteristic handle due to invalid input parameter. MLResult.Result will be MLResult.Code.MediaGenericUnexpectedNull if failed to capture raw image due to null pointer. MLResult.Result will be MLResult.Code.AllocFailed if failed to allocate memory. MLResult.Result will be MLResult.Code.PermissionDenied if a required permission is missing.
MLResult.Code MLCameraGetDeviceStatus
Poll camera device status. Use #MLCamera.DeviceStatusFlag to view specific status bit. Call MLCameraGetErrorCode() to obtain the error code if MLCamera.DeviceStatusFlag.Error bit is set. Note: This API can still be used even if MLCameraSetDeviceStatusCallbacks() has been called.
public MLResult.Code MLCameraGetDeviceStatus(
ulong contextHandle,
out uint outDeviceStatus
)
Parameters
Type | Name | Description |
---|---|---|
ulong | contextHandle | Context obtained from MLCameraConnect. |
out uint | outDeviceStatus | Device status. |
Returns: MLResult.Result will be MLResult.Code.Ok if obtained device status successfully. MLResult.Result will be MLResult.Code.InvalidParam if failed to obtain device status due to invalid input parameter.
MLResult.Code MLCameraGetErrorCode
Obtain device error code.
public MLResult.Code MLCameraGetErrorCode(
ulong contextHandle,
out MLCamera.ErrorType outErrorCode
)
Parameters
Type | Name | Description |
---|---|---|
ulong | outErrorCode | Device error code. |
out MLCamera.ErrorType | outErrorCode | Camera errors |
Returns: MLResult.Result will be MLResult.Code.Ok if obtained device error code successfully. MLResult.Result will be MLResult.Code.InvalidParam if failed to obtain device error code due to invalid input parameter.
MLResult.Code MLCameraGetNumSupportedStreams
public MLResult.Code MLCameraGetNumSupportedStreams(
ulong handle,
out uint numSupportedStreams
)
Parameters
Type | Name | Description |
---|---|---|
ulong | handle | |
out uint | numSupportedStreams |
MLResult.Code MLCameraInit
public MLResult.Code MLCameraInit(
ref MLCameraDeviceAvailabilityStatusCallbacks deviceAvailabilityStatusCallback,
IntPtr userData
)
Parameters
Type | Name | Description |
---|---|---|
ref MLCameraDeviceAvailabilityStatusCallbacks | deviceAvailabilityStatusCallback | Device availability status callbacks to be implemented by client to receive device availability status. |
IntPtr | userData |
MLResult.Code MLCameraPrepareCapture
Prepare for capture. This API prepares capture per specified MLCamera.CaptureType 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.h before performing the capture. Shall be called after MLCameraConnect().
public MLResult.Code MLCameraPrepareCapture(
ulong contextHandle,
ref MLCameraCaptureConfig config,
out ulong metadataHandle
)
Parameters
Type | Name | Description |
---|---|---|
ulong | contextHandle | Context obtained from MLCameraConnect. |
ref MLCameraCaptureConfig | config | Capture configuration. |
out ulong | metadataHandle | Handle to the capture metadata. Only valid if result is MLResult_Ok. |
Returns: MLResult.Result will be MLResult.Code.Ok if prepared for capture successfully. MLResult.Result will be MLResult.Code.InvalidParam if failed to prepare for capture due to an invalid parameter. MLResult.Result will be MLResult.Code.MediaGenericUnexpectedNull if failed to prepare for capture due to null pointer. MLResult.Result will be MLResult.Code.BadType if failed to prepare for capture due to null pointer. MLResult.Result will be MLResult.Code.UnspecifiedFailure if failed due to internal error. MLResult.Result will be MLResult.Code.AllocFailed if failed to allocate memory. MLResult.Result will be MLResult.Code.PermissionDenied if a required permission is missing.
MLResult.Code MLCameraSetDeviceStatusCallbacks
Set the client-implemented callbacks to convey camera device status. Client needs to implement the callbacks defined by MLCameraDeviceStatusCallbacks. The library passes the camera device status to the client via those callbacks. Shall be called before MLCameraConnect().
public MLResult.Code MLCameraSetDeviceStatusCallbacks(
ulong contextHandle,
ref MLCameraDeviceStatusCallbacks deviceStatusCallbacks,
IntPtr data
)
Parameters
Type | Name | Description |
---|---|---|
ulong | deviceStatusCallbacks | Capture status callbacks. |
ref MLCameraDeviceStatusCallbacks | data | User metadata. |
IntPtr | data |
Returns: MLResult.Result will be MLResult.Code.Ok if callbacks were set successfully. MLResult.Result will be MLResult.Code.UnspecifiedFailure if failed due to internal error.
delegate void OnCaptureAbortedDelegate
public delegate void OnCaptureAbortedDelegate(
IntPtr data
)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | data |
delegate void OnCaptureCompletedDelegate
public delegate void OnCaptureCompletedDelegate(
ulong metadataHandle,
ref MLCameraResultExtras extra,
IntPtr data
)
Parameters
Type | Name | Description |
---|---|---|
ulong | metadataHandle | |
ref MLCameraResultExtras | extra | ResultExtras is a structure to encapsulate various indices for a capture result. |
IntPtr | data |
delegate void OnCaptureFailedDelegate
public delegate void OnCaptureFailedDelegate(
ref MLCameraResultExtras extra,
IntPtr data
)
Parameters
Type | Name | Description |
---|---|---|
ref MLCameraResultExtras | extra | ResultExtras is a structure to encapsulate various indices for a capture result. |
IntPtr | data |
delegate void OnDataCallback
A generic delegate for camera events.
public delegate void OnDataCallback(
IntPtr data
)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | data | Custom data returned when the callback is triggered, user metadata. |
delegate void OnDeviceDisconnectedDelegate
public delegate void OnDeviceDisconnectedDelegate(
MLCamera.DisconnectReason reason,
IntPtr data
)
Parameters
Type | Name | Description |
---|---|---|
MLCamera.DisconnectReason | reason | Camera Disconnect Reason. |
IntPtr | data |
delegate void OnDeviceErrorDelegate
public delegate void OnDeviceErrorDelegate(
MLCamera.ErrorType error,
IntPtr data
)
Parameters
Type | Name | Description |
---|---|---|
MLCamera.ErrorType | error | Camera errors |
IntPtr | data |
delegate void OnDeviceIdleDelegate
public delegate void OnDeviceIdleDelegate(
IntPtr data
)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | data |
delegate void OnDeviceStreamingDelegate
public delegate void OnDeviceStreamingDelegate(
IntPtr data
)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | data |
delegate void OnErrorDataCallback
A delegate for camera error events.
public delegate void OnErrorDataCallback(
MLCamera.ErrorType error,
IntPtr data
)
Parameters
Type | Name | Description |
---|---|---|
MLCamera.ErrorType | error | The type of error that was reported. |
IntPtr | data | Custom data returned when the callback is triggered, user metadata. |
delegate void OnHandleAndResultExtrasRefDataCallback
A delegate for camera capture events with additional information.
public delegate void OnHandleAndResultExtrasRefDataCallback(
MLCamera.Metadata metadataHandle,
ref MLCameraResultExtras extra,
IntPtr data
)
Parameters
Type | Name | Description |
---|---|---|
MLCamera.Metadata | metadataHandle | A handle to the metadata. |
ref MLCameraResultExtras | extra | A structure containing extra result information. |
IntPtr | data | Custom data returned when the callback is triggered, user metadata. |
delegate void OnHandleDataCallback
A delegate for camera preview events.
public delegate void OnHandleDataCallback(
ulong metadataHandle,
IntPtr data
)
Parameters
Type | Name | Description |
---|---|---|
ulong | metadataHandle | A handle to the metadata. |
IntPtr | data | Custom data returned when the callback is triggered, user metadata. |
delegate void OnImageBufferAvailableDelegate
public delegate void OnImageBufferAvailableDelegate(
ref MLCameraOutput output,
ulong metadataHandle,
ref MLCameraResultExtras extra,
IntPtr data
)
Parameters
Type | Name | Description |
---|---|---|
ref MLCameraOutput | output | Captured output |
ulong | metadataHandle | |
ref MLCameraResultExtras | extra | ResultExtras is a structure to encapsulate various indices for a capture result. |
IntPtr | data |
delegate void OnOutputRefDataCallback
A delegate for image buffer events.
public delegate void OnOutputRefDataCallback(
ref MLCameraOutput output,
IntPtr data
)
Parameters
Type | Name | Description |
---|---|---|
ref MLCameraOutput | output | The camera output type. |
IntPtr | data | Custom data returned when the callback is triggered, user metadata. |
delegate void OnPreviewBufferAvailableDelegate
public delegate void OnPreviewBufferAvailableDelegate(
ulong bufferHandle,
ulong metadataHandle,
ref MLCameraResultExtras extra,
IntPtr data
)
Parameters
Type | Name | Description |
---|---|---|
ulong | bufferHandle | |
ulong | metadataHandle | |
ref MLCameraResultExtras | extra | ResultExtras is a structure to encapsulate various indices for a capture result. |
IntPtr | data |
delegate void OnResultExtrasRefDataCallback
A delegate for camera capture events.
public delegate void OnResultExtrasRefDataCallback(
ref MLCameraResultExtras extra,
IntPtr data
)
Parameters
Type | Name | Description |
---|---|---|
ref MLCameraResultExtras | extra | A structure containing extra result information. |
IntPtr | data | Custom data returned when the callback is triggered, user metadata. |
delegate void OnVideoBufferAvailableDelegate
public delegate void OnVideoBufferAvailableDelegate(
ref MLCameraOutput output,
ulong metadataHandle,
ref MLCameraResultExtras extra,
IntPtr data
)
Parameters
Type | Name | Description |
---|---|---|
ref MLCameraOutput | output | Captured output |
ulong | metadataHandle | |
ref MLCameraResultExtras | extra | ResultExtras is a structure to encapsulate various indices for a capture result. |
IntPtr | data |
Public Attributes
MLCameraMaxImagePlanes
Number of MLCamera image planes.
public const int MLCameraMaxImagePlanes = 3;