Ruben Brunk | 370e243 | 2014-10-14 18:33:23 -0700 | [diff] [blame] | 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 |
Yin-Chia Yeh | fbae37b | 2015-02-03 09:42:54 -0800 | [diff] [blame^] | 27 | ERROR_TOLERANCE = 0.97 # Allow ISO to be rounded down by 3% |
Ruben Brunk | 370e243 | 2014-10-14 18:33:23 -0700 | [diff] [blame] | 28 | |
| 29 | with its.device.ItsSession() as cam: |
| 30 | props = cam.get_camera_properties() |
Chien-Yu Chen | 34fa85d | 2014-10-22 16:58:08 -0700 | [diff] [blame] | 31 | its.caps.skip_unless(its.caps.manual_sensor(props) and |
| 32 | its.caps.per_frame_control(props)) |
Ruben Brunk | 370e243 | 2014-10-14 18:33:23 -0700 | [diff] [blame] | 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"] |
Yin-Chia Yeh | fbae37b | 2015-02-03 09:42:54 -0800 | [diff] [blame^] | 45 | assert(s_req >= s_res) |
| 46 | assert(s_res/float(s_req) > ERROR_TOLERANCE) |
Ruben Brunk | 370e243 | 2014-10-14 18:33:23 -0700 | [diff] [blame] | 47 | |
| 48 | if __name__ == '__main__': |
| 49 | main() |
| 50 | |