aboutsummaryrefslogtreecommitdiff
path: root/apps/CameraITS/tests/inprog/test_3a_remote.py
blob: c76ff6dafd7bd4fc73b11c8e462a06a842f1118c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Copyright 2013 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import its.image
import its.device
import its.objects
import os.path
import pprint
import math
import numpy
import matplotlib.pyplot
import mpl_toolkits.mplot3d

def main():
    """Run 3A remotely (from this script).
    """
    NAME = os.path.basename(__file__).split(".")[0]

    with its.device.ItsSession() as cam:
        props = cam.get_camera_properties()
        w_map = props["android.lens.info.shadingMapSize"]["width"]
        h_map = props["android.lens.info.shadingMapSize"]["height"]

        # TODO: Test for 3A convergence, and exit this test once converged.

        triggered = False
        while True:
            req = its.objects.auto_capture_request()
            req["android.statistics.lensShadingMapMode"] = 1
            req['android.control.aePrecaptureTrigger'] = (0 if triggered else 1)
            req['android.control.afTrigger'] = (0 if triggered else 1)
            triggered = True

            cap = cam.do_capture(req)

            ae_state = cap["metadata"]["android.control.aeState"]
            awb_state = cap["metadata"]["android.control.awbState"]
            af_state = cap["metadata"]["android.control.afState"]
            gains = cap["metadata"]["android.colorCorrection.gains"]
            transform = cap["metadata"]["android.colorCorrection.transform"]
            exp_time = cap["metadata"]['android.sensor.exposureTime']
            lsc_map = cap["metadata"]["android.statistics.lensShadingMap"]
            foc_dist = cap["metadata"]['android.lens.focusDistance']
            foc_range = cap["metadata"]['android.lens.focusRange']

            print "States (AE,AWB,AF):", ae_state, awb_state, af_state
            print "Gains:", gains
            print "Transform:", [its.objects.rational_to_float(t)
                                 for t in transform]
            print "AE region:", cap["metadata"]['android.control.aeRegions']
            print "AF region:", cap["metadata"]['android.control.afRegions']
            print "AWB region:", cap["metadata"]['android.control.awbRegions']
            print "LSC map:", w_map, h_map, lsc_map[:8]
            print "Focus (dist,range):", foc_dist, foc_range
            print ""

if __name__ == '__main__':
    main()