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