Skip to main content
Version: 12 Dec 2024

ml_cv_camera.h

Enums

Name
enumMLCVCameraID
{
MLCVCameraID_ColorCamera = 0,
MLCVCameraID_Ensure32Bits = 0x7FFFFFFF
}
Camera id enum.

Functions

Name
MLResultMLCVCameraTrackingCreate(MLHandle * out_handle)
Create CV Camera Tracker.
MLResultMLCVCameraGetFramePose(MLHandle camera_handle, MLHandle head_handle, MLCVCameraID id, MLTime camera_timestamp, MLTransform * out_transform)
Get the camera pose in the world coordinate system.
MLResultMLCVCameraTrackingDestroy(MLHandle camera_handle)
Destroy Tracker after usage.

Enums Documentation

MLCVCameraID

EnumeratorValueDescription
MLCVCameraID_ColorCamera0Default camera id.
MLCVCameraID_Ensure32Bits0x7FFFFFFFCamera id.

Camera id enum.

API Level:

  • 5

Functions Documentation

MLCVCameraTrackingCreate

MLResult MLCVCameraTrackingCreate(
MLHandle * out_handle
)

Create CV Camera Tracker.

Parameters

MLHandle *out_handleTracker handle.

Returns

MLResultMLResult_OkOn success.
MLResultMLResult_PerceptionSystemNotStartedPerception System has not been started.
MLResultMLResult_PermissionDeniedNecessary permission is missing.

Required Permissions:

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

API Level:

  • 5

MLCVCameraGetFramePose

MLResult MLCVCameraGetFramePose(
MLHandle camera_handle,
MLHandle head_handle,
MLCVCameraID id,
MLTime camera_timestamp,
MLTransform * out_transform
)

Get the camera pose in the world coordinate system.

Parameters

MLHandlecamera_handleMLHandle previously created with MLCVCameraTrackingCreate.
MLHandlehead_handleMLHandle previously created with MLHeadTrackingCreate.
MLCVCameraIDidCamera id.
MLTimecamera_timestampTime to request the pose.
MLTransform *out_transformTransform from camera to world origin.

Returns

MLResultMLResult_InvalidParamid parameter was not valid or out_transform parameter was not valid (null).
MLResultMLResult_OkObtained transform successfully.
MLResultMLResult_PerceptionSystemNotStartedPerception System has not been started.
MLResultMLResult_PoseNotFoundPose is currently not available.
MLResultMLResult_UnspecifiedFailureFailed to obtain transform due to internal error.

Required Permissions:

  • None

Use the timestamp provided from the #on_video_buffer_available callback from ml_camera_v2.h. The camera tracker only caches a limited set of poses. Retrieve the camera pose as soon as the timestamp is available else the API may return MLResult_PoseNotFound.

API Level:

  • 5

MLCVCameraTrackingDestroy

MLResult MLCVCameraTrackingDestroy(
MLHandle camera_handle
)

Destroy Tracker after usage.

Parameters

MLHandlecamera_handleMLHandle previously created with MLCVCameraTrackingCreate.

Returns

MLResultMLResult_OkOn success.
MLResultMLResult_PerceptionSystemNotStartedPerception System has not been started.

Required Permissions:

  • None

API Level:

  • 5

Source code

// %BANNER_BEGIN%
// ---------------------------------------------------------------------
// %COPYRIGHT_BEGIN%
// Copyright (c) 2017 Magic Leap, Inc. All Rights Reserved.
// Use of this file is governed by the Software License Agreement,
// located here: https://www.magicleap.com/software-license-agreement-ml2
// Terms and conditions applicable to third-party materials accompanying
// this distribution may also be found in the top-level NOTICE file
// appearing herein.
// %COPYRIGHT_END%
// ---------------------------------------------------------------------
// %BANNER_END%

#pragma once

#include "ml_api.h"
#include "ml_types.h"

ML_EXTERN_C_BEGIN

typedef enum MLCVCameraID {
MLCVCameraID_ColorCamera = 0,
MLCVCameraID_Ensure32Bits = 0x7FFFFFFF
} MLCVCameraID;

ML_API MLResult ML_CALL MLCVCameraTrackingCreate(MLHandle *out_handle);

ML_API MLResult ML_CALL MLCVCameraGetFramePose(MLHandle camera_handle, MLHandle head_handle, MLCVCameraID id, MLTime camera_timestamp, MLTransform *out_transform);

ML_API MLResult ML_CALL MLCVCameraTrackingDestroy(MLHandle camera_handle);

ML_EXTERN_C_END