• 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
15import its.image
16import its.device
17import its.objects
18import os.path
19import pprint
20import math
21import numpy
22import matplotlib.pyplot
23import mpl_toolkits.mplot3d
24
25def main():
26    """Run 3A remotely (from this script).
27    """
28    NAME = os.path.basename(__file__).split(".")[0]
29
30    with its.device.ItsSession() as cam:
31        props = cam.get_camera_properties()
32        w_map = props["android.lens.info.shadingMapSize"]["width"]
33        h_map = props["android.lens.info.shadingMapSize"]["height"]
34
35        # TODO: Test for 3A convergence, and exit this test once converged.
36
37        triggered = False
38        while True:
39            req = its.objects.auto_capture_request()
40            req["android.statistics.lensShadingMapMode"] = 1
41            req['android.control.aePrecaptureTrigger'] = (0 if triggered else 1)
42            req['android.control.afTrigger'] = (0 if triggered else 1)
43            triggered = True
44
45            cap = cam.do_capture(req)
46
47            ae_state = cap["metadata"]["android.control.aeState"]
48            awb_state = cap["metadata"]["android.control.awbState"]
49            af_state = cap["metadata"]["android.control.afState"]
50            gains = cap["metadata"]["android.colorCorrection.gains"]
51            transform = cap["metadata"]["android.colorCorrection.transform"]
52            exp_time = cap["metadata"]['android.sensor.exposureTime']
53            lsc_map = cap["metadata"]["android.statistics.lensShadingMap"]
54            foc_dist = cap["metadata"]['android.lens.focusDistance']
55            foc_range = cap["metadata"]['android.lens.focusRange']
56
57            print "States (AE,AWB,AF):", ae_state, awb_state, af_state
58            print "Gains:", gains
59            print "Transform:", [its.objects.rational_to_float(t)
60                                 for t in transform]
61            print "AE region:", cap["metadata"]['android.control.aeRegions']
62            print "AF region:", cap["metadata"]['android.control.afRegions']
63            print "AWB region:", cap["metadata"]['android.control.awbRegions']
64            print "LSC map:", w_map, h_map, lsc_map[:8]
65            print "Focus (dist,range):", foc_dist, foc_range
66            print ""
67
68if __name__ == '__main__':
69    main()
70
71