File size: 1,472 Bytes
aa77e96
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import f_Face_info
import cv2
import time
import imutils
import argparse

parser = argparse.ArgumentParser(description="Face Info")
parser.add_argument('--input', type=str, default= 'webcam',
                    help="webcam or image")
parser.add_argument('--path_im', type=str,
                    help="path of image")
args = vars(parser.parse_args())

type_input = args['input']
if type_input == 'image':
    # ----------------------------- image -----------------------------
    #ingestar data
    frame = cv2.imread(args['path_im'])
    # obtenego info del frame
    out = f_Face_info.get_face_info(frame)
    # pintar imagen
    res_img = f_Face_info.bounding_box(out,frame)
    cv2.imshow('Face info',res_img)
    cv2.waitKey(0)

if type_input == 'webcam':
    # ----------------------------- webcam -----------------------------
    cv2.namedWindow("Face info")
    cam = cv2.VideoCapture(0)
    while True:
        star_time = time.time()
        ret, frame = cam.read()
        frame = imutils.resize(frame, width=720)
        
        # obtenego info del frame
        out = f_Face_info.get_face_info(frame)
        # pintar imagen
        res_img = f_Face_info.bounding_box(out,frame)

        end_time = time.time() - star_time    
        FPS = 1/end_time
        cv2.putText(res_img,f"FPS: {round(FPS,3)}",(10,50),cv2.FONT_HERSHEY_COMPLEX,1,(0,0,255),2)
        cv2.imshow('Face info',res_img)
        if cv2.waitKey(1) &0xFF == ord('q'):
            break