Reputation: 2473
Is there a way to get a timestamp of when the Android Camera Preview Frame was captured?
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
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