ITS: add additional face scenes to ITS
bug: 116851882
Change-Id: Id98a51a412e1ca29199f5162bd55d6616f175f05
diff --git a/apps/CameraITS/tests/scene2b/scene2b.pdf b/apps/CameraITS/tests/scene2b/scene2b.pdf
new file mode 100644
index 0000000..9e9f960
--- /dev/null
+++ b/apps/CameraITS/tests/scene2b/scene2b.pdf
Binary files differ
diff --git a/apps/CameraITS/tests/scene2b/scene2b_0.5_scaled.pdf b/apps/CameraITS/tests/scene2b/scene2b_0.5_scaled.pdf
new file mode 100644
index 0000000..3a5bd85
--- /dev/null
+++ b/apps/CameraITS/tests/scene2b/scene2b_0.5_scaled.pdf
Binary files differ
diff --git a/apps/CameraITS/tests/scene2b/scene2b_0.67_scaled.pdf b/apps/CameraITS/tests/scene2b/scene2b_0.67_scaled.pdf
new file mode 100644
index 0000000..706140a
--- /dev/null
+++ b/apps/CameraITS/tests/scene2b/scene2b_0.67_scaled.pdf
Binary files differ
diff --git a/apps/CameraITS/tests/scene2b/test_num_faces.py b/apps/CameraITS/tests/scene2b/test_num_faces.py
new file mode 100644
index 0000000..044c154
--- /dev/null
+++ b/apps/CameraITS/tests/scene2b/test_num_faces.py
@@ -0,0 +1,100 @@
+# 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 os.path
+import cv2
+import its.caps
+import its.device
+import its.image
+import its.objects
+
+NAME = os.path.basename(__file__).split('.')[0]
+NUM_TEST_FRAMES = 20
+NUM_FACES = 3
+FD_MODE_OFF = 0
+FD_MODE_SIMPLE = 1
+FD_MODE_FULL = 2
+W, H = 640, 480
+
+
+def main():
+ """Test face detection."""
+ with its.device.ItsSession() as cam:
+ props = cam.get_camera_properties()
+ its.caps.skip_unless(its.caps.face_detect(props))
+ mono_camera = its.caps.mono_camera(props)
+ fd_modes = props['android.statistics.info.availableFaceDetectModes']
+ a = props['android.sensor.info.activeArraySize']
+ aw, ah = a['right'] - a['left'], a['bottom'] - a['top']
+
+ if its.caps.read_3a(props):
+ _, _, _, _, _ = cam.do_3a(get_results=True,
+ mono_camera=mono_camera)
+
+ for fd_mode in fd_modes:
+ assert FD_MODE_OFF <= fd_mode <= FD_MODE_FULL
+ req = its.objects.auto_capture_request()
+ req['android.statistics.faceDetectMode'] = fd_mode
+ fmt = {'format': 'yuv', 'width': W, 'height': H}
+ caps = cam.do_capture([req]*NUM_TEST_FRAMES, fmt)
+ for i, cap in enumerate(caps):
+ md = cap['metadata']
+ assert md['android.statistics.faceDetectMode'] == fd_mode
+ faces = md['android.statistics.faces']
+
+ # 0 faces should be returned for OFF mode
+ if fd_mode == FD_MODE_OFF:
+ assert not faces
+ continue
+ # Face detection could take several frames to warm up,
+ # but should detect the correct number of faces in last frame
+ if i == NUM_TEST_FRAMES - 1:
+ img = its.image.convert_capture_to_rgb_image(cap,
+ props=props)
+ fnd_faces = len(faces)
+ print 'Found %d face(s), expected %d.' % (fnd_faces,
+ NUM_FACES)
+ # draw boxes around faces
+ for rect in [face['bounds'] for face in faces]:
+ top_left = (int(round(rect['left']*W/aw)),
+ int(round(rect['top']*H/ah)))
+ bot_rght = (int(round(rect['right']*W/aw)),
+ int(round(rect['bottom']*H/ah)))
+ cv2.rectangle(img, top_left, bot_rght, (0, 1, 0), 2)
+ img_name = '%s_fd_mode_%s.jpg' % (NAME, fd_mode)
+ its.image.write_image(img, img_name)
+ assert fnd_faces == NUM_FACES
+ if not faces:
+ continue
+
+ print 'Frame %d face metadata:' % i
+ print ' Faces:', faces
+ print ''
+
+ # Reasonable scores for faces
+ face_scores = [face['score'] for face in faces]
+ for score in face_scores:
+ assert score >= 1 and score <= 100
+ # Face bounds should be within active array
+ face_rectangles = [face['bounds'] for face in faces]
+ for rect in face_rectangles:
+ assert rect['top'] < rect['bottom']
+ assert rect['left'] < rect['right']
+ assert 0 <= rect['top'] <= ah
+ assert 0 <= rect['bottom'] <= ah
+ assert 0 <= rect['left'] <= aw
+ assert 0 <= rect['right'] <= aw
+
+if __name__ == '__main__':
+ main()
diff --git a/apps/CameraITS/tests/scene2c/scene2c.pdf b/apps/CameraITS/tests/scene2c/scene2c.pdf
new file mode 100644
index 0000000..d11a02d
--- /dev/null
+++ b/apps/CameraITS/tests/scene2c/scene2c.pdf
Binary files differ
diff --git a/apps/CameraITS/tests/scene2c/scene2c_0.5_scaled.pdf b/apps/CameraITS/tests/scene2c/scene2c_0.5_scaled.pdf
new file mode 100644
index 0000000..9ac02a1
--- /dev/null
+++ b/apps/CameraITS/tests/scene2c/scene2c_0.5_scaled.pdf
Binary files differ
diff --git a/apps/CameraITS/tests/scene2c/scene2c_0.67_scaled.pdf b/apps/CameraITS/tests/scene2c/scene2c_0.67_scaled.pdf
new file mode 100644
index 0000000..4a8bb09
--- /dev/null
+++ b/apps/CameraITS/tests/scene2c/scene2c_0.67_scaled.pdf
Binary files differ
diff --git a/apps/CameraITS/tests/scene2c/test_num_faces.py b/apps/CameraITS/tests/scene2c/test_num_faces.py
new file mode 100644
index 0000000..044c154
--- /dev/null
+++ b/apps/CameraITS/tests/scene2c/test_num_faces.py
@@ -0,0 +1,100 @@
+# 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 os.path
+import cv2
+import its.caps
+import its.device
+import its.image
+import its.objects
+
+NAME = os.path.basename(__file__).split('.')[0]
+NUM_TEST_FRAMES = 20
+NUM_FACES = 3
+FD_MODE_OFF = 0
+FD_MODE_SIMPLE = 1
+FD_MODE_FULL = 2
+W, H = 640, 480
+
+
+def main():
+ """Test face detection."""
+ with its.device.ItsSession() as cam:
+ props = cam.get_camera_properties()
+ its.caps.skip_unless(its.caps.face_detect(props))
+ mono_camera = its.caps.mono_camera(props)
+ fd_modes = props['android.statistics.info.availableFaceDetectModes']
+ a = props['android.sensor.info.activeArraySize']
+ aw, ah = a['right'] - a['left'], a['bottom'] - a['top']
+
+ if its.caps.read_3a(props):
+ _, _, _, _, _ = cam.do_3a(get_results=True,
+ mono_camera=mono_camera)
+
+ for fd_mode in fd_modes:
+ assert FD_MODE_OFF <= fd_mode <= FD_MODE_FULL
+ req = its.objects.auto_capture_request()
+ req['android.statistics.faceDetectMode'] = fd_mode
+ fmt = {'format': 'yuv', 'width': W, 'height': H}
+ caps = cam.do_capture([req]*NUM_TEST_FRAMES, fmt)
+ for i, cap in enumerate(caps):
+ md = cap['metadata']
+ assert md['android.statistics.faceDetectMode'] == fd_mode
+ faces = md['android.statistics.faces']
+
+ # 0 faces should be returned for OFF mode
+ if fd_mode == FD_MODE_OFF:
+ assert not faces
+ continue
+ # Face detection could take several frames to warm up,
+ # but should detect the correct number of faces in last frame
+ if i == NUM_TEST_FRAMES - 1:
+ img = its.image.convert_capture_to_rgb_image(cap,
+ props=props)
+ fnd_faces = len(faces)
+ print 'Found %d face(s), expected %d.' % (fnd_faces,
+ NUM_FACES)
+ # draw boxes around faces
+ for rect in [face['bounds'] for face in faces]:
+ top_left = (int(round(rect['left']*W/aw)),
+ int(round(rect['top']*H/ah)))
+ bot_rght = (int(round(rect['right']*W/aw)),
+ int(round(rect['bottom']*H/ah)))
+ cv2.rectangle(img, top_left, bot_rght, (0, 1, 0), 2)
+ img_name = '%s_fd_mode_%s.jpg' % (NAME, fd_mode)
+ its.image.write_image(img, img_name)
+ assert fnd_faces == NUM_FACES
+ if not faces:
+ continue
+
+ print 'Frame %d face metadata:' % i
+ print ' Faces:', faces
+ print ''
+
+ # Reasonable scores for faces
+ face_scores = [face['score'] for face in faces]
+ for score in face_scores:
+ assert score >= 1 and score <= 100
+ # Face bounds should be within active array
+ face_rectangles = [face['bounds'] for face in faces]
+ for rect in face_rectangles:
+ assert rect['top'] < rect['bottom']
+ assert rect['left'] < rect['right']
+ assert 0 <= rect['top'] <= ah
+ assert 0 <= rect['bottom'] <= ah
+ assert 0 <= rect['left'] <= aw
+ assert 0 <= rect['right'] <= aw
+
+if __name__ == '__main__':
+ main()
diff --git a/apps/CameraITS/tools/run_all_tests.py b/apps/CameraITS/tools/run_all_tests.py
index 1fb9dc1..9ca3a93 100644
--- a/apps/CameraITS/tools/run_all_tests.py
+++ b/apps/CameraITS/tools/run_all_tests.py
@@ -169,15 +169,17 @@
dist: [Experimental] chart distance in cm.
"""
- all_scenes = ["scene0", "scene1", "scene2", "scene3", "scene4", "scene5",
+ all_scenes = ["scene0", "scene1", "scene2", "scene2b", "scene2c", "scene3", "scene4", "scene5",
"sensor_fusion"]
- auto_scenes = ["scene0", "scene1", "scene2", "scene3", "scene4"]
+ auto_scenes = ["scene0", "scene1", "scene2", "scene2b", "scene2c", "scene3", "scene4"]
scene_req = {
"scene0": None,
"scene1": "A grey card covering at least the middle 30% of the scene",
"scene2": "A picture containing human faces",
+ "scene2b": "A picture containing human faces",
+ "scene2c": "A picture containing human faces",
"scene3": "The ISO 12233 chart",
"scene4": "A specific test page of a circle covering at least the "
"middle 50% of the scene. See CameraITS.pdf section 2.3.4 "