0

I am trying to make an app using the camera on android.

I try example given by Google, but it says older sdk is on my phone.

Google sample uses camera2.

How to let my android 4.0 phone launch it?


Also, in my custom camera app I need to get images from cam preview and if the correspond my criteria then show them on the screen - do not show every preview image on screen, is it possible?

Alex Cohn
  • 56,089
  • 9
  • 113
  • 307
  • 2
    The `android.hardware.camera2` package was added in API level 21 (Android 'Lollilop' 5.0). As it's non-existent in older versions of Android, you simply *cannot* use it on your Android 4.0 (API level 14) device. For any recommendations, it would be helpful to know what kind of criteria you're talking about? I.e. face recognition, marker recognition, something completely different? Depending on your answer, there may be other API's and/or libraries worth looking into. – MH. Oct 27 '15 at 09:49

1 Answers1

0

You actually ask two unrelated questions. The first question got a complete answer from MH under dsiguise of a comment.

The second answer is: you cannot control the frames that are displayed by camera preview (whether this be camera SurfaceView, or TextureView, or SurfaceTexture). You can hide1 all preview frames (e.g. simply overlay the camera preview with another non-transparent view), but still receive the preview frames in onPreviewFrame() callback. You can perform whatever processing in your callback2, and display the frame (as it arrives from the camera, or changed by your processing) in your favorite manner (using Canvas, or OpenGL, or something else).


Footnotes:

1 There are many attempts to run Android camera without displaying the preview. Each such approach has its limitations, and don't work flawlessly on all devices.

Note that if you choose the SurfaceTexture + OpenGL approach, it is relatively easy to reliably hide the raw preview flow, and only show the frames that correspond to your criteria.

2 It is not impossible to perform image processing in OpenGL, e.g. see replacing glReadPixels with EGL_KHR_image_base for faster pixel copy, but this involves advanced device-dependent techniques.

Community
  • 1
  • 1
Alex Cohn
  • 56,089
  • 9
  • 113
  • 307