aboutsummaryrefslogtreecommitdiff
path: root/apps/CameraITS/tests/inprog
diff options
context:
space:
mode:
authorTimothy Knight <tknight@google.com>2014-10-15 13:45:29 -0700
committerTimothy Knight <tknight@google.com>2014-10-15 17:50:13 -0700
commit17ddf87a3d3669089b62098eda4965b6f16e70c8 (patch)
treea9874b15dd45075bcd789f2400b93b066b12e3d1 /apps/CameraITS/tests/inprog
parent77eabea3e8a72b008a4dec492a2781ccb77485bc (diff)
downloadpdk-17ddf87a3d3669089b62098eda4965b6f16e70c8.tar.gz
CameraITS: Simplified test for 3A lock + YUV burst
Bug: 17994909 Change-Id: I5df394d5db2087c10f259f741ac367aaabe16667
Diffstat (limited to 'apps/CameraITS/tests/inprog')
-rw-r--r--apps/CameraITS/tests/inprog/test_burst_sameness_auto.py93
1 files changed, 93 insertions, 0 deletions
diff --git a/apps/CameraITS/tests/inprog/test_burst_sameness_auto.py b/apps/CameraITS/tests/inprog/test_burst_sameness_auto.py
new file mode 100644
index 0000000..f3d49be
--- /dev/null
+++ b/apps/CameraITS/tests/inprog/test_burst_sameness_auto.py
@@ -0,0 +1,93 @@
+# 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.caps
+import its.device
+import its.objects
+import os.path
+import numpy
+
+def main():
+ """Take long bursts of images and check that they're all identical.
+
+ Assumes a static scene. Can be used to idenfity if there are sporadic
+ frames that are processed differently or have artifacts, or if 3A isn't
+ stable, since this test converges 3A at the start but doesn't lock 3A
+ throughout capture.
+ """
+ NAME = os.path.basename(__file__).split(".")[0]
+
+ BURST_LEN = 50
+ BURSTS = 5
+ FRAMES = BURST_LEN * BURSTS
+
+ SPREAD_THRESH = 0.03
+
+ with its.device.ItsSession() as cam:
+
+ # Capture at the smallest resolution.
+ props = cam.get_camera_properties()
+ if not its.caps.manual_sensor(props):
+ print "Test skipped"
+ return
+
+ _, fmt = its.objects.get_fastest_manual_capture_settings(props)
+ w,h = fmt["width"], fmt["height"]
+
+ # Converge 3A prior to capture.
+ cam.do_3a(lock_ae=True, lock_awb=True)
+
+ # After 3A has converged, lock AE+AWB for the duration of the test.
+ req = its.objects.auto_capture_request()
+ req["android.blackLevel.lock"] = True
+ req["android.control.awbLock"] = True
+ req["android.control.aeLock"] = True
+
+ # Capture bursts of YUV shots.
+ # Get the mean values of a center patch for each.
+ # Also build a 4D array, which is an array of all RGB images.
+ r_means = []
+ g_means = []
+ b_means = []
+ imgs = numpy.empty([FRAMES,h,w,3])
+ for j in range(BURSTS):
+ caps = cam.do_capture([req]*BURST_LEN, [fmt])
+ for i,cap in enumerate(caps):
+ n = j*BURST_LEN + i
+ imgs[n] = its.image.convert_capture_to_rgb_image(cap)
+ tile = its.image.get_image_patch(imgs[n], 0.45, 0.45, 0.1, 0.1)
+ means = its.image.compute_image_means(tile)
+ r_means.append(means[0])
+ g_means.append(means[1])
+ b_means.append(means[2])
+
+ # Dump all images.
+ print "Dumping images"
+ for i in range(FRAMES):
+ its.image.write_image(imgs[i], "%s_frame%03d.jpg"%(NAME,i))
+
+ # The mean image.
+ img_mean = imgs.mean(0)
+ its.image.write_image(img_mean, "%s_mean.jpg"%(NAME))
+
+ # Pass/fail based on center patch similarity.
+ for means in [r_means, g_means, b_means]:
+ spread = max(means) - min(means)
+ print spread
+ assert(spread < SPREAD_THRESH)
+
+if __name__ == '__main__':
+ main()
+