Log in or register to post comments

Loading Dataset from sd card without ndk-building

March 25, 2013 - 3:15am #1

I just want to ask if ist possible to automatically read dataset without ndk-building?

Loading Dataset from sd card without ndk-building

March 28, 2013 - 11:43pm #24

I have nothing else to suggest unfortunately:

to me it sounds you have two options: 

  • use less than 100 targets in total (so you can activate all your datasets simultaneiously)
  • or, use the Cloud

 

Loading Dataset from sd card without ndk-building

March 28, 2013 - 8:58pm #23

also, what if the user is just not correctly focusing the device on the printed target ? is the target not being found because it is not in the dataset, or just because the user is too far from the target ?

 

I think this invalidate my idea .. hmm i really work on it for this one without using cloud because ive coding a lot already for Videoplayback functions

Is there anything you can suggest?

Loading Dataset from sd card without ndk-building

March 28, 2013 - 9:55am #22

or it could be activating first in dataset1 and if not there activate dataset2 or if not there activate dataset3 or  i dont know how,..thanks

In theory that could be a possible technique; however in practice it will not work, because in order to decide to switch dataset (i.e. activate dataset2 and deactivate datset1, etc.) you need to determine that the target was not detected in dataset1;

how do you determine that ? do you base that decision on time elapsed ? (for instance, if the target is not detected for 10 seconds, then I decide to activate dataset2...); but suppose you follow this approach, then, how do you decide for how long you need to wait before switching dataset ?

also, what if the user is just not correctly focusing the device on the printed target ? is the target not being found because it is not in the dataset, or just because the user is too far from the target ?

So, these are usability questions that may invalidate your approach...

That's why I would rather consider using Cloud Reco if you need to use many targets.

 

Loading Dataset from sd card without ndk-building

March 28, 2013 - 3:14am #21

i want to know the dataset of that marker. For eg. I have 3 datasets or more that is beeing loaded ,I scan the image and the name of that image is : imagetarget1001, and that image belons to dataset2, how can i recognized that image by detecting its parent dataset so i can switch to that dataset..

as you know already that we cannot identify the marker if not yet activated., or it could be activating first in dataset1 and if not there activate dataset2 or if not there activate dataset3 or  i dont know how,..thanks

Loading Dataset from sd card without ndk-building

March 28, 2013 - 1:13am #20

You can switch DataSets, as it is demonstrated in the ImageTargets sample. But what is your specific question/goal here ?

 

Loading Dataset from sd card without ndk-building

March 28, 2013 - 12:00am #19

How about the switching of  datasets sir?

Loading Dataset from sd card without ndk-building

March 27, 2013 - 11:30pm #18

Indeed, you cannot recognize (detect) a target if no dataset has been activated yet;

now I understand your original question: when you said "how can we identify a target at first.." you were meaning how can we detect a target (so, I was understanding it differently, sorry that I did not understand it in the first place);  

so, unfortunately, as you already realized, that's not possible, as you need to have activated at least one dataset in order to recognize something;

the problem that you are posing here has no solution, unless you load and activate all the datasets at once (but then you will be limited to a maximum of 100 targets, otherwise getting an error, as you know )

So, either you use less than 100 targets in your datasets, or you need to use a Cloud Database.

 

 

Loading Dataset from sd card without ndk-building

March 27, 2013 - 9:48pm #17

if i put this code under the rendFrame method in VideoPlayback,.cpp after creating and loading all datasets

it will not recognized the marker because its not yet activated i tried it and it will not track 

Java_com_qualcomm_QCARSamples_VideoPlayback_VideoPlaybackRenderer_renderFrame(JNIEnv* env, jobject obj)
{
    //LOG("Java_com_qualcomm_QCARSamples_VideoPlayback_GLRenderer_renderFrame");

    // 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);
    
    // We must detect if background reflection is active and adjust the culling direction. 
    // If the reflection is active, this means the post matrix has been reflected as well,
    // therefore standard counter clockwise face culling will result in "inside out" models. 
    glEnable(GL_CULL_FACE);
    glCullFace(GL_BACK);
    if(QCAR::Renderer::getInstance().getVideoBackgroundConfig().mReflection == QCAR::VIDEO_BACKGROUND_REFLECTION_ON)
        glFrontFace(GL_CW);  //Front camera
    else
        glFrontFace(GL_CCW);   //Back camera

   
    for (int i=0; i<NUM_TARGETS; i++)
    {
        isTracking[i] = false;
        targetPositiveDimensions[i].data[0] = 0.0;
        targetPositiveDimensions[i].data[1] = 0.0;
    }

    // Did we find any trackables this frame?
    for(int tIdx = 0; tIdx < state.getNumTrackableResults(); tIdx++)
    {
        // Get the trackable:
        const QCAR::TrackableResult* trackableResult = state.getTrackableResult(tIdx);
        const QCAR::ImageTarget& imageTarget = (const QCAR::ImageTarget&) trackableResult->getTrackable();


        int currentTarget;
        //TEST FROM ALESSANDRO

        	 jstring js = env->NewStringUTF(imageTarget.getName());
        	 jclass javaClass = env->GetObjectClass(obj);
        	 jmethodID method = env->GetMethodID(javaClass, "setTargetName", "(Ljava/lang/String;)V");
        	 env->CallVoidMethod(obj, method, js);



        	  QCAR::TrackerManager& trackerManager = QCAR::TrackerManager::getInstance();
        	  QCAR::ImageTracker* imageTracker = static_cast<QCAR::ImageTracker*>(
        	            trackerManager.getTracker(QCAR::Tracker::IMAGE_TRACKER));

        for(int ctr=0;ctr<myDataSetArray.size();ctr++)//for dataset array loop
        {
        	 for (int i = 0; i < myDataSetArray[ctr]->getNumTrackables(); i++)
        	 {
        		 QCAR::Trackable *trackable =  myDataSetArray[ctr]->getTrackable( i );

        	     const char *targetName = trackable->getName();

        	     if (strcmp(targetName, imageTarget.getName()) == 0)
        	     {
        	         //yes, this is the target I was looking for => TODO something
        	    	  imageTracker->deactivateDataSet(imageTracker->getActiveDataSet());
        	          imageTracker->activateDataSet(myDataSetArray[ctr]);

        	     }
        	     LOG("here its is");
        	     LOG(targetName);
        	 }
        }

 

Loading Dataset from sd card without ndk-building

March 27, 2013 - 6:18am #16

you're welcome.

Loading Dataset from sd card without ndk-building

March 27, 2013 - 6:14am #15

Thanks man . Your very Brilliant :)

Loading Dataset from sd card without ndk-building

March 27, 2013 - 6:05am #14

Oh, reading again the code:

you need to replace this line:

Trackable *trackable = dataSetStonesAndChips->getTrackable( i );

with this:

QCAR::Trackable *trackable = dataSetStonesAndChips->getTrackable( i );

Loading Dataset from sd card without ndk-building

March 27, 2013 - 5:54am #13

I have already add that but still same error.

Loading Dataset from sd card without ndk-building

March 27, 2013 - 5:44am #12

You eed to add this include statement:

#include <QCAR/Trackable.h>

 

Loading Dataset from sd card without ndk-building

March 27, 2013 - 5:08am #11

There is some error when building my code when i add your code below

 

 
 
C:\Development\Android\vuforia-sdk-android-2-0-31\samples\VideoPlayback-2-0-7>nd
k-build
Install        : libQCAR.so => libs/armeabi/libQCAR.so
"Compile++ arm  : VideoPlayback <= VideoPlayback.cpp
jni/VideoPlayback.cpp: In function 'void Java_com_qualcomm_QCARSamples_VideoPlay
back_VideoPlaybackRenderer_renderFrame(JNIEnv*, jobject)':
jni/VideoPlayback.cpp:466:14: error: 'Trackable' was not declared in this scope
jni/VideoPlayback.cpp:466:14: note: suggested alternative:
jni/../../../build/include/QCAR/Trackable.h:29:16: note:   'QCAR::Trackable'
jni/VideoPlayback.cpp:466:25: error: 'trackable' was not declared in this scope
make: *** [obj/local/armeabi/objs/VideoPlayback/VideoPlayback.o] Error 1
 
   for(int tIdx = 0; tIdx < state.getNumTrackableResults(); tIdx++)
    {
        // Get the trackable:
        const QCAR::TrackableResult* trackableResult = state.getTrackableResult(tIdx);
        const QCAR::ImageTarget& imageTarget = (const QCAR::ImageTarget&) trackableResult->getTrackable();


        QCAR::TrackerManager& trackerManager = QCAR::TrackerManager::getInstance();
        QCAR::ImageTracker* imageTracker = static_cast<QCAR::ImageTracker*>(
            trackerManager.getTracker(QCAR::Tracker::IMAGE_TRACKER));

        int currentTarget;
        //TEST FROM ALESSANDRO

        	 jstring js = env->NewStringUTF(imageTarget.getName());
        	 jclass javaClass = env->GetObjectClass(obj);
        	 jmethodID method = env->GetMethodID(javaClass, "setTargetName", "(Ljava/lang/String;)V");
        	 env->CallVoidMethod(obj, method, js);

        	 for (int i = 0; i < dataSetStonesAndChips->getNumTrackables(); i++)
        	 {
        	    Trackable *trackable = dataSetStonesAndChips->getTrackable( i );
        	    // const QCAR::Trackable& trackable = dataSetStonesAndChips->getTrackable(i);

        	     const char *targetName = trackable.getName();

        	     if (strcmp(targetName, imageTarget.getName()) == 0)
        	     {
        	         //yes, this is the target I was looking for => TODO something
        	    	  imageTracker->deactivateDataSet(imageTracker->getActiveDataSet());
        	          imageTracker->activateDataSet(dataSetStonesAndChips);
        	     }
        	 }

 

 
 

Loading Dataset from sd card without ndk-building

March 27, 2013 - 4:12am #10

Yes, you should be able to put that code in renderFrame without problems. The only thing to keep in mind is that, if you need to deactivate / activate a dataset (e.g. when you want to switch the active dataset to a differrent one), you need to use the QCAR_onUpdate method (see ImageTargets.cpp for an example of that code).

 

Loading Dataset from sd card without ndk-building

March 27, 2013 - 4:04am #9

ahh i see.. but for the code you sent below.. ist okay to put it under the renderFrame function in VideoPlayaback.cpp

because i need to recognized the target and get the name and compare which dataset it belongs.

Loading Dataset from sd card without ndk-building

March 27, 2013 - 3:54am #8

You should not need to activate a dataset  in order to get someDataSet.getNumTrackables()

This must not be confused with someDataSet.getNumTrackableResults(), which instead returns the currently detected targets (and is based on activated datsets)

Loading Dataset from sd card without ndk-building

March 27, 2013 - 2:04am #7

 

hmm..but we still didnt activate the someDataSet for that specific marker, so how can we identify at the first and get the value of 
 
someDataSet.getNumTrackables()??

Loading Dataset from sd card without ndk-building

March 27, 2013 - 1:53am #6

Every target has a name; for each DataSet, you can get the list of all the image targets contained in it, and then for each target you can query the name and see if one of them matches the name you are interested in; for example, look at this snippet (just for illustration purpose):

for (int i = 0; i < someDataSet.getNumTrackables(); i++) 
{
    Trackable *trackable = someDataSet.getTrackable( i );

    const char *targetName = trackable->getName();

    if (strcmp(targetName, "chips") == 0)
    {
        //yes, this is the target I was looking for => TODO something

    }
}

See also the API reference of the DataSet class:

https://developer.vuforia.com/resources/api/class_q_c_a_r_1_1_data_set

Loading Dataset from sd card without ndk-building

March 27, 2013 - 1:34am #5

I wanna ask , how to identify the imagetarget in its specifc dataset so that i can load and activate the specific dataset in loadTrackeData.

Loading Dataset from sd card without ndk-building

March 26, 2013 - 1:21am #4

You're welcome.

Loading Dataset from sd card without ndk-building

March 26, 2013 - 12:30am #3

Thanks  ill work on it. 

Loading Dataset from sd card without ndk-building

March 25, 2013 - 3:24am #2

Hi, yes, you can load a dataset for instance from a string variable where you hold the value of a path;

the path can point to a path on you external storage (sd card, as you mention) for instance.

Just a note: if you want to load the dataset from the sd card, you need to call the "load()" function with this storage parameter:

QCAR::STORAGE_ABSOLUTE

 

Log in or register to post comments