Topic locked

Freezing the Video Background by using State

January 2, 2015 - 8:26am #1

Hi, I'm trying to freeze the background for my app. I'm not sure if I'm using the correct way or term. Basically, I want to stop the camera from updating once I tap on the screen. 

I'm using this page as a reference. 
https://developer.vuforia.com/resources/dev-guide/freezing-video-background

However, I'm having a problem. I'm getting an error from running this particular code at line 15. 

        state = Renderer.getInstance().begin( frozenState );

I've noted that this function actually returns void.

https://developer.vuforia.com/sites/default/files/doxygen/11-21-2014-10-31-55_doxygen/Vuforia_Android_Vuforia_Android_-_API_Documentation_Public_-_Java_3.2.5_159_artifacts/publicAPI/nav_f.png); background-color: rgb(221, 236, 238); background-repeat: repeat-x;">
void com.qualcomm.vuforia.Renderer.begin ( State state )  

Marks the beginning of rendering for the given frame. Use this to draw a specific camera frame, rather than the latest available one.

So, naturally, eclipse wouldn't let me run it. So I removed the "state =".

 Renderer.getInstance().begin( frozenState );

And this came out in my LogCat

01-03 00:16:02.624: E/AndroidRuntime(22737): FATAL EXCEPTION: GLThread 2332
01-03 00:16:02.624: E/AndroidRuntime(22737): java.lang.NullPointerException: Attempt to dereference null QCAR::State
01-03 00:16:02.624: E/AndroidRuntime(22737): at com.qualcomm.vuforia.VuforiaJNI.Renderer_begin__SWIG_1(Native Method)
01-03 00:16:02.624: E/AndroidRuntime(22737): at com.qualcomm.vuforia.Renderer.begin(Renderer.java:67)
01-03 00:16:02.624: E/AndroidRuntime(22737): at com.qualcomm.vuforia.samples.VuforiaSamples.app.ImageTargets.ImageTargetRenderer.renderFrame(ImageTargetRenderer.java:266)
01-03 00:16:02.624: E/AndroidRuntime(22737): at com.qualcomm.vuforia.samples.VuforiaSamples.app.ImageTargets.ImageTargetRenderer.onDrawFrame(ImageTargetRenderer.java:148)
01-03 00:16:02.624: E/AndroidRuntime(22737): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1527)
01-03 00:16:02.624: E/AndroidRuntime(22737): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1244)
 
 
I'm not sure what is the problem here. Is it something to do with a Null Pointer? But I've checked the "frozenState" before I begin() it. It's not Null.
 

 

Freezing the Video Background by using State

January 4, 2015 - 6:00am #3

closing thread.

 

Freezing the Video Background by using State

January 2, 2015 - 3:35pm #2

Fixed. I've used frozenState = state.clone(); instead of frozenState = state;

private void renderFrame()
    {
        GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);
                
        State state;
        State curState;
        if ( renderFrozenFrame )
        {
            // Get the state from QCAR and mark the beginning of a rendering section
            mRenderer.begin(frozenState);
            curState = frozenState;
        }
        else
        {
        	
            state = mRenderer.begin();
            curState = state;
            if ( freezeCurrent ) 
            {
                frozenState = state.clone();
     
                // Release camera
                CameraDevice.getInstance().stop();
                CameraDevice.getInstance().deinit();
                renderFrozenFrame = true;
                
            }
        }
         
        // Explicitly render the Video Background
        mRenderer.drawVideoBackground();

 

Topic locked