3

I have been developing an android application which uses camera preview raw data for real time image processing.

i have registered the PreviewCallback with camera, and i am able to get each frame data with

 @Override
 public void onPreviewFrame(byte[] data, Camera camera) {

    }

i have another requirement , which is calculating system time (captured time /shutter time ) for each frames (in ms) . each frame should be associated with the appropriate captured time/shutter time.

while using camera.takePicture(shutterCallback, null, null); i can get the shutter time for individual picture.but in preview how can i get the shutter time for each frame which arrives to onpreviewframe callback.

Dinesh Kannan
  • 1,255
  • 13
  • 32
  • 1
    Unfortunately, the only timestamp you can get in Java for preview frames of the *deprecated* camera API is `elapsedRealtimeNanos()` at the first line of the `onPreviewFrame()` callback. There are some platform-dependent alternatives if you work with camera via *undocumented* native API, but maybe for your purposes the best solution could be switching to the new [camera2 API](http://developer.android.com/reference/android/hardware/camera2/CaptureResult.html#SENSOR_TIMESTAMP). On a positive note, the delay between sensor and `onPreviewFrame()` is usually quite small. – Alex Cohn Dec 22 '15 at 12:27
  • @AlexCohn thanks for your replay !.. yeah camera 2 api offers more control over the android camera but it won't work on api level lower than 20 rit ?.. is there any other ways to get the capturing time stamp??.. – Dinesh Kannan Dec 22 '15 at 12:30
  • 1
    Right, camera2 is for 21 and up; also not all devices with 21 feature full support for camera2. Please read my prev. comment - I tried to explain what can be done within the old API. – Alex Cohn Dec 22 '15 at 12:40
  • @AlexCohn yeah.. but my problem finding the android device pitch value (angle around x-axis) for each frame.. getting the pitch value from rotation sensor in very small intervals.i could not match the pitch values to frames because of the delay in onpreview frame callback.. i have asked another question with more details http://stackoverflow.com/questions/34372994/android-camera-onpreviewframe-callback-and-rotation-sensor-callback-synchronizat – Dinesh Kannan Dec 22 '15 at 12:46
  • answered at http://stackoverflow.com/questions/34372994/android-camera-onpreviewframe-callback-and-rotation-sensor-callback-synchronizat – Alex Cohn Dec 22 '15 at 12:50
  • @AlexCohn there is no answer posted ,http://stackoverflow.com/questions/34372994/android-camera-onpreviewframe-callback-and-rotation-sensor-callback-synchronizat – Dinesh Kannan Dec 22 '15 at 12:54
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/98699/discussion-between-user1992200-and-alex-cohn). – Dinesh Kannan Dec 22 '15 at 12:58
  • 1
    FWIW, you can get the timestamp from the camera if you send the frames to a SurfaceTexture, and do your work in GLES instead of Java. Various examples in Grafika (https://github.com/google/grafika). – fadden Dec 22 '15 at 16:55
  • @fadden grafika contains many source samples .. can u tell me which sample contains the solution.. – Dinesh Kannan Dec 23 '15 at 05:37
  • Did you come to any further conculsions than what is in https://stackoverflow.com/questions/34372994/android-camera-onpreviewframe-callback-and-rotation-sensor-callback-synchronizat? – WillC May 09 '18 at 05:38

0 Answers0