99from pathlib import Path
1010from argparse import ArgumentParser
1111
12- from face_detector import FaceDetector
13- from head_pose_estimator import HeadposeEstimator
14- from landmark_detector import LandmarkDetector
15- from gaze_estimator import GazeEstimator
16- from input_feeder import InputFeeder
12+ from lib . face_detector import FaceDetector
13+ # from lib. head_pose_estimator import HeadposeEstimator
14+ # from lib. landmark_detector import LandmarkDetector
15+ # from lib. gaze_estimator import GazeEstimator
16+ from lib . input_feeder import InputFeeder
1717
18- from mouse_controller import MouseController
18+ # from lib. mouse_controller import MouseController
1919import logging
2020
2121#Create and configure logger
@@ -45,33 +45,25 @@ def build_argparser():
4545 help = "Path to an xml file of Face Detection Model." )
4646 parser .add_argument ("-ldm" ,
4747 "--lmar_det_m" ,
48- required = True ,
48+ required = False ,
4949 type = str ,
5050 help = "Path to an xml file of Landmark Detection model" )
5151 parser .add_argument (
5252 "-hem" ,
5353 "--h_pose_m" ,
54- required = True ,
54+ required = False ,
5555 type = str ,
5656 help = "Path to an xml file of Head Pose Estimation model." )
5757 parser .add_argument ("-gem" ,
5858 "--g_est_m" ,
59- required = True ,
59+ required = False ,
6060 type = str ,
6161 help = "Path to an xml file of Gaze Estimation Model." )
6262 parser .add_argument ("-i" ,
6363 "--input" ,
6464 required = True ,
6565 type = str ,
6666 help = "Path to image or video file" )
67- parser .add_argument ("-l" ,
68- "--cpu_extension" ,
69- required = False ,
70- type = str ,
71- default = None ,
72- help = "MKLDNN (CPU)-targeted custom layers."
73- "Absolute path to a shared library with the"
74- "kernels impl." )
7567 parser .add_argument ("-d" ,
7668 "--device" ,
7769 type = str ,
@@ -116,7 +108,7 @@ def infer_on_stream(args):
116108 """
117109 # Check if all input files are present
118110 for _ in [
119- args .face_det_m , args .lmar_det_m , args .h_pose_m , args .g_est_m ,
111+ args .face_det_m ,# args.lmar_det_m, args.h_pose_m, args.g_est_m,
120112 args .input
121113 ]:
122114 if not Path (_ ).is_file ():
@@ -157,28 +149,27 @@ def infer_on_stream(args):
157149
158150 ### Load All Models
159151 ## Load Face Detector Model
160- face_detector = FaceDetector (args .face_det_m , args .device ,
161- args .cpu_extension )
152+ face_detector = FaceDetector (args .face_det_m , args .device )
162153 face_detector .load_model ()
163154
164155 logger .info ("Face Detection model loaded successfully" )
165156 ## Load Headpose Estimator Model
166- headpose_estimator = HeadposeEstimator (args .h_pose_m , args .device ,
167- args .cpu_extension )
168- headpose_estimator .load_model ()
169- logger .info ("Headpose Estimator model loaded successfully" )
170-
171- ## Load Landmark Detector Model
172- landmark_detector = LandmarkDetector (args .lmar_det_m , args .device ,
173- args .cpu_extension )
174- landmark_detector .load_model ()
175- logger .info ("Landmark Detector model loaded successfully" )
176-
177- ## Load Gaze Estimation Model
178- gaze_estimator = GazeEstimator (args .g_est_m , args .device ,
179- args .cpu_extension )
180- gaze_estimator .load_model ()
181- logger .info ("Gaze Estimation model loaded successfully" )
157+ # headpose_estimator = HeadposeEstimator(args.h_pose_m, args.device,
158+ # args.cpu_extension)
159+ # headpose_estimator.load_model()
160+ # logger.info("Headpose Estimator model loaded successfully")
161+
162+ # # # Load Landmark Detector Model
163+ # landmark_detector = LandmarkDetector(args.lmar_det_m, args.device,
164+ # args.cpu_extension)
165+ # landmark_detector.load_model()
166+ # logger.info("Landmark Detector model loaded successfully")
167+
168+ # # # Load Gaze Estimation Model
169+ # gaze_estimator = GazeEstimator(args.g_est_m, args.device,
170+ # args.cpu_extension)
171+ # gaze_estimator.load_model()
172+ # logger.info("Gaze Estimation model loaded successfully")
182173 ### Initialize Input Feeder
183174 input_feeder = InputFeeder (input_type , args .input )
184175 (initial_w , initial_h ) = input_feeder .load_data ()
@@ -192,14 +183,15 @@ def infer_on_stream(args):
192183 break
193184 f_count += 1
194185 logger .info ("Processing Frame: {}" .format (f_count ))
195- print ("\n Processing Frame: {}" .format (f_count ))
196-
197186 ### Detect Face in Frame
198187 output = face_detector .predict (frame )
199188 ## Crop Face
200- face , face_coords = face_detector .preprocess_output (
189+ face , face_coords = face_detector .postprocess_output (
201190 output , args .prob_threshold , frame , initial_w , initial_h )
202-
191+ if np .any (face ):
192+ cv2 .imshow ("face" , face )
193+ cv2 .waitKey ()
194+ exit ()
203195 # skip frame if face not found
204196 if not np .any (face ):
205197 print ("Face Not found in Frame\t Skipping Frame" )
0 commit comments