WVR_EnumerateTrackableMarkers

WVR_EXPORT WVR_Result WVR_EnumerateTrackableMarkers(WVR_MarkerObserverTarget target, uint32_t markerCapacityInput, uint32_t * markerCountOutput, WVR_Uuid * markers)

Function is used to enumerate the markers that have been created as trackable markers related to the target parameter. .

This is two calls API. Developers should call this API with the value of markerCapacityInput equals to 0 to retrieve the size of markers from markerCountOutput. Then developers allocate the array of WVR_Uuid and assign the markerCapacityInput and call the API in the second time. Then runtime will fill the WVR_Uuid array.

Note: Since there is a time gap between the first and the second calls, developers should verify the markerCountOutput when retrieving the data that filled by runtime during the second time.

Version
API Level 13
Parameters
  • target: the observer target that developers would like to get the trackable markers. (refer to WVR_MarkerObserverTarget)
  • markerCapacityInput: the capacity of the markers array, or 0 to indicate a request to retrieve the required capacity.
  • markerCountOutput: a pointer to the count of markers written, or a pointer to the required capacity in the case that markerCapacityInput is insufficient.
  • markers: a pointer to an array of WVR_Uuid, but can be NULL if markerCapacityInput is 0.
Return Value
  • WVR_Success: Enumerate trackable markers successfully.
  • others: WVR_Result mean failure.

How to use

Sample function:

#include <wvr/wvr_marker.h>

if (WVR_StartMarker() == WVR_Success) {
    //
    // start marker observer
    if (WVR_StartMarkerObserver(WVR_MarkerObserverTarget_Aruco) == WVR_Success) {
        // Start Aruco marker observer related resources success

        uint32_t tracker_count = 0;
        int result = WVR_EnumerateTrackableMarkers(WVR_MarkerObserverTarget_Aruco, 0, &tracker_count, nullptr);
        if (result != WVR_Success) {
            // error
            return;
        }

        uint32_t tracker_input = tracker_count;
        std::vector<WVR_Uuid> uuids(tracker_input);
        if (WVR_EnumerateTrackableMarkers(WVR_MarkerObserverTarget_Aruco, tracker_input, &tracker_count, uuids.data()) == WVR_Success) {
            // get the valid uuid of trackable markers
            uint32_t size = tracker_input<=tracker_count?tracker_input:tracker_count;
            for (int i = 0 ; i < size ; i ++) {
                // get the valid Aruco markers
                WVR_TrackableMarkerState state{};
                if (WVR_GetTrackableMarkerState(uuids[i], WVR_PoseOriginModel_OriginOnGround, &state) == WVR_Success) {
                    // get trackable marker state
                }
                 WVR_ArucoMarkerData arucoData{};
                 if (WVR_GetArucoMarkerData(uuids[i], &arucoData) == WVR_Success) {
                     // get trackable marker related to Aruco specific data
                 }
            }

        // release Aruco marker observer related resources success
        if (WVR_StopMarkerObserver(WVR_MarkerObserverTarget_Aruco) == WVR_Success) {

        }
    }

    WVR_StopMarker();
} else {
    // start marker failed!
}