mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-05-05 04:57:42 +03:00
api endpoint
This commit is contained in:
parent
b061d083ba
commit
9fcc590efd
@ -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:
|
||||||
|
|||||||
5
frigate/api/defs/request/classification_body.py
Normal file
5
frigate/api/defs/request/classification_body.py
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
|
||||||
|
class RenameFaceBody(BaseModel):
|
||||||
|
new_name: str
|
||||||
Loading…
Reference in New Issue
Block a user