8 using System.Runtime.InteropServices;
9 using System.Collections.Generic;
27 FOCUS_MODE_CONTINUOUS_AUTO = 1,
102 private int cameraId = 0;
103 private int preferredWidth = 0;
104 private int preferredHeight = 0;
105 private bool flipHorizontal =
false;
106 private bool flipVertical =
false;
107 private byte[] cameraFrameBuffer = null;
119 if (Application.platform == RuntimePlatform.OSXEditor || Application.platform == RuntimePlatform.WindowsEditor)
130 switch (cameraResolution)
133 preferredWidth = 640;
134 preferredHeight = 480;
138 preferredWidth = 1280;
139 preferredHeight = 720;
143 preferredWidth = 1920;
144 preferredHeight = 1080;
148 preferredWidth = 640;
149 preferredHeight = 480;
153 Debug.Log(
"Camera id : " + cameraId);
155 if (Application.platform == RuntimePlatform.IPhonePlayer)
172 if (Application.platform == RuntimePlatform.IPhonePlayer)
187 if (Application.platform == RuntimePlatform.IPhonePlayer)
202 if (Application.platform == RuntimePlatform.IPhonePlayer)
219 if (Application.platform == RuntimePlatform.IPhonePlayer)
245 List<string> paramList =
new List<string>();
246 if (Application.platform == RuntimePlatform.IPhonePlayer)
249 for (
int i = 0; i < size; i++)
252 byte[] keyBytes =
new byte[keyLength];
254 string keyString = Encoding.UTF8.GetString(keyBytes).TrimEnd(
'\0');
255 paramList.Add(keyString);
261 for (
int i = 0; i < size; i++)
264 byte[] keyBytes =
new byte[keyLength];
266 string keyString = Encoding.UTF8.GetString(keyBytes).TrimEnd(
'\0');
267 paramList.Add(keyString);
281 public bool SetParam(
string key,
bool boolTypeValue)
283 if (Application.platform == RuntimePlatform.IPhonePlayer)
285 return NativeStaticAPI.CameraDevice_setBoolTypeParameter(key, boolTypeValue);
289 return NativeSharedAPI.CameraDevice_setBoolTypeParameter(key, boolTypeValue);
301 if (Application.platform == RuntimePlatform.IPhonePlayer)
303 return NativeStaticAPI.CameraDevice_setIntTypeParameter(key, intTypeValue);
307 return NativeSharedAPI.CameraDevice_setIntTypeParameter(key, intTypeValue);
320 if (Application.platform == RuntimePlatform.IPhonePlayer)
322 return NativeStaticAPI.CameraDevice_setRangeTypeParameter(key, min, max);
326 return NativeSharedAPI.CameraDevice_setRangeTypeParameter(key, min, max);
336 public bool SetParam(
string key,
string stringTypeValue)
338 if (Application.platform == RuntimePlatform.IPhonePlayer)
340 return NativeStaticAPI.CameraDevice_setStringTypeParameter(key, stringTypeValue);
344 return NativeSharedAPI.CameraDevice_setStringTypeParameter(key, stringTypeValue);
353 if (Application.platform == RuntimePlatform.IPhonePlayer)
368 if (Application.platform == RuntimePlatform.IPhonePlayer)
383 if (Application.platform == RuntimePlatform.IPhonePlayer)
393 internal void GetProjectionMatrix(
float[] matrix)
395 if (Application.platform == RuntimePlatform.IPhonePlayer)
401 NativeSharedAPI.CameraDevice_getProjectionMatrix(matrix);
405 internal bool IsFlipHorizontal()
407 return flipHorizontal;
410 internal bool IsFlipVertical()
415 internal byte [] GetCameraFrameBuffer()
417 if (cameraFrameBuffer == null)
421 if (cameraWidth > 0 && cameraHeight > 0)
423 cameraFrameBuffer =
new byte[cameraWidth * cameraHeight * 3];
427 if (cameraFrameBuffer != null)
429 TrackingState trackingState = TrackerManager.GetInstance().GetTrackingState();
430 NativeSharedAPI.CameraDevice_getCameraImagePtr(trackingState.GetTrackingStateCPtr(), cameraFrameBuffer);
433 return cameraFrameBuffer;
bool SetFlashLightMode(bool toggle)
Turn on/off flash light
ResultCode Start()
Start camera preview
static AbstractConfigurationScriptableObject GetInstance()
Get configuration asset instance
bool SetParam(string key, int min, int max)
Set camera parameter (Android only supported now)
void Stop()
Stop camera preview
void FlipVideo(FlipDirection direction, bool on)
Flip video background
bool SetFocusMode(FocusMode focusMode)
Set camera focus mode
CameraResolution
Supported camera resolution
CameraDevice.CameraType CameraType
Select camera type
int WebcamType
Select webcam type
bool SetParam(string key, string stringTypeValue)
Set camera parameter (Android only supported now)
static CameraDevice GetInstance()
Get a CameraDevice instance.
bool SetAutoWhiteBalanceLock(bool toggle)
Toggle auto white balance lock (Android only supported now)
CameraType
Supported camera type (Mobile only)
ResultCode
API call return value
List< string > GetParamList()
Get parameter key list (Android only supported now)
bool SetParam(string key, int intTypeValue)
Set camera parameter (Android only supported now)
Control the configuration asset file
bool SetParam(string key, bool boolTypeValue)
Set camera parameter (Android only supported now)
CameraDevice.CameraResolution CameraResolution
Select camera resolution
class for camera device handling
FocusMode
Camera focus mode