I am developing sample application which gives me color code of pointed image or object via Camera in android. My application is similar to this application and I am using this
Nothing will guarantee precise 500ms - camera hardware is not set to respond immediately. Still, you can be rather close to that. First of all, open the camera from a background Handler thread (see https://stackoverflow.com/a/19154438/192373).
public void onPreviewFrame(byte[] data, Camera camera) {
long releaseTime = SystemClock.currentThreadTimeMillis() + 500;
decodeYUV420SP(pixels, data, previewSize.width, previewSize.height);
listener.OnPreviewUpdated(pixels, previewSize.width, previewSize.height);
resetBuffer();
SystemClock.sleep(releaseTime-SystemClock.currentThreadTimeMillis());
}
This assumes that decodeYUV420SP()
and OnPreviewUpdated()
together take much less than 500ms.