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.device
17import its.objects
18import os.path
19
20def main():
21    """Test sensor test patterns.
22    """
23    NAME = os.path.basename(__file__).split(".")[0]
24
25    with its.device.ItsSession() as cam:
26        caps = []
27        for i in range(1,6):
28            req = its.objects.manual_capture_request(100, 10*1000*1000)
29            req['android.sensor.testPatternData'] = [40, 100, 160, 220]
30            req['android.sensor.testPatternMode'] = i
31
32            # Capture the shot twice, and use the second one, so the pattern
33            # will have stabilized.
34            caps = cam.do_capture([req]*2)
35
36            img = its.image.convert_capture_to_rgb_image(caps[1])
37            its.image.write_image(img, "%s_pattern=%d.jpg" % (NAME, i))
38
39if __name__ == '__main__':
40    main()
41
42