Log in or register to post comments

how to add a new ImageTarget in videoplayback sample ?

March 7, 2013 - 7:17am #1

Hi,  

   There are tow ImageTarget ( stones and chips ) in the videoplayback sample . I added a new ImageTarget for tacking , and it could be tracked but could not

load the VuforiaSizzleReel_2.png , where should I modify ?  

Video not load , another video load inverted

May 21, 2016 - 4:44pm #15

Hi AlessandroB,

 

I follow this instruction 

When i change stone and chips with my target, run fine with 2 target .

You say we can do add 100 target in dataset, but

When i try to add more target (4 target at all)

target 1 --> ok

target 2 --> not play video 2 -->play invert video 4 (invert : 180 degree)

target 3 --> not play video 3 -->play invert video 4

target 4 --? ok

 

All videos tested in app and work fine

I checked my edited codes twice but i dont know what wrong with me

please help me,

If you want, i can share my code to see that .

I want to add more than 2 target in videoplayback sample! (up to 100)

 

Thanks .

how to add a new ImageTarget in videoplayback sample ?

April 4, 2013 - 5:17am #14

Hi, the issue of the video inversion is related to the code, that you need to adjust as I explained previously; please also check this link:

https://developer.vuforia.com/forum/faq/android-how-do-i-add-another-target-video-playback-sample

the other issue you mention, the "color shadows" in the video, might be caused by something else, maybe the specific video file; to verify if it is the video itself causing this issue, I suggest you replace the official videos in the sample with that specific video, as I eplained in my previous message.

 

how to add a new ImageTarget in videoplayback sample ?

April 4, 2013 - 5:00am #13

Why in low quality images the video is invert ??

Like previous post i had sent.

how to add a new ImageTarget in videoplayback sample ?

April 4, 2013 - 1:28am #12

Hi, if you are sure that all the code has been updated correctly, then the issue might be with the video file itself;

to verify that, you could go back to the original VideoPlayback sample (with no modifications at all), and simply replace the VuforiaSizzleReel_1.m4v file with your video, (i.e. remore the VuforiaSizzleReel_1.m4v,  then copy your video to the assets folder, and rename your video to VuforiaSizzleReel_1.m4v, so that the sample will use it as if it was the original video).

This should work fine; if you see a problem with the video playback of your video, sicne there are no changes in the code this will indicate that the video has some problem;

otherwise, it is an issue in the code.

 

how to add a new ImageTarget in videoplayback sample ?

April 4, 2013 - 1:18am #11

I follow all the procedure you have written to show my own video model but the video is not plaing properly now sound is coming but the video is coming with different colors shadows only what the issue i am not getting?Please help me out.

how to add a new ImageTarget in videoplayback sample ?

April 4, 2013 - 12:59am #10

Hi, look carefully at this code that you wrote:

if (target == jack)
    {
     uvMultMat4f(videoQuadTextureCoordsTransformedChips[0], videoQuadTextureCoordsTransformedChips[1], videoQuadTextureCoords[0], videoQuadTextureCoords[1], mtx);
     uvMultMat4f(videoQuadTextureCoordsTransformedChips[2], videoQuadTextureCoordsTransformedChips[3], videoQuadTextureCoords[2], videoQuadTextureCoords[3], mtx);
     uvMultMat4f(videoQuadTextureCoordsTransformedChips[4], videoQuadTextureCoordsTransformedChips[5], videoQuadTextureCoords[4], videoQuadTextureCoords[5], mtx);
     uvMultMat4f(videoQuadTextureCoordsTransformedChips[6], videoQuadTextureCoordsTransformedChips[7], videoQuadTextureCoords[6], videoQuadTextureCoords[7], mtx);
    }

There (in the function uvMultMat4f)  you are using videoQuadTextureCoordsTransformedChips, but you should use videoQuadTextureCoordsTransformedjack instead;

same for "mylove" target; make sure the code is consistent everywhere.

 

how to add a new ImageTarget in videoplayback sample ?

April 3, 2013 - 11:11pm #9

Hi,  

   here i attach my code to u for ur reference.. I did all my changes but it is not  playing my assets videos.

 

GLfloat videoQuadTextureCoordsTransformedjack[] = {
    0.0f, 0.0f,
    1.0f, 0.0f,
    1.0f, 1.0f,
    0.0f, 1.0f,
};

GLfloat videoQuadTextureCoordsTransformedmylove[] = {
    0.0f, 0.0f,
    1.0f, 0.0f,
    1.0f, 1.0f,
    0.0f, 1.0f,
};
Here also i modified,....    
if (target == jack)
    {
     uvMultMat4f(videoQuadTextureCoordsTransformedChips[0], videoQuadTextureCoordsTransformedChips[1], videoQuadTextureCoords[0], videoQuadTextureCoords[1], mtx);
     uvMultMat4f(videoQuadTextureCoordsTransformedChips[2], videoQuadTextureCoordsTransformedChips[3], videoQuadTextureCoords[2], videoQuadTextureCoords[3], mtx);
     uvMultMat4f(videoQuadTextureCoordsTransformedChips[4], videoQuadTextureCoordsTransformedChips[5], videoQuadTextureCoords[4], videoQuadTextureCoords[5], mtx);
     uvMultMat4f(videoQuadTextureCoordsTransformedChips[6], videoQuadTextureCoordsTransformedChips[7], videoQuadTextureCoords[6], videoQuadTextureCoords[7], mtx);
    }

     else if (target == mylove)
    {
     uvMultMat4f(videoQuadTextureCoordsTransformedChips[0], videoQuadTextureCoordsTransformedChips[1], videoQuadTextureCoords[0], videoQuadTextureCoords[1], mtx);
     uvMultMat4f(videoQuadTextureCoordsTransformedChips[2], videoQuadTextureCoordsTransformedChips[3], videoQuadTextureCoords[2], videoQuadTextureCoords[3], mtx);
     uvMultMat4f(videoQuadTextureCoordsTransformedChips[4], videoQuadTextureCoordsTransformedChips[5], videoQuadTextureCoords[4], videoQuadTextureCoords[5], mtx);
     uvMultMat4f(videoQuadTextureCoordsTransformedChips[6], videoQuadTextureCoordsTransformedChips[7], videoQuadTextureCoords[6], videoQuadTextureCoords[7], mtx);
    }

    env->ReleaseFloatArrayElements(textureCoordMatrix, mtx, 0);
}

 

 

how to add a new ImageTarget in videoplayback sample ?

April 3, 2013 - 11:09pm #8

Hi,  

   here i attach my code to u for ur reference.. I did all my changes but it is not  playing my assets videos.

 

GLfloat videoQuadTextureCoordsTransformedjack[] = {
    0.0f, 0.0f,
    1.0f, 0.0f,
    1.0f, 1.0f,
    0.0f, 1.0f,
};

GLfloat videoQuadTextureCoordsTransformedmylover[] = {
    0.0f, 0.0f,
    1.0f, 0.0f,
    1.0f, 1.0f,
    0.0f, 1.0f,
};
Here also i modified,....    
if (target == jack)
    {
     uvMultMat4f(videoQuadTextureCoordsTransformedChips[0], videoQuadTextureCoordsTransformedChips[1], videoQuadTextureCoords[0], videoQuadTextureCoords[1], mtx);
     uvMultMat4f(videoQuadTextureCoordsTransformedChips[2], videoQuadTextureCoordsTransformedChips[3], videoQuadTextureCoords[2], videoQuadTextureCoords[3], mtx);
     uvMultMat4f(videoQuadTextureCoordsTransformedChips[4], videoQuadTextureCoordsTransformedChips[5], videoQuadTextureCoords[4], videoQuadTextureCoords[5], mtx);
     uvMultMat4f(videoQuadTextureCoordsTransformedChips[6], videoQuadTextureCoordsTransformedChips[7], videoQuadTextureCoords[6], videoQuadTextureCoords[7], mtx);
    }

     else if (target == mylove)
    {
     uvMultMat4f(videoQuadTextureCoordsTransformedChips[0], videoQuadTextureCoordsTransformedChips[1], videoQuadTextureCoords[0], videoQuadTextureCoords[1], mtx);
     uvMultMat4f(videoQuadTextureCoordsTransformedChips[2], videoQuadTextureCoordsTransformedChips[3], videoQuadTextureCoords[2], videoQuadTextureCoords[3], mtx);
     uvMultMat4f(videoQuadTextureCoordsTransformedChips[4], videoQuadTextureCoordsTransformedChips[5], videoQuadTextureCoords[4], videoQuadTextureCoords[5], mtx);
     uvMultMat4f(videoQuadTextureCoordsTransformedChips[6], videoQuadTextureCoordsTransformedChips[7], videoQuadTextureCoords[6], videoQuadTextureCoords[7], mtx);
    }

    env->ReleaseFloatArrayElements(textureCoordMatrix, mtx, 0);
}

 

 

how to add a new ImageTarget in videoplayback sample ?

April 3, 2013 - 5:42am #7

Hi, if ythe issue only occurs with your custom video, then chances are that you forgot to update the setVideoDimensions function (as indicated in the prvious post with the step-by-step instructions);

you should update the following code to do the necessary texture coordinates adjustments for your custom target too (next to the cases already handled for CHIPS and STONES):

JNIEXPORT void JNICALL
Java_com_qualcomm_QCARSamples_VideoPlayback_VideoPlaybackRenderer_setVideoDimensions(JNIEnv *env, jobject, jint target, jfloat videoWidth, jfloat videoHeight, jfloatArray textureCoordMatrix)
{
    // The quad originaly comes as a perfect square, however, the video
    // often has a different aspect ration such as 4:3 or 16:9,
    // To mitigate this we have two options:
    //    1) We can either scale the width (typically up)
    //    2) We can scale the height (typically down)
    // Which one to use is just a matter of preference. This example scales the height down.
    // (see the render call in Java_com_qualcomm_QCARSamples_VideoPlayback_VideoPlaybackRenderer_renderFrame)
    videoQuadAspectRatio[target] = videoHeight/videoWidth;

    jfloat *mtx = env->GetFloatArrayElements(textureCoordMatrix, 0);

    if (target == STONES)
    {
        uvMultMat4f(videoQuadTextureCoordsTransformedStones[0], videoQuadTextureCoordsTransformedStones[1], videoQuadTextureCoords[0], videoQuadTextureCoords[1], mtx);
        uvMultMat4f(videoQuadTextureCoordsTransformedStones[2], videoQuadTextureCoordsTransformedStones[3], videoQuadTextureCoords[2], videoQuadTextureCoords[3], mtx);
        uvMultMat4f(videoQuadTextureCoordsTransformedStones[4], videoQuadTextureCoordsTransformedStones[5], videoQuadTextureCoords[4], videoQuadTextureCoords[5], mtx);
        uvMultMat4f(videoQuadTextureCoordsTransformedStones[6], videoQuadTextureCoordsTransformedStones[7], videoQuadTextureCoords[6], videoQuadTextureCoords[7], mtx);
    }
    else if (target == CHIPS)
    {
        uvMultMat4f(videoQuadTextureCoordsTransformedChips[0], videoQuadTextureCoordsTransformedChips[1], videoQuadTextureCoords[0], videoQuadTextureCoords[1], mtx);
        uvMultMat4f(videoQuadTextureCoordsTransformedChips[2], videoQuadTextureCoordsTransformedChips[3], videoQuadTextureCoords[2], videoQuadTextureCoords[3], mtx);
        uvMultMat4f(videoQuadTextureCoordsTransformedChips[4], videoQuadTextureCoordsTransformedChips[5], videoQuadTextureCoords[4], videoQuadTextureCoords[5], mtx);
        uvMultMat4f(videoQuadTextureCoordsTransformedChips[6], videoQuadTextureCoordsTransformedChips[7], videoQuadTextureCoords[6], videoQuadTextureCoords[7], mtx);
    }

    env->ReleaseFloatArrayElements(textureCoordMatrix, mtx, 0);
}

 

how to add a new ImageTarget in videoplayback sample ?

April 3, 2013 - 2:54am #6

While i am clicking to play the video the video is plaing in invert format for example :

[ M ]: this is the alphabet M inside bracket but it showing invert like [ W].

How to solve this ???

 

 

how to add a new ImageTarget in videoplayback sample ?

April 3, 2013 - 2:45am #5

Hi siba,

what do you mean by "inverted video" ? can you be slightly more specific ?

 

 

how to add a new ImageTarget in videoplayback sample ?

April 3, 2013 - 1:47am #4

Can anybody help me while i am appling my new video as model its rendering inverted video.How to solve this issue i am not getting any solution for this.

how to add a new ImageTarget in videoplayback sample ?

March 8, 2013 - 7:24am #3

thank you very much, I will try it

how to add a new ImageTarget in videoplayback sample ?

March 7, 2013 - 12:02pm #2

Hi, 

 

here are some guidelines on how to achieve what you want:

- open VideoPlayback.java:

- modify the NUM_TARGETS value to 3 or more (now it is set to 2)

- add a definition for an extra target next to CHIPS and STONES, i.e. update this code:

 

    public static final int NUM_TARGETS                 = 3; // was 2, set it to 3 or more

    public static final int STONES                    = 0;

    public static final int CHIPS                       = 1;

 

    public static final int MY_TARGET                = 2; // added code

 
- Add the filename of your new movie in mMovieNames, i.e.:
 
    mMovieName[STONES] = "VuforiaSizzleReel_1.m4v";
    mMovieName[CHIPS] = "VuforiaSizzleReel_2.m4v";
    mMovieName[MY_TARGET] = "My_Movie_Filename.m4v"; //added line of code
 
 
- Open VideoPlayback.cpp (under the JNI directory of the project):
 
  Update the definitions of NUM_TARGETS and the target names as follow:
 
static const int NUM_TARGETS = 3; //was 2 in original sample code, set it to 3 or more
static const int STONES = 0;
static const int CHIPS = 1;
static const int MY_TARGET = 2; //new line of code for my target
 
Update this code (in _initRendering function):
   keyframeQuadAspectRatio[STONES] = (float)textures[0]->mHeight / (float)textures[0]->mWidth;
    keyframeQuadAspectRatio[CHIPS]  = (float)textures[1]->mHeight / (float)textures[1]->mWidth;
    keyframeQuadAspectRatio[MY_TARGET]  = (float)textures[2]->mHeight / (float)textures[2]->mWidth; //added line of code for my target
 
 
In _renderFrame function, update the code to determine the currentTarget as follows:
 
if (strcmp(imageTarget.getName(), "stones") == 0)
            currentTarget=STONES;
else if (strcmp(imageTarget.getName(), "chips") == 1)
            currentTarget=CHIPS;
else
        currentTarget=MY_TARGET;
 
 
Similarly, update the glVertexAtribPointer code:
 
if (strcmp(imageTarget.getName(), "stones") == 0)
                glVertexAttribPointer(videoPlaybackTexCoordHandle, 2, GL_FLOAT, GL_FALSE, 0,
                                  (const GLvoid*) &videoQuadTextureCoordsTransformedStones[0]);
       else if (strcmp(imageTarget.getName(), "chips") == 0)
                glVertexAttribPointer(videoPlaybackTexCoordHandle, 2, GL_FLOAT, GL_FALSE, 0,
                                  (const GLvoid*) &videoQuadTextureCoordsTransformedChips[0]);  
      else 
               glVertexAttribPointer(videoPlaybackTexCoordHandle, 2, GL_FLOAT, GL_FALSE, 0,
                                  (const GLvoid*) &videoQuadTextureCoordsTransformed_My_Target[0]);
 
- Add this definition at the beginning of PlaybackVideo.cpp (next to the other two for chips and stones):
 
GLfloat videoQuadTextureCoordsTransformed_My_Target[] = {
    0.0f, 0.0f,
    1.0f, 0.0f,
    1.0f, 1.0f,
    0.0f, 1.0f,
};
 
 
- Update the _setVideoDimensions function to account the MY_TARGET case (next to CHIPS and STONES)
 
 
Finally, create a new DataSet using the TMS and uploading three images (Chips, Stones and a third image of your choice), and use it instead of the currently used DataSet in the sample.
 
 

I would also suggest to read the "code walk-through" of the VideoPlayback sample:

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

(see under the heading Sample Specific Notes -> Sample Code Structure (Android))

This will guide you through all the main parts of the sample code, explaining them.

 

 

Log in or register to post comments