Marker-Based Location Sharing APIs (PC VR)
These APIs can only be used with PC VR applications. For APIs designed for use with compatible AIO applications developed with the VIVE Wave VR SDK, see Marker-Based Location Sharing APIs (AIO).
Configure marker ID and dictionary
Configures the marker ID and dictionary for one or two ArUco markers. Location sharing only starts after users scan the secondary marker when configuring two markers.
There are two ways to configure the marker ID and dictionary when setting up Marker-Based Location Sharing with PC VR:
- Use the API to retrieve the marker settings from markers_list.json (saved to your PC)
- Insert the marker settings from markers_list_escape.json directly into the API
You can choose which method to apply when setting up Marker-Based Location Sharing with VIVE Business Streaming. For details, see Setting up Marker-Based Location Sharing with VIVE Business Streaming.
One ArUco marker
string key = "PLAYER00InitMA"; setting = "{\"marker1\": {\"id\": 66,\"behavior\": 3,\"size\": 0.280}}"; key += setting; string result = SendRequestMessage(DeviceType.HMD, key); if (string.Compare(result, "InitMAErr") == 0) { // Write your error handling code here. } |
Two ArUco markers
string key = "PLAYER00InitMA"; setting = "{\"marker1\": {\"id\": 66,\"behavior\": 3,\"size\": 0.280,\"isMainMarker\": true,\"pairMarkerID\": 88},\"marker2\": {\"id\": 88,\"behavior\": 3,\"size\": 0.280,\"isMainMarker\": false,\"pairMarkerID\": 66}}"; key += setting; string result = SendRequestMessage(DeviceType.HMD, key); if (string.Compare(result, "InitMAErr") == 0) { // Write your error handling code here. } |
Send marker settings
Retrieves the marker settings from the JSON file on the PC and sends them to the headset.
string key = "PLAYER00InitMA"; // default path: C:\Users\{USERNAME}\Data\markers_list.json string filePath = Environment.ExpandEnvironmentVariables(@"%USERPROFILE%\Data\markers_list.json"); string setting = File.ReadAllText(filePath); setting = setting.Replace("\n", "").Replace(" ", ""); // Spaces must be removed from the setting string. key += setting; string result = SendRequestMessage(DeviceType.HMD, key); if (string.Compare(result, "InitMAErr") == 0) { // Write your error handling code here. } |
Send requests
Helper function for sending requests.
enum DeviceType { HMD = 0, Controller_Left, Controller_Right } private string SendRequestMessage(DeviceType deviceType, string inString) { string addprefix = inString.Insert(0, "GetParameters "); // The trailing space in "GetParameters " is required. uint RETURN_SIZE = 256; StringBuilder value = new StringBuilder("", Convert.ToInt32(RETURN_SIZE)); OpenVR.Debug.DriverDebugRequest((uint)deviceType, addprefix, value, RETURN_SIZE); return value.ToString(); } private string SetParameters(DeviceType deviceType, string inString) { string addprefix = inString.Insert(0, "SetParameters "); // The trailing space in "SetParameters " is required. uint RETURN_SIZE = 256; StringBuilder value = new StringBuilder("", Convert.ToInt32(RETURN_SIZE)); OpenVR.Debug.DriverDebugRequest((uint)deviceType, addprefix, value, RETURN_SIZE); return value.ToString(); } |
Scan marker
Prompts the headset's tracking engine to detect an ArUco marker and process the data.
string key = "ClearRecenterXform"; SetParameters(DeviceType.HMD, key); SetParameters(DeviceType.Controller_Right, key); SetParameters(DeviceType.Controller_Left, key); string key = "PLAYER00StartScan"; SendRequestMessage(DeviceType.HMD, key); |
Stop scan
Stops the scanning process.
string key = "PLAYER00StopScan"; SendRequestMessage(DeviceType.HMD, key); |
Check scan status (optional)
Checks the status of the latest scan at regular intervals.
string key = "PLAYER00CheckMA"; string result = SendRequestMessage(DeviceType.HMD, key); if (string.Compare(result, "CTdone") == 0) { // Handles the case where all markers have been scanned. } else if (string.Compare(result, "CTpass") == 0) { // Handles the case where the 1st marker has been scanned, if you are using 2 markers. Remove this code if you are using 1 marker. } |