aboutsummaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorTimothy Knight <tknight@google.com>2014-07-26 11:57:38 -0700
committerTimothy Knight <tknight@google.com>2014-07-26 11:57:38 -0700
commit63aa9248f017033ef68ddf0f20e7f64614eef2f0 (patch)
tree0a0e487ca3ce875c458cf0e2b21c51ea8ebfa5f7 /apps
parent9d33b0db842c1bcaf8f5ab74ecd96b2cea22b5d6 (diff)
downloadpdk-63aa9248f017033ef68ddf0f20e7f64614eef2f0.tar.gz
CameraITS: Added test for sameness of long bursts of images
Change-Id: I6700d66a394b6bbeca625db071ad4c8198671b3f
Diffstat (limited to 'apps')
-rw-r--r--apps/CameraITS/tests/scene1/test_burst_sameness.py85
1 files changed, 85 insertions, 0 deletions
diff --git a/apps/CameraITS/tests/scene1/test_burst_sameness.py b/apps/CameraITS/tests/scene1/test_burst_sameness.py
new file mode 100644
index 0000000..e4b37be
--- /dev/null
+++ b/apps/CameraITS/tests/scene1/test_burst_sameness.py
@@ -0,0 +1,85 @@
+# 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 numpy
+import pylab
+import matplotlib
+import matplotlib.pyplot
+
+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 = 10
+ FRAMES = BURST_LEN * BURSTS
+
+ DELTA_THRESH = 0.1
+
+ with its.device.ItsSession() as cam:
+
+ # Capture at the smallest resolution.
+ props = cam.get_camera_properties()
+ _, fmt = its.objects.get_fastest_manual_capture_settings(props)
+ req = its.objects.auto_capture_request()
+ w,h = fmt["width"], fmt["height"]
+
+ # Converge 3A prior to capture.
+ cam.do_3a()
+
+ # Capture bursts of YUV shots.
+ # Build a 4D array, which is an array of all RGB images.
+ 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)
+
+ # 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))
+
+ # Compute the deltas of each image from the mean image; this test
+ # passes if none of the deltas are large.
+ print "Computing frame differences"
+ delta_maxes = []
+ for i in range(FRAMES):
+ deltas = (imgs[i] - img_mean).reshape(h*w*3)
+ delta_max_pos = numpy.max(deltas)
+ delta_max_neg = numpy.min(deltas)
+ delta_maxes.append(max(abs(delta_max_pos), abs(delta_max_neg)))
+ max_delta_max = max(delta_maxes)
+ print "Frame %d has largest diff %f" % (
+ delta_maxes.index(max_delta_max), max_delta_max)
+ assert(max_delta_max < DELTA_THRESH)
+
+if __name__ == '__main__':
+ main()
+