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 15 import its.image 16 import its.caps 17 import its.device 18 import its.objects 19 import its.target 20 21 def 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 28 with its.device.ItsSession() as cam: 29 props = cam.get_camera_properties() 30 if not its.caps.manual_sensor(props): 31 print "Test skipped" 32 return 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 47 if __name__ == '__main__': 48 main() 49 50