MaxstARSDK  3.5.0
TrackedImage.cs
1 using UnityEngine;
2 using System;
3 using System.Collections.Generic;
4 using System.Linq;
5 using System.Text;
6 using System.Runtime.InteropServices;
7 
8 namespace maxstAR
9 {
13  public class TrackedImage
14  {
15  private int width;
16  private int height;
17  private int length;
18  private ColorFormat colorFormat;
19  private byte[] data = null;
20  private IntPtr imagePtr = IntPtr.Zero;
21 
22  internal void SetDataPtr(ulong Image_cPtr)
23  {
24  if (Application.platform == RuntimePlatform.IPhonePlayer)
25  {
26  width = NativeStaticAPI.TrackedImage_getWidth(Image_cPtr);
27  height = NativeStaticAPI.TrackedImage_getHeight(Image_cPtr);
28  length = NativeStaticAPI.TrackedImage_getLength(Image_cPtr);
29  int format = NativeStaticAPI.TrackedImage_getFormat(Image_cPtr);
30  colorFormat = (ColorFormat)format;
31  if (width == 0 || height == 0)
32  {
33  return;
34  }
35 
36  imagePtr = (IntPtr)NativeStaticAPI.TrackedImage_getDataPtr(Image_cPtr, length);
37  }
38  else
39  {
40  width = NativeSharedAPI.TrackedImage_getWidth(Image_cPtr);
41  height = NativeSharedAPI.TrackedImage_getHeight(Image_cPtr);
42  length = NativeSharedAPI.TrackedImage_getLength(Image_cPtr);
43  int format = NativeSharedAPI.TrackedImage_getFormat(Image_cPtr);
44  colorFormat = (ColorFormat)format;
45  if (width == 0 || height == 0)
46  {
47  return;
48  }
49 
50  imagePtr = (IntPtr)NativeSharedAPI.TrackedImage_getDataPtr(Image_cPtr, length);
51  }
52  }
53 
54  internal void SetData(ulong Image_cPtr)
55  {
56  if (Application.platform == RuntimePlatform.IPhonePlayer)
57  {
58  width = NativeStaticAPI.TrackedImage_getWidth(Image_cPtr);
59  height = NativeStaticAPI.TrackedImage_getHeight(Image_cPtr);
60  length = NativeStaticAPI.TrackedImage_getLength(Image_cPtr);
61  int format = NativeStaticAPI.TrackedImage_getFormat(Image_cPtr);
62  colorFormat = (ColorFormat)format;
63  if (width ==0 || height == 0)
64  {
65  return;
66  }
67 
68  if (data == null)
69  {
70  data = new byte[length];
71  }
72 
73  NativeStaticAPI.TrackedImage_getData(Image_cPtr, data, length);
74  }
75  else
76  {
77  width = NativeSharedAPI.TrackedImage_getWidth(Image_cPtr);
78  height = NativeSharedAPI.TrackedImage_getHeight(Image_cPtr);
79  length = NativeSharedAPI.TrackedImage_getLength(Image_cPtr);
80  int format = NativeSharedAPI.TrackedImage_getFormat(Image_cPtr);
81  colorFormat = (ColorFormat)format;
82  if (width == 0 || height == 0)
83  {
84  return;
85  }
86 
87  if (data == null)
88  {
89  data = new byte[length];
90  }
91 
92  NativeSharedAPI.TrackedImage_getData(Image_cPtr, data, length);
93  }
94  }
95 
100  public int GetWidth()
101  {
102  return width;
103  }
104 
109  public int GetHeight()
110  {
111  return height;
112  }
113 
118  public int GetLength()
119  {
120  return length;
121  }
122 
128  {
129  return colorFormat;
130  }
131 
136  public byte [] GetData()
137  {
138  return data;
139  }
140 
141  public IntPtr GetDataPtr()
142  {
143  return imagePtr;
144  }
145  }
146 }
int GetHeight()
Get height
int GetLength()
Get length (width * height * bits per pixel)
byte [] GetData()
Image byte array
int GetWidth()
Get width
ColorFormat GetFormat()
Image format
ColorFormat
Camera image format
Definition: ColorFormat.cs:11
image data which is used for tracker and rendering
Definition: TrackedImage.cs:13