api endpoint

This commit is contained in:
Josh Hawkins 2025-04-23 17:38:15 -05:00
parent b061d083ba
commit 9fcc590efd
2 changed files with 31 additions and 0 deletions

View File

@ -14,6 +14,7 @@ from peewee import DoesNotExist
from playhouse.shortcuts import model_to_dict from playhouse.shortcuts import model_to_dict
from frigate.api.auth import require_role from frigate.api.auth import require_role
from frigate.api.defs.request.classification_body import RenameFaceBody
from frigate.api.defs.tags import Tags from frigate.api.defs.tags import Tags
from frigate.config.camera import DetectConfig from frigate.config.camera import DetectConfig
from frigate.const import FACE_DIR from frigate.const import FACE_DIR
@ -260,6 +261,31 @@ def deregister_faces(request: Request, name: str, body: dict = None):
) )
@router.put("/faces/{old_name}/rename", dependencies=[Depends(require_role(["admin"]))])
def rename_face(request: Request, old_name: str, body: RenameFaceBody):
if not request.app.frigate_config.face_recognition.enabled:
return JSONResponse(
status_code=400,
content={"message": "Face recognition is not enabled.", "success": False},
)
context: EmbeddingsContext = request.app.embeddings
try:
context.rename_face(old_name, body.new_name)
return JSONResponse(
content={
"success": True,
"message": f"Successfully renamed face to {body.new_name}.",
},
status_code=200,
)
except ValueError as e:
return JSONResponse(
status_code=400,
content={"message": str(e), "success": False},
)
@router.put("/lpr/reprocess") @router.put("/lpr/reprocess")
def reprocess_license_plate(request: Request, event_id: str): def reprocess_license_plate(request: Request, event_id: str):
if not request.app.frigate_config.lpr.enabled: if not request.app.frigate_config.lpr.enabled:

View File

@ -0,0 +1,5 @@
from pydantic import BaseModel
class RenameFaceBody(BaseModel):
new_name: str