Unable to sync less than 3 Ms at best
ajavamind opened this issue · 2 comments
I'm have two Samsung S8 phones mounted for stereo photography and capture photos with SoftwareSync running in debug mode. I am not able to sync these cameras to less than 3 Milliseconds. A sample size of 10 capture syncs ranged from 3 to 13 Ms (7, 6, 10, 4, 6, 10, 13, 7, 3, 9). I'm using a 10 LED linear array display counter, updated at 1 Ms intervals and measure the difference of the LED binary display values between the two camera photos. I verified the timing of the LED count up sequence with an oscilloscope - exactly 1 Ms. The SoftwareSync shutter speed was set to 1/2000 second.
The phase configuration json file used:
{
"periodNs": 33323892,
"goalPhaseNs": 15000000,
"alignThresholdNs": 200000,
"overheadNs": 200000,
"minExposureNs": 33170000
}
The periodNs value was selected based on the frameDurationMs value from debug output.
com.googleresearch.capturesync V/CameraController: onCaptureCompleted: timestampMs = 1,595,063,382,777.953, frameDurationMs = 33.323892, phase = 30.534, sequence id = 0
otherwise these are same values as Pixel 2 phase configuration.
I do not yet understand the algorithm well enough to change these values. Could you advise how to determine the constants for a phone and how to derive these numbers. Note that the Samsung S8 shares the same cpu/gpu as the Pixel 2 but have different cameras.
When I first began to use the SoftwareSync app I was not seeing any captures saved at all.
The shouldSaveFrame(long synchronizedTimestampNs) method in CameraController always returned false.
When I powered down and up both phones nearly simultaneously, only then would the photos be saved.
When any phone was turned off for a while, and capture resumed, the photos would not be saved.
I'm guessing the SystemClock.elapsedRealtimeNanos() clocks in the phones become too far out of range to trigger the save.
My goal is to get less than 1 Ms sync at least. Any help would be appreciated, thanks.
Thanks for your response and suggestions.
Trying to improve synchronization, I chose not to use the mobile hotspot method to connect because the S8 mobile hotspot will only work when a connection to the Internet goes through my Telecom provider with the phone radio. Instead I connected the two phones through a small Mobile router (TP-Link290A 5G channel). One phone is assigned as leader using a static IP address. (Airplane mode with only WIFI turned on). All other apps are closed (I am not able to shutdown hidden apps that are running in the background).
The client sync time shown in leader display varies from 3.4, 3.61, 3.83 to 4.33 ms after starting the app and stays fixed until the next app close and restart. The phase error is less than 0.05 ms (after pressing Align button) when using a frameDurationMs 33323892. I tried other (periodNs) frameDurationMs values and this value gave the minimum client sync time.
Debug output:
2020-07-19 21:44:24.157 9306-9446/com.googleresearch.capturesync V/CameraController: onCaptureCompleted: timestampMs = 1,595,209,456,117.579, frameDurationMs = 33.323892, phase = 21.764, sequence id = 0
After taking a couple of photos the synchronization becomes progressively worse. In one series, it went from 6 ms to 42 ms after a number of captures. I suspect autofocus may be causing a synchronization problem too, because under low light conditions, I saw instances of focus hunting.
I turned off auto focus, sync improved to less than 1 ms. for a few captures. However it was inconsistent over a group of captures, varying up to 120 ms worst case. This variation occurs with or without auto focus.
I am beginning to believe the S8 has too much network latency and/or background app overhead for good synchronization and that auto focus also contributes to the poor synchronization.
I have to restart each phone after a couple of hours before launching the app for it to save any image files. Shutting down and starting the app does not resolve this problem, only Android restart.
The ISO sensitivity range assigned by the app (0-800) does not match camera ISO limits. It seemed like too low ISO (0) setting caused noisy photos over the range. When I fixed this to match the camera ISO range (56-7237), photos looked better.