Log in or register to post comments

Open URL upon image recognition

July 7, 2013 - 11:38pm #1

I need help figuring out what should I do in order to make the Cloud Recognition sample open a URL directly when an image is detected.

What code should i modify and how?
thank you

Open URL upon image recognition

May 24, 2017 - 1:31am #12

how to display image when we recognize an image https://www.youtube.com/watch?v=WG3rtib2tVc i am trying in this manner

Open URL upon image recognition

August 26, 2013 - 11:04pm #11

Hi again,

now all works fine, when a trackable is detected the toast with the image's name appear correctly, but I have another doubt...

My objective it's only take the image's name and open a URL like www.sitename.com/name=? and append to this url image's name, for make it no problem it's very easy.

But in CloudRecognition demo there are a lot of instructions that use book in java and in c++ code, I'm afraid that deleting code will cause crash in application or other problem, there is a list of instructions that are dedicated to this demo and that I can/must delete without problem?

Someone can help me to individuate them?

Thanks in advance.

Luca

Open URL upon image recognition

August 26, 2013 - 12:45pm #10

Thanks for your reply.

Now I've correct to this:

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

Scuse me for the stupid question ;-)

Thanks

Luca

Open URL upon image recognition

August 26, 2013 - 12:28pm #9

That's a syntax error, occuring in the _renderFrame method. What is on line 294 at character 40?

Open URL upon image recognition

August 26, 2013 - 11:52am #8

Hi,

I'm trying to modify this code for make the same action that are posted in object of this post but I've some difficulties.

I've modified the code that work for ImageTarget and my code is this:

// ----------------------------------------------------------------------------
// renderFrame Method - Takes care of drawing in the different render states
// ----------------------------------------------------------------------------
int lastTrackableId = -1;
JNIEXPORT void JNICALL
Java_com_qualcomm_QCARSamples_CloudRecognition_CloudRecoRenderer_renderFrame(JNIEnv *env, jobject obj)
{
    // Clear color and depth buffer
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    // 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();

    glEnable(GL_DEPTH_TEST);
    glEnable(GL_CULL_FACE);

    if (deleteCurrentProductTexture)
    {
        // Deletes the product texture if necessary
        if (productTexture != 0)
        {
            glDeleteTextures(1, &(productTexture->mTextureID));
            delete productTexture;
            productTexture = 0;
        }

        deleteCurrentProductTexture = false;
    }

    // If the render state indicates that the texture is generated it generates
    // the OpenGL texture for start drawing the plane with the book data
    if (renderState == RS_TEXTURE_GENERATED)
    {
        generateProductTextureInOpenGL();
    }

    // Did we find any trackables this frame?
    if (state.getNumTrackableResults() > 0)
    {
        trackingStarted = true;

        // If we are already tracking something we don't need
        // to wait any frame before starting the 2D transition
        // when the target gets lost
        pthread_mutex_lock(&framesToSkipMutex);
        framesToSkipBeforeRenderingTransition = 0;
        pthread_mutex_unlock(&framesToSkipMutex);

        // Gets current trackable result
        const QCAR::TrackableResult* trackableResult = state.getTrackableResult(0);

        if (trackableResult == NULL)
        {
            return;
        }

			//LUCA APP MODIFY --- INIT
 		  const QCAR::Trackable& trackable = trackableResult->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(jobject, method, js);
            lastTrackableId = trackable.getId();
        }
 
			//LUCA APP MODIFY --- FINISH



        modelViewMatrix = QCAR::Tool::convertPose2GLMatrix(trackableResult->getPose());

        // Get the size of the ImageTarget
        QCAR::ImageTargetResult *imageResult = (QCAR::ImageTargetResult *)trackableResult;
        targetSize = imageResult->getTrackable().getSize();

        // Renders the Augmentation View with the 3D Book data Panel
        renderAugmentation(trackableResult);

    }...

But when I try to compile this code I receive these errors:

Gdbserver      : [arm-linux-androideabi-4.6] libs/armeabi/gdbserver
Gdbsetup       : libs/armeabi/gdb.setup
Gdbserver      : [arm-linux-androideabi-4.6] libs/armeabi-v7a/gdbserver
Gdbsetup       : libs/armeabi-v7a/gdb.setup
Compile++ arm    : CloudReco <= CloudReco.cpp
CloudReco.cpp: In function 'void Java_com_qualcomm_QCARSamples_CloudRecognition_CloudRecoRenderer_renderFrame(JNIEnv*, jobject)':
CloudReco.cpp:294:40: error: expected primary-expression before ',' token
make: *** [/home/panthe/Documenti/Android/vuforia-sdk-android-2-6-10/samples/CloudRecognition-2-6-7/obj/local/armeabi/objs-debug/CloudReco/CloudReco.o] Error 1

I never used c++ and I don't understand very well the problem because error say that the function have these two parameters (JNIEnv*, jobject)' but my function it this:

JNIEXPORT void JNICALL
Java_com_qualcomm_QCARSamples_CloudRecognition_CloudRecoRenderer_renderFrame(JNIEnv *env, jobject obj)

Someone can help me?

Thanks in advance.

Luca

Open URL upon image recognition

July 8, 2013 - 12:56am #7

Okay thank you i will do so
Just one last question, if i add this same code only changing the variables name according to the cloud Reco sample it will work?

Because it seems a bit complicated and only related to image target sample

thanks 

Open URL upon image recognition

July 8, 2013 - 12:34am #6

The article I was mentioning is what explains what you eed to do in C++ (and also in Java):

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

Start from there and you will simply need minor adjustments of the code 

Open URL upon image recognition

July 8, 2013 - 12:33am #5

Thank you so much for the explaation
But, i am new to C++ and i am not familiar with the changes that i should make

so could u help me modify the C++ code to inform the JNI and open the url? 

Open URL upon image recognition

July 8, 2013 - 12:27am #4

Ok, so if you look at the loud Reco sample code, in the CloudReco.cpp file you can find a class called CloudReco_UpdateCallback, which has a method called QCAR_onUpdate();

in that method, you wiull find some code that is meant to handle target search result, i.e. targets which have been recognized on the Cloud:

else if (statusCode == QCAR::TargetFinder::UPDATE_RESULTS_AVAILABLE)
        {
            // Process new search results
            if (finder->getResultCount() > 0)
            {
                const QCAR::TargetSearchResult* result = finder->getResult(0);
 
                // Check if this target is suitable for tracking:
                if (result->getTrackingRating() > 0)
                {
                    // Create a new Trackable from the result:
                    QCAR::Trackable* newTrackable = finder->enableTracking(*result);
 
You can add some code in the above, so to send a message from C++  to Java, using JNI.
This way, the Java part of your application will be able to receive a notification of the avilability of a new target; you can then perform some actions in Java in response to that, such as updating your UI or (like you mention) open a web URL in a web viewer.
 
In Java (Android), you can open a URL with some code like the following:
String url = "http://my_url";
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
startActivity(intent);

How to communicate from C++ to JNI is explained in this article:

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

more on JNI:

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

 

Open URL upon image recognition

July 8, 2013 - 12:09am #3

Hello, I am using Android Platform 

Open URL upon image recognition

July 8, 2013 - 12:07am #2

Hi Karine,

what plafform are you using ? Android, Unity, IOS ?

 

Log in or register to post comments