Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Camera Preview Frame Timestamp

Is there a way to get a timestamp of when the Android Camera Preview Frame was captured?

  1. no Camera method is returning a timestamp
  2. you can not access Camera from native code
  3. buffer size is not static (depends on the min preview size acquired from the camera - when and if the method is working) and if there are more frames in the queue then there are preview buffers they are discarded
  4. frame rate that was set (again, if/when the method is working) is just a hint to the system, camera can ignore the value. Same goes for the frame rate the camera is returning.

I am doing some heavy image processing in real time, and the small errors when added together are a real problem.

like image 477
LambergaR Avatar asked Jan 27 '12 20:01

LambergaR


People also ask

What is preview callback?

Callback interface used to deliver copies of preview frames as they are displayed. See also: Camera. setPreviewCallback(Camera. PreviewCallback)

What is Camera API in Android?

This package is the primary API for controlling device cameras. It can be used to take pictures or videos when you are building a camera application. Camera. This class is the older deprecated API for controlling device cameras.


1 Answers

The only way I know to do this is use a SurfaceTexture instead of the preview callback.

The SurfaceTexture has a getTimestamp() method that returns nanoseconds since some unspecified (but constant) time.

Unfortunately, the SurfaceTexture is an OpenGL external texture, so it's not as easy to work with the preview callback.

On the other hand, it's substantially more CPU efficient: The preview callback does color conversion and image reshaping in software, whereas one can use the OpenGL ES2 features to do significant amounts of image processing on the GPU.

like image 96
Michael O Avatar answered Sep 28 '22 23:09

Michael O