def detect(self, img, face_records, options):
    detected_templates = self._detect(img, options)
    for i in range(0, self.num_faces):
        curr_template = roc.roc_template_array_getitem(detected_templates, i)
        if ((curr_template.algorithm_id & roc.ROC_INVALID) or (curr_template.algorithm_id == 0)):
            continue
        else:
            face_record = face_records.face_records.add()
            face_record.detection.score = curr_template.detection.confidence
            (xc, yc, w, h) = (curr_template.detection.x, curr_template.detection.y, curr_template.detection.width, curr_template.detection.height)
            x = int((xc - (w * 0.5)))
            y = int((yc - (w * 0.5)))
            face_record.detection.location.CopyFrom(pt.rect_val2proto(x, y, w, h))
            face_record.detection.detection_id = i
            face_record.detection.detection_class = 'FACE'
            face_record.template.buffer = self._rocFlatten(curr_template)
    for i in range(0, self.num_faces):
        roc.roc_free_template(roc.roc_template_array_getitem(detected_templates, i))
def detect(self, img, face_records, options):
    detected_templates = self._detect(img, options)
    for i in range(0, self.num_faces):
        curr_template = roc.roc_template_array_getitem(detected_templates, i)
        if ((curr_template.algorithm_id & roc.ROC_INVALID) or (curr_template.algorithm_id == 0)):
            continue
        else:
            face_record = face_records.face_records.add()
            face_record.detection.score = curr_template.detection.confidence
            (xc, yc, w, h) = (curr_template.detection.x, curr_template.detection.y, curr_template.detection.width, curr_template.detection.height)
            x = int((xc - (w * 0.5)))
            y = int((yc - (w * 0.5)))
            face_record.detection.location.CopyFrom(pt.rect_val2proto(x, y, w, h))
            face_record.detection.detection_id = i
            face_record.detection.detection_class = 'FACE'
            face_record.template.buffer = self._rocFlatten(curr_template)
    for i in range(0, self.num_faces):
        roc.roc_free_template(roc.roc_template_array_getitem(detected_templates, i))