Skip to main content

ScanModule

Class

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

  • Available on all platforms
1 platform note
  • SnapchatFully supported
  • SPECSFully supported
  • Camera Kit WebFully supported
  • Camera Kit MobileFully supported

Applies to all platforms

  • Restricted when the Lens uses internet-connected APIs (see Privacy Restrictions).

Platform details

  • Snapchat — Fully supported.

  • SPECS — Fully supported.

  • Camera Kit Web — Fully supported.

  • Camera Kit Mobile — Fully supported.

  • All platforms. Restricted when the Lens uses internet-connected APIs (see Privacy Restrictions)

Since Lens Scripting v143Exposes 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.

Index

Example

//@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);
});

Extends

Properties

name

name: string

The name of the Asset in Lens Studio.

Default Value

""

Inherited from

Asset.name


scanTarget

scanTarget: Texture

Exposes user data

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

Since

Lens Scripting Version 143

Default Value

null
@exposesUserData

uniqueIdentifier

readonly uniqueIdentifier: string

Since

Lens Scripting Version 176

Inherited from

Asset.uniqueIdentifier

Methods

getTypeName()

static getTypeName(): TypeName<ScanModule>

Exposes user data

Returns the fully-qualified JavaScript type name for this class (for example, "Component.Camera"). This is a static accessor (no instance required) and returns the same value as the instance getTypeName().

Returns

TypeName<ScanModule>

Since

Lens Scripting Version 143

Overrides

Asset.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

Asset.getTypeName


isOfType()

isOfType(type): boolean

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

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

Asset.isOfType


isSame()

isSame(other): boolean

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

Parameters

ParameterType
otherScriptObject

Returns

boolean

Inherited from

Asset.isSame


scan()

scan(contexts, scanComplete, scanFailed): void

Exposes user data

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

ParameterType
contextsstring[]
scanComplete(resultJson) => void
scanFailed(failureMessage) => void

Returns

void

Since

Lens Scripting Version 143

See also

Scan Overview

Nested types

Namespaces

NamespaceDescription
Contexts-

Type Aliases

Type AliasDescription
Contexts-