MaxstARSDK  3.5.0
TrackingState.cs
1 /*==============================================================================
2 Copyright 2017 Maxst, Inc. All Rights Reserved.
3 ==============================================================================*/
4 
5 using UnityEngine;
6 using System;
7 using System.Collections.Generic;
8 using System.Linq;
9 using System.Text;
10 using System.Runtime.InteropServices;
11 
12 namespace maxstAR
13 {
17  public class TrackingState
18  {
19  private ulong cPtr;
20  private TrackedImage image;
21  private TrackingResult trackingResult = null;
22 
23  internal TrackingState()
24  {
25  image = new TrackedImage();
26  trackingResult = new TrackingResult();
27  }
28 
29  internal void SetTrackingStateCPtr(ulong trackingStateCPtr)
30  {
31  cPtr = trackingStateCPtr;
32  }
33 
34  internal ulong GetTrackingStateCPtr()
35  {
36  return cPtr;
37  }
38 
42  {
43  ulong trackingResultCPtr;
44 
45  if (Application.platform == RuntimePlatform.IPhonePlayer)
46  {
47  trackingResultCPtr = NativeStaticAPI.TrackingState_getTrackingResult(cPtr);
48  }
49  else
50  {
51  trackingResultCPtr = NativeSharedAPI.TrackingState_getTrackingResult(cPtr);
52  }
53 
54  trackingResult.SetCPtr(trackingResultCPtr);
55  return trackingResult;
56  }
57 
60  public string GetCodeScanResult()
61  {
62  if (Application.platform == RuntimePlatform.IPhonePlayer)
63  {
64  int length = NativeStaticAPI.TrackingState_getCodeScanResultLength(cPtr);
65  if (length > 0)
66  {
67  byte[] result = new byte[length];
68  NativeStaticAPI.TrackingState_getCodeScanResult(cPtr, result, length);
69  return Encoding.UTF8.GetString(result);
70  }
71  else
72  {
73  return "";
74  }
75  }
76  else
77  {
78  int length = NativeSharedAPI.TrackingState_getCodeScanResultLength(cPtr);
79  if (length > 0)
80  {
81  byte[] result = new byte[length];
82  NativeSharedAPI.TrackingState_getCodeScanResult(cPtr, result, length);
83  return Encoding.UTF8.GetString(result);
84  }
85  else
86  {
87  return "";
88  }
89  }
90  }
91 
97  {
98  ulong Image_Cptr = 0;
99  if (Application.platform == RuntimePlatform.IPhonePlayer)
100  {
101  Image_Cptr = NativeStaticAPI.TrackingState_getImage(cPtr);
102  }
103  else
104  {
105  Image_Cptr = NativeSharedAPI.TrackingState_getImage(cPtr);
106  }
107 
108  image.SetData(Image_Cptr);
109 
110  return image;
111  }
112 
113  public TrackedImage GetImagePtr()
114  {
115  ulong Image_Cptr = 0;
116  if (Application.platform == RuntimePlatform.IPhonePlayer)
117  {
118  Image_Cptr = NativeStaticAPI.TrackingState_getImage(cPtr);
119  }
120  else
121  {
122  Image_Cptr = NativeSharedAPI.TrackingState_getImage(cPtr);
123  }
124 
125  image.SetDataPtr(Image_Cptr);
126 
127  return image;
128  }
129  }
130 }
TrackingResult GetTrackingResult()
Output the number of trackers that have been tracked successfully.
Container for individual tracking information
string GetCodeScanResult()
Outputs the recognition result of the bar code / QR code.
TrackedImage GetImage()
Extract image used for tracking
Contains tracked targets informations
image data which is used for tracker and rendering
Definition: TrackedImage.cs:13