Log in or register to post comments

How to set scan function to vedioplayback example in android

April 15, 2013 - 4:34am #1

Hi  using vedio playback example i am able to play vedios,but i waht i want is ? when camera activated that time i need to set scan funtion and after few seconds if targeted images correct means i need to display vedio otherwise i need to display one alert dailog   "No Target Image Found" like that please any one suggest me how to display that alert msg and scan action to vedioplayback sample application

 

 

 

              Thankyou 

How to set scan function to vedioplayback example in android

April 16, 2013 - 1:50am #7

thankyou frnds all your responses is correct toast masg is displaying when target image is detected.but what i need is i  have to scan image some time(few seconds ) after that if targetd image is correct means i need to display that image related toast msgs like "chips" other wise i have to display onother  toast msg "target image not match"  like that

How to set scan function to vedioplayback example in android

April 16, 2013 - 12:32am #6

Hi, this is because you just copy-pasted the code by replacing your previous renderFrame() function, but you actually need to integrate the code provided in the tutorial into your existing code (the one that is provided with the original ImageTargets code):

 // Did we find any targets this frame?
    for(int tIdx = 0; tIdx < state.getNumTrackableResults(); tIdx++)
    {
        // Get the target:
        const QCAR::TrackableResult* result = state.getTrackableResult( tIdx );
        const QCAR::Trackable& trackable = result->getTrackable();
        // Compare this target's id to a globally stored id
        // If this is a new target, find the displayMessage java method and
        // call it with the target's name
        if (trackable.getId() != lastTrackableId) {
            jstring js = env->NewStringUTF(trackable.getName());
            jclass javaClass = env->GetObjectClass(obj);
            jmethodID method = env->GetMethodID(javaClass, "displayMessage", "(Ljava/lang/String;)V");
            env->CallVoidMethod(obj, method, js);
            lastTrackableId = trackable.getId();
        }

Look at the original sample code, you will find a "for loop" similar to the one above; you just need to update that part of the code using the one above.

 

How to set scan function to vedioplayback example in android

April 16, 2013 - 12:10am #5

Thnkyou.i follewd your sended link but while building ndk i am facing below exception

 

 

Compile++ arm    : ImageTargets <= ImageTargets.cpp
jni/ImageTargets.cpp: In function 'void Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargetsRenderer_renderFrame(JNIEnv*, jobject)':
jni/ImageTargets.cpp:314:30: error: 'state' was not declared in this scope
/cygdrive/c/Development/Android/android-ndk-r8/build/core/build-binary.mk:272: recipe for target `obj/local/armeabi/objs/ImageTargets/ImageTargets.o' failed
make: *** [obj/local/armeabi/objs/ImageTargets/ImageTargets.o] Error 1
 
here what is state

How to set scan function to vedioplayback example in android

April 15, 2013 - 11:54pm #4

Hi, you can use this link below, which contains the correct code (the previous link is referring to some API of version 1.5):

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

 

How to set scan function to vedioplayback example in android

April 15, 2013 - 11:51pm #3

hi thankyou for your replay,displaying toast msg in imagetargets.cpp i pasetd below code insted of  renderFrame() but  while build ndk am getting exception

 

 

int lastTrackableId=-1;

JNIEXPORT void JNICALL

Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargetsRenderer_renderFrame(JNIEnv* env, jobject obj)

{

// Get the state from QCAR and mark the beginning of a rendering section

    QCAR::State state = QCAR::Renderer::getInstance().begin();

        // Explicitly render the Video Background

    QCAR::Renderer::getInstance().drawVideoBackground();

    // Did we find any trackables this frame?

    if (state.getNumActiveTrackables() == 0)

{

     lastTrackableId = -1;

}

    for(int tIdx = 0; tIdx < state.getNumActiveTrackables(); tIdx++)

    {

        // Get the trackable:

        const QCAR::Trackable* trackable = state.getActiveTrackable(tIdx);   

        // Compare this trackable's id to a globally stored id

        // If this is a new trackable, find the displayMessage java method and

        // call it with the trackable's name

        if (trackable->getId() != lastTrackableId) {

            jstring js = env->NewStringUTF(trackable->getName());

            jclass javaClass = env->GetObjectClass(obj);

            jmethodID method = env->GetMethodID(javaClass, "displayMessage", "(Ljava/lang/String;)V");

            env->CallVoidMethod(obj, method, js);

            lastTrackableId = trackable->getId();

        }   

    }

 

my cygwin log details:

 

Compile++ arm    : ImageTargets <= ImageTargets.cpp
jni/ImageTargets.cpp: In function 'void Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargetsRenderer_renderFrame(JNIEnv*, jobject)':
jni/ImageTargets.cpp:325:15: error: 'class QCAR::State' has no member named 'getNumActiveTrackables'
jni/ImageTargets.cpp:333:36: error: 'class QCAR::State' has no member named 'getNumActiveTrackables'
jni/ImageTargets.cpp:339:50: error: 'class QCAR::State' has no member named 'getActiveTrackable'
/cygdrive/c/Development/Android/android-ndk-r8/build/core/build-binary.mk:272: recipe for target `obj/local/armeabi/objs/ImageTargets/ImageTargets.o' failed
make: *** [obj/local/armeabi/objs/ImageTargets/ImageTargets.o] Error 1
 

How to set scan function to vedioplayback example in android

April 15, 2013 - 8:09am #2

Hi, the following article explains how to display a Toast message when a target is found;

https://developer.vuforia.com/resources/dev-guide/open-web-site-and-display-toast-target-detection

you could take inspiration from it to achieve what you are aiming for.

Also, a helpful reading is the Sample Code walk-through (see "Sample Specific Notes") at this page:

https://developer.vuforia.com/resources/sample-apps/video-playback-sample-app

The rest is about application logic.

 

Log in or register to post comments