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 33 # TODO: Test for 3A convergence, and exit this test once converged. 34 35 triggered = False 36 while True: 37 req = its.objects.auto_capture_request() 38 req["android.statistics.lensShadingMapMode"] = 1 39 req['android.control.aePrecaptureTrigger'] = (0 if triggered else 1) 40 req['android.control.afTrigger'] = (0 if triggered else 1) 41 triggered = True 42 43 cap = cam.do_capture(req) 44 45 ae_state = cap["metadata"]["android.control.aeState"] 46 awb_state = cap["metadata"]["android.control.awbState"] 47 af_state = cap["metadata"]["android.control.afState"] 48 gains = cap["metadata"]["android.colorCorrection.gains"] 49 transform = cap["metadata"]["android.colorCorrection.transform"] 50 exp_time = cap["metadata"]['android.sensor.exposureTime'] 51 lsc_obj = cap_res["android.statistics.lensShadingCorrectionMap"] 52 lsc_map = lsc_obj["map"] 53 w_map = lsc_obj["width"] 54 h_map = lsc_obj["height"] 55 foc_dist = cap["metadata"]['android.lens.focusDistance'] 56 foc_range = cap["metadata"]['android.lens.focusRange'] 57 58 print "States (AE,AWB,AF):", ae_state, awb_state, af_state 59 print "Gains:", gains 60 print "Transform:", [its.objects.rational_to_float(t) 61 for t in transform] 62 print "AE region:", cap["metadata"]['android.control.aeRegions'] 63 print "AF region:", cap["metadata"]['android.control.afRegions'] 64 print "AWB region:", cap["metadata"]['android.control.awbRegions'] 65 print "LSC map:", w_map, h_map, lsc_map[:8] 66 print "Focus (dist,range):", foc_dist, foc_range 67 print "" 68 69if __name__ == '__main__': 70 main() 71 72