CameraITS: Add AE and AF tests to 3A
Also update device.py that it supports documented behavior for A subsets:
ie. ae_only has None for AF values, etc.
Change-Id: I6d151d44960d1ff136294a90b2022e1a2b5a47ce
diff --git a/apps/CameraITS/pymodules/its/device.py b/apps/CameraITS/pymodules/its/device.py
index d084f83..5a29074 100644
--- a/apps/CameraITS/pymodules/its/device.py
+++ b/apps/CameraITS/pymodules/its/device.py
@@ -389,6 +389,7 @@
Triggers some or all of AE, AWB, and AF, and returns once they have
converged. Uses the vendor 3A that is implemented inside the HAL.
+ Note: do_awb is always enabled regardless of do_awb flag
Throws an assertion if 3A fails to converge.
@@ -416,8 +417,8 @@
Five values are returned if get_results is true::
* AE sensitivity; None if do_ae is False
* AE exposure time; None if do_ae is False
- * AWB gains (list); None if do_awb is False
- * AWB transform (list); None if do_awb is false
+ * AWB gains (list);
+ * AWB transform (list);
* AF focus position; None if do_af is false
Otherwise, it returns five None values.
"""
@@ -447,9 +448,11 @@
data,_ = self.__read_response_from_socket()
vals = data['strValue'].split()
if data['tag'] == 'aeResult':
- ae_sens, ae_exp = [int(i) for i in vals]
+ if do_ae:
+ ae_sens, ae_exp = [int(i) for i in vals]
elif data['tag'] == 'afResult':
- af_dist = float(vals[0])
+ if do_af:
+ af_dist = float(vals[0])
elif data['tag'] == 'awbResult':
awb_gains = [float(f) for f in vals[:4]]
awb_transform = [float(f) for f in vals[4:]]
diff --git a/apps/CameraITS/tests/scene1/test_ae_af.py b/apps/CameraITS/tests/scene1/test_ae_af.py
new file mode 100644
index 0000000..626a475
--- /dev/null
+++ b/apps/CameraITS/tests/scene1/test_ae_af.py
@@ -0,0 +1,62 @@
+# Copyright 2017 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.caps
+import its.device
+import its.target
+
+import numpy
+
+GAIN_LENGTH = 4
+TRANSFORM_LENGTH = 9
+GREEN_GAIN = 1.0
+GREEN_GAIN_TOL = 0.05
+SINGLE_A = {'ae': [True, False, True], 'af': [False, True, True],
+ 'full_3a': [True, True, True]} # note no AWB solo
+
+
+def main():
+ """Basic test for bring-up of 3A.
+
+ To pass, 3A must converge. Check that the returned 3A values are legal.
+ """
+
+ with its.device.ItsSession() as cam:
+ props = cam.get_camera_properties()
+ its.caps.skip_unless(its.caps.read_3a(props))
+
+ for k, v in sorted(SINGLE_A.items()):
+ print k
+ try:
+ s, e, g, xform, fd = cam.do_3a(get_results=True,
+ do_ae=v[0],
+ do_af=v[1],
+ do_awb=v[2])
+ print ' sensitivity', s, 'exposure', e
+ print ' gains', g, 'transform', xform
+ print ' fd', fd
+ print ''
+ except its.error.Error:
+ print ' FAIL\n'
+ if k == 'full_3a':
+ assert s > 0
+ assert e > 0
+ assert len(g) == 4
+ assert len(xform) == 9
+ assert fd >= 0
+ assert numpy.isclose(g[2], GREEN_GAIN, GREEN_GAIN_TOL)
+
+if __name__ == '__main__':
+ main()
+
diff --git a/apps/CameraITS/tools/run_all_tests.py b/apps/CameraITS/tools/run_all_tests.py
index 77a3dcd..d20cb4a 100644
--- a/apps/CameraITS/tools/run_all_tests.py
+++ b/apps/CameraITS/tools/run_all_tests.py
@@ -50,6 +50,7 @@
"test_jitter"
],
"scene1":[
+ "test_ae_af",
"test_ae_precapture_trigger",
"test_crop_region_raw",
"test_ev_compensation_advanced",