mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-02 17:25:22 +03:00
Use int for birdseye mode
This commit is contained in:
parent
a0a932b3d6
commit
020dcb4561
@ -1,4 +1,3 @@
|
||||
from ctypes import c_char
|
||||
import logging
|
||||
import multiprocessing as mp
|
||||
from multiprocessing.queues import Queue
|
||||
@ -27,6 +26,7 @@ from frigate.output import output_frames
|
||||
from frigate.plus import PlusApi
|
||||
from frigate.record import RecordingCleanup, RecordingMaintainer
|
||||
from frigate.stats import StatsEmitter, stats_init
|
||||
from frigate.util import int_from_birdseye_mode
|
||||
from frigate.version import VERSION
|
||||
from frigate.video import capture_camera, track_camera
|
||||
from frigate.watchdog import FrigateWatchdog
|
||||
@ -104,7 +104,7 @@ class FrigateApp:
|
||||
"capture_process": None,
|
||||
"process": None,
|
||||
"birdseye_enabled": mp.Value("i", self.config.cameras[camera_name].birdseye.enabled),
|
||||
"birdseye_mode": mp.Array(c_char, self.config.cameras[camera_name].birdseye.mode),
|
||||
"birdseye_mode": mp.Value("i", int_from_birdseye_mode(self.config.cameras[camera_name].birdseye.mode)),
|
||||
}
|
||||
|
||||
def set_log_levels(self) -> None:
|
||||
|
||||
@ -13,7 +13,7 @@ from ws4py.server.wsgiutils import WebSocketWSGIApplication
|
||||
from ws4py.websocket import WebSocket
|
||||
|
||||
from frigate.config import BirdseyeModeEnum, FrigateConfig
|
||||
from frigate.util import restart_frigate
|
||||
from frigate.util import birdseye_mode_from_int, int_from_birdseye_mode, restart_frigate
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -212,29 +212,29 @@ def create_mqtt_client(config: FrigateConfig, camera_metrics):
|
||||
payload = message.payload.decode()
|
||||
logger.debug(f"on_birdseye_mode_toggle: {message.topic} {payload}")
|
||||
|
||||
camera_name = message.topic.split("/")[-3]
|
||||
camera_name = message.topic.split("/")[-4]
|
||||
|
||||
birdseye_settings = config.cameras[camera_name].birdseye
|
||||
|
||||
if payload == BirdseyeModeEnum.continuous:
|
||||
if camera_metrics[camera_name]["birdseye_mode"].value != BirdseyeModeEnum.continuous:
|
||||
if birdseye_mode_from_int(camera_metrics[camera_name]["birdseye_mode"].value) != BirdseyeModeEnum.continuous:
|
||||
logger.info(f"Setting birdseye mode for {camera_name} to {payload} via mqtt")
|
||||
camera_metrics[camera_name]["birdseye_mode"].value = BirdseyeModeEnum.continuous
|
||||
camera_metrics[camera_name]["birdseye_mode"].value = int_from_birdseye_mode(BirdseyeModeEnum.continuous)
|
||||
birdseye_settings.mode = BirdseyeModeEnum.continuous
|
||||
elif payload == BirdseyeModeEnum.motion:
|
||||
if camera_metrics[camera_name]["birdseye_mode"].value != BirdseyeModeEnum.motion:
|
||||
if birdseye_mode_from_int(camera_metrics[camera_name]["birdseye_mode"].value) != BirdseyeModeEnum.motion:
|
||||
logger.info(f"Setting birdseye mode for {camera_name} to {payload} via mqtt")
|
||||
camera_metrics[camera_name]["birdseye_mode"].value = BirdseyeModeEnum.motion
|
||||
camera_metrics[camera_name]["birdseye_mode"].value = int_from_birdseye_mode(BirdseyeModeEnum.motion)
|
||||
birdseye_settings.mode = BirdseyeModeEnum.motion
|
||||
elif payload == BirdseyeModeEnum.objects:
|
||||
if camera_metrics[camera_name]["birdseye_mode"].value != BirdseyeModeEnum.objects:
|
||||
if birdseye_mode_from_int(camera_metrics[camera_name]["birdseye_mode"].value) != BirdseyeModeEnum.objects:
|
||||
logger.info(f"Setting birdseye mode for {camera_name} to {payload} via mqtt")
|
||||
camera_metrics[camera_name]["birdseye_mode"].value = BirdseyeModeEnum.objects
|
||||
camera_metrics[camera_name]["birdseye_mode"].value = int_from_birdseye_mode(BirdseyeModeEnum.objects)
|
||||
birdseye_settings.mode = BirdseyeModeEnum.objects
|
||||
else:
|
||||
logger.warning(f"Received unsupported value at {message.topic}: {payload}")
|
||||
|
||||
state_topic = f"{message.topic[:-4]}/state"
|
||||
state_topic = f"{message.topic[:-4]}"
|
||||
client.publish(state_topic, payload, retain=True)
|
||||
|
||||
def on_restart_command(client, userdata, message):
|
||||
|
||||
@ -1,13 +1,7 @@
|
||||
import copy
|
||||
import datetime
|
||||
import hashlib
|
||||
import json
|
||||
import logging
|
||||
import math
|
||||
import signal
|
||||
import subprocess as sp
|
||||
import threading
|
||||
import time
|
||||
import traceback
|
||||
from abc import ABC, abstractmethod
|
||||
from collections.abc import Mapping
|
||||
@ -15,7 +9,6 @@ from multiprocessing import shared_memory
|
||||
from typing import AnyStr
|
||||
|
||||
import cv2
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
import os
|
||||
import psutil
|
||||
@ -625,6 +618,30 @@ def load_labels(path, encoding="utf-8"):
|
||||
return {index: line.strip() for index, line in enumerate(lines)}
|
||||
|
||||
|
||||
def birdseye_mode_from_int(mode: int) -> str:
|
||||
"""Returns a string name for a given int"""
|
||||
if mode == 1:
|
||||
return "continuous"
|
||||
elif mode == 2:
|
||||
return "motion"
|
||||
elif mode == 3:
|
||||
return "objects"
|
||||
else:
|
||||
logger.error(f"{mode} is not a valid int for birdseye mode.")
|
||||
|
||||
|
||||
def int_from_birdseye_mode(mode: str) -> int:
|
||||
"""Returns an int for a given birdseye mode string."""
|
||||
if mode == "continuous":
|
||||
return 1
|
||||
elif mode == "motion":
|
||||
return 2
|
||||
elif mode == "objects":
|
||||
return 3
|
||||
else:
|
||||
logger.error(f"{mode} is not a valid birdseye mode.")
|
||||
|
||||
|
||||
class FrameManager(ABC):
|
||||
@abstractmethod
|
||||
def create(self, name, size) -> AnyStr:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user