Log in or register to post comments

Videoplayback video inverted

October 24, 2012 - 5:34am #1

I see video is inverted i.e. upside down when I put camera in front of marker. How to fix it?

Videoplayback video inverted

February 11, 2020 - 2:57am #31

Solved!

I changed Below Quad, I have 3 videos

    Class Name: VideoPlaybackRenderer

    //Before

    private final float[] videoQuadTextureCoords = { 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, };

  

    // This variable will hold the transformed coordinates (changes every frame)

    private final float[] videoQuadTextureCoordsTransformedStones = { 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, };

    private final float[] videoQuadTextureCoordsTransformedChips = { 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f,};

 

    //After 



    private final float[] videoQuadTextureCoords = { 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, };

   

    // This variable will hold the transformed coordinates (changes every frame)

    private final float[] videoQuadTextureCoordsTransformedStones = { 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, };

    private final float[] videoQuadTextureCoordsTransformedChips = { 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f,};

Videoplayback video inverted

August 26, 2016 - 6:17am #30

can you help me MHPAR.

I have the same issue that you were facing for flipped video.

Videoplayback video inverted

August 26, 2016 - 6:16am #29

Hi guys,

same issue as MHPAR was facing. videos are flipped .so please help me out.

Videoplayback video inverted

April 20, 2016 - 6:16am #28

hi all

 

I still have ARFixer problem. I am using Vuforia SDK 5.5.9 Android (some Videos play mirror but after tracking other videos , that videos will play ok !!!)

 

ARFixer problem was:

 

 

1. I've 2 movies in mp4 format. Lets call them 1.mp4 and 2.mp4 (in my case i have 3)

2. I've 2 markers named: 1 and 2. When recogniced video is start plaing on them. Marker 1 => 1.mp4 2=>2.mp4

 

Ok and problem that makes me crazy ....

Scenario1.

1. App launched.

2. Focus camera on Marker 2 => video 2.mp4 is starting to play OK !

3. Focus camera on MArker 1 => video 1.mp4 is starting to play OK !

 Great Scenario1 works great

 

Scenario2:

1. App lauched

2. Focus camera on Marker 1 => video 1.mp4 is starting to play BUT FLIPED and rotate 180Degrees(fliped horizontaly and rotate 180 degree). 

3. Focus camera on MArker 2 => video 2.mp4 is starting to play OK !

4. Move camera over marker 1 again: => video 1.mp4 is plaing correctly

What to hell....  is going on ? :) ?

 

i don't know what i should do??? I can change cordinates but it's not help because some video works good , some not, also the videos that play not currectly in senario 2 will play OK as in sernario said after comeback again on it from video 1.

Videoplayback video inverted

December 8, 2014 - 2:15am #27

Make sure all the "stones" or "chips" wording are replaced by your own image target name when u using your own target. I just missed a place, and it showed a flipped video.

Videoplayback video inverted

December 8, 2014 - 2:15am #26

Make sure all the "stones" or "chips" wording are replaced by your own image target name when u using your own target. I just missed a place, and it showed a flipped video.

Videoplayback video inverted

September 27, 2013 - 2:55am #25

Hi, the issue may depend on the need to adapt the sample code to your target name (if you have changed that):

if you look at the code in VideoPlayback.cpp, you will find these lines:

 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);
    }

and these:

if (strcmp(imageTarget.getName(), "stones") == 0)
                glVertexAttribPointer(videoPlaybackTexCoordHandle, 2, GL_FLOAT, GL_FALSE, 0,
                                  (const GLvoid*) &videoQuadTextureCoordsTransformedStones[0]);
            else
                glVertexAttribPointer(videoPlaybackTexCoordHandle, 2, GL_FLOAT, GL_FALSE, 0,
                                  (const GLvoid*) &videoQuadTextureCoordsTransformedChips[0]);

 

If you don't adjust the code to work with your target, the transfromed texture coordinates will not be correctly updated, and this will result in the video to appear flipped / inverted.

 

 

Videoplayback video inverted

September 27, 2013 - 2:44am #24

I am waiting for a reply to this.

Does it work the same for everyone who uses the VideoPlayback sample app?

 

Videoplayback video inverted

September 26, 2013 - 11:48pm #23

I am facing the same Issue.My video is coming as Inverted and mirrored.I have not chnaged anything in the sample code other than changing the Video and Image target.Code wise no changes.

Its visible in the Image Target with Texts.I cannot make comments on the stones and chips Image Target because it looks like having the same orientation all the side
Could you provide a permanant solution for this?

Regards,

Najiya

Videoplayback video inverted

May 24, 2013 - 10:00am #22

On app that based on VP sample. (Only modyfications is incrase NUM_TARGETS to 20 and base only on one texture insteed of 2 ) :/ I'll spend this night and try to fixed it but have no idea where ot start :) We will see I'll give You some more info tomorow morning. I'll also generate new trackables. It looks like that this marker named "1" may do some bad things :) I will generate the same marker on other name insteed of "1" and I'll also test other 19 markers.   

Videoplayback video inverted

May 24, 2013 - 4:52am #21

Hi ARFixer,

do you see the same issue in the VideoPlyback sample ? or just in your application (which I presume is based on VP sample)

?

 

Videoplayback video inverted

May 24, 2013 - 3:23am #20

I switched videos files problem is the same so there is no problem in movie files. <so angry>

Videoplayback video inverted

May 24, 2013 - 3:21am #19

Hi,

My problem:

 

1. I've 2 movies in mp4 format. Lets call them 1.mp4 and 2.mp4

2. I've 2 markers named: 1 and 2. When recogniced video is start plaing on them. Marker 1 => 1.mp4 2=>2.mp4

 

Ok and problem that makes me crazy ....

Scenario1.

1. App launched.

2. FOcus camera on Marker 2 => video 2.mp4 is starting to play OK !

3. Focus camera on MArker 1 => video 1.mp4 is starting to play OK !

 Great Scenario1 works great

 

Scenario2:

1. App lauched

2. FOcus camera on Marker 1 => video 1.mp4 is starting to play BUT FLIPED and rotate 180Degrees. 

3. Focus camera on MArker 2 => video 2.mp4 is starting to play OK !

4. Move camera over marker 1 again: => video 1.mp4 is plaing correctly

What to hell....  is going on ? :) ?

 

Any ideas ? mp4 is ok I belive becouse app works great on iOS. I will try now to switch names 1.mp4 <=> 2.mp4 but I dont belive that is movie problem.

 

Thx for any help I have deadline 28.05 all is done only that crazy  ;)

Videoplayback video inverted

May 4, 2013 - 12:37am #18

Hi alhammadi_am,

not sure what you are changing in the code, but the video playback sample makes proper use of those functions to have the video non-inverted.

 

Videoplayback video inverted

May 3, 2013 - 11:09pm #17

I have the same exact issue, but this function ( glVertexAttribPointer(videoPlaybackTexCoordHandle, 2, GL_FLOAT, GL_FALSE, 0,

(const GLvoid*) &videoQuadTextureCoordsTransformedStones[0]);) is being used only once! the video is still mirrored. Any help?

Videoplayback video inverted

December 4, 2012 - 6:41am #16

studying

Videoplayback video inverted

November 1, 2012 - 1:54pm #15

Good to hear that it was solved.

Videoplayback video inverted

October 31, 2012 - 11:39pm #14

I had repititive calls of 

glVertexAttribPointer(videoPlaybackTexCoordHandle, 2, GL_FLOAT, GL_FALSE, 0, (

const  GLvoid*) &videoQuadTextureCoordsTransformedStones[0]);

Removing one of them solved the issue.

Videoplayback video inverted

October 25, 2012 - 8:49am #13

Hi, ok I see;

the flipping in this case comes from some problems with the texture coordinates (so you can remove the rotatePoseMatrix() code that we previously tried, as that's not the issue);

 now, in the original VideoPlayback sample there is a method (in VideoPlayback.cpp) called:

Java_com_qualcomm_QCARSamples_VideoPlayback_VideoPlaybackRenderer_setVideoDimensions

if you look at it, it makes some calculation to convert the texture coordinates so to have the right texture coordinates to be applied to the video quad;

if you happened to modify the sample code and forgot to call that function, that could be one reason for getting the video flipped (i.e. wrong texture coordinates);

check also the line of code in renderFrame method:

glVertexAttribPointer(videoPlaybackTexCoordHandle, 2, GL_FLOAT, GL_FALSE, 0, (

const  GLvoid*) &videoQuadTextureCoordsTransformedStones[0]);

and similar function calls in _renderFrame(), and check again your code against the original sample code, if you have changed anything there.

 

Videoplayback video inverted

October 25, 2012 - 8:03am #12

Do you think below code could be the issue

 

JNIEXPORT void JNICALL

Java_com_putitout_buck_VideoPlayback_setProjectionMatrix(JNIEnv *, jobject)

{

    LOG("Java_com_putitout_buck_VideoPlayback_setProjectionMatrix");

 

    // Cache the projection matrix:

    const QCAR::CameraCalibration& cameraCalibration =

                                QCAR::CameraDevice::getInstance().getCameraCalibration();

    projectionMatrix = QCAR::Tool::getProjectionGL(cameraCalibration, 2.0f,

                                            2000.0f);

 

    inverseProjMatrix = SampleMath::Matrix44FInverse(projectionMatrix);

    //inverseProjMatrix = projectionMatrix;

}

Videoplayback video inverted

October 25, 2012 - 7:55am #11

If  I increment angle by 30 degree than frame moves accordingly but issue is NOT with frame but with the way video is displaying on the frame. CONTENTS of the video are flipped upside down. Is this written somewhere in the code that video can be mirrored?

Videoplayback video inverted

October 25, 2012 - 2:15am #10

I strongly suspect this could be a matrix normalization issue due to the scale; 

try moving the rotatePoseMatrix() line BEFORE the scalePoseMatrix (i.e. first translate, then rotate and finally scale); I believe this could solve the problem;

if it does not, you can check by rotating with small angles (like rotate only 15 degrees, then test the app to see how it looks, then increment to 30 deg and test again, and so on ..., to see if you see weird effects such as collapsing your quad as the rotation angle increases);

 

Videoplayback video inverted

October 25, 2012 - 2:08am #9

I tried replacing X as 1.0f and then y as 1.0f. In both cases audio is there but video is gone. Here is my code

QCAR::Matrix44F modelViewMatrixVideo =

                QCAR::Tool::convertPose2GLMatrix(trackable->getPose());

            QCAR::Matrix44F modelViewProjectionVideo;

            SampleUtils::translatePoseMatrix(0.0f, 0.0f, targetPositiveDimensions[currentTarget].data[0],

                                             &modelViewMatrixVideo.data[0]);

 

            // Here we use the aspect ratio of the video frame

            SampleUtils::scalePoseMatrix(targetPositiveDimensions[currentTarget].data[0],

                                         targetPositiveDimensions[currentTarget].data[0]*videoQuadAspectRatio[currentTarget],

                                         targetPositiveDimensions[currentTarget].data[0],

                                         &modelViewMatrixVideo.data[0]);

            SampleUtils::rotatePoseMatrix(180.0f, 1.0f, 0.0f, 0.0f, &modelViewMatrixVideo.data[0]);

            SampleUtils::multiplyMatrix(&projectionMatrix.data[0],

                                        &modelViewMatrixVideo.data[0] ,

                                        &modelViewProjectionVideo.data[0]);

 

 

            glUseProgram(videoPlaybackShaderID);

 

 

Below code is same as before.

Videoplayback video inverted

October 24, 2012 - 11:58pm #8

This sounds quite weird; however you can just replace the rotation around Z with a rotation around X instead, and then it should be OK:

SampleUtils::rotatePoseMatrix(180.0f, 1.0f, 0.0f, 0.0f, &modelViewMatrixKeyframe.data[0]);//instead of rotating around Z

 

Videoplayback video inverted

October 24, 2012 - 11:31pm #7

thanks the code worked and videos have now fine orientation. Now another bug appeared that contents of videos are flipped and mirrored i.e. left became right and right became left.

Videoplayback video inverted

October 24, 2012 - 8:48am #6

Hi, the target reference frame is by definition the one associated to the target, so your video should be already in the "same" orientation, unless you mean something special;

maybe you mean that the "natural" orientation of your image (i.e. the one for which you consider your image orientation "correct" when you look at it, is the opposite of the one you get from QCAR as pose for the video) ?

if that is the case, and you want to fix it via code, you can of course add a simpe, rotation of 180 degrees with the following code:

SampleUtils::rotatePoseMatrix(180.0f, 0.0f, 0.0f, 1.0f, &modelViewMatrixKeyframe.data[0]);

This line should be added right before the call to SampleUtils::scalePoseMatrix(...)

I hope that helps :-)

 

Videoplayback video inverted

October 24, 2012 - 8:21am #5

yes your suggestion worked and when I invert target video is playing just fine. But how can I make this to have same orientation as of image target?

Videoplayback video inverted

October 24, 2012 - 8:10am #4

 Hi, since the texture is applied to a 3D object (in this case a simple flat rectangle positioned on top of the target), this will follow the reference frame associated to the target, which in turn depends on how the printed paper target is currently oriented on your table or desk in front of you;

so, there is nothing wrong with it, it's just that your printed target is probably rotated upside-down with respect to your current point of view; just rotate the paper target 180 and you'll see the video texture correctly.

 

 

Videoplayback video inverted

October 24, 2012 - 7:54am #3

yes video is upside down. Here is the code that binds texture in front of marker. Should I use rotate here?

 

QCAR::Matrix44F modelViewMatrixVideo =

                QCAR::Tool::convertPose2GLMatrix(trackable->getPose());

            QCAR::Matrix44F modelViewProjectionVideo;

            SampleUtils::translatePoseMatrix(0.0f, 0.0f, targetPositiveDimensions[currentTarget].data[0],

                                             &modelViewMatrixVideo.data[0]);

 

            // Here we use the aspect ratio of the video frame

            SampleUtils::scalePoseMatrix(targetPositiveDimensions[currentTarget].data[0],

                                         targetPositiveDimensions[currentTarget].data[0]*videoQuadAspectRatio[currentTarget],

                                         targetPositiveDimensions[currentTarget].data[0],

                                         &modelViewMatrixVideo.data[0]);

            SampleUtils::multiplyMatrix(&projectionMatrix.data[0],

                                        &modelViewMatrixVideo.data[0] ,

                                        &modelViewProjectionVideo.data[0]);

 

            glUseProgram(videoPlaybackShaderID);

 

            // Prepare for rendering the keyframe

            glVertexAttribPointer(videoPlaybackVertexHandle, 3, GL_FLOAT, GL_FALSE, 0,

                                  (const GLvoid*) &quadVertices[0]);

            glVertexAttribPointer(videoPlaybackNormalHandle, 3, GL_FLOAT, GL_FALSE, 0,

                                  (const GLvoid*) &quadNormals[0]);

 

            glVertexAttribPointer(videoPlaybackTexCoordHandle, 2, GL_FLOAT, GL_FALSE, 0,

                                              (const GLvoid*) &videoQuadTextureCoordsTransformed[0]);

            if (strcmp(trackable->getName(), "OneDollarFrontSide") == 0) {

 

            }

 

            else {

 

            }

            glVertexAttribPointer(videoPlaybackTexCoordHandle, 2, GL_FLOAT, GL_FALSE, 0,

                                  (const GLvoid*) &videoQuadTextureCoordsTransformedChips[0]);

 

 

            glEnableVertexAttribArray(videoPlaybackVertexHandle);

            glEnableVertexAttribArray(videoPlaybackNormalHandle);

            glEnableVertexAttribArray(videoPlaybackTexCoordHandle);

 

            glActiveTexture(GL_TEXTURE0);

 

            // IMPORTANT:

            // Notice here that the texture that we are binding is not the

            // typical GL_TEXTURE_2D but instead the GL_TEXTURE_EXTERNAL_OES

            glBindTexture(GL_TEXTURE_EXTERNAL_OES, videoPlaybackTextureID[currentTarget]);

            glUniformMatrix4fv(videoPlaybackMVPMatrixHandle, 1, GL_FALSE,

                               (GLfloat*)&modelViewProjectionVideo.data[0]);

 

            // Render

            glDrawElements(GL_TRIANGLES, NUM_QUAD_INDEX, GL_UNSIGNED_SHORT,

                           (const GLvoid*) &quadIndices[0]);

 

            glDisableVertexAttribArray(videoPlaybackVertexHandle);

            glDisableVertexAttribArray(videoPlaybackNormalHandle);

            glDisableVertexAttribArray(videoPlaybackTexCoordHandle);

 

            glUseProgram(0);

Videoplayback video inverted

October 24, 2012 - 6:03am #2

Hi, do you mean that you see the video on texture inverted (with texture attached to the target in 3d space) ?

Log in or register to post comments