0

I am developing a Google Glass app that uses a live card and a SurfaceView that runs in the background. What I'm trying to do is to create a dummy SurfaceView inside my custom view that the live card is rendering with DirectRenderingCallback. I have referenced the project in comment #3 and it works, but the difference is that I am not using any Activities to create the SurfaceView (if that matters).

I'm running into the issue where every time I try to start the camera preview, I get a message saying "app passed a NULL surface". I don't know whether it is because I'm creating the SurfaceView inside a service or not, but I just cannot seem to be able to get it working. Also, surfaceCreated() is never called.

As far as I know, there is nothing wrong with my code, or how I have set up the live card. I have been through the glass documentation and all of the GDK samples on their Github page. To sum it up, I'm trying to get the stream from the camera into a SurfaceView by using a Live Card. Am I doing anything wrong, or should I be doing something different to accomplish this?

Thanks.

user990230
  • 307
  • 5
  • 13

1 Answers1

1

Well, in my project it is "half-working" as I can display an image but the red and blue colors are swapped, I still have no idea why.

So what I do is in a clas:

public class CameraView extends SurfaceView implements SurfaceHolder.Callback{

I create the surface, then on surfaceCreated open the camera and prepare the parameters:

    camera = Camera.open();
    Parameters parameters = camera.getParameters();
    parameters.setPreviewFpsRange(30000, 30000);            
    camera.setParameters(parameters);   

On surfaceChanged set the display and start the preview:

    if (camera != null){                    
        try {
            camera.setPreviewDisplay(holder);
        } catch (IOException e) {
            this.releaseCamera();
        }
        camera.startPreview();
    }

And this has worked for me, hope it helps!

gkapellmann
  • 313
  • 3
  • 19
  • How are you displaying this view? – user990230 Jul 09 '14 at 16:26
  • Using surfaceView, nevertheless this is where my colour issue comes around. That's why the class says "extends SurfaceView implements SurfaceHolder.Callback", there is a lot of literature around the net of how to implement this. – gkapellmann Jul 10 '14 at 12:54
  • I understand, however I probably should have been more explicit in my question. How are you displaying this view in terms of how the app is built? Are using a high-frequency live card with directRenderingCallback, or a low-frequency live card with RemoteViews? In either case, I have not been able to programmatically create SurfaceView without getting the "app passed NULL surface" message. – user990230 Jul 10 '14 at 21:22
  • Ah right, well I'm far of being an expert, but check this [project](https://github.com/jaredsburrows/OpenQuartz/tree/master/example-apps/OG_CameraApp), this is the one I took as reference, might give you an answer to what you are asking. – gkapellmann Jul 13 '14 at 21:20