1. Check out our companion app, Forums for Android! Download from Google Play

How to manually display frames from Camera.PreviewCallback after processing, without Camera.Preview

Discussion in 'Application Development' started by JamesBurnstone, Dec 5, 2010.

  1. JamesBurnstone

    Thread Starter
    5

    Nov 22, 2010
    9
    0
    5
    PhD
    Manchester, UK
    I have built a face detection app where I get the frames from onPreviewFrame, do the face detection and then draw a circle on a canvas above my surfaceView. The problem is frames are automatically displayed using the surfaceview thread when Camera.StartPreview() is started. This is obviously necessary for the PreviewCallback to kick in. As the processing, face detection and drawing, is done in a separate thread(I am assuming here), there is a 2 second delay between the frame being displayed and the result of that frame being processed and drawn on the canvas.

    What I want to do is stop the camera preview displaying the frames and display them myself after processing. I believe this has three benefits:

    The delay with disappear.

    I can draw straight to the bitmap instead of on a canvas which is useless as you can not undo what you have done.

    It will help keep memory comsumption low by not having two threads using the same image.

    I've read that it is possible to display frames from the previewCallback, does anybody know how and how to stop the frames being displayed automatically?

    Many thanks in advance.
     

    Advertisement

  2. JamesBurnstone

    Thread Starter
    5

    Nov 22, 2010
    9
    0
    5
    PhD
    Manchester, UK
    Comment out

    //mCamera.setPreviewDisplayHolder(mHolder);

    //setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFER);

    Got this from Ken Li on StackOverflow.
     
  3. dhivya2110

    dhivya2110 New Member
    5

    Mar 3, 2012
    1
    0
    5
    Hi how do you process the frames to detect faces? Could you upload the source code of your application please :)
     

Share This Page

Loading...