Lens Scripting API

    Class ScanModuleExposes User Data

    Provides access to a Scan system that allows users to scan objects, places, and cars with a database of item labels within a Lens.

    //@input Asset.ScanModule scanModule
    //@input Asset.Texture someTexture

    function scanComplete(json)
    {
    var obj = JSON.parse(json);
    var annotations = obj["annotations"][ScanModule.Contexts.Objects]["annotations"];
    if(annotations.length > 0 && annotations[0].confidence > 0.95)
    {
    print("Scan found: " + annotations[0].name);
    }
    }

    function onFailure(reason)
    {
    print("Scan failure: " + reason);
    }

    //if not filled via GUI
    script.scanModule.targetTexture = script.someTexture;

    script.createEvent("LongPressStartEvent").bind(function() {
    script.scanModule.scan([ScanModule.Contexts.Objects], scanComplete, onFailure);
    });

    Hierarchy (View Summary, Expand)

    Index

    Constructors

    Properties

    name: string

    The name of the Asset in Lens Studio.

    scanTarget: Texture

    Optional property to pass in a texture for Scan to use.

    uniqueIdentifier: string

    Methods

    • Returns the name of this object's type.

      Returns string

    • Returns true if the object matches or derives from the passed in type.

      Parameters

      • type: string

      Returns boolean

    • Returns true if this object is the same as other. Useful for checking if two references point to the same thing.

      Parameters

      Returns boolean

    • Starts a single Scan call using the provided list of ScanModule.Contexts. On success it will invoke scanComplete providing a JSON string. On failure it will invoke onFailure with a failure message passed in as an argument.

      Parameters

      • contexts: string[]
      • scanComplete: (resultJson: string) => void
      • scanFailed: (failureMessage: string) => void

      Returns void

    MMNEPVFCICPMFPCPTTAAATR