@mattrayner/vuforia-recognition
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

@capacitor-community/vuforia-recognition

Use the Vuforia SDK to detect ImageTarget(s) and VuMark(s) on iOS and Android

Install

npm install @capacitor-community/vuforia-recognition
npx cap sync

## Setup Steps

  • Folder structure

Create test app

npm install @mattrayner/vuforia-recognition  
npx cap sync

### iOS

  • Bridging file setup
  • Add image

Notes

Trying to get VuMesh detected is a dick: - Try bridging file... Done - Add VuforiaEngine.framework/Headers to the Search Paths for headers, clieck 'ALL' at the top of the build settings page to see this

Android

local.properties SDK location

You may need to set your local Android SDK location to build the plugin uncomment the sample file (configured for MAC)

AndroidManifest.xml

Add the dollowing within the <application> tag. Update the !!!PACKAGE!!! value to match your projects

<activity
            android:name=".VuforiaActivity"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:rotationAnimation="seamless"
            android:label="@string/title_activity_vuforia"
            android:parentActivityName=".MainActivity"
            android:theme="@style/FullscreenTheme">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="!!!PACKAGE!!!.MainActivity" />
        </activity>

Add this after the </application> tag but before the </manifest> tag

<!-- Permissions -->
    <uses-feature android:glEsVersion="0x00030001" android:required="true" />

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

    <!--
        Required by Vuforia: Add this permission to get access to the camera.
    -->
    <uses-permission android:name="android.permission.CAMERA" />

    <!--
        Required by Vuforia: Add this permission to access IMU sensors at high rate
        for device tracker functionality on Android 12+.
    -->
    <uses-permission android:name="android.permission.HIGH_SAMPLING_RATE_SENSORS" />

    <!--
        Required by Vuforia: Add this permission to allow checking of network.
    -->
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <!--
        Required by Vuforia: Add this permission to allow opening network sockets.
    -->
    <uses-permission android:name="android.permission.INTERNET"/>

API

startVuforia(...)

startVuforia(options: VuforiaStartOptions) => Promise<void>

Start a Vuforia session searching for Image Target(s) and VuMarks.

Param Type
options VuforiaStartOptions

Since: 1.0.0


stopVuforia()

stopVuforia() => Promise<void>

Stop the current Vuforia session.

But why?

Well, you could pair this with a setTimeout to give users a certain amount of time to search for an image. Or you can pair it with the autostopOnImageFound option within startVuforia to have more granular control over when the Vuforia camera actually stops.

Since: 1.0.0


addListener('vuforiaEvent', ...)

addListener(eventName: 'vuforiaEvent', listenerFunc: (event: VuforiaEvent) => void) => Promise<PluginListenerHandle> & PluginListenerHandle

Add a listener for events within Vuforia.

Param Type
eventName 'vuforiaEvent'
listenerFunc (event: VuforiaEvent) => void

Returns: Promise<PluginListenerHandle> & PluginListenerHandle

Since: 1.0.0


removeAllListeners()

removeAllListeners() => Promise<void>

Remove all event listeners

Since: 1.0.0


Interfaces

VuforiaStartOptions

Configuration object passed to Vuforia, used to configure license and detection.

What if I don't want Image Target or VuMark recognition?

Providing an empty target list for either Image Targets, or VuMarks will prevent detection of that type. You must provide either Image Targets, VuMarks, or both. Not providing either will preent the plugin from running.

Prop Type Description Default Since
vuforiaLicense string Vuforia license key from http://developer.vuforia.com. 1.0.0
imageTargetDatabaseXmlFile string Path to your Vuforia Image Target database (.xml) file. "" 1.0.0
imageTargetTargetList string[] List of targets within the database that you are searching for. [] 1.0.0
vuMarkDatabaseXmlFile string Path to your Vuforia VuMark template database (.xml) file. "" 1.0.0
vuMarkTargetList string[] List of VuMark templates within the database that you are searching for. [] 1.0.0
autostopOnImageFound boolean Should the Vuforia session end when a target has been found. true 1.0.0

PluginListenerHandle

Prop Type
remove () => Promise<void>

VuforiaEvent

Event object returned from within Vuforia when a target is found, or the session is manually closed.

Prop Type Description Since
status VuforiaEventStatus Object describing the event. 1.0.0
result VuforiaEventResult Object containing the detected result. 1.0.0

VuforiaEventStatus

Prop Type Description Since
manuallyClosed boolean Was the Vuforia session manually closed? 1.0.0
imageTargetFound boolean Was an Image Target found? 1.0.0
vuMarkFound boolean Was a VuMark found? 1.0.0
message string A brief message from Vufora describing the event. 1.0.0

VuforiaEventResult

Prop Type Description Default Since
imageTargetName string The Image Target name (if detected). "" 1.0.0
vuMarkName string The VuMark template name (if detected). "" 1.0.0

Readme

Keywords

Package Sidebar

Install

npm i @mattrayner/vuforia-recognition

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

159 MB

Total Files

212

Last publish

Collaborators

  • mattrayner