MaxstARSDK  3.5.0
All Classes Functions Variables
CameraDevice.java
1 /*
2  * Copyright 2016 Maxst, Inc. All Rights Reserved.
3  */
4 package com.maxst.ar;
5 
6 import java.util.Arrays;
7 import java.util.List;
8 
12 public class CameraDevice {
13 
14  private static CameraDevice instance = null;
15 
16  public enum FlipDirection {
17  HORIZONTAL(0),
18  VERTICAL(1);
19 
20  private int value;
21 
22  FlipDirection(int value) {this.value = value;}
23  public int getValue() { return value;}
24  }
25 
31  public enum FocusMode {
32  FOCUS_MODE_CONTINUOUS_AUTO(1),
33  FOCUS_MODE_AUTO(2);
34 
35  private int value;
36 
37  FocusMode(int value) {
38  this.value = value;
39  }
40 
41  public int getValue() {
42  return value;
43  }
44  }
45 
46  public static CameraDevice getInstance() {
47  if(!MaxstAR.isInitialized()) {
48  throw new RuntimeException("MaxstAR has not been initialized!");
49  } else {
50  if (instance == null) {
51  instance = new CameraDevice();
52  }
53 
54  return instance;
55  }
56  }
57 
58  private CameraDevice() {}
59 
67  public ResultCode start(int cameraId, int width, int height) {
68  int startResult = MaxstARJNI.CameraDevice_start(cameraId, width, height);
69  return ResultCode.getCodeFromInt(startResult);
70  }
71 
75  public void stop() {
76  MaxstARJNI.CameraDevice_stop();
77  }
78 
87  public void setNewFrame(byte[] data, int length, int width, int height, ColorFormat format) {
88  if (MaxstARJNI.getLicenseType() == 2) {
89  MaxstARJNI.CameraDevice_setNewFrame(data, length, width, height, format.getValue());
90  } else {
91  try {
92  throw new Exception("Set external camera image is activated only enterprise license!!");
93  } catch (Exception e) {
94  e.printStackTrace();
95  }
96  }
97  }
98 
104  public boolean setFocusMode(FocusMode focusMode) {
105  return MaxstARJNI.CameraDevice_setFocusMode(focusMode.getValue());
106  }
107 
113  public boolean setFlashLightMode(boolean toggle) {
114  return MaxstARJNI.CameraDevice_setFlashLightMode(toggle);
115  }
116 
122  public boolean setAutoWhiteBalanceLock(boolean toggle) {
123  return MaxstARJNI.CameraDevice_setAutoWhiteBalanceLock(toggle);
124  }
125 
131  public void flipVideo(FlipDirection direction, boolean toggle) {
132  MaxstARJNI.CameraDevice_flipVideo(direction.getValue(), toggle);
133  }
134 
139  public List<String> getParamList() {
140  return Arrays.asList(MaxstARJNI.CameraDevice_getParamList());
141  }
142 
149  public boolean setParam(String paramKey, boolean paramValue) {
150  return MaxstARJNI.CameraDevice_setBoolTypeParameter(paramKey, paramValue);
151  }
152 
159  public boolean setParam(String paramKey, int paramValue) {
160  return MaxstARJNI.CameraDevice_setIntTypeParameter(paramKey, paramValue);
161  }
162 
170  public boolean setParam(String paramKey, int min, int max) {
171  return MaxstARJNI.CameraDevice_setRangeTypeParameter(paramKey, min, max);
172  }
173 
180  public boolean setParam(String paramKey, String paramValue) {
181  return MaxstARJNI.CameraDevice_setStringTypeParameter(paramKey, paramValue);
182  }
183 
188  public float [] getProjectionMatrix() {
189  float [] projection = new float[16];
190  MaxstARJNI.CameraDevice_getProjectionMatrix(projection);
191  return projection;
192  }
193 
198  float [] projection = new float[16];
199  MaxstARJNI.CameraDevice_getBackgroundPlaneProjectionMatrix(projection);
200  return projection;
201  }
202 }
boolean setFlashLightMode(boolean toggle)
void setNewFrame(byte[] data, int length, int width, int height, ColorFormat format)
boolean setParam(String paramKey, int paramValue)
static boolean isInitialized()
Definition: MaxstAR.java:33
boolean setParam(String paramKey, int min, int max)
boolean setAutoWhiteBalanceLock(boolean toggle)
ResultCode start(int cameraId, int width, int height)
void flipVideo(FlipDirection direction, boolean toggle)
boolean setParam(String paramKey, String paramValue)
boolean setParam(String paramKey, boolean paramValue)
float [] getBackgroundPlaneProjectionMatrix()
List< String > getParamList()
boolean setFocusMode(FocusMode focusMode)