def crop_face(self,image_data): image_batch = image_data files = [] face_detect = face_detection_model('/usr/share/opencv/haarcascades/haarcascade_frontalface_default.xml') face_files = face_detect.run(image_data) #print(face_files) return face_files
def __init__(self, wait=0.0): image_topic = "/hsrb/head_rgbd_sensor/rgb/image_rect_color" rospy.Subscriber(image_topic, Image, self.image_callback) s = rospy.Service('/face_recognition_run', face_recognition_srv, self.Isrunnging) DATA_DIR = abspath(join(dirname(__file__), 'known_faces')) self.string_pub = rospy.Publisher('/face_detected_name', String, queue_size=10) self.bridge = CvBridge() self.path = exists("known_faces") print self.path self.takepicture = False self.threshold = 0.6 self.known_folder = DATA_DIR self.known_imgs = [ f for f in listdir(self.known_folder) if isfile(join(self.known_folder, f)) ] print self.known_imgs self.known_img_names = [] self.known_encodings = [] self.count = 0 self.unknowncount = 0 self.Isrecognized = False self.detected_name = "unknown" self.detection_model = face_detection_model( '/usr/share/opencv/haarcascades/haarcascade_frontalface_default.xml' ) for img_name in self.known_imgs: img = face_recognition.load_image_file(self.known_folder + '/' + img_name) print img_name self.known_encodings.append( face_recognition.face_encodings(img)[0]) dot_idx = img_name.rfind('.') name = img_name[0:dot_idx] self.known_img_names.append(name)