1 # Copyright 2014 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 os.path 16 17 import its.caps 18 import its.device 19 import its.image 20 import its.objects 21 22 NAME = os.path.basename(__file__).split(".")[0] 23 24 25 def main(): 26 """Test capturing a single frame as both DNG and YUV outputs. 27 """ 28 29 with its.device.ItsSession() as cam: 30 props = cam.get_camera_properties() 31 its.caps.skip_unless(its.caps.raw(props) and 32 its.caps.read_3a(props)) 33 mono_camera = its.caps.mono_camera(props) 34 35 cam.do_3a(mono_camera=mono_camera) 36 37 req = its.objects.auto_capture_request() 38 max_dng_size = its.objects.get_available_output_sizes("raw", props)[0] 39 w, h = its.objects.get_available_output_sizes( 40 "yuv", props, (1920, 1080), max_dng_size)[0] 41 out_surfaces = [{"format": "dng"}, 42 {"format": "yuv", "width": w, "height": h}] 43 cap_dng, cap_yuv = cam.do_capture(req, out_surfaces) 44 45 img = its.image.convert_capture_to_rgb_image(cap_yuv) 46 its.image.write_image(img, "%s.jpg" % (NAME)) 47 48 with open("%s.dng"%(NAME), "wb") as f: 49 f.write(cap_dng["data"]) 50 51 # No specific pass/fail check; test is assumed to have succeeded if 52 # it completes. 53 54 if __name__ == "__main__": 55 main() 56 57