Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7005801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:23:50+00:00 2026-05-27T21:23:50+00:00

I am building an augmented reality app that takes frames from the camera, filters

  • 0

I am building an augmented reality app that takes frames from the camera, filters them using a few image processing techniques, and displays them to the user in place of the camera preview.

When I first started I was simply calling:

holder = getHolder();
holder.addCallback(this);
... 
camera.addCallbackBuffer(buffer);
camera.setPreviewDisplay(holder);
camera.setPreviewCallbackWithBuffer(callback);
camera.startPreview();

Inside the callback I do the following:

SurfaceHolder holder;
Canvas c = holder.lockCanvas();
if (c != null) {
    try {
        // Draw to canvas
    } finally {
        holder.unlockCanvasAndPost(c);
    }
}

This worked fairly well, and was giving decent performance on the Motorola Photon.

I also own a Motorola Droid as well as an LG Optimus; on these two devices onPreviewFrame would never get called, and as a result the holder would never get drawn in the callback. And the user would be stuck with a black screen.

After searching around I found that the following line needed to be added

holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);

With this line I finally get the callback. But the problem is if I try to call holder.lockCanvas() I get an error since this isn’t allowed with SURFACE_TYPE_PUSH_BUFFERS.

Now I’ve been able to work around this by placing an ImageView on top of the SurfaceView and drawing the frames to the ImageView instead. But the performance of this is terrible in comparison to using SURFACE_TYPE_NORMAL.

My questions are:

  • Is SURFACE_TYPE_NORMAL a valid usable type, or can I only trust SURFACE_TYPE_PUSH_BUFFERS?
  • If so, is it possible to determine if a device supports SURFACE_TYPE_NORMAL so I can squeeze that extra bit of performance out of devices that do? Are there certain Android versions, or manufacturers that support it?

As a side note, I understand that for Honeycomb (3.0) these values are no longer supported. But they are requred for 2.3 and lower. Also for ICS (4.0), the new SurfaceTexture pipeline is blazing fast. But I would still like to support at least 2.2 and 2.3.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T21:23:50+00:00Added an answer on May 27, 2026 at 9:23 pm

    While I have not received an official answer, and probably will not since on newer Android versions this is deprecated, I have found that SURFACE_TYPE_NORMAL is not valid for use with a camera preview on many devices.

    This answer comes from testing on various devices. On some devices no video will ever be received; it has nothing to do with the various parameters used.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Building an app using a calendar on a Google Apps domain that has SSL
I'm building a custom control for Windows Phone 7+ that can do augmented reality
building a site using PHP and MySQL that needs to store a lot of
Building our Android app from Ant fails with this error: [apply] [apply] UNEXPECTED TOP-LEVEL
Building an iPad app. I have a button on my main view that I
Building from source outside of macports is a breeze. Building with macports takes forever
Building my first web app using Yii and wondering if it is best to
Building an app with the Facebook JavaScript API that will embedded into a page
Building an iPhone app, using: Xcode 4.1 Base SDK iOS 4.3 Apple LLVM Compiler
Building an app using the Facebook iOS SDK. When testing on the simulator, I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.