aboutsummaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorTimothy Knight <tknight@google.com>2014-07-13 17:59:32 -0700
committerTimothy Knight <tknight@google.com>2014-07-14 21:25:29 +0000
commit8481a195ca2a4caa42aef8088998f129f7fccd39 (patch)
tree8b8e1caee736313a1a56468d95b4669b319c3ccf /apps
parent07fdc65748b3094c40bf960f2c415ca0aa26e0fe (diff)
downloadpdk-8481a195ca2a4caa42aef8088998f129f7fccd39.tar.gz
CameraITS: Moved DNG test into scene2 and updated it slightly
Change-Id: Ifa8f232a23141a1f9ce0fe82565684f95123ed24 (cherry picked from commit 20c56787c6a51377db2ce3edb34003e9561440f7)
Diffstat (limited to 'apps')
-rw-r--r--apps/CameraITS/tests/scene2/README5
-rw-r--r--apps/CameraITS/tests/scene2/test_dng_tags.py83
-rw-r--r--apps/CameraITS/tests/test_dng_tags.py76
3 files changed, 88 insertions, 76 deletions
diff --git a/apps/CameraITS/tests/scene2/README b/apps/CameraITS/tests/scene2/README
new file mode 100644
index 0000000..88c3b81
--- /dev/null
+++ b/apps/CameraITS/tests/scene2/README
@@ -0,0 +1,5 @@
+Scene 2 requires a camera lab with controlled illuminants, for example
+light sources capable of producing D65, D50, A, TL84, etc. illumination.
+Specific charts may also be required, for example grey cards, color
+checker charts, and resolution charts. The individual tests will specify
+the setup that they require.
diff --git a/apps/CameraITS/tests/scene2/test_dng_tags.py b/apps/CameraITS/tests/scene2/test_dng_tags.py
new file mode 100644
index 0000000..946edef
--- /dev/null
+++ b/apps/CameraITS/tests/scene2/test_dng_tags.py
@@ -0,0 +1,83 @@
+# 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.dng
+import its.objects
+import numpy
+import os.path
+
+def main():
+ """Test that the DNG tags are internally self-consistent.
+ """
+ NAME = os.path.basename(__file__).split(".")[0]
+
+ with its.device.ItsSession() as cam:
+ props = cam.get_camera_properties()
+
+ # Assumes that illuminant 1 is D65, and illuminant 2 is standard A.
+ # TODO: Generalize DNG tags check for any provided illuminants.
+ illum_code = [21, 17] # D65, A
+ illum_str = ['D65', 'A']
+ ref_str = ['android.sensor.referenceIlluminant%d'%(i) for i in [1,2]]
+ cm_str = ['android.sensor.colorTransform%d'%(i) for i in [1,2]]
+ fm_str = ['android.sensor.forwardMatrix%d'%(i) for i in [1,2]]
+ cal_str = ['android.sensor.calibrationTransform%d'%(i) for i in [1,2]]
+ dng_illum = [its.dng.D65, its.dng.A]
+
+ for i in [0,1]:
+ assert(props[ref_str[i]] == illum_code[i])
+ raw_input("\n[Point camera at grey card under %s and press ENTER]"%(
+ illum_str[i]))
+
+ cam.do_3a(do_af=False)
+ cap = cam.do_capture(its.objects.auto_capture_request())
+ gains = cap["metadata"]["android.colorCorrection.gains"]
+ ccm = its.objects.rational_to_float(
+ cap["metadata"]["android.colorCorrection.transform"])
+ cal = its.objects.rational_to_float(props[cal_str[i]])
+ print "HAL reported gains:\n", numpy.array(gains)
+ print "HAL reported ccm:\n", numpy.array(ccm).reshape(3,3)
+ print "HAL reported cal:\n", numpy.array(cal).reshape(3,3)
+
+ # Compute the matrices that are expected under this illuminant from
+ # the HAL-reported WB gains, CCM, and calibration matrix.
+ cm, fm = its.dng.compute_cm_fm(dng_illum[i], gains, ccm, cal)
+ asn = its.dng.compute_asn(dng_illum[i], cal, cm)
+ print "Expected ColorMatrix:\n", cm
+ print "Expected ForwardMatrix:\n", fm
+ print "Expected AsShotNeutral:\n", asn
+
+ # Get the matrices that are reported by the HAL for this
+ # illuminant.
+ cm_ref = numpy.array(its.objects.rational_to_float(
+ props[cm_str[i]])).reshape(3,3)
+ fm_ref = numpy.array(its.objects.rational_to_float(
+ props[fm_str[i]])).reshape(3,3)
+ asn_ref = numpy.array(cap['android.sensor.neutralColorPoint'])
+ print "Reported ColorMatrix:\n", cm_ref
+ print "Reported ForwardMatrix:\n", fm_ref
+ print "Reported AsShotNeutral:\n", asn_ref
+
+ # Compute the deltas between reported and expected.
+ print "Deltas in ColorMatrix:\n", cm - cm_ref
+ print "Deltas in ForwardMatrix:\n", fm - fm_ref
+ print "Deltas in AsShotNeutral:\n", asn - asn_ref
+
+ # TODO: Add pass/fail test on DNG matrices.
+
+if __name__ == '__main__':
+ main()
+
diff --git a/apps/CameraITS/tests/test_dng_tags.py b/apps/CameraITS/tests/test_dng_tags.py
deleted file mode 100644
index 0a609fb..0000000
--- a/apps/CameraITS/tests/test_dng_tags.py
+++ /dev/null
@@ -1,76 +0,0 @@
-# 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.dng
-import its.objects
-
-import numpy
-import os.path
-
-def main():
- """Test that the DNG tags are consistent.
- """
- NAME = os.path.basename(__file__).split(".")[0]
-
- # Capture two shots, one of a grey card illuminated by A, and the other D65.
- # In each case, wait for AE+AWB to converge first. Get the WB gains and ccm
- # reported by the HAL for each shot.
- # gains <- android.colorCorrection.gains
- # ccm <- android.colorCorrection.transform
-
- with its.device.ItsSession() as cam:
- print ""
- raw_input("[Point camera at a grey card illuminated by Standard A]")
- cam.do_3a(do_af=False)
- cap = cam.do_capture(its.objects.auto_capture_request())
- gains = cap["metadata"]["android.colorCorrection.gains"]
- ccm = its.objects.rational_to_float(
- cap["metadata"]["android.colorCorrection.transform"])
- cal = [1,0,0,0,1,0,0,0,1] # TODO: Use real values when plumbed.
- print "HAL reported gains:\n", numpy.array(gains)
- print "HAL reported ccm:\n", numpy.array([ccm[0:3],ccm[3:6],ccm[6:9]])
-
- cm_A, fm_A = its.dng.compute_cm_fm(its.dng.A, gains, ccm, cal)
- asn_A = its.dng.compute_asn(its.dng.A, cal, cm_A)
- print ""
- print "Expected values, based on provided gains and ccm for A:"
- print "A ColorMatrix:\n", cm_A
- print "A ForwardMatrix:\n", fm_A
- print "A AsShotNeutral:\n", asn_A
-
- print ""
- raw_input("[Point camera at a grey card illuminated by D65]")
- cam.do_3a(do_af=False)
- cap = cam.do_capture(its.objects.auto_capture_request())
- gains = cap["metadata"]["android.colorCorrection.gains"]
- ccm = its.objects.rational_to_float(
- cap["metadata"]["android.colorCorrection.transform"])
- cal = [1,0,0,0,1,0,0,0,1] # TODO: Use real values when plumbed.
- print "HAL reported gains:\n", numpy.array(gains)
- print "HAL reported ccm:\n", numpy.array([ccm[0:3],ccm[3:6],ccm[6:9]])
-
- cm_D65, fm_D65 = its.dng.compute_cm_fm(its.dng.D65, gains, ccm, cal)
- asn_D65 = its.dng.compute_asn(its.dng.D65, cal, cm_D65)
- print "\nExpected values, based on provided gains and ccm for D65:"
- print "D65 ColorMatrix:\n", cm_D65
- print "D65 ForwardMatrix:\n", fm_D65
- print "D65 AsShotNeutral:\n", asn_D65, "\n"
-
- # TODO: Query DNG matrices from HAL and compare to expected matrices.
-
-if __name__ == '__main__':
- main()
-