- Sort Posts
- 14 replies
- Last post
how to add a new ImageTarget in videoplayback sample ?
how to add a new ImageTarget in videoplayback sample ?
how to add a new ImageTarget in videoplayback sample ?
how to add a new ImageTarget in videoplayback sample ?
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 ?
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 ?
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 ?
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 ?
how to add a new ImageTarget in videoplayback sample ?
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 ?
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.
Video not load , another video load inverted
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 .
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
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.