aboutsummaryrefslogtreecommitdiff
path: root/apps/CameraITS/tests/scene0/test_jitter.py
diff options
context:
space:
mode:
authorTimothy Knight <tknight@google.com>2014-07-12 10:21:08 -0700
committerTimothy Knight <tknight@google.com>2014-07-12 10:48:43 -0700
commit85240a0befc7bcd4869280966b6c468d94d28994 (patch)
tree3b7c333bb77a24614f9f2f2e9b4b6c2bc8378d66 /apps/CameraITS/tests/scene0/test_jitter.py
parent35ebc222b3cbb3df757c5ecdaac84191289dfedf (diff)
downloadpdk-85240a0befc7bcd4869280966b6c468d94d28994.tar.gz
CameraITS: Created scene0, added test_raw_sensitivity_burst.py.
Also added helper function to get the fastest legal capture settings, for the scene0 tests to use. Change-Id: I38a6da33645723a8119b12b6f752656ceb69d690
Diffstat (limited to 'apps/CameraITS/tests/scene0/test_jitter.py')
-rw-r--r--apps/CameraITS/tests/scene0/test_jitter.py62
1 files changed, 62 insertions, 0 deletions
diff --git a/apps/CameraITS/tests/scene0/test_jitter.py b/apps/CameraITS/tests/scene0/test_jitter.py
new file mode 100644
index 0000000..0983816
--- /dev/null
+++ b/apps/CameraITS/tests/scene0/test_jitter.py
@@ -0,0 +1,62 @@
+# Copyright 2014 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import its.image
+import its.device
+import its.objects
+import os.path
+import pylab
+import matplotlib
+import matplotlib.pyplot
+
+def main():
+ """Measure jitter in camera timestamps.
+ """
+ NAME = os.path.basename(__file__).split(".")[0]
+
+ # Pass/fail thresholds
+ MIN_AVG_FRAME_DELTA = 30 # at least 30ms delta between frames
+ MAX_VAR_FRAME_DELTA = 0.01 # variance of frame deltas
+ MAX_FRAME_DELTA_JITTER = 0.3 # max ms gap from the average frame delta
+
+ with its.device.ItsSession() as cam:
+ props = cam.get_camera_properties()
+ req, fmt = its.objects.get_fastest_manual_capture_settings(props)
+ caps = cam.do_capture([req]*50, [fmt])
+
+ # Print out the millisecond delta between the start of each exposure
+ tstamps = [c['metadata']['android.sensor.timestamp'] for c in caps]
+ deltas = [tstamps[i]-tstamps[i-1] for i in range(1,len(tstamps))]
+ deltas_ms = [d/1000000.0 for d in deltas]
+ avg = sum(deltas_ms) / len(deltas_ms)
+ var = sum([d*d for d in deltas_ms]) / len(deltas_ms) - avg * avg
+ range0 = min(deltas_ms) - avg
+ range1 = max(deltas_ms) - avg
+ print "Average:", avg
+ print "Variance:", var
+ print "Jitter range:", range0, "to", range1
+
+ # Draw a plot.
+ pylab.plot(range(len(deltas_ms)), deltas_ms)
+ matplotlib.pyplot.savefig("%s_deltas.png" % (NAME))
+
+ # Test for pass/fail.
+ assert(avg > MIN_AVG_FRAME_DELTA)
+ assert(var < MAX_VAR_FRAME_DELTA)
+ assert(abs(range0) < MAX_FRAME_DELTA_JITTER)
+ assert(abs(range1) < MAX_FRAME_DELTA_JITTER)
+
+if __name__ == '__main__':
+ main()
+