• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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"""Verifies single capture of both DNG and YUV."""
15
16
17import logging
18import os.path
19from mobly import test_runner
20
21import its_base_test
22import camera_properties_utils
23import capture_request_utils
24import image_processing_utils
25import its_session_utils
26
27MAX_IMG_SIZE = (1920, 1080)
28NAME = os.path.splitext(os.path.basename(__file__))[0]
29
30
31class YuvPlusDngTest(its_base_test.ItsBaseTest):
32  """Test capturing a single frame as both DNG and YUV outputs."""
33
34  def test_yuv_plus_dng(self):
35    logging.debug('Starting %s', NAME)
36    with its_session_utils.ItsSession(
37        device_id=self.dut.serial,
38        camera_id=self.camera_id,
39        hidden_physical_id=self.hidden_physical_id) as cam:
40      props = cam.get_camera_properties()
41      props = cam.override_with_hidden_physical_camera_props(props)
42      log_path = self.log_path
43
44      # check SKIP conditions
45      camera_properties_utils.skip_unless(
46          camera_properties_utils.raw(props) and
47          camera_properties_utils.read_3a(props))
48
49      # Load chart for scene
50      its_session_utils.load_scene(
51          cam, props, self.scene, self.tablet, self.chart_distance)
52
53      # Create requests
54      mono_camera = camera_properties_utils.mono_camera(props)
55      cam.do_3a(mono_camera=mono_camera)
56      req = capture_request_utils.auto_capture_request()
57      max_dng_size = capture_request_utils.get_available_output_sizes(
58          'raw', props)[0]
59      w, h = capture_request_utils.get_available_output_sizes(
60          'yuv', props, MAX_IMG_SIZE, max_dng_size)[0]
61      out_surfaces = [{'format': 'dng'},
62                      {'format': 'yuv', 'width': w, 'height': h}]
63      cap_dng, cap_yuv = cam.do_capture(req, out_surfaces)
64
65      img = image_processing_utils.convert_capture_to_rgb_image(cap_yuv)
66      image_processing_utils.write_image(
67          img, '%s_yuv.jpg' % os.path.join(log_path, NAME))
68
69      with open('%s.dng'%(os.path.join(log_path, NAME)), 'wb') as f:
70        f.write(cap_dng['data'])
71
72      # No specific pass/fail check; test assumed to succeed if it completes.
73
74if __name__ == '__main__':
75  test_runner.main()
76