mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-18 17:14:26 +03:00
Implement update topic
This commit is contained in:
parent
e183781fa5
commit
ab12995b8d
@ -14,6 +14,7 @@ class EmbeddingsRequestEnum(Enum):
|
|||||||
embed_thumbnail = "embed_thumbnail"
|
embed_thumbnail = "embed_thumbnail"
|
||||||
generate_search = "generate_search"
|
generate_search = "generate_search"
|
||||||
register_face = "register_face"
|
register_face = "register_face"
|
||||||
|
reprocess_face = "reprocess_face"
|
||||||
|
|
||||||
|
|
||||||
class EmbeddingsResponder:
|
class EmbeddingsResponder:
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import datetime
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
|
import shutil
|
||||||
import string
|
import string
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
@ -400,6 +401,34 @@ class FaceProcessor(RealTimeProcessorApi):
|
|||||||
"message": "Successfully registered face.",
|
"message": "Successfully registered face.",
|
||||||
"success": True,
|
"success": True,
|
||||||
}
|
}
|
||||||
|
elif topic == EmbeddingsRequestEnum.reprocess_face:
|
||||||
|
current_file = request_data["image_file"]
|
||||||
|
face_score = current_file[current_file.rfind("-") : current_file.rfind(".")]
|
||||||
|
img = None
|
||||||
|
|
||||||
|
if current_file:
|
||||||
|
img = cv2.imread(current_file)
|
||||||
|
|
||||||
|
if not img:
|
||||||
|
return {
|
||||||
|
"message": "Invalid image file.",
|
||||||
|
"success": False,
|
||||||
|
}
|
||||||
|
|
||||||
|
res = self.__classify_face(img)
|
||||||
|
|
||||||
|
if not res:
|
||||||
|
return
|
||||||
|
|
||||||
|
sub_label, score = res
|
||||||
|
|
||||||
|
if self.config.face_recognition.save_attempts:
|
||||||
|
# write face to library
|
||||||
|
folder = os.path.join(FACE_DIR, "train")
|
||||||
|
new_file = os.path.join(
|
||||||
|
folder, f"{id}-{sub_label}-{score}-{face_score}.webp"
|
||||||
|
)
|
||||||
|
shutil.move(current_file, new_file)
|
||||||
|
|
||||||
def expire_object(self, object_id: str):
|
def expire_object(self, object_id: str):
|
||||||
if object_id in self.detected_faces:
|
if object_id in self.detected_faces:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user