diff options
author | Yin-Chia Yeh <yinchiayeh@google.com> | 2014-10-14 17:18:36 -0700 |
---|---|---|
committer | Yin-Chia Yeh <yinchiayeh@google.com> | 2014-10-15 13:10:37 -0700 |
commit | 9615995da440156c1a0c6759179d046314678029 (patch) | |
tree | f013b9a9f148aa46ef4103d22ef05c440803258b | |
parent | 2760cd5bc10f76cab96bd3fe7525bda6ed9328e9 (diff) | |
download | pdk-9615995da440156c1a0c6759179d046314678029.tar.gz |
Camera2 ITS: add proper capability gating
Skip tests if corresponding capability is not supported.
Bug: 17994909
Change-Id: I48fcd2a766f62a44e3cdb933006ca9e6f9350ad3
39 files changed, 268 insertions, 73 deletions
diff --git a/apps/CameraITS/pymodules/its/caps.py b/apps/CameraITS/pymodules/its/caps.py index 08817cc..6caebc0 100644 --- a/apps/CameraITS/pymodules/its/caps.py +++ b/apps/CameraITS/pymodules/its/caps.py @@ -13,6 +13,7 @@ # limitations under the License. import unittest +import its.objects def full(props): """Returns whether a device is a FULL capability camera2 device. @@ -88,6 +89,28 @@ def raw(props): return props.has_key("android.request.availableCapabilities") and \ 3 in props["android.request.availableCapabilities"] +def raw16(props): + """Returns whether a device supports RAW16 output. + + Args: + props: Camera properties object. + + Returns: + Boolean. + """ + return len(its.objects.get_available_output_sizes("raw", props)) > 0 + +def raw10(props): + """Returns whether a device supports RAW10 output. + + Args: + props: Camera properties object. + + Returns: + Boolean. + """ + return len(its.objects.get_available_output_sizes("raw10", props)) > 0 + def sensor_fusion(props): """Returns whether the camera and motion sensor timestamps for the device are in the same time domain and can be compared direcctly. @@ -101,6 +124,34 @@ def sensor_fusion(props): return props.has_key("android.sensor.info.timestampSource") and \ props["android.sensor.info.timestampSource"] == 1 +def read_3a(props): + """Return whether a device supports reading out the following 3A settings: + sensitivity + exposure time + awb gain + awb cct + focus distance + + Args: + props: Camera properties object. + + Returns: + Boolean. + """ + # TODO: check available result keys explicitly + return manual_sensor(props) and manual_post_proc(props) + +def compute_target_exposure(props): + """Return whether a device supports target exposure computation in its.target module. + + Args: + props: Camera properties object. + + Returns: + Boolean. + """ + return manual_sensor(props) and manual_post_proc(props) + class __UnitTest(unittest.TestCase): """Run a suite of unit tests on this module. """ diff --git a/apps/CameraITS/pymodules/its/objects.py b/apps/CameraITS/pymodules/its/objects.py index 4b9a811..d11ef84 100644 --- a/apps/CameraITS/pymodules/its/objects.py +++ b/apps/CameraITS/pymodules/its/objects.py @@ -131,7 +131,7 @@ def get_available_output_sizes(fmt, props): Returns: A sorted list of (w,h) tuples (sorted large-to-small). """ - fmt_codes = {"raw":0x20, "yuv":0x23, "jpg":0x100, "jpeg":0x100} + fmt_codes = {"raw":0x20, "raw10":0x25, "yuv":0x23, "jpg":0x100, "jpeg":0x100} configs = props['android.scaler.streamConfigurationMap']\ ['availableStreamConfigurations'] fmt_configs = [cfg for cfg in configs if cfg['format'] == fmt_codes[fmt]] diff --git a/apps/CameraITS/service/src/com/android/camera2/its/ItsService.java b/apps/CameraITS/service/src/com/android/camera2/its/ItsService.java index 5d8ba28..4039311 100644 --- a/apps/CameraITS/service/src/com/android/camera2/its/ItsService.java +++ b/apps/CameraITS/service/src/com/android/camera2/its/ItsService.java @@ -166,7 +166,7 @@ public class ItsService extends Service implements SensorEventListener { public int accuracy; public long timestamp; public float values[]; - }; + } // For capturing motion sensor traces. private SensorManager mSensorManager = null; @@ -322,6 +322,7 @@ public class ItsService extends Service implements SensorEventListener { class SerializerRunnable implements Runnable { // Use a separate thread to perform JSON serialization (since this can be slow due to // the reflection). + @Override public void run() { Logt.i(TAG, "Serializer thread starting"); while (! mThreadExitFlag) { @@ -387,6 +388,7 @@ public class ItsService extends Service implements SensorEventListener { mOpenSocket = openSocket; } + @Override public void run() { Logt.i(TAG, "Socket writer thread starting"); while (true) { @@ -430,6 +432,7 @@ public class ItsService extends Service implements SensorEventListener { private Socket mOpenSocket = null; private SocketWriteRunnable mSocketWriteRunnable = null; + @Override public void run() { Logt.i(TAG, "Socket thread starting"); try { @@ -1238,16 +1241,28 @@ public class ItsService extends Service implements SensorEventListener { } if (mConvergedAE && (!mNeedsLockedAE || mLockedAE)) { - mSocketRunnableObj.sendResponse("aeResult", String.format("%d %d", - result.get(CaptureResult.SENSOR_SENSITIVITY).intValue(), - result.get(CaptureResult.SENSOR_EXPOSURE_TIME).intValue() - )); + if (result.get(CaptureResult.SENSOR_SENSITIVITY) != null + && result.get(CaptureResult.SENSOR_EXPOSURE_TIME) != null) { + mSocketRunnableObj.sendResponse("aeResult", String.format("%d %d", + result.get(CaptureResult.SENSOR_SENSITIVITY).intValue(), + result.get(CaptureResult.SENSOR_EXPOSURE_TIME).intValue() + )); + } else { + Logt.i(TAG, String.format( + "AE converged but NULL exposure values, sensitivity:%b, expTime:%b", + result.get(CaptureResult.SENSOR_SENSITIVITY) == null, + result.get(CaptureResult.SENSOR_EXPOSURE_TIME) == null)); + } } if (mConvergedAF) { - mSocketRunnableObj.sendResponse("afResult", String.format("%f", - result.get(CaptureResult.LENS_FOCUS_DISTANCE) - )); + if (result.get(CaptureResult.LENS_FOCUS_DISTANCE) != null) { + mSocketRunnableObj.sendResponse("afResult", String.format("%f", + result.get(CaptureResult.LENS_FOCUS_DISTANCE) + )); + } else { + Logt.i(TAG, "AF converged but NULL focus distance values"); + } } if (mConvergedAWB && (!mNeedsLockedAWB || mLockedAWB)) { diff --git a/apps/CameraITS/tests/scene0/test_camera_properties.py b/apps/CameraITS/tests/scene0/test_camera_properties.py index 274c388..05fc364 100644 --- a/apps/CameraITS/tests/scene0/test_camera_properties.py +++ b/apps/CameraITS/tests/scene0/test_camera_properties.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import its.caps import its.device import its.objects import pprint @@ -22,10 +23,13 @@ def main(): with its.device.ItsSession() as cam: props = cam.get_camera_properties() + pprint.pprint(props) # Test that a handful of required keys are present. - assert(props.has_key('android.sensor.info.sensitivityRange')) + if its.caps.manual_sensor(props): + assert(props.has_key('android.sensor.info.sensitivityRange')) + assert(props.has_key('android.sensor.orientation')) assert(props.has_key('android.scaler.streamConfigurationMap')) assert(props.has_key('android.lens.facing')) diff --git a/apps/CameraITS/tests/scene0/test_capture_result_dump.py b/apps/CameraITS/tests/scene0/test_capture_result_dump.py index 4fd5d4a..c8b1f8f 100644 --- a/apps/CameraITS/tests/scene0/test_capture_result_dump.py +++ b/apps/CameraITS/tests/scene0/test_capture_result_dump.py @@ -12,24 +12,26 @@ # See the License for the specific language governing permissions and # limitations under the License. +import its.caps import its.image import its.device import its.objects import its.target -import os.path import pprint def main(): """Test that a capture result is returned from a manual capture; dump it. """ - NAME = os.path.basename(__file__).split(".")[0] with its.device.ItsSession() as cam: # Arbitrary capture request exposure values; image content is not # important for this test, only the metadata. props = cam.get_camera_properties() + if not its.caps.manual_sensor(props): + print "Test skipped" + return + req,fmt = its.objects.get_fastest_manual_capture_settings(props) - req["android.statistics.lensShadingMapMode"] = 1 cap = cam.do_capture(req, fmt) pprint.pprint(cap["metadata"]) diff --git a/apps/CameraITS/tests/scene0/test_gyro_bias.py b/apps/CameraITS/tests/scene0/test_gyro_bias.py index d0c41ce..64a5ff0 100644 --- a/apps/CameraITS/tests/scene0/test_gyro_bias.py +++ b/apps/CameraITS/tests/scene0/test_gyro_bias.py @@ -13,16 +13,15 @@ # limitations under the License. import its.image +import its.caps import its.device import its.objects import its.target import time -import math import pylab import os.path import matplotlib import matplotlib.pyplot -import json import numpy def main(): @@ -38,6 +37,12 @@ def main(): VAR_THRESH = 0.001 with its.device.ItsSession() as cam: + props = cam.get_camera_properties() + # Only run test if the appropriate caps are claimed. + if not its.caps.sensor_fusion(props): + print "Test skipped" + return + print "Collecting gyro events" cam.start_sensor_events() time.sleep(5) diff --git a/apps/CameraITS/tests/scene0/test_jitter.py b/apps/CameraITS/tests/scene0/test_jitter.py index 0983816..29b3047 100644 --- a/apps/CameraITS/tests/scene0/test_jitter.py +++ b/apps/CameraITS/tests/scene0/test_jitter.py @@ -13,6 +13,7 @@ # limitations under the License. import its.image +import its.caps import its.device import its.objects import os.path @@ -32,6 +33,10 @@ def main(): with its.device.ItsSession() as cam: props = cam.get_camera_properties() + if not its.caps.manual_sensor(props): + print "Test skipped" + return + req, fmt = its.objects.get_fastest_manual_capture_settings(props) caps = cam.do_capture([req]*50, [fmt]) diff --git a/apps/CameraITS/tests/scene0/test_metadata.py b/apps/CameraITS/tests/scene0/test_metadata.py index ea5a301..5e21bb9 100644 --- a/apps/CameraITS/tests/scene0/test_metadata.py +++ b/apps/CameraITS/tests/scene0/test_metadata.py @@ -17,8 +17,6 @@ import its.device import its.objects import its.target import its.caps -import os.path -import pprint def main(): """Test the validity of some metadata entries. @@ -26,14 +24,13 @@ def main(): Looks at capture results and at the camera characteristics objects. """ global md, props, failed - NAME = os.path.basename(__file__).split(".")[0] with its.device.ItsSession() as cam: # Arbitrary capture request exposure values; image content is not # important for this test, only the metadata. props = cam.get_camera_properties() - req,fmt = its.objects.get_fastest_manual_capture_settings(props) - cap = cam.do_capture(req, fmt) + auto_req = its.objects.auto_capture_request() + cap = cam.do_capture(auto_req) md = cap["metadata"] print "Hardware level" @@ -62,7 +59,7 @@ def main(): check('md["android.sensor.rollingShutterSkew"] is not None') check('props.has_key("android.scaler.availableMinFrameDurations")') check('props["android.scaler.availableMinFrameDurations"] is not None') - check('md["android.sensor.frameDuration"] > ' \ + check('md["android.sensor.frameDuration"] > ' 'md["android.sensor.rollingShutterSkew"] > 0') # Test: timestampSource must be a valid value. diff --git a/apps/CameraITS/tests/scene0/test_param_sensitivity_burst.py b/apps/CameraITS/tests/scene0/test_param_sensitivity_burst.py index 93accf1..eb9a3c1 100644 --- a/apps/CameraITS/tests/scene0/test_param_sensitivity_burst.py +++ b/apps/CameraITS/tests/scene0/test_param_sensitivity_burst.py @@ -13,24 +13,24 @@ # limitations under the License. import its.image +import its.caps import its.device import its.objects import its.target -import pylab -import os.path -import matplotlib -import matplotlib.pyplot def main(): """Test that the android.sensor.sensitivity parameter is applied properly within a burst. Inspects the output metadata only (not the image data). """ - NAME = os.path.basename(__file__).split(".")[0] NUM_STEPS = 3 with its.device.ItsSession() as cam: props = cam.get_camera_properties() + if not its.caps.manual_sensor(props): + print "Test skipped" + return + sens_range = props['android.sensor.info.sensitivityRange'] sens_step = (sens_range[1] - sens_range[0]) / NUM_STEPS sens_list = range(sens_range[0], sens_range[1], sens_step) diff --git a/apps/CameraITS/tests/scene0/test_sensor_events.py b/apps/CameraITS/tests/scene0/test_sensor_events.py index 2097310..61f0383 100644 --- a/apps/CameraITS/tests/scene0/test_sensor_events.py +++ b/apps/CameraITS/tests/scene0/test_sensor_events.py @@ -13,6 +13,7 @@ # limitations under the License. import its.device +import its.caps import time def main(): @@ -23,6 +24,12 @@ def main(): """ with its.device.ItsSession() as cam: + props = cam.get_camera_properties() + # Only run test if the appropriate caps are claimed. + if not its.caps.sensor_fusion(props): + print "Test skipped" + return + cam.start_sensor_events() time.sleep(1) events = cam.get_sensor_events() diff --git a/apps/CameraITS/tests/scene0/test_unified_timestamps.py b/apps/CameraITS/tests/scene0/test_unified_timestamps.py index f31ef22..cdc9567 100644 --- a/apps/CameraITS/tests/scene0/test_unified_timestamps.py +++ b/apps/CameraITS/tests/scene0/test_unified_timestamps.py @@ -15,13 +15,11 @@ import its.device import its.objects import its.caps -import os.path import time def main(): """Test if image and motion sensor events are in the same time domain. """ - NAME = os.path.basename(__file__).split(".")[0] with its.device.ItsSession() as cam: props = cam.get_camera_properties() @@ -51,7 +49,7 @@ def main(): ts_mag0 = events["mag"][0]["time"] ts_mag1 = events["mag"][-1]["time"] - # Get the timestamp of another iamge. + # Get the timestamp of another image. cap = cam.do_capture(req, fmt) ts_image1 = cap['metadata']['android.sensor.timestamp'] diff --git a/apps/CameraITS/tests/scene1/test_3a.py b/apps/CameraITS/tests/scene1/test_3a.py index d179883..6cb8b51 100644 --- a/apps/CameraITS/tests/scene1/test_3a.py +++ b/apps/CameraITS/tests/scene1/test_3a.py @@ -13,6 +13,7 @@ # limitations under the License. import its.device +import its.caps def main(): """Basic test for bring-up of 3A. @@ -21,6 +22,11 @@ def main(): """ with its.device.ItsSession() as cam: + props = cam.get_camera_properties() + if not its.caps.read_3a(props): + print "Test skipped" + return + sens, exp, gains, xform, focus = cam.do_3a() print "AE: sensitivity %d, exposure %dms" % (sens, exp/1000000) print "AWB: gains", gains, "transform", xform diff --git a/apps/CameraITS/tests/scene1/test_ae_precapture_trigger.py b/apps/CameraITS/tests/scene1/test_ae_precapture_trigger.py index 8c1c7a7..59b7db1 100644 --- a/apps/CameraITS/tests/scene1/test_ae_precapture_trigger.py +++ b/apps/CameraITS/tests/scene1/test_ae_precapture_trigger.py @@ -13,6 +13,7 @@ # limitations under the License. import its.device +import its.caps import its.objects import its.target @@ -29,6 +30,10 @@ def main(): with its.device.ItsSession() as cam: props = cam.get_camera_properties() + if not its.caps.compute_target_exposure(props): + print "Test skipped" + return + _,fmt = its.objects.get_fastest_manual_capture_settings(props) # Capture 5 manual requests, with AE disabled, and the last request diff --git a/apps/CameraITS/tests/scene1/test_auto_vs_manual.py b/apps/CameraITS/tests/scene1/test_auto_vs_manual.py index 2964e47..01a373c 100644 --- a/apps/CameraITS/tests/scene1/test_auto_vs_manual.py +++ b/apps/CameraITS/tests/scene1/test_auto_vs_manual.py @@ -13,6 +13,7 @@ # limitations under the License. import its.image +import its.caps import its.device import its.objects import os.path @@ -30,6 +31,11 @@ def main(): NAME = os.path.basename(__file__).split(".")[0] with its.device.ItsSession() as cam: + props = cam.get_camera_properties() + if (not its.caps.manual_sensor(props) or + not its.caps.manual_post_proc(props)): + print "Test skipped" + return # Converge 3A and get the estimates. sens, exp, gains, xform, focus = cam.do_3a() diff --git a/apps/CameraITS/tests/scene1/test_black_white.py b/apps/CameraITS/tests/scene1/test_black_white.py index ee7fb47..e471602 100644 --- a/apps/CameraITS/tests/scene1/test_black_white.py +++ b/apps/CameraITS/tests/scene1/test_black_white.py @@ -13,13 +13,9 @@ # limitations under the License. import its.image +import its.caps import its.device import its.objects -import sys -import numpy -import Image -import pprint -import math import pylab import os.path import matplotlib @@ -36,6 +32,10 @@ def main(): with its.device.ItsSession() as cam: props = cam.get_camera_properties() + if not its.caps.manual_sensor(props): + print "Test skipped" + return + expt_range = props['android.sensor.info.exposureTimeRange'] sens_range = props['android.sensor.info.sensitivityRange'] diff --git a/apps/CameraITS/tests/scene1/test_burst_sameness_auto.py b/apps/CameraITS/tests/scene1/test_burst_sameness_auto.py index aa6cced..f3d49be 100644 --- a/apps/CameraITS/tests/scene1/test_burst_sameness_auto.py +++ b/apps/CameraITS/tests/scene1/test_burst_sameness_auto.py @@ -13,13 +13,11 @@ # limitations under the License. import its.image +import its.caps 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. @@ -41,6 +39,10 @@ def main(): # Capture at the smallest resolution. props = cam.get_camera_properties() + if not its.caps.manual_sensor(props): + print "Test skipped" + return + _, fmt = its.objects.get_fastest_manual_capture_settings(props) w,h = fmt["width"], fmt["height"] diff --git a/apps/CameraITS/tests/scene1/test_burst_sameness_manual.py b/apps/CameraITS/tests/scene1/test_burst_sameness_manual.py index e500860..3858c0c 100644 --- a/apps/CameraITS/tests/scene1/test_burst_sameness_manual.py +++ b/apps/CameraITS/tests/scene1/test_burst_sameness_manual.py @@ -13,14 +13,12 @@ # limitations under the License. import its.image +import its.caps import its.device import its.objects import its.target 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. @@ -41,6 +39,10 @@ def main(): # Capture at the smallest resolution. props = cam.get_camera_properties() + if not its.caps.manual_sensor(props): + print "Test skipped" + return + _, fmt = its.objects.get_fastest_manual_capture_settings(props) e, s = its.target.get_target_exposure_combos(cam)["minSensitivity"] req = its.objects.manual_capture_request(s, e) diff --git a/apps/CameraITS/tests/scene1/test_capture_result.py b/apps/CameraITS/tests/scene1/test_capture_result.py index c88a2e0..81ec43c 100644 --- a/apps/CameraITS/tests/scene1/test_capture_result.py +++ b/apps/CameraITS/tests/scene1/test_capture_result.py @@ -13,14 +13,12 @@ # limitations under the License. import its.image +import its.caps import its.device import its.objects import os.path -import pprint -import math import numpy import matplotlib.pyplot -import mpl_toolkits.mplot3d def main(): """Test that valid data comes back in CaptureResult objects. @@ -33,6 +31,10 @@ def main(): with its.device.ItsSession() as cam: props = cam.get_camera_properties() + if (not its.caps.manual_sensor(props) or + not its.caps.manual_post_proc(props)): + print "Test skipped" + return manual_tonemap = [0,0, 1,1] # Linear manual_transform = its.objects.int_to_rational([1,2,3, 4,5,6, 7,8,9]) diff --git a/apps/CameraITS/tests/scene1/test_crop_region_raw.py b/apps/CameraITS/tests/scene1/test_crop_region_raw.py index 6fd0732..94c8e2b 100644 --- a/apps/CameraITS/tests/scene1/test_crop_region_raw.py +++ b/apps/CameraITS/tests/scene1/test_crop_region_raw.py @@ -13,6 +13,7 @@ # limitations under the License. import its.image +import its.caps import its.device import its.objects import its.target @@ -28,6 +29,11 @@ def main(): with its.device.ItsSession() as cam: props = cam.get_camera_properties() + if (not its.caps.compute_target_exposure(props) or + not its.caps.raw16(props)): + print "Test skipped" + return + a = props['android.sensor.info.activeArraySize'] ax, ay = a["left"], a["top"] aw, ah = a["right"] - a["left"], a["bottom"] - a["top"] diff --git a/apps/CameraITS/tests/scene1/test_crop_regions.py b/apps/CameraITS/tests/scene1/test_crop_regions.py index 90b6c4c..da0cd0a 100644 --- a/apps/CameraITS/tests/scene1/test_crop_regions.py +++ b/apps/CameraITS/tests/scene1/test_crop_regions.py @@ -13,14 +13,11 @@ # limitations under the License. import its.image +import its.caps import its.device import its.objects import its.target -import pylab import os.path -import matplotlib -import matplotlib.pyplot -import copy import numpy def main(): @@ -38,6 +35,10 @@ def main(): with its.device.ItsSession() as cam: props = cam.get_camera_properties() + if not its.caps.compute_target_exposure(props): + print "Test skipped" + return + a = props['android.sensor.info.activeArraySize'] ax, ay = a["left"], a["top"] aw, ah = a["right"] - a["left"], a["bottom"] - a["top"] diff --git a/apps/CameraITS/tests/scene1/test_exposure.py b/apps/CameraITS/tests/scene1/test_exposure.py index 5090d3c..8676358 100644 --- a/apps/CameraITS/tests/scene1/test_exposure.py +++ b/apps/CameraITS/tests/scene1/test_exposure.py @@ -13,6 +13,7 @@ # limitations under the License. import its.image +import its.caps import its.device import its.objects import its.target @@ -42,8 +43,12 @@ def main(): b_means = [] with its.device.ItsSession() as cam: - e,s = its.target.get_target_exposure_combos(cam)["minSensitivity"] props = cam.get_camera_properties() + if not its.caps.compute_target_exposure(props): + print "Test skipped" + return + + e,s = its.target.get_target_exposure_combos(cam)["minSensitivity"] expt_range = props['android.sensor.info.exposureTimeRange'] sens_range = props['android.sensor.info.sensitivityRange'] diff --git a/apps/CameraITS/tests/scene1/test_format_combos.py b/apps/CameraITS/tests/scene1/test_format_combos.py index a7cf5b8..a021102 100644 --- a/apps/CameraITS/tests/scene1/test_format_combos.py +++ b/apps/CameraITS/tests/scene1/test_format_combos.py @@ -13,12 +13,12 @@ # limitations under the License. import its.image +import its.caps import its.device import its.objects import its.error import its.target import sys -import time import os import os.path @@ -33,6 +33,10 @@ def main(): with its.device.ItsSession() as cam: props = cam.get_camera_properties() + if (not its.caps.compute_target_exposure(props) or + not its.caps.raw16(props)): + print "Test skipped" + return successes = [] failures = [] @@ -65,7 +69,7 @@ def main(): [fmt_yuv_prev, fmt_jpg_prev, fmt_raw_full], # F8 [fmt_yuv_prev, fmt_jpg_full, fmt_raw_full]] # F9 - # Two different burst lenghts: single frame, and 3 frames. + # Two different burst lengths: single frame, and 3 frames. burst_lens = [1, # B0 3] # B1 diff --git a/apps/CameraITS/tests/scene1/test_jpeg.py b/apps/CameraITS/tests/scene1/test_jpeg.py index 54a6189..bc2d64e 100644 --- a/apps/CameraITS/tests/scene1/test_jpeg.py +++ b/apps/CameraITS/tests/scene1/test_jpeg.py @@ -13,13 +13,11 @@ # limitations under the License. import its.image +import its.caps import its.device import its.objects import its.target import os.path -import Image -import shutil -import numpy import math def main(): @@ -31,6 +29,9 @@ def main(): with its.device.ItsSession() as cam: props = cam.get_camera_properties() + if not its.caps.compute_target_exposure(props): + print "Test skipped" + return e, s = its.target.get_target_exposure_combos(cam)["midExposureTime"] req = its.objects.manual_capture_request(s, e, True) diff --git a/apps/CameraITS/tests/scene1/test_latching.py b/apps/CameraITS/tests/scene1/test_latching.py index bc1cad7..bef41ac 100644 --- a/apps/CameraITS/tests/scene1/test_latching.py +++ b/apps/CameraITS/tests/scene1/test_latching.py @@ -13,6 +13,7 @@ # limitations under the License. import its.image +import its.caps import its.device import its.objects import its.target @@ -20,22 +21,25 @@ import pylab import os.path import matplotlib import matplotlib.pyplot -import copy def main(): """Test that settings latch on the right frame. Takes a bunch of shots using back-to-back requests, varying the capture request parameters between shots. Checks that the images that come back - have the expexted properties. + have the expected properties. """ NAME = os.path.basename(__file__).split(".")[0] with its.device.ItsSession() as cam: props = cam.get_camera_properties() + if not its.caps.full(props): + print "Test skipped" + return + _,fmt = its.objects.get_fastest_manual_capture_settings(props) e, s = its.target.get_target_exposure_combos(cam)["midExposureTime"] - e = e / 2.0 + e /= 2.0 r_means = [] g_means = [] diff --git a/apps/CameraITS/tests/scene1/test_linearity.py b/apps/CameraITS/tests/scene1/test_linearity.py index 9fbb1f4..fed0324 100644 --- a/apps/CameraITS/tests/scene1/test_linearity.py +++ b/apps/CameraITS/tests/scene1/test_linearity.py @@ -13,13 +13,11 @@ # limitations under the License. import its.image +import its.caps import its.device import its.objects import its.target -import sys import numpy -import Image -import pprint import math import pylab import os.path @@ -38,7 +36,7 @@ def main(): RESIDUAL_THRESHOLD = 0.00005 # The HAL3.2 spec requires that curves up to 64 control points in length - # must be supported. + # must be supported. L = 64 LM1 = float(L-1) @@ -48,9 +46,13 @@ def main(): sum([[i/LM1, math.pow(i/LM1, 2.2)] for i in xrange(L)], [])) with its.device.ItsSession() as cam: + props = cam.get_camera_properties() + if not its.caps.compute_target_exposure(props): + print "Test skipped" + return + e,s = its.target.get_target_exposure_combos(cam)["midSensitivity"] s /= 2 - props = cam.get_camera_properties() sens_range = props['android.sensor.info.sensitivityRange'] sensitivities = [s*1.0/3.0, s*2.0/3.0, s, s*4.0/3.0, s*5.0/3.0] sensitivities = [s for s in sensitivities diff --git a/apps/CameraITS/tests/scene1/test_param_color_correction.py b/apps/CameraITS/tests/scene1/test_param_color_correction.py index 1b4838b..82f2342 100644 --- a/apps/CameraITS/tests/scene1/test_param_color_correction.py +++ b/apps/CameraITS/tests/scene1/test_param_color_correction.py @@ -13,6 +13,7 @@ # limitations under the License. import its.image +import its.caps import its.device import its.objects import its.target @@ -35,6 +36,10 @@ def main(): THRESHOLD_MAX_DIFF = 0.1 with its.device.ItsSession() as cam: + props = cam.get_camera_properties() + if not its.caps.compute_target_exposure(props): + print "Test skipped" + return # Baseline request e, s = its.target.get_target_exposure_combos(cam)["midSensitivity"] diff --git a/apps/CameraITS/tests/scene1/test_param_exposure_time.py b/apps/CameraITS/tests/scene1/test_param_exposure_time.py index 838b39d..390fd3c 100644 --- a/apps/CameraITS/tests/scene1/test_param_exposure_time.py +++ b/apps/CameraITS/tests/scene1/test_param_exposure_time.py @@ -13,6 +13,7 @@ # limitations under the License. import its.image +import its.caps import its.device import its.objects import its.target @@ -32,6 +33,11 @@ def main(): b_means = [] with its.device.ItsSession() as cam: + props = cam.get_camera_properties() + if not its.caps.compute_target_exposure(props): + print "Test skipped" + return + e,s = its.target.get_target_exposure_combos(cam)["midExposureTime"] for i,e_mult in enumerate([0.8, 0.9, 1.0, 1.1, 1.2]): req = its.objects.manual_capture_request(s, e * e_mult, True) diff --git a/apps/CameraITS/tests/scene1/test_param_flash_mode.py b/apps/CameraITS/tests/scene1/test_param_flash_mode.py index 3ab64cf..6d1be4f 100644 --- a/apps/CameraITS/tests/scene1/test_param_flash_mode.py +++ b/apps/CameraITS/tests/scene1/test_param_flash_mode.py @@ -13,13 +13,11 @@ # limitations under the License. import its.image +import its.caps import its.device import its.objects import its.target -import pylab import os.path -import matplotlib -import matplotlib.pyplot def main(): """Test that the android.flash.mode parameter is applied. @@ -27,6 +25,10 @@ def main(): NAME = os.path.basename(__file__).split(".")[0] with its.device.ItsSession() as cam: + props = cam.get_camera_properties() + if not its.caps.compute_target_exposure(props): + print "Test skipped" + return flash_modes_reported = [] flash_states_reported = [] diff --git a/apps/CameraITS/tests/scene1/test_param_noise_reduction.py b/apps/CameraITS/tests/scene1/test_param_noise_reduction.py index bef029e..618f8a7 100644 --- a/apps/CameraITS/tests/scene1/test_param_noise_reduction.py +++ b/apps/CameraITS/tests/scene1/test_param_noise_reduction.py @@ -13,6 +13,7 @@ # limitations under the License. import its.image +import its.caps import its.device import its.objects import its.target @@ -43,6 +44,10 @@ def main(): with its.device.ItsSession() as cam: props = cam.get_camera_properties() + if not its.caps.compute_target_exposure(props): + print "Test skipped" + return + # NR mode 0 with low gain e, s = its.target.get_target_exposure_combos(cam)["minSensitivity"] req = its.objects.manual_capture_request(s, e) diff --git a/apps/CameraITS/tests/scene1/test_param_sensitivity.py b/apps/CameraITS/tests/scene1/test_param_sensitivity.py index 0d1b5eb..c26e9f9 100644 --- a/apps/CameraITS/tests/scene1/test_param_sensitivity.py +++ b/apps/CameraITS/tests/scene1/test_param_sensitivity.py @@ -13,6 +13,7 @@ # limitations under the License. import its.image +import its.caps import its.device import its.objects import its.target @@ -34,8 +35,12 @@ def main(): b_means = [] with its.device.ItsSession() as cam: - expt,_ = its.target.get_target_exposure_combos(cam)["midSensitivity"] props = cam.get_camera_properties() + if not its.caps.compute_target_exposure(props): + print "Test skipped" + return + + expt,_ = its.target.get_target_exposure_combos(cam)["midSensitivity"] sens_range = props['android.sensor.info.sensitivityRange'] sens_step = (sens_range[1] - sens_range[0]) / float(NUM_STEPS-1) sensitivities = [sens_range[0] + i * sens_step for i in range(NUM_STEPS)] diff --git a/apps/CameraITS/tests/scene1/test_param_tonemap_mode.py b/apps/CameraITS/tests/scene1/test_param_tonemap_mode.py index cc7147a..fbd452c 100644 --- a/apps/CameraITS/tests/scene1/test_param_tonemap_mode.py +++ b/apps/CameraITS/tests/scene1/test_param_tonemap_mode.py @@ -13,15 +13,11 @@ # limitations under the License. import its.image +import its.caps import its.device import its.objects import its.target import os -import sys -import numpy -import Image -import math -import time import os.path def main(): @@ -41,6 +37,10 @@ def main(): LM1 = float(L-1) with its.device.ItsSession() as cam: + props = cam.get_camera_properties() + if not its.caps.compute_target_exposure(props): + print "Test skipped" + return e, s = its.target.get_target_exposure_combos(cam)["midExposureTime"] e /= 2 diff --git a/apps/CameraITS/tests/scene1/test_raw_burst_sensitivity.py b/apps/CameraITS/tests/scene1/test_raw_burst_sensitivity.py index 1135231..bc304c9 100644 --- a/apps/CameraITS/tests/scene1/test_raw_burst_sensitivity.py +++ b/apps/CameraITS/tests/scene1/test_raw_burst_sensitivity.py @@ -13,9 +13,9 @@ # limitations under the License. import its.device +import its.caps import its.objects import its.image -import pprint import os.path import pylab import matplotlib @@ -37,6 +37,11 @@ def main(): with its.device.ItsSession() as cam: props = cam.get_camera_properties() + if not its.caps.raw16(props) or \ + not its.caps.manual_sensor(props) or \ + not its.caps.read_3a(props): + print "Test skipped" + return # Expose for the scene with min sensitivity sens_min, sens_max = props['android.sensor.info.sensitivityRange'] diff --git a/apps/CameraITS/tests/scene1/test_raw_sensitivity.py b/apps/CameraITS/tests/scene1/test_raw_sensitivity.py index 9845623..7c8eccd 100644 --- a/apps/CameraITS/tests/scene1/test_raw_sensitivity.py +++ b/apps/CameraITS/tests/scene1/test_raw_sensitivity.py @@ -13,9 +13,9 @@ # limitations under the License. import its.device +import its.caps import its.objects import its.image -import pprint import os.path import pylab import matplotlib @@ -35,6 +35,11 @@ def main(): with its.device.ItsSession() as cam: props = cam.get_camera_properties() + if (not its.caps.raw16(props) or + not its.caps.manual_sensor(props) or + not its.caps.read_3a(props)): + print "Test skipped" + return # Expose for the scene with min sensitivity sens_min, sens_max = props['android.sensor.info.sensitivityRange'] diff --git a/apps/CameraITS/tests/scene1/test_tonemap_sequence.py b/apps/CameraITS/tests/scene1/test_tonemap_sequence.py index 4f519cb..100bcf8 100644 --- a/apps/CameraITS/tests/scene1/test_tonemap_sequence.py +++ b/apps/CameraITS/tests/scene1/test_tonemap_sequence.py @@ -13,6 +13,7 @@ # limitations under the License. import its.image +import its.caps import its.device import its.objects import os.path @@ -29,6 +30,12 @@ def main(): MIN_DIFF_DELTA = 0.10 with its.device.ItsSession() as cam: + props = cam.get_camera_properties() + if (not its.caps.manual_sensor(props) or + not its.caps.manual_post_proc(props)): + print "Test skipped" + return + sens, exp_time, _,_,_ = cam.do_3a(do_af=False) means = [] diff --git a/apps/CameraITS/tests/scene1/test_yuv_jpeg_all.py b/apps/CameraITS/tests/scene1/test_yuv_jpeg_all.py index aed9b66..2367ca2 100644 --- a/apps/CameraITS/tests/scene1/test_yuv_jpeg_all.py +++ b/apps/CameraITS/tests/scene1/test_yuv_jpeg_all.py @@ -13,11 +13,11 @@ # limitations under the License. import its.image +import its.caps import its.device import its.objects import its.target import os.path -import Image import math def main(): @@ -29,6 +29,9 @@ def main(): with its.device.ItsSession() as cam: props = cam.get_camera_properties() + if not its.caps.compute_target_exposure(props): + print "Test skipped" + return # Use a manual request with a linear tonemap so that the YUV and JPEG # should look the same (once converted by the its.image module). diff --git a/apps/CameraITS/tests/scene1/test_yuv_plus_dng.py b/apps/CameraITS/tests/scene1/test_yuv_plus_dng.py index 6fff221..4924c7b 100644 --- a/apps/CameraITS/tests/scene1/test_yuv_plus_dng.py +++ b/apps/CameraITS/tests/scene1/test_yuv_plus_dng.py @@ -13,6 +13,7 @@ # limitations under the License. import its.image +import its.caps import its.device import its.objects import os.path @@ -24,6 +25,10 @@ def main(): with its.device.ItsSession() as cam: props = cam.get_camera_properties() + if (not its.caps.raw(props) or + not its.caps.read_3a(props)): + print "Test skipped" + return cam.do_3a() diff --git a/apps/CameraITS/tests/scene1/test_yuv_plus_jpeg.py b/apps/CameraITS/tests/scene1/test_yuv_plus_jpeg.py index 7841b36..15aa17c 100644 --- a/apps/CameraITS/tests/scene1/test_yuv_plus_jpeg.py +++ b/apps/CameraITS/tests/scene1/test_yuv_plus_jpeg.py @@ -13,6 +13,7 @@ # limitations under the License. import its.image +import its.caps import its.device import its.objects import its.target @@ -30,6 +31,11 @@ def main(): fmt_jpeg = {"format":"jpeg"} with its.device.ItsSession() as cam: + props = cam.get_camera_properties() + if not its.caps.compute_target_exposure(props): + print "Test skipped" + return + # Use a manual request with a linear tonemap so that the YUV and JPEG # should look the same (once converted by the its.image module). e, s = its.target.get_target_exposure_combos(cam)["midExposureTime"] diff --git a/apps/CameraITS/tests/scene1/test_yuv_plus_raw.py b/apps/CameraITS/tests/scene1/test_yuv_plus_raw.py index 1d71626..7a345c9 100644 --- a/apps/CameraITS/tests/scene1/test_yuv_plus_raw.py +++ b/apps/CameraITS/tests/scene1/test_yuv_plus_raw.py @@ -13,6 +13,7 @@ # limitations under the License. import its.image +import its.caps import its.device import its.objects import its.target @@ -28,6 +29,10 @@ def main(): with its.device.ItsSession() as cam: props = cam.get_camera_properties() + if (not its.caps.compute_target_exposure(props) or + not its.caps.raw16(props)): + print "Test skipped" + return # Use a manual request with a linear tonemap so that the YUV and RAW # should look the same (once converted by the its.image module). diff --git a/apps/CameraITS/tests/scene1/test_yuv_plus_raw10.py b/apps/CameraITS/tests/scene1/test_yuv_plus_raw10.py index 3ed860b..15612c5 100644 --- a/apps/CameraITS/tests/scene1/test_yuv_plus_raw10.py +++ b/apps/CameraITS/tests/scene1/test_yuv_plus_raw10.py @@ -13,6 +13,7 @@ # limitations under the License. import its.image +import its.caps import its.device import its.objects import its.target @@ -29,6 +30,11 @@ def main(): with its.device.ItsSession() as cam: props = cam.get_camera_properties() + if (not its.caps.compute_target_exposure(props) or + not its.caps.raw10(props)): + print "Test skipped" + return + # Use a manual request with a linear tonemap so that the YUV and RAW # should look the same (once converted by the its.image module). e, s = its.target.get_target_exposure_combos(cam)["midExposureTime"] |