aboutsummaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorTimothy Knight <tknight@google.com>2014-08-02 12:08:25 -0700
committerTimothy Knight <tknight@google.com>2014-08-04 11:27:11 -0700
commita238520df755416ef6d9b9a4a3002f8a50ceaf80 (patch)
tree6ed4aa2a56f44294547aee268c0ee5285bfda7cb /apps
parent6fb5a6b7cc2681212c84fe0d86fbe513dab6b618 (diff)
downloadpdk-a238520df755416ef6d9b9a4a3002f8a50ceaf80.tar.gz
CameraITS: Added test for raw cropRegion behavior
Change-Id: I8f3d72967ac5068c505caec135e5922df7dd3b39
Diffstat (limited to 'apps')
-rw-r--r--apps/CameraITS/tests/scene1/test_crop_region_raw.py62
1 files changed, 62 insertions, 0 deletions
diff --git a/apps/CameraITS/tests/scene1/test_crop_region_raw.py b/apps/CameraITS/tests/scene1/test_crop_region_raw.py
new file mode 100644
index 0000000..d805100
--- /dev/null
+++ b/apps/CameraITS/tests/scene1/test_crop_region_raw.py
@@ -0,0 +1,62 @@
+# 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 its.target
+import os.path
+
+def main():
+ """Test that raw streams are not croppable.
+ """
+ NAME = os.path.basename(__file__).split(".")[0]
+
+ with its.device.ItsSession() as cam:
+ props = cam.get_camera_properties()
+ a = props['android.sensor.info.activeArraySize']
+ ax, ay = a["left"], a["top"]
+ aw, ah = a["right"] - a["left"], a["bottom"] - a["top"]
+ print "Active sensor region: (%d,%d %dx%d)" % (ax, ay, aw, ah)
+
+ # Capture without a crop region.
+ e, s = its.target.get_target_exposure_combos(cam)["minSensitivity"]
+ req = its.objects.manual_capture_request(s,e)
+ cap1_yuv, cap1_raw = cam.do_capture(req, cam.CAP_RAW_YUV)
+
+ # Capture with a center crop region.
+ req["android.scaler.cropRegion"] = {
+ "top": ay + ah/3,
+ "left": ax + aw/3,
+ "right": ax + 2*aw/3,
+ "bottom": ay + 2*ah/3}
+ cap2_raw, cap2_yuv = cam.do_capture(req, cam.CAP_RAW_YUV)
+
+ for s,cap in [("yuv_full",cap1_yuv), ("raw_full",cap1_raw),
+ ("yuv_crop",cap2_yuv), ("raw_crop",cap2_raw)]:
+ img = its.image.convert_capture_to_rgb_image(cap, props=props)
+ its.image.write_image(img, "%s_%s.jpg" % (NAME, s))
+ r = cap["metadata"]["android.scaler.cropRegion"]
+ x, y = a["left"], a["top"]
+ w, h = a["right"] - a["left"], a["bottom"] - a["top"]
+ print "Crop on %s: (%d,%d %dx%d)" % (s, x,y,w,h)
+
+ # TODO: Add pass/fail test.
+ # cap1_raw should match cap2_raw (full frame)
+ # cap1_raw should match cap1_yuv (full frame)
+ # cap2_yuv should actually be cropped
+
+if __name__ == '__main__':
+ main()
+