Pre-10.0 Engine API documentation for Native

Hello,

Please find the native (C++) API documentation for the pre-10.0 Engine release (v9.8) here:

https://library.vuforia.com/sites/default/files/references/9.8/cpp/index.html

Thanks,

Vuforia Engine Support

Loading large datasets in Android

Hello,

It has come to our attention that changes in the behavior of the Android Build Tools (starting with version 25? we are unclear on the exact number) can affect the performance of device database loading times of the Vuforia SDK.

For smaller databases (less than 10 images), the effect may not be noticeable. However, for larger databases, the time to load can take several seconds or longer. 

Our analysis has determined that the updated Android Build Tools are now compressing the device database files within the APK, rather than just storing them in their native size as downloaded from the Vuforia Target Manager. As the .dat component of the Vuforia device database is already a zip file in itself, the compression produces little gains with respect to the overall size of the APK, but can be costly when reading the data upon app start.

We found that the compression of the .dat file can be prevented by adding the following to the build.gradle file:

aaptOptions {

        noCompress 'dat'

}

Note that loading device databases from external sources (such as /sdcard, or the app's private file space) are not affected by this change. It is particular to device databases that are packaged with the APK.

Thanks,

Vuforia Support

 

Load dataset from Android split binary (obb)

A previous thread has described a few different approaches to handling an Android app that exceeds 100mb in size: https://developer.vuforia.com/forum/faq/unity-how-can-i-handle-large-android-apps

This thread will provide a small example of how to load a dataset from the obb file when using the split binary option.

Create a new Unity project and import the Vuforia SDK and Vuforia Sample Project. Download here: https://developer.vuforia.com/downloads/sdk

Vuforia Configuration

  •     Enter your license key
  •     Make sure your dataset is loaded and activated (in this example I will be using the StonesAndChips dataset present in the sample project)

Player Settings -> Android Settings

  •     Other Settings: Set "Write Permissions" to "External (SDCard)"
  •     Publishing Settings: Check the "Split Application Binary" box

Once the above is all set up, copy the code at the bottom of this post (ObbExtractor.cs) and create a new scene. In this scene, create a new script with the code below and attach it to an object. This scene will need to be run before Vuforia is initialized to function properly.

For this example, add the Vuforia sample project scenes to the build settings' "Scenes in Build" and then add this extra scene with the ObbExtractor at the top of the list of scenes. This will start the app in this scene and allow the datasets to be extracted before moving on to the Vuforia initialization in the following scenes. The sample script provided in this case will automatically load the scene "Vuforia-0-Splash" when the extraction has been completed.

Once Vuforia has been loaded, the image target for the StonesAndChips dataset will be ready to go.

using System.IO;
using System.Collections;
using UnityEngine;
using UnityEngine.SceneManagement;


public class ObbExtractor : MonoBehaviour {

    void Start () {
        StartCoroutine(ExtractObbDatasets());
    }

    private IEnumerator ExtractObbDatasets () {
        string[] filesInOBB = {"VuforiaMars_Images.dat", "VuforiaMars_Images.xml"};
        foreach (var filename in filesInOBB) {
            string uri = Application.streamingAssetsPath + "/Vuforia/" + filename;

            string outputFilePath = Application.persistentDataPath + "/Vuforia/" + filename;
            if(!Directory.Exists(Path.GetDirectoryName(outputFilePath)))
                Directory.CreateDirectory(Path.GetDirectoryName(outputFilePath));

            var www = new WWW(uri);
            yield return www;

            Save(www, outputFilePath);
            yield return new WaitForEndOfFrame();
        }

        // When done extracting the datasets, Start Vuforia AR scene
        SceneManager.LoadScene( "0-Splash" );
    }

    private void Save(WWW w, string outputPath) {
        File.WriteAllBytes( outputPath, w.bytes );

        // Verify that the File has been actually stored
        if( File.Exists( outputPath ) )
        {
            Debug.Log( "File successfully saved at: " + outputPath );
        }
        else
        {
            Debug.Log( "Failure!! - File does not exist at: " + outputPath );  
        }
    }
}

This code will pull the StonesAndChips .dat and .xml files from the obb and output them in the applications persistentDataPath, allowing them to be loaded once Vuforia is initialized. This code will need to run before Vuforia is initialized.

Edit (March 7, 2018): Updated dataset reference to Mars datasets used in current versions of SDK. Updated StreamingAssets path to point to the "Vuforia" sub-directory as "QCAR" is no longer used post Vuforia 6.5. Updated the name of the scene to load into as this has changed in our samples.

Video Playback on Texture - Black screen appears at beginning for a moment

Issue explanation: a blank screen appears for a few moments (it's usually less than half a second), after the target was detected

When?: right after a target is detected, and the video is right about to start (PLAYING state)

Known issues: there seems to be a similar issue in Unity (check https://developer.vuforia.com/forum/unity-3-extension-technical-discussion/video-playback-black-screen-appears-moment).

How to solve? Well, the solution is based on NalinS' idea: try to delay a few frames the render of the contents

Just go to VideoPlaybackRenderer.java, inside renderFrame method, and replace this:

if ((currentStatus[currentTarget] == VideoPlayerHelper.MEDIA_STATE.READY)               || (currentStatus[currentTarget] == VideoPlayerHelper.MEDIA_STATE.REACHED_END)               || (currentStatus[currentTarget] == VideoPlayerHelper.MEDIA_STATE.NOT_READY)               || (currentStatus[currentTarget] == VideoPlayerHelper.MEDIA_STATE.ERROR)){    .....} else {    .....} with this: if ((currentStatus[currentTarget] == VideoPlayerHelper.MEDIA_STATE.READY)               || (currentStatus[currentTarget] == VideoPlayerHelper.MEDIA_STATE.REACHED_END)               || (currentStatus[currentTarget] == VideoPlayerHelper.MEDIA_STATE.NOT_READY)               || (currentStatus[currentTarget] == VideoPlayerHelper.MEDIA_STATE.ERROR)){    .....} else {    mFramesPlayed++;    if (mFramesPlayed < MAX_FRAMES_TO_JUMP) return;    .....} You will also have to add a new class member:private int mFramesPlayed = 0; And a constant to define how many frames you'd like to eat from the beginning of the video:private static final int MAX_FRAMES_TO_JUMP = 10;  Hope this helps someone!

Using Android Studio with Vuforia

If you are using or planning to use the Android Studio IDE, here are some notes about how to import and build the Vuforia samples:

  • Read our Getting Started Guide for instructions on setting up the Java SDK, Android SDK and NDK:
  • Make sure you have installed the latest version available of Android Studio from:
  • Use the Android SDK Manager (from within Android Studio) to get the latest Android SDK and Platform tools
  • Launch Android Studio
  • Select File - > Import Project ...
  • Select "Create Project from Existing Source" and select the "ImageTargets-x-y-z" sample directory (or any other Vuforia sample) to import the sample project
  • In the Project view, right-click on the Project and select "Open Module Settings..."
  • In the dialog window that opens, select "Modules" and then select the "Dependenciestab
  • Click on the "+" icon to add a new dependency, and select "Jars and directories..."
  • Browse to the QCAR.jar under your vuforia installation directory (e.g., "C:\Development\Android\vuforia-sdk-2-5-7\build\java\QCAR.jar")
  • Click Apply
  •  
  • Compile the project
  • Build the native code using the cygwin console and ndk-build (as explained in our Getting Started guide)
  • Run the app on your device

Note: as reported on the Android website:

Android Studio is currently available as anearly access preview. Several features are either incomplete or not yet implemented and you may encounter bugs. If you are not comfortable using an unfinished product, you may want to instead download (or continue to use) the ADT Bundle(Eclipse with the ADT Plugin).

 

 

AlessandroB

Mon, 01/04/2016 - 17:34

UPDATE:

The Vuforia 5.0.10 Android Samples support the Android Studio IDE and come already packaged with the correct project format.

Vuforia and Android - Common topics

This is a list of common questions, issues and how-to topics related to using the Vuforia SDK onm the Android platform:

  • How to replace the sample Dataset with a custom Dataset in the Image Targets sample:

https://developer.vuforia.com/forum/faq/android-how-do-i-replace-dataset-image-targets-sample

  • How to capture a screenshot of the AR view (video background and 3D augmentation):

https://developer.vuforia.com/forum/faq/android-how-can-i-capture-ar-view

  • How to fix common compile and runtime errors with Vuforia Android samples:

https://developer.vuforia.com/forum/faq/android-how-do-i-fix-my-compile-or-runtime-errors

  • How to update the UI in response to tracking events:

https://developer.vuforia.com/forum/faq/android-how-can-i-update-my-ui-response-tracking-events

  • How to call Java methods from C++:

https://developer.vuforia.com/forum/faq/android-how-can-i-call-java-methods-c

  • Threading issues:

https://developer.vuforia.com/forum/faq/android-which-methods-are-called-ui-vs-opengl-thread

https://developer.vuforia.com/forum/faq/android-how-threading-implemented-samples

  • How to compute the distance of the target from the camera:

https://developer.vuforia.com/forum/faq/android-how-can-i-calculate-distance-target

 

Vuforia, Android and OpenGL ES

 

OpenGL ES is the standard for rendering 3D content on mobile platforms.

The Vuforia samples show you how to set up an OpenGL rendering context and render simple 3D content (e.g. static, textured models) using OpenGL ES 1.1 or 2.0. 

For issues concerning OpenGL ES rendering please consult these pages:

https://developer.vuforia.com/forum/rendering-opengl-es/vuforia-and-opengl-es

https://developer.vuforia.com/forum/ar-technical-discussion/rendering-opengl-es 

https://developer.vuforia.com/forum/ar-technical-discussion/rendering-opengl-es

How do I fix my compile or runtime errors

 

The general procedure on how to build and run a Vuforia sample app is described in this page:

https://developer.vuforia.com/resources/dev-guide/step-3-compiling-running-vuforia-sample-app

If after reading the developer guide, you are still facing compile or runtime errors, make sure to check the issues below.

 

UnsatisfiedLinkError

If you observe runtime errors where the message indicates that some links are unresolved (similar to the one reported here below):

02-25 15:00:48.270: E/AndroidRuntime(31474): java.lang.UnsatisfiedLinkError: …

or if you the error message indicates that some libraries are missing, like in this message:

the library libQCAR.so could not be loaded

those error messages typically indicate that you have not built the native (C++) part of your Android project; to fix the issue you can open a command console (e.g. cygwin), change directory to your project root and type:

ndk-build

After ndk-build has successfully built the native code, you should see the \libs folder appearing under your project directory; in Eclipse, make sure to refresh your project (right-click on the project and select Refresh or simply press F5) and then run the app again.

Note:

in case you renamed the Java package and/or class names, you might get an UnsatisfiedLinkError due to the fact that you did not rename the C++ native functions accordingly; for instance, if your package name is:

com.my.company.ImageTargets (instead of com.qualcomm.QCARSamples.ImageTargets);

and your main Java class is called:

com.my.company.ImageTargets.ImageTargets  (instead ofcom.qualcomm.QCARSamples.ImageTargets.ImageTargets),

then the native functions will have to be renamed like in this example:

Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_initApplicationNative

must be renamed to:

Java_com_my_company_ImageTargets_ImageTargets_initApplicationNative

Then, as usual, remember to run ndk-build again and refresh the Java project in Eclipse.

 

Could not find method

If you get a runtime error with a message similar to the following:

unable to resolve static method XY: …

or similar to the following:

Could not find method com.qualcomm.QCAR.QCAR.someMethod…

The problem might be with your QCAR_SDK_ROOT variable; in this case you need to verify whether your QCAR_SDK_ROOT has been defined and whether it is pointing to the correct path (for instance, if you upgrade to a newer version of the Vuforia SDK, the QCAR_SDK_ROOT might still point to an older version, such as V1.5).

To verify this (in Eclipse), open the Window menu and select Preferences / Java / Build Path / Classpath Variables; you should see a list of symbols, including QCAR_SDK_ROOT; if you don’t see it, add it to the list and set its value to the path of your Vuforia library (for instance “C:\Development\Android\vuforia-sdk-2-0-30\”); if it is already defined, make sure that the path corresponds to the actual location of your latest Vuforia installation directory.

Another possible cause could be that the QCAR jar file is not exported with your APK when the app is deployed on your device; to enforce that, right-click on your project, select Properties / Java Build Path / Order and Exportand make sure to check (tick) the checkbox for QCAR_SDK_ROOT; then press Apply/OK and clean/rebuild the project.

 

Compliance level

If you get the following error message upon importing a Vuforia sample project into Eclipse:

Android requires compiler compliance level 5.0 or 6.0. Found '1.7' instead. Please use Android Tools > Fix Project Properties.

you can fix this by simply right-clicking the project, and selecting Android Tools -> Fix Project Properties.

 

No matching EGL configs

If you get an error with the following (or similar) message:

02-11 08:56:29.312: E/AndroidRuntime(878): FATAL EXCEPTION: GLThread 83

02-11 08:56:29.312: E/AndroidRuntime(878): java.lang.IllegalArgumentException: No matching EGL configs

 

the most likely reason for such error is that you are trying to run a Vuforia application on the Android emulator (on a “virtual device”); Vuforia requires a real device, it cannot be run on the Android emulator.

Web Game Development Company

Platform

Get a competitive edge through our mobile game development outsourcing services and an appealing game solution with quality performance that fits your unique business requirements. Collaborate with us to simplify your game development process because we are actively involved in your projects to make your ideas come true. [url=https://www.cubix.co/web-game-development]Web Game Development Company[/url]

How to find free audiobooks online

You can also search for free audiobooks at https://horbuchkostenlos.de/. This site offers over 300,000 free audiobooks, including the latest bestsellers. These audiobooks can be viewed and returned as regular library books. You can also subscribe to new releases, read book descriptions, and listen to chapters by chapter without downloading the entire book. You can also search for a specific author by last name. Whether you like novels or classics, you're sure to find a free audiobook to enjoy.

Another great place to find free audiobooks is the iTunes Store. The iTunes Store has over 90 podcasts, including free audiobooks. If you are a fan of religious stories, this site is perfect for you. You can easily download free audiobooks whether you want to learn about a religion or just want to have a good laugh. You can even sign up for a subscription service to receive regular free audiobooks.