- Sort Posts
- 30 replies
- Last post
Videoplayback video inverted
Videoplayback video inverted
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
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
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
Videoplayback video inverted
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
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
Videoplayback video inverted
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
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
Videoplayback video inverted
Videoplayback video inverted
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
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
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
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
Videoplayback video inverted
Videoplayback video inverted
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
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,};
Hi, do you mean that you see the video on texture inverted (with texture attached to the target in 3d space) ?