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