Пример #1
0
    def _load_faces_from_segment(self, segment_id):
        # TODO: add docstring
        pattern = FACE_DETECTION.get_file_pattern(self._face_detection_method)

        self._log.debug('Faces in segment %s' % segment_id)
        for detection_path in list_files_in_segment(self._detection_dir,
                                                    segment_id,
                                                    file_pattern=pattern):
            self._log.debug('Loading faces from %s' % detection_path)
            faces = load_faces_from_file(detection_path,
                                         format=self._face_detection_method)
            # skip loop if no faces found
            if not faces:
                self._log.warning('No faces found in file %s segment %s' %
                                  ((detection_path, segment_id)))
                continue

            filtered_faces = self._filter(faces,
                                          segment_id,
                                          use_confidence=self._min_confidence
                                          is not None)

            if not filtered_faces:
                self._log.warning(
                    'No faces after filtering in file %s segment %s' %
                    ((detection_path, segment_id)))
                continue

            yield filtered_faces
    def _get_detections(self, segment_id):
        """ list face detection files in given segment.

        Args:
            :param segment_id: segment id. Detection files are expected in
            json format.
        Returns:
            :return: list of face detection files.
        """
        self._log.debug(
            'Listing detection files in segment {}'.format(segment_id))
        return list_files_in_segment(self._input_dir,
                                     segment_id,
                                     file_pattern='*.json')
 def _segment_sequence(self, segment_id):
     # TODO: add docstring
     self._log.debug('Listing segment {}'.format(segment_id))
     return list_files_in_segment(self._input_dir,
                                  segment_id,
                                  file_pattern='*.json')
Пример #4
0
 def _get_images(self, segment_id):
     # TODO: add docstring
     self._log.debug('Listing images in segment {}'.format(segment_id))
     return list_files_in_segment(self._input_dir,
                                  segment_id,
                                  file_pattern='*.jpg')