ScanModule
ClassProvides 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
- 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).
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
Properties
Methods
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
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
readonlyuniqueIdentifier:string
Since
Lens Scripting Version 176
Inherited from
Methods
getTypeName()
staticgetTypeName():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
getTypeName()
getTypeName():
string
Returns the name of this object's type.
Returns
string
Inherited from
isOfType()
isOfType(
type):boolean
Returns true if the object matches or derives from the passed in type.
Parameters
| Parameter | Type |
|---|---|
type | string |
Returns
boolean
Inherited from
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
| Parameter | Type |
|---|---|
other | ScriptObject |
Returns
boolean
Inherited from
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
| Parameter | Type |
|---|---|
contexts | string[] |
scanComplete | (resultJson) => void |
scanFailed | (failureMessage) => void |
Returns
void
Since
Lens Scripting Version 143
See also
Nested types
Namespaces
| Namespace | Description |
|---|---|
| Contexts | - |
Type Aliases
| Type Alias | Description |
|---|---|
| Contexts | - |