I need getFrameNumber
for Image object received from ImageReader
for my camera2.
Currently, I received different timestamp for the following code so due to that, I am not able to map getFrameNumber
of CameraResult
callback.
CameraCaptureSession.CaptureCallback captureListenerLeft = new CameraCaptureSession.CaptureCallback() {
@Override
public void onCaptureCompleted(CameraCaptureSession session, CaptureRequest request, TotalCaptureResult result) {
super.onCaptureCompleted(session, request, result);
Log.d(TAG, "#### Camera Preview: FrameNumber:[" + result.getFrameNumber()+"] TimeStamp:[" + result.get(CaptureResult.SENSOR_TIMESTAMP) / 1000000 + "] Expo:[" +result.get(CaptureResult.SENSOR_EXPOSURE_TIME)+ "] FrameDuration:[" + result.get(CaptureResult.SENSOR_FRAME_DURATION) + "]");
}
};
Now at ImageReader Callback:-
ImageReader.OnImageAvailableListener mImgLeftCameraListener=new ImageReader.OnImageAvailableListener() {
@Override
public void onImageAvailable(ImageReader imageReader) {
try{
Image mImage=imageReader.acquireNextImage();
long mTimeStap=mImage.getTimestamp()/1000000;
mImage.close();
}catch (Exception exc){
exc.printStackTrace();
}
}
};
Now the issue is Image reader mTimeStap
does not match with result.get(CaptureResult.SENSOR_TIMESTAMP) / 1000000
value, So i am not able to map getFrameNumber.
NOTE: My android is 7.1.1 custom OS build for Qualcomm 820.
The timestamps are the only way to match these; by design of the API, they should match. What kinds of differences are you seeing in the timestamp values?
Edit: And to add, there's no way to get a frame number from the image reader; that value is not passed to the ImageReader at all.