Wikitude SDK API Reference

API Docs for: 8.2.0
Show:

hardware Class

Module: AR

hardware includes some general functions which allow interaction with the device itself.

The Singleton instance of the class will automatically be created on World startup and can be accessed via AR.hardware.

Example:
AR.hardware.camera.position = AR.CONST.CAMERA_POSITION.FRONT

Methods

camera.setExposurePointOfInterest

(
  • point
)

Sets the screen coordinate at which the camera should expose at. Setting a manual exposure point might change the active exposure mode to Once, depending on the platform and underlying camera functionality.

The input value for this property can either be defined manually or through e.g. the AR.context.onScreenClick callback result. This means that it doesn't necessarily has to be the location at which the user tapped. The parameter set has to be an object containing a x and y property e.g. {x: 100, y:100}. The value of x and y is a pixel coordinate of the screen ranging from 0/0 to screen.width/screen.height.

Parameters:

  • point Object

    as object containing a x and y coordinates e.g. {x: 100, y:100}

camera.setFocusPointOfInterest

(
  • point
)

Sets the screen coordinate at which the camera should focus at. Setting a manual focus point might change the active focus mode to Once on iOS and will only work if the focus mode is Once on Android.

The input value for this property can either be defined manually or through e.g. the AR.context.onScreenClick callback result. This means that it doesn't necessarily has to be the location at which the user tapped. The parameter set has to be an object containing a x and y property e.g. {x: 100, y:100}. The value of x and y is a pixel coordinate of the screen ranging from 0/0 to screen.width/screen.height.

Parameters:

  • point Object

    as object containing a x and y coordinates e.g. {x: 100, y:100}

smart.isPlatformAssistedTrackingSupported

()

Starts a querying process that determines whether platform assisted tracking is supported or not. The current status will be reported through the onPlatformAssistedTrackingAvailabilityChanged in regular intervals.

You may call call this function multiple times without adverse effects. The onPlatformAssistedTrackingAvailabilityChanged callback function will only be invoked a single time per interval cycle regardless. The iOS implementation of this querying procedure will return a definitive result immediately. The Android implementation may takes several cycles of the interval to reach a conclusion about whether platform tracking support is available or not.

Properties

camera.enabled

Boolean

Controls if the camera is active or not.

If the property is set to true, the camera is visible on the screen, and computer vision components are activated. If the property is set to false, the camera will be disabled, a black background will be visible and computer vision components are specifically deactivated.

It is recommended to disable the camera service temporarily when fullscreen HTML is shown. This reduces power consumption and increases performance.

Default: true

camera.features

Object

Queries the capabilities of the device camera, returns informations about min and max zoom levels, supported camera positions, and focus modes.

camera.flashlight

Boolean

Turns the device flashlight on or off. Use the isFlashlightAvailable property to check if the device has a flashlight or not. If the device has no flashlight and the property is set to true, this will have no effect.

Default: false

camera.flashlightAvailable

Boolean

true if the device has a flashlight, false otherwise.

Note that the following permissions are required on Android:

<uses-permission android:name="android.permission.FLASHLIGHT"/>
<uses-feature android:name="android.hardware.camera.flash" />

Default: false

camera.focusDistance

Number

Sets the focus distance of the camera. Use a value between 0 and 100 where 0 is infinity focus and 100 is the shortest distance from frontmost surface of the lens that can be brought into sharp focus.

Default: 0

camera.focusMode

Object

Sets the autofocus mode of the camera, possible values are ONCE to start one-shot autofocus or CONTINUOUS to keep adjusting focus automatically.

Default: AR.CONST.CAMERA_FOCUS_MODE.CONTINUOUS

camera.manualFocusAvailable

Boolean

true if the current camera supports manual focus, false otherwise.

Default: false

camera.onError

Function

onError will be triggered when a camera setting could not be applied.

The trigger is null by default, and will thus result in no action executed when the trigger fires. A developer can add custom functionality by assigning a custom function to onError.

camera.position

Object

Sets the active camera position, possible values are FRONT or BACK.

Default: AR.CONST.CAMERA_POSITION.BACK

camera.zoom

Number

Sets the zoom level of the camera. Use a value of 1 for no zoom. If a particular value is not supported, a "best match" will be used.

Default: 1

sensors.compass.correctionAngle

Number

Defines a correction angle clockwise of the compass in degrees. Values will be applied modulo 360. A value of 361 degrees has the same effect as setting the value to 1 degree.

Default: 0

sensors.enabled

Boolean

Controls if the sensors are active or not. Sensors include GPS, mangetometer, accelerometer and gyroscope.

If the property is set to true, any geo-related components (such as GeoObjects and ActionRanges) are active. If the property is set to false, any geo-related components will not be visible on the screen, and triggers will not fire.

It is recommended to disable the sensors when only computer vision components are used. This reduces power consumption and increases performance.

Default: true

smart.onPlatformAssistedTrackingAvailabilityChanged

Function

This callback function will be invoked at regular intervals after a querying process has been initiated by calling isPlatformAssistedTrackingSupported. Once a conclusive state has been reached, it will not longer be called.

SmartAvailability

Object

The current state of the platform assisted tracking availability query will be communicated using one of the following values:

  • INDETERMINATE_QUERY_FAILED - The query failed for some reason. You may try again or run without platform assisted tracking enabled. The callback will not be called again.
  • CHECKING_QUERY_ONGOING - The query is currently ongoing. Be patient and wait for the callback to be called again. Meanwhile, it might be a good idead to inform the user about the ongoing process.
  • UNSUPPORTED - The query has reached a conclusion; platform assisted tracking is not supported. Continue without platform assisted tracking enabled or not at all, depending on your requirements. The callback will not be called again.
  • SUPPORTED_UPDATE_REQUIRED - The query has reached a conclusion; platform assisted tracking is supported, but an update is required. Create the tracker with platform assisted tracking enabled to install the update. The callback MIGHT be called again with SUPPORTED. Take care not to create the tracker multiple times.
  • SUPPORTED - The query has reached a conclusion; platform assisted tracking is supported. The callback will not be called again.