1.0.1 • Published 2 years ago

@mattrayner/vuforia-recognition v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@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.

ParamType
optionsVuforiaStartOptions

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.

ParamType
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.

PropTypeDescriptionDefaultSince
vuforiaLicensestringVuforia license key from http://developer.vuforia.com.1.0.0
imageTargetDatabaseXmlFilestringPath to your Vuforia Image Target database (.xml) file.""1.0.0
imageTargetTargetListstring[]List of targets within the database that you are searching for.[]1.0.0
vuMarkDatabaseXmlFilestringPath to your Vuforia VuMark template database (.xml) file.""1.0.0
vuMarkTargetListstring[]List of VuMark templates within the database that you are searching for.[]1.0.0
autostopOnImageFoundbooleanShould the Vuforia session end when a target has been found.true1.0.0

PluginListenerHandle

PropType
remove() => Promise<void>

VuforiaEvent

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

PropTypeDescriptionSince
statusVuforiaEventStatusObject describing the event.1.0.0
resultVuforiaEventResultObject containing the detected result.1.0.0

VuforiaEventStatus

PropTypeDescriptionSince
manuallyClosedbooleanWas the Vuforia session manually closed?1.0.0
imageTargetFoundbooleanWas an Image Target found?1.0.0
vuMarkFoundbooleanWas a VuMark found?1.0.0
messagestringA brief message from Vufora describing the event.1.0.0

VuforiaEventResult

PropTypeDescriptionDefaultSince
imageTargetNamestringThe Image Target name (if detected).""1.0.0
vuMarkNamestringThe VuMark template name (if detected).""1.0.0
1.0.1

2 years ago

1.0.0

2 years ago