Log in or register to post comments

video on screen when lost tracking..

February 4, 2013 - 12:58am #1

Hi dude

When got  tracking  in videoplayback  the video sucessfully playing on the surface but I have to keep continious video playing center of the screen when lost the tracking  and if again got the tacking it has to play like privious..

video on screen when lost tracking..

November 4, 2013 - 5:20am #28

Send it

video on screen when lost tracking..

November 4, 2013 - 5:09am #27

It will be great if you could send the code to

video on screen when lost tracking..

November 4, 2013 - 1:36am #26

 

Ok

 

I modified the script DefultTrackableEventHandler  
 
You can download a sample 
 
i need your email to send a link

video on screen when lost tracking..

November 1, 2013 - 12:03pm #25

Yes , still looking for a solution

video on screen when lost tracking..

November 1, 2013 - 9:05am #24

Hello there

 

You still need a solution to this problem?

video on screen when lost tracking..

October 7, 2013 - 5:00am #23

Is there anyone successfull in implementing the cloudreco app with videoplayback?

The video has to be in texture when the tracker is detected, and in centre of the screen when the tracker is lost.

 

Anyone successfull or atleast managed to videoplayback on texture with cloudreco.?

 

Help!!

video on screen when lost tracking..

October 3, 2013 - 5:28am #22

Hi ashunkhs

I am also implementing the same...

I am trying to do as you did...but i am having problem while modifying...can you post how you have modified _renderFrame() that uses

transition2Dto3D and other functions that are given in CloudReco sample

Can you suggest how to integrate videoplayback sample and cloudReco sample

thank you

video on screen when lost tracking..

February 12, 2013 - 12:48am #21

Hi, the only thing I can suggest here is to check if there is any difference in the code inside the getFinalPositionMatrix() function (i.e. if it is the same as in the original Cloud Reco sample); 

also, you can verify that the output of that function (i.e. your newMatrix) when logged produces the same result as the one computed from the CloudReco sample (i.e. you could Log the matrix from one sample, and the matrix from your app, and see if there is any difference; then, if there is, you can Log the individual parameters used to compute that matrix; at some point you should be able to identify if some of the parameters are different, and check why; for example you might have not initialized some of them correctlty).

I hope this helps.

video on screen when lost tracking..

February 12, 2013 - 12:39am #20

Hi  Aless.

  thanks for quick responce. I did that changes but video still not vissible on the screen . folloing  is the matrix which i set ..pls check once ..

 

 

case 1.    
     QCAR::Matrix44F newMatrix=transition2Dto3D->getFinalPositionMatrix();
 
               getFinalPositionMatrix()  - get the orthoMatrix and do som changes and then return that result matrix ..whtch i set in renderframe();
 
               QCAR::Matrix44F result = orthoMatrix;
               SampleUtils::translatePoseMatrix(translateX, translateY, 0.0f,&result.data[0]); 
             
                ..........and as result i video not vissible on the screen.
 
 
case 2.
      QCAR::Matrix44F newMatrix=transition2Dto3D->getOrthoMatrix();
 
               QCAR::Matrix44F Transition3Dto2D::getOrthoMatrix(){
                          return orthoMatrix;    
                  }
          and this matrix does't change any thing . it directlly return the orthoMatrix.  and set it renderFrame();
         
            .....as result video not vissible...
 
//...and these are my matrixs which i am getting .......//
 
orthoMatrix matrix-----
0.002857 0.000000 0.000000 0.000000
0.000000 0.001667 0.000000 0.000000
0.000000 0.000000 1.000000 0.000000
0.000000 0.000000 0.000000 1.000000
 
 
finalPositionMatrix===
1.920281 0.000000 0.000000 0.000000
0.000000 1.265625 0.000000 0.000000
0.000000 0.000000 -1.000000 0.000000
0.000000 0.000000  0.000000  1.000000
 
 
if there is any possible condition ..pls refer to me..
 
 
 
 

 

video on screen when lost tracking..

February 11, 2013 - 10:38pm #19

Hi, looking at your code, this line must be removed:

 

SampleUtils::multiplyMatrix(&projectionMatrix.data[0],&modelViewMatrixVideo.data[0],  
  &newMatrix.data[0]);

                                                       

The code here above multiplies the projectionMatrix by the modelViewMatrixVideo and stores the result into newMatrix; so, this means that the content of newMatrix (which was previously set to getFinalPositionMatrix() ) is being reset to something else;
so you need to remove that line.
 
 

video on screen when lost tracking..

February 11, 2013 - 10:26pm #18

Hi dude

  I set the ( QCAR::Matrix44F newMatrix=transition2Dto3D->getFinalPositionMatrix(); ) newMatrix on the place of modelViewProjectionVideo.

But it works like priviousally . meens it does't work.  folloing is my updated code pls check once and tell me what i have to do next....

 

 

 

 

// In any other case, such as playing or paused, we render the actual content
 
renderFrame()
{
else
{
QCAR::Matrix44F modelViewMatrixVideo = QCAR::Tool::convertPose2GLMatrix(trackableResult->getPose());
 
QCAR::Matrix44F modelViewProjectionVideo;
 
QCAR::Matrix44F newMatrix=transition2Dto3D->getFinalPositionMatrix();                //got getFinalPositionMatrix
 
/*for(int i=0;i<16;i++)
{
LOG("newMatrix===%f",newMatrix);
}*/
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] ,
                                                              &newMatrix.data[0]);                                                        //set  newMatrix on place of modelViewProjectionVideo
 
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]);
 
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]);
 
 
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*) &newMatrix.data[0]);                               //set  newMatrix on place of modelViewProjectionVideo
 
glUniform1i(videoPlaybackTexSamplerOESHandle, 0 /*GL_TEXTURE0*/);
 
// Render
glDrawElements(GL_TRIANGLES, NUM_QUAD_INDEX, GL_UNSIGNED_SHORT,(const GLvoid*) &quadIndices[0]);      
 
glDisableVertexAttribArray(videoPlaybackVertexHandle);
glDisableVertexAttribArray(videoPlaybackNormalHandle);
glDisableVertexAttribArray(videoPlaybackTexCoordHandle);
 
glUseProgram(0);
 
}

 

video on screen when lost tracking..

February 11, 2013 - 9:17am #17

Hi, the matrix computed by the getFinalPositionMatrix() function is meant to act as a combined <ModelView and Projection> matrix, so you need to use it in place of modelViewProjectionVideo  

 

video on screen when lost tracking..

February 11, 2013 - 3:57am #16

hi aless

    Here i am getting orthoMatrix: in renderframe().

     QCAR::Matrix44F newMatrix=transition2Dto3D->getFinalPositionMatrix();

    my orthoMatrix  is as...

   newMatrix matrix ------------------1.920281

newMatrix matrix ------------------0.000000
newMatrix matrix ------------------0.000000
newMatrix matrix ------------------0.000000
newMatrix matrix ------------------0.000000
newMatrix matrix ------------------1.265625
newMatrix matrix ------------------0.000000
newMatrix matrix ------------------0.000000
newMatrix matrix ------------------0.000000
newMatrix matrix ------------------0.000000
newMatrix matrix -------------------1.000000
newMatrix matrix ------------------0.000000
newMatrix matrix ------------------0.000000
newMatrix matrix ------------------0.000000
newMatrix matrix ------------------0.000000
newMatrix matrix ------------------1.000000  ...like this
 
But  i not  sure ..wheere i have to set this matrix.. 
i have to set this matrix on the place of   modelViewMatrixVideo  OR  modelViewProjectionVideo  to play the video on the screen  .

video on screen when lost tracking..

February 8, 2013 - 6:47am #15

Hi, 

the getFinalPositionMatrix() function uses several parameters to make its calculations:

  • orthoMatrix: this is the most important one; you need to make sure that it is set correctly;   in the CloudReco sample, this matrix is updated in the updateScreenPoperties() function, which is called from the Transition3Dto2D constructor;  the key paramaters used are the screen width and screen height; if these are incorrectly set, then the whole orthoMatrix will be incorrect
  • the scaleX and scaleY parameters, these are also important and can only be correctly computed if the screenRect variable is correctly updated (once again, this is computed in the updateScreenPoperties() function)

Another thing to keep in mind are the verrtex coordinates of the rectangle used in CloudReco and the one used in Videoplayback sample:

  • see planeVertices[] in CloudReco.h (CloudReco sample), in which coordinates range between -0.5f and +0.5f 
  • see quadVertices[] in Quad.h (VideoPlayback sample), which range between -1 and +1 (so there is a scale factor 2 of difference between the two samples, in terms of geometry of the textured quad)

If you check these elements, you should be able to come up with something working.

I hope this helps.

video on screen when lost tracking..

February 8, 2013 - 4:08am #14

HI aless..

   There  is any solution...? pls help me out.

video on screen when lost tracking..

February 7, 2013 - 3:14am #13

Hi Aless..

  As you  told I tried to set  the  transition2Dto3D->getFinalPositionMatrix()  in  renderFrame()  to play the video center of the screen .....like this

 

QCAR::Matrix44F newMatrix=transition2Dto3D->getFinalPositionMatrix();

glUniformMatrix4fv(videoPlaybackMVPMatrixHandle, 1, GL_FALSE,(GLfloat*)& newMatrix.data[0]) ;  //modelViewProjectionVideo.data[0]);

 

but as result i can hear the voice of video but ..video is not visuallise. pls

............................................................................

 

// In any other case, such as playing or paused, we render the actual contents
else
{
 
QCAR::Matrix44F modelViewMatrixVideo = QCAR::Tool::convertPose2GLMatrix(trackableResult->getPose());
 
QCAR::Matrix44F modelViewProjectionVideo;
 
 
 
QCAR::Matrix44F newMatrix=transition2Dto3D->getFinalPositionMatrix();
 
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]);
 
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]);
 
 
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*)& newMatrix.data[0]);//modelViewProjectionVideo.data[0]);
 
glUniform1i(videoPlaybackTexSamplerOESHandle, 0 /*GL_TEXTURE0*/);
 
// Render
glDrawElements(GL_TRIANGLES, NUM_QUAD_INDEX, GL_UNSIGNED_SHORT,(const GLvoid*) &quadIndices[0]);
 
glDisableVertexAttribArray(videoPlaybackVertexHandle);
glDisableVertexAttribArray(videoPlaybackNormalHandle);
glDisableVertexAttribArray(videoPlaybackTexCoordHandle);
 
glUseProgram(0);
 
}

video on screen when lost tracking..

February 6, 2013 - 4:05am #12

Hi yogendra,

the CloudReco sample uses a class called Transition3Dto2D; that class contains a function called getFinalPositionMatrix(); this function basically computes a matrix which is the combination of a modelview and a projection matrix (i.e. it computes a "modelviewProjectionMatrix" if you like);

such a matrix is what allows the 3D object to be renderered screen-aligned and at the center of the screen.

Now, if you look at the function void Transition3Dto2D::render(), you will see that the getFinalPositionMatrix() function is used here for obtaining the final modelViewProjection matrix, as above. 

In addition to that, the linearInterpolate() function is used for interpolating between the "current" modelviewProjection matrix and the "final" one (so to obtain the smooth transition effect); the interpolation is performed with a very simple linear scheme (to keep the code simple).

I cannot explain in details every line of code, but I would really invite you to read through the code in those functions and trying to understand what matrices and what variables get involved in the various processing steps (if you don;t get the full mathematical details is not so important, as long as you follow the logical process and the variables / matrices involved).

I hope this helps.

 

video on screen when lost tracking..

February 5, 2013 - 8:52pm #11

what changes in modelViewMatrix is required to keep it on centre of screen ?

i tried to find how book texture is drawn in centre of screen when animation is finished but unable to understand.

video on screen when lost tracking..

February 5, 2013 - 10:21am #10

Back to ashunkhs:

if you look at the CloudReco sample, you will see renderAugmentation function; this function uses the "modelviewMatrix" to position the augmentation in 3D; this matrix is derived from the trackable pose (see trackableResult->getPose() function).

If you want to show the video at the center of the screen, you might save the movelview matrix (or the pose) and use it when tracking is lost, by replacing the rotation part of the matrix with a null rotation, while keeping the translation part.

 

video on screen when lost tracking..

February 5, 2013 - 10:18am #9

@ yogendra:

if you look at the VideoPlayback sample code, you will see that each trackable has an associated modelview matrix:

modelViewMatrix[currentTarget]

So, you need to play with that matrix.

 

 

video on screen when lost tracking..

February 5, 2013 - 4:27am #8

AlessandroB wrote:

@yogendra: if you take the same Matrix manipulation of the CloudReco sample (see functions used to do "transition 2D to 3D" and vice versa), and you use the modelview matrices used for rendering the textured quads of the video playback sample, you should be able to achieve the desired effect;

if you get lost at some point, I would suggest to proceed in small steps;

for instance you could start from the CloudReco sample and then replace the "Book" cover rendering with something where the texture is not build from the book cover, but from a video like in the VideoPlayback sample.

thanks for reply I already gone through CloudReco sample to see how it animate texture on tracker lost,but if i want simply put video on centre of screen when tracker lost and put back on marker surface ,what matrix i have to pass so that video texure simply become independent on marker and come on centre of screen.

video on screen when lost tracking..

February 5, 2013 - 4:15am #7

@yogendra: if you take the same Matrix manipulation of the CloudReco sample (see functions used to do "transition 2D to 3D" and vice versa), and you use the modelview matrices used for rendering the textured quads of the video playback sample, you should be able to achieve the desired effect;

if you get lost at some point, I would suggest to proceed in small steps;

for instance you could start from the CloudReco sample and then replace the "Book" cover rendering with something where the texture is not build from the book cover, but from a video like in the VideoPlayback sample.

video on screen when lost tracking..

February 5, 2013 - 4:04am #6

hi i also have the same problm in videoplayback

 

i want to bring videotexture in centre of camera screen whenever tracking is lost and when again tracking starts it should be on marker as usual.

 

till now i tried passing different matrices in jni when image tracker result is null but got no luck so far....

 

plz help me out

video on screen when lost tracking..

February 5, 2013 - 2:50am #5

hi  dude 

      I think  you can't understand my question.

   as In CloudeReco sample - play the video if  got the target and if  target is lost the texture of video is animated on the center of screen .

  and  in videoplayback (ice-creem sendwitch)-  play the video on the surface if got target and stop or lost video if target lost.

   BUT  

 i want to play the video ( same  height and width )   continuasally center of  the camere screen (camere still running)  if target is lost and if  got  the target again    

set the metrix   same like CloudeReco . I do't have to play the vodeo on fullscreen . play the video same height , width as first time played .

  

video on screen when lost tracking..

February 4, 2013 - 7:15am #4

Thanks for the clarification, so you basically want to have:

- video-on-texture (rendered on the target in 3D space) when target is tracked 

- fullscreen video when target is lost

From an application logic point of view, you could get inspiration from CloudReco sample, and detect when the tracking is lost so to switch to the fullscreen view;

then, in order to play the video in fullscreen mode, you can look at the "load()" function in the sample code in the VideoPlaybackHelper class (VideoPlaybackHelper.java), in particular at this code snippet, which shows how to trigger fullsreen video playback by using an Intent:

if ((requestedType == MEDIA_TYPE.FULLSCREEN) || (requestedType == MEDIA_TYPE.ON_TEXTURE_FULLSCREEN))
                {
                    mPlayerHelperActivityIntent = new Intent(mParentActivity, FullscreenPlayback.class);
                    mPlayerHelperActivityIntent.setAction(android.content.Intent.ACTION_VIEW);
                    canBeFullscreen = true;
                }

Those are the main things to look at.

I hope this helps.

video on screen when lost tracking..

February 4, 2013 - 2:42am #3

HI  

 

Actually i  have to bring video on device screen when tracking is lost,as in cloudreco sample when tracking is lost book texture comes on device screen.

   

video on screen when lost tracking..

February 4, 2013 - 2:25am #2

Hi, not quite sure to understand  what you are saying, can you be a bit clearer... ?

 

Log in or register to post comments