Home | History | Annotate | Download | only in inprog
      1 # Copyright 2015 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 import os.path
     21 import math
     22 
     23 def main():
     24     """Test capturing some rawstats data.
     25     """
     26     NAME = os.path.basename(__file__).split(".")[0]
     27 
     28     with its.device.ItsSession() as cam:
     29 
     30         cam.do_3a(do_af=False);
     31         req = its.objects.auto_capture_request()
     32 
     33         for (gw,gh) in [(16,16)]:#,(4080,1)]:
     34             cap = cam.do_capture(req,
     35                 {"format":"rawStats","gridWidth":gw,"gridHeight":gh})
     36             mean_image, var_image = its.image.unpack_rawstats_capture(cap)
     37 
     38             if gw > 1 and gh > 1:
     39                 h,w,_ = mean_image.shape
     40                 for ch in range(4):
     41                     m = mean_image[:,:,ch].reshape(h,w,1)/1023.0
     42                     v = var_image[:,:,ch].reshape(h,w,1)
     43                     its.image.write_image(m, "%s_mean_ch%d.jpg" % (NAME,ch), True)
     44                     its.image.write_image(v, "%s_var_ch%d.jpg" % (NAME,ch), True)
     45 
     46 if __name__ == '__main__':
     47     main()
     48 
     49