def process_image(self, image): """Process an image.""" try: detections = self._api.detect(image) self.faces = hound.get_faces(detections) self.people = hound.get_people(detections) metadata = hound.get_metadata(detections) self._image_width = metadata["image_width"] self._image_height = metadata["image_height"] self._state = len(self.people) if self._state > 0: self._last_detection = dt_util.now().strftime(DATETIME_FORMAT) if hasattr(self, "_save_file_folder") and self._state > 0: self.save_image(image, self.people, self.faces, self._save_file_folder) for face in self.faces: self.fire_face_detected_event(face) for person in self.people: self.fire_person_detected_event(person) except hound.SimplehoundException as exc: _LOGGER.error(str(exc)) self.faces = [] self.people = [] self._image_width = None self._image_height = None
def process_image(self, image): """Process an image.""" self._plates = [] self._color = [] self._make = [] self._model = [] self._vehicle_type = [] detections = self._api.recognize(image, "vehicle,licenseplate") vehicles = hound.get_vehicles(detections) self._state = len(vehicles) if self._state > 0: self._last_detection = dt_util.now().strftime(DATETIME_FORMAT) metadata = hound.get_metadata(detections) self._image_width = metadata["image_width"] self._image_height = metadata["image_height"] for vehicle in vehicles: self.fire_vehicle_detected_event(vehicle) self._plates.append(vehicle["licenseplate"]) self._color.append(vehicle["color"]) self._make.append(vehicle["make"]) self._model.append(vehicle["model"]) self._vehicle_type.append(vehicle["vehicleType"]) if self._save_file_folder: if self._state > 0 or self._always_save_latest_jpg: self.save_image(image, vehicles, self._save_file_folder)
def process_image(self, image): """Process an image.""" detections = self._api.detect(image) people = hound.get_people(detections) self._state = len(people) metadata = hound.get_metadata(detections) self._image_width = metadata["image_width"] self._image_height = metadata["image_height"] for person in people: self.fire_person_detected_event(person)
def process_image(self, image): """Process an image.""" detections = self._api.detect(image) people = hound.get_people(detections) self._state = len(people) if self._state > 0: self._last_detection = dt_util.now().strftime(DATETIME_FORMAT) metadata = hound.get_metadata(detections) self._image_width = metadata["image_width"] self._image_height = metadata["image_height"] for person in people: self.fire_person_detected_event(person) if self._save_file_folder and self._state > 0: self.save_image(image, people, self._save_file_folder)
def process_image(self, image): """Process an image.""" detections = self._api.recognize(image, "vehicle,licenseplate") vehicles = hound.get_vehicles(detections) self._state = len(vehicles) if self._state > 0: self._last_detection = dt_util.now().strftime(DATETIME_FORMAT) metadata = hound.get_metadata(detections) self._image_width = metadata["image_width"] self._image_height = metadata["image_height"] for vehicle in vehicles: self.fire_vehicle_detected_event(vehicle) if self._save_file_folder: if self._state > 0 or self._always_save_latest_jpg: self.save_image(image, vehicles, self._save_file_folder)
def process_image(self, image): """Process an image.""" self._age = [] self._gender = [] detections = self._api.detect(image) people = hound.get_people(detections) faces = hound.get_faces(detections) self._state = len(people) if self._state > 0: self._last_detection = dt_util.now().strftime(DATETIME_FORMAT) metadata = hound.get_metadata(detections) self._image_width = metadata["image_width"] self._image_height = metadata["image_height"] for person in people: self.fire_person_detected_event(person) if self._save_file_folder: if self._state > 0 or self._always_save_latest_jpg: self.save_image(image, people, self._save_file_folder) for face in faces: self._age.append(face["age"]) self._gender.append(face["gender"])
def test_get_metadata(): assert hound.get_metadata(DETECTIONS) == METADATA