• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2013 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14"""CameraITS test to see sensitivity param applied properly in burst or not.
15"""
16
17from mobly import test_runner
18
19import its_base_test
20import camera_properties_utils
21import capture_request_utils
22import its_session_utils
23
24_NUM_STEPS = 3
25_ERROR_TOLERANCE = 0.96  # Allow ISO to be rounded down by 4%
26
27
28class ParamSensitivityBurstTest(its_base_test.ItsBaseTest):
29  """Test android.sensor.sensitivity parameter applied properly in burst.
30
31  Inspects the output metadata only (not the image data).
32  """
33
34  def test_param_sensitivity_burst(self):
35    with its_session_utils.ItsSession(
36        device_id=self.dut.serial,
37        camera_id=self.camera_id,
38        hidden_physical_id=self.hidden_physical_id) as cam:
39      props = cam.get_camera_properties()
40      props = cam.override_with_hidden_physical_camera_props(props)
41      camera_properties_utils.skip_unless(
42          camera_properties_utils.manual_sensor(props) and
43          camera_properties_utils.per_frame_control(props))
44
45      sens_range = props['android.sensor.info.sensitivityRange']
46      sens_step = (sens_range[1] - sens_range[0]) // _NUM_STEPS
47      sens_list = range(sens_range[0], sens_range[1], sens_step)
48      exp = min(props['android.sensor.info.exposureTimeRange'])
49      if exp == 0:
50        raise AssertionError('Minimum exposure time is 0')
51      reqs = [
52          capture_request_utils.manual_capture_request(s, exp)
53          for s in sens_list
54      ]
55      _, fmt = capture_request_utils.get_fastest_manual_capture_settings(props)
56
57      caps = cam.do_capture(reqs, fmt)
58      for i, cap in enumerate(caps):
59        s_req = sens_list[i]
60        s_cap = cap['metadata']['android.sensor.sensitivity']
61        if (s_req < s_cap or s_cap / float(s_req) < _ERROR_TOLERANCE):
62          raise AssertionError(f's_request: {s_req}, s_capture: {s_cap}, '
63                               f'TOL: {_ERROR_TOLERANCE:.2f}')
64
65
66if __name__ == '__main__':
67  test_runner.main()
68