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 its.image 16 import its.device 17 import its.objects 18 import os.path 19 20 def main(): 21 """Test face detection. 22 """ 23 NAME = os.path.basename(__file__).split(".")[0] 24 25 with its.device.ItsSession() as cam: 26 cam.do_3a() 27 req = its.objects.auto_capture_request() 28 req['android.statistics.faceDetectMode'] = 2 29 caps = cam.do_capture([req]*5) 30 for i,cap in enumerate(caps): 31 md = cap['metadata'] 32 print "Frame %d face metadata:" % i 33 print " Ids:", md['android.statistics.faceIds'] 34 print " Landmarks:", md['android.statistics.faceLandmarks'] 35 print " Rectangles:", md['android.statistics.faceRectangles'] 36 print " Scores:", md['android.statistics.faceScores'] 37 print "" 38 39 if __name__ == '__main__': 40 main() 41 42