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