VINS-Mobile-Android
VINS-Mobile-Android copied to clipboard
image.getTimestamp field incorrectly populated on OPPO R9s
Thanks to the author, transplant the Android version of vins.
The timestamp of the camera and the timestamp of the accelerometer on the OPPO R9s device vary greatly. OPPO R9s log
nanoTime = 44057405311086, currentTimeMillis = 1536722201467, elapsedRealtimeNanos = 181727623633029
image timeStamp = 44057166311000
accl timestamp = 181727627713798
gyro timestamp = 181727629515875
The printed data on the XIAOMI MIX 2S device is like this XIAOMI MIX 2S log
nanoTime = 12108982931733, currentTimeMillis = 1536722547743, elapsedRealtimeNanos = 65299522890167
image timeStamp = 65299452327413
accl timestamp = 65299506914160
gyro timestamp = 65299515881035
I did not find a solution, see https://issuetracker.google.com/issues/36916900 The following is a simple process I have done, and everyone has a good solution to discuss. on MainActivity.java
long nanoTime = System.nanoTime();
long elapsedNanos = SystemClock.elapsedRealtimeNanos();
long imageTimestamp = image.getTimestamp();
boolean imageTimestampIsNanoTime = false;
imageTimestampIsNanoTime = (Math.abs(imageTimestamp - nanoTime) < Math.abs(imageTimestamp - elapsedNanos)) ? true : false;
if (imageTimestampIsNanoTime) {
imageTimestamp = imageTimestamp - nanoTime + elapsedNanos;
}
// pass image to c++ part
VinsJNI.onImageAvailable(image.getWidth(), image.getHeight(),
Y_rowStride, Y_plane.getBuffer(),
UV_rowStride, U_plane.getBuffer(), V_plane.getBuffer(),
surface, imageTimestamp, isScreenRotated,
virtualCamDistance);
Thanks to the author, transplant the Android version of vins.
The timestamp of the camera and the timestamp of the accelerometer on the OPPO R9s device vary greatly. OPPO R9s log
nanoTime = 44057405311086, currentTimeMillis = 1536722201467, elapsedRealtimeNanos = 181727623633029 image timeStamp = 44057166311000 accl timestamp = 181727627713798 gyro timestamp = 181727629515875
The printed data on the XIAOMI MIX 2S device is like this XIAOMI MIX 2S log
nanoTime = 12108982931733, currentTimeMillis = 1536722547743, elapsedRealtimeNanos = 65299522890167 image timeStamp = 65299452327413 accl timestamp = 65299506914160 gyro timestamp = 65299515881035
I did not find a solution, see https://issuetracker.google.com/issues/36916900 The following is a simple process I have done, and everyone has a good solution to discuss. on MainActivity.java
long nanoTime = System.nanoTime(); long elapsedNanos = SystemClock.elapsedRealtimeNanos(); long imageTimestamp = image.getTimestamp(); boolean imageTimestampIsNanoTime = false; imageTimestampIsNanoTime = (Math.abs(imageTimestamp - nanoTime) < Math.abs(imageTimestamp - elapsedNanos)) ? true : false; if (imageTimestampIsNanoTime) { imageTimestamp = imageTimestamp - nanoTime + elapsedNanos; } // pass image to c++ part VinsJNI.onImageAvailable(image.getWidth(), image.getHeight(), Y_rowStride, Y_plane.getBuffer(), UV_rowStride, U_plane.getBuffer(), V_plane.getBuffer(), surface, imageTimestamp, isScreenRotated, virtualCamDistance);
I also have this problem, just restart the phone