WVR_GetArucoMarkers¶
-
WVR_EXPORT WVR_Result WVR_GetArucoMarkers(uint32_t markerCapacityInput, uint32_t * markerCountOutput, WVR_PoseOriginModel originModel, WVR_ArucoMarker * markers)
Function is used to retrieve aruco markers.
This is two calls API. Developers should call this API with the value of markerCapacityInput equals to 0 to retrieve the size of aruco markers from markerCountOutput. Then developers allocate the array of WVR_ArucoMarker data and assign the markerCapacityInput and call the API in the second time. Then runtime will fill the WVR_ArucoMarker array.
Note: that only WVR_PoseOriginModel_OriginOnHead and WVR_PoseOriginModel_OriginOnGround cases are supported in originModel. 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
markerCapacityInput
: the capacity of the aruco markers array, or 0 to indicate a request to retrieve the required capacity.markerCountOutput
: a pointer to the count of aruco markers written, or a pointer to the required capacity in the case that markerCapacityInput is insufficient.originModel
: Only WVR_PoseOriginModel_OriginOnHead and WVR_PoseOriginModel_OriginOnGround are supported, refer to WVR_PoseOriginModel.markers
: An array of WVR_ArucoMarker will be filled by the runtime.
- Return Value
WVR_Success
: Get aruco 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
if (WVR_StartMarkerDetection(WVR_MarkerObserverTarget_Aruco) == WVR_Success)) {
// Start detecting the Aruco marker, and the Aruco marker detection will be WVR_MarkerObserverState_Detecting
uint32_t count = 0;
int result = WVR_GetArucoMarkers(0, &count, WVR_PoseOriginModel_OriginOnGround, nullptr);
if (result==0 & count!=0) {
uint32_t input = count;
std::vector<WVR_ArucoMarker> markers(input);
int ret = WVR_GetArucoMarkers(input, &count, WVR_PoseOriginModel_OriginOnGround, markers.data());
if (ret != WVR_Success) {
LOGE("%s(%d) WVR_GetArucoMarkers failed ret=(%d)", __FUNCTION__, __LINE__, ret);
return;
}
// get the valid Aruco markers
uint32_t size = input<=count? input : count;
for (int i = 0 ; i < size ; i ++) {
// get aruco markers data
}
}
// Stop detecting Aruco marker
if (WVR_StopMarkerDetection(WVR_MarkerObserverTarget_Aruco) == WVR_Success)) {
// The Aruco marker detection will be WVR_MarkerObserverState_Idle
}
}
// release Aruco marker observer related resources success
if (WVR_StopMarkerObserver(WVR_MarkerObserverTarget_Aruco) == WVR_Success) {
}
}
WVR_StopMarker();
} else {
// start marker failed!
}