Log in or register to post comments

Dynamic NUM_TARGETS(markers & Videos),VidePlayback

March 22, 2013 - 4:35am #1

GUYS,

 

ANY ONE here, tried to manipulate a dynamic NUM_TARGETS in VidePlayback example.

for example: i have 100 markers in my dataset and i download my videos from url 

which function can i used exactly so that i can make a function for getting the name of the imagetarget then play the specific video on it

 

Thanks . Hope You can help.

Dynamic NUM_TARGETS(markers & Videos),VidePlayback

March 25, 2013 - 10:22am #11

hi. I'm beginner.

any one help me.

i was copy  zok_lods's code in my VideoPlayback.cpp and VideoPlaybackRenderer.java.

and than...

how can i use this in my VideoPlayback.java??

 show me example plz

Dynamic NUM_TARGETS(markers & Videos),VidePlayback

March 25, 2013 - 2:12am #10

Excellent!

Dynamic NUM_TARGETS(markers & Videos),VidePlayback

March 25, 2013 - 2:10am #9

Thanks ALESSANDRO.  I can now get the imagetarget.

Thanks again for your help

Dynamic NUM_TARGETS(markers & Videos),VidePlayback

March 25, 2013 - 1:05am #8

Hi, it looks like this line:

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

is wrong; it should be:

jstring js = env->NewStringUTF( imageTarget.getName() );

so, you should rebuild with ndk-build and check that the build is successfull before running the Java app.

Dynamic NUM_TARGETS(markers & Videos),VidePlayback

March 25, 2013 - 12:14am #7

 Thanks but it wont display the name of marker

Heres my code in my VideoPlayback.cpp

JNIEXPORT void JNICALL
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);
    ..

And in VideoPlaybackRenderer.java i made a method like this for displaying the targetname

   public void setTargetName(String targetname)
    {
    	Log.d("TARGETNAME==>", targetname);
    }

 

Dynamic NUM_TARGETS(markers & Videos),VidePlayback

March 24, 2013 - 11:36pm #6

In Java, the method must not be declared "native"; in this case it is just a standard Java method, in which you define your logic:


 public void setTargetName(String name) {
   // TODO do something with the 'name' variable

  }

 

Dynamic NUM_TARGETS(markers & Videos),VidePlayback

March 24, 2013 - 8:59pm #5

Thanks AlessandroB,

But i how can i set method called "setTargetName(String name)" in ImageTargetsRenderer.java?

i did it like this ist correct? 

  public native void setTargetName(String name);

Dynamic NUM_TARGETS(markers & Videos),VidePlayback

March 22, 2013 - 6:51am #4

Hi, suppose you have a method called "setTargetName(String name)" defined in your class ImageTargetsRenderer.java, then the code to pass the name to that Java method from C++ would be:

const QCAR::TrackableResult* result = state.getTrackableResult( tIdx );
const QCAR::Trackable& trackable = result->getTrackable();

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

 

Dynamic NUM_TARGETS(markers & Videos),VidePlayback

March 22, 2013 - 5:59am #3

How can i pass the imageTarget.getName() to java?

because it is in videoplayback.cpp

Dynamic NUM_TARGETS(markers & Videos),VidePlayback

March 22, 2013 - 5:19am #2

Hi, if you want to retrieve the name of an image target (so that you can play a video from a URL based on that name), you could simply use the getName() function of the ImageTarget class.

 const QCAR::TrackableResult* result = state.getTrackableResult(tIdx);
 const QCAR::Trackable& trackable = result->getTrackable();
 const char *name = trackable.getName();

 

Log in or register to post comments