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 15import its.caps 16import its.device 17import its.image 18import its.objects 19import its.target 20 21NUM_STEPS = 3 22ERROR_TOLERANCE = 0.96 # Allow ISO to be rounded down by 4% 23 24 25def main(): 26 """Test android.sensor.sensitivity parameter applied properly in burst. 27 28 Inspects the output metadata only (not the image data). 29 """ 30 31 with its.device.ItsSession() as cam: 32 props = cam.get_camera_properties() 33 its.caps.skip_unless(its.caps.manual_sensor(props) and 34 its.caps.per_frame_control(props)) 35 36 sens_range = props['android.sensor.info.sensitivityRange'] 37 sens_step = (sens_range[1] - sens_range[0]) / NUM_STEPS 38 sens_list = range(sens_range[0], sens_range[1], sens_step) 39 e = min(props['android.sensor.info.exposureTimeRange']) 40 assert e != 0 41 reqs = [its.objects.manual_capture_request(s, e) for s in sens_list] 42 _, fmt = its.objects.get_fastest_manual_capture_settings(props) 43 44 caps = cam.do_capture(reqs, fmt) 45 for i, cap in enumerate(caps): 46 s_req = sens_list[i] 47 s_res = cap['metadata']['android.sensor.sensitivity'] 48 msg = 's_write: %d, s_read: %d, TOL: %.2f' % (s_req, s_res, 49 ERROR_TOLERANCE) 50 assert s_req >= s_res, msg 51 assert s_res/float(s_req) > ERROR_TOLERANCE, msg 52 53if __name__ == '__main__': 54 main() 55 56