com.google.ar.core.Config Java Examples

The following examples show how to use com.google.ar.core.Config. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ARUtils.java    From unity-ads-android with Apache License 2.0 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.KITKAT)
public static JSONObject getConfigEnums() {
	JSONObject enums = new JSONObject();

	try {
		ArrayList<String> values = new ArrayList<>();
		for (Config.LightEstimationMode lem: Config.LightEstimationMode.values()) {
			values.add(lem.name());
		}
		enums.put("lightEstimationMode", new JSONArray(values.toArray()));

		values.clear();
		for (Config.PlaneFindingMode pfm: Config.PlaneFindingMode.values()) {
			values.add(pfm.name());
		}
		enums.put("planeFindingMode", new JSONArray(values.toArray()));

		values.clear();
		for (Config.UpdateMode um: Config.UpdateMode.values()) {
			values.add(um.name());
		}
		enums.put("updateMode", new JSONArray(values.toArray()));
	} catch (JSONException ignored) {}

	return enums;
}
 
Example #2
Source File: AugmentedImageFragment.java    From science-journal with Apache License 2.0 5 votes vote down vote up
@Override
protected Config getSessionConfiguration(Session session) {
  Config config = super.getSessionConfiguration(session);
  config.setFocusMode(Config.FocusMode.AUTO);
  if (!setupAugmentedImageDatabase(config, session)) {
    Log.e(TAG, "Could not setup augmented image database");
  }
  return config;
}
 
Example #3
Source File: ARUtils.java    From unity-ads-android with Apache License 2.0 5 votes vote down vote up
public static int isSupported(Context context) {
	if (!ARCheck.isFrameworkPresent()) {
		return AR_CHECK_NOT_SUPPORTED;
	}

	if (planeFindingModes == null) {
		planeFindingModes = Config.PlaneFindingMode.values();
		lightEstimationModes = Config.LightEstimationMode.values();
		updateModes = Config.UpdateMode.values();
	}

	ArCoreApk.Availability availability = ArCoreApk.getInstance().checkAvailability(context);
	if (availability.isTransient()) {
		return AR_CHECK_TRANSIENT;
	}

	// ARCore APK might be side loaded onto the device. In that case, the availability check
	// will return SUPPORTED_INSTALLED but session creation will still fail. We try creating a
	// session here, just to make sure the device supports ARCore.
	// Anything other than SUPPORTED_INSTALLED is considered unsupported in our case, because
	// we don't want to prompt an install dialog before showing an ad.
	if (availability == ArCoreApk.Availability.SUPPORTED_INSTALLED) {
		try {
			//noinspection unused
			Session session = new Session(context);
		} catch (FatalException | UnavailableException e) {
			return AR_CHECK_NOT_SUPPORTED;
		} catch (SecurityException ignored) {
			// Session creation failed because we don't have camera permission yet.
			// This can be ignored.
		}

		return AR_CHECK_SUPPORTED;
	}

	return AR_CHECK_NOT_SUPPORTED;
}