blob: 890cf124e191181cca7758a8af93af75b500e5cf [file] [log] [blame]
Yin-Chia Yehab98ada2015-03-05 13:28:53 -08001# 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
15import sys
16import its.device
17import its.objects
18import its.image
Yin-Chia Yeh9c0d9262015-04-03 17:02:13 -070019import its.caps
Yin-Chia Yeh0e0276f2015-06-03 15:27:06 -070020import re
Yin-Chia Yehab98ada2015-03-05 13:28:53 -080021
22def main():
23 """capture a yuv image and save it to argv[1]
24 """
25 camera_id = -1
26 out_path = ""
Yin-Chia Yeh0e0276f2015-06-03 15:27:06 -070027 scene_name = ""
28 scene_desc = "No requirement"
Yin-Chia Yeh143612d2016-04-27 15:44:08 -070029 do_af = True
Yin-Chia Yehab98ada2015-03-05 13:28:53 -080030 for s in sys.argv[1:]:
31 if s[:7] == "camera=" and len(s) > 7:
32 camera_id = s[7:]
33 elif s[:4] == "out=" and len(s) > 4:
34 out_path = s[4:]
Yin-Chia Yeh0e0276f2015-06-03 15:27:06 -070035 elif s[:6] == "scene=" and len(s) > 6:
36 scene_desc = s[6:]
Yin-Chia Yeh143612d2016-04-27 15:44:08 -070037 elif s[:5] == "doAF=" and len(s) > 5:
38 do_af = s[5:] == "True"
Yin-Chia Yeh0e0276f2015-06-03 15:27:06 -070039
40 if out_path != "":
41 scene_name = re.split("/|\.", out_path)[-2]
Yin-Chia Yehab98ada2015-03-05 13:28:53 -080042
43 if camera_id == -1:
44 print "Error: need to specify which camera to use"
45 assert(False)
46
47 with its.device.ItsSession() as cam:
48 raw_input("Press Enter after placing camera " + camera_id +
Yin-Chia Yeh0e0276f2015-06-03 15:27:06 -070049 " to frame the test scene: " + scene_name +
50 "\nThe scene setup should be: " + scene_desc )
Yin-Chia Yehab98ada2015-03-05 13:28:53 -080051 # Converge 3A prior to capture.
Yin-Chia Yehab98ada2015-03-05 13:28:53 -080052 props = cam.get_camera_properties()
huansbe345192018-01-26 17:15:24 -080053 cam.do_3a(do_af=do_af, lock_ae=its.caps.ae_lock(props),
54 lock_awb=its.caps.awb_lock(props))
Yin-Chia Yehab98ada2015-03-05 13:28:53 -080055 req = its.objects.fastest_auto_capture_request(props)
Yin-Chia Yeh9c0d9262015-04-03 17:02:13 -070056 if its.caps.ae_lock(props):
57 req["android.control.awbLock"] = True
58 if its.caps.awb_lock(props):
59 req["android.control.aeLock"] = True
Yin-Chia Yehab98ada2015-03-05 13:28:53 -080060 while True:
61 print "Capture an image to check the test scene"
62 cap = cam.do_capture(req)
63 img = its.image.convert_capture_to_rgb_image(cap)
leslieshawad758902020-09-01 19:45:16 -070064 its.image.validate_lighting(img)
Yin-Chia Yehab98ada2015-03-05 13:28:53 -080065 if out_path != "":
66 its.image.write_image(img, out_path)
67 print "Please check scene setup in", out_path
68 choice = raw_input(
Yin-Chia Yeh0e0276f2015-06-03 15:27:06 -070069 "Is the image okay for ITS " + scene_name +\
70 "? (Y/N)").lower()
Yin-Chia Yehab98ada2015-03-05 13:28:53 -080071 if choice == "y":
72 break
73 else:
74 raw_input("Press Enter after placing camera " + camera_id +
75 " to frame the test scene")
76
77if __name__ == '__main__':
78 main()