LambergaR
LambergaR

Reputation: 2473

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.

Upvotes: 16

Views: 3693

Answers (1)

Michael O
Michael O

Reputation: 3415

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.

Upvotes: 4

Related Questions