NVR with realtime local object detection for IP cameras
TypeScript aicameragoogle-coralhome-assistanthome-automationhomeautomationmqttnvrobject-detectionrealtimertsptensorflow
Miscellaneous fixes (#23358)
Josh Hawkins08be019bedea
diff --git a/frigate/app.py b/frigate/app.pyindex b2402d2326..785dc24470 100644--- a/frigate/app.py+++ b/frigate/app.py@@ -343,13 +343,21 @@ class FrigateApp:)self.dispatcher.profile_manager = self.profile_manager+ def restore_active_profile(self) -> None:+ """Re-activate the persisted profile after subscribers are connected.++ ZMQ PUB/SUB drops messages with no subscribers, so activation must+ run after every config_updater subscriber is up.+ """+ if self.profile_manager is None:+ return+persisted = ProfileManager.load_persisted_profile()if persisted and any(persisted in cam.profiles for cam in self.config.cameras.values()):logger.info("Restoring persisted profile '%s'", persisted)- # don't clear runtime overrides here, restore_runtime_state() later- # in startup replays it on top of the activated profile+ # runtime overrides are layered on top via restore_runtime_state()self.profile_manager.activate_profile(persisted, clear_runtime_overrides=False)@@ -617,6 +625,7 @@ class FrigateApp:self.start_watchdog()# restore persisted runtime overrides on top of config+ self.restore_active_profile()self.dispatcher.restore_runtime_state()self.init_auth()diff --git a/web/public/locales/en/views/events.json b/web/public/locales/en/views/events.jsonindex 103d93b7eb..f25e3022c5 100644--- a/web/public/locales/en/views/events.json+++ b/web/public/locales/en/views/events.json@@ -67,7 +67,7 @@"needsReview": "Needs review","securityConcern": "Security concern","motionSearch": {- "menuItem": "Motion search",+ "menuItem": "Motion Search","openMenu": "Camera options"},"motionPreviews": {diff --git a/web/src/components/button/BlurredIconButton.tsx b/web/src/components/button/BlurredIconButton.tsxindex 8fe17f869b..90ffa36eec 100644--- a/web/src/components/button/BlurredIconButton.tsx+++ b/web/src/components/button/BlurredIconButton.tsx@@ -14,8 +14,8 @@ const BlurredIconButton = forwardRef<HTMLDivElement, BlurredIconButtonProps>()}{...rest}>- <div className="pointer-events-none absolute inset-0 m-auto size-5 scale-95 rounded-full bg-black opacity-0 blur-sm transition-all duration-200 group-hover:scale-100 group-hover:opacity-100 group-hover:blur-xl" />- <div className="relative z-10 cursor-pointer text-white/85 hover:text-white">+ <div className="pointer-events-none absolute inset-0 m-auto size-5 scale-95 rounded-full bg-black opacity-30 blur-md transition-all duration-200 group-hover:scale-100 group-hover:opacity-100 group-hover:blur-xl" />+ <div className="relative z-10 cursor-pointer text-white/85 drop-shadow-[0_1px_1px_rgba(0,0,0,0.9)] hover:text-white">{children}</div></div>diff --git a/web/src/components/overlay/ActionsDropdown.tsx b/web/src/components/overlay/ActionsDropdown.tsxindex 1bc750dd78..7f501a2067 100644--- a/web/src/components/overlay/ActionsDropdown.tsx+++ b/web/src/components/overlay/ActionsDropdown.tsx@@ -12,14 +12,21 @@ type ActionsDropdownProps = {onDebugReplayClick?: () => void;onExportClick: () => void;onShareTimestampClick: () => void;+ onMotionSearchClick?: () => void;};export default function ActionsDropdown({onDebugReplayClick,onExportClick,onShareTimestampClick,+ onMotionSearchClick,}: Readonly<ActionsDropdownProps>) {- const { t } = useTranslation(["components/dialog", "views/replay", "common"]);+ const { t } = useTranslation([+ "components/dialog",+ "views/replay",+ "views/events",+ "common",+ ]);return (<DropdownMenu>@@ -42,6 +49,11 @@ export default function ActionsDropdown({<DropdownMenuItem onClick={onShareTimestampClick}>{t("recording.shareTimestamp.label", { ns: "components/dialog" })}</DropdownMenuItem>+ {onMotionSearchClick && (+ <DropdownMenuItem onClick={onMotionSearchClick}>+ {t("motionSearch.menuItem", { ns: "views/events" })}+ </DropdownMenuItem>+ )}{onDebugReplayClick && (<DropdownMenuItem onClick={onDebugReplayClick}>{t("title", { ns: "views/replay" })}diff --git a/web/src/components/overlay/MobileReviewSettingsDrawer.tsx b/web/src/components/overlay/MobileReviewSettingsDrawer.tsxindex c2daf6d051..273cb5946c 100644--- a/web/src/components/overlay/MobileReviewSettingsDrawer.tsx+++ b/web/src/components/overlay/MobileReviewSettingsDrawer.tsx@@ -3,7 +3,7 @@ import { baseUrl } from "@/api/baseUrl";import { Drawer, DrawerContent, DrawerTrigger } from "../ui/drawer";import { Button } from "../ui/button";import { FaArrowDown, FaCalendarAlt, FaCog, FaFilter } from "react-icons/fa";-import { LuBug, LuShare2 } from "react-icons/lu";+import { LuBug, LuSearch, LuShare2 } from "react-icons/lu";import { TimeRange } from "@/types/timeline";import { ExportContent, ExportPreviewDialog, ExportTab } from "./ExportDialog";import {@@ -46,6 +46,7 @@ const DRAWER_FEATURES = ["filter","debug-replay","share-timestamp",+ "motion-search",] as const;export type DrawerFeatures = (typeof DRAWER_FEATURES)[number];const DEFAULT_DRAWER_FEATURES: DrawerFeatures[] = [@@ -54,6 +55,7 @@ const DEFAULT_DRAWER_FEATURES: DrawerFeatures[] = ["filter","debug-replay","share-timestamp",+ "motion-search",];type MobileReviewSettingsDrawerProps = {@@ -75,6 +77,7 @@ type MobileReviewSettingsDrawerProps = {setDebugReplayMode?: (mode: ExportMode) => void;setDebugReplayRange?: (range: TimeRange | undefined) => void;onShareTimestamp?: (timestamp: number) => void;+ onMotionSearch?: () => void;onUpdateFilter: (filter: ReviewFilter) => void;setRange: (range: TimeRange | undefined) => void;setMode: (mode: ExportMode) => void;@@ -99,6 +102,7 @@ export default function MobileReviewSettingsDrawer({setDebugReplayMode = () => {},setDebugReplayRange = () => {},onShareTimestamp = () => {},+ onMotionSearch,onUpdateFilter,setRange,setMode,@@ -108,6 +112,7 @@ export default function MobileReviewSettingsDrawer({"views/recording","components/dialog","views/replay",+ "views/events","common",]);const isAdmin = useIsAdmin();@@ -343,27 +348,6 @@ export default function MobileReviewSettingsDrawer({{t("export")}</Button>)}- {features.includes("share-timestamp") && (- <Button- className="flex w-full items-center justify-center gap-2"- aria-label={t("recording.shareTimestamp.label", {- ns: "components/dialog",- })}- onClick={() => {- const initialTimestamp = Math.floor(currentTime);-- setShareTimestampAtOpen(initialTimestamp);- setCustomShareTimestamp(initialTimestamp);- setSelectedShareOption("current");- setDrawerMode("share-timestamp");- }}- >- <LuShare2 className="size-5 rounded-md bg-secondary-foreground stroke-secondary p-1" />- {t("recording.shareTimestamp.label", {- ns: "components/dialog",- })}- </Button>- )}{features.includes("calendar") && (<ButtonclassName="flex w-full items-center justify-center gap-2"@@ -390,6 +374,40 @@ export default function MobileReviewSettingsDrawer({{t("filter")}</Button>)}+ {features.includes("share-timestamp") && (+ <Button+ className="flex w-full items-center justify-center gap-2"+ aria-label={t("recording.shareTimestamp.label", {+ ns: "components/dialog",+ })}+ onClick={() => {+ const initialTimestamp = Math.floor(currentTime);++ setShareTimestampAtOpen(initialTimestamp);+ setCustomShareTimestamp(initialTimestamp);+ setSelectedShareOption("current");+ setDrawerMode("share-timestamp");+ }}+ >+ <LuShare2 className="size-5 rounded-md bg-secondary-foreground stroke-secondary p-1" />+ {t("recording.shareTimestamp.label", {+ ns: "components/dialog",+ })}+ </Button>+ )}+ {features.includes("motion-search") && onMotionSearch && (+ <Button+ className="flex w-full items-center justify-center gap-2"+ aria-label={t("motionSearch.menuItem", { ns: "views/events" })}+ onClick={() => {+ onMotionSearch();+ setDrawerMode("none");+ }}+ >+ <LuSearch className="size-5 rounded-md bg-secondary-foreground stroke-secondary p-1" />+ {t("motionSearch.menuItem", { ns: "views/events" })}+ </Button>+ )}{isAdmin && features.includes("debug-replay") && (<ButtonclassName="flex w-full items-center justify-center gap-2"diff --git a/web/src/pages/Events.tsx b/web/src/pages/Events.tsxindex bc5d56a7a0..393f895b0e 100644--- a/web/src/pages/Events.tsx+++ b/web/src/pages/Events.tsx@@ -56,11 +56,9 @@ export default function Events() {false,);- const [recording, setRecording] = useOverlayState<RecordingStartingPoint>(- "recording",- undefined,- false,- );+ const [recording, setRecording] = useOverlayState<+ RecordingStartingPoint | undefined+ >("recording", undefined, false);const [motionPreviewsCamera, setMotionPreviewsCamera] = useOverlayState<string | undefined>("motionPreviewsCamera", undefined);@@ -668,6 +666,10 @@ export default function Events() {filter={reviewFilter}updateFilter={onUpdateFilter}refreshData={reloadData}+ onMotionSearch={(camera) => {+ setMotionSearchCamera(camera);+ setRecording(undefined);+ }}/>);}diff --git a/web/src/views/motion-search/MotionSearchDialog.tsx b/web/src/views/motion-search/MotionSearchDialog.tsxindex 72f3497364..5b622c1607 100644--- a/web/src/views/motion-search/MotionSearchDialog.tsx+++ b/web/src/views/motion-search/MotionSearchDialog.tsx@@ -112,35 +112,8 @@ export default function MotionSearchDialog({}: MotionSearchDialogProps) {const { t } = useTranslation(["views/motionSearch", "common"]);const apiHost = useApiHost();- const [containerNode, setContainerNode] = useState<HTMLDivElement | null>(- null,- );- const [containerSize, setContainerSize] = useState({ width: 0, height: 0 });- const containerWidth = containerSize.width;- const containerHeight = containerSize.height;const [imageLoaded, setImageLoaded] = useState(false);- useEffect(() => {- if (!containerNode) {- return;- }-- const measure = () => {- const rect = containerNode.getBoundingClientRect();- setContainerSize((prev) =>- prev.width === rect.width && prev.height === rect.height- ? prev- : { width: rect.width, height: rect.height },- );- };-- measure();-- const observer = new ResizeObserver(() => measure());- observer.observe(containerNode);- return () => observer.disconnect();- }, [containerNode]);-const cameraConfig = useMemo(() => {if (!selectedCamera) return undefined;return config.cameras[selectedCamera];@@ -169,28 +142,6 @@ export default function MotionSearchDialog({setIsDrawingROI(true);}, [isSearching, polygonPoints.length, setIsDrawingROI, setPolygonPoints]);- const imageSize = useMemo(() => {- if (!containerWidth || !containerHeight || !cameraConfig) {- return { width: 0, height: 0 };- }-- const cameraAspectRatio =- cameraConfig.detect.width / cameraConfig.detect.height;- const availableAspectRatio = containerWidth / containerHeight;-- if (availableAspectRatio >= cameraAspectRatio) {- return {- width: containerHeight * cameraAspectRatio,- height: containerHeight,- };- }-- return {- width: containerWidth,- height: containerWidth / cameraAspectRatio,- };- }, [containerWidth, containerHeight, cameraConfig]);-useEffect(() => {setImageLoaded(false);}, [selectedCamera]);@@ -280,19 +231,9 @@ export default function MotionSearchDialog({height: "100%",}}>- <div- ref={setContainerNode}- className="relative flex w-full items-center justify-center overflow-hidden rounded-lg border bg-secondary"- style={{ aspectRatio: "16 / 9" }}- >+ <div className="relative flex aspect-video w-full items-center justify-center overflow-hidden rounded-lg border bg-secondary">{selectedCamera && cameraConfig ? (- <div- className="relative"- style={{- width: imageSize.width || "100%",- height: imageSize.height || "100%",- }}- >+ <div className="relative h-full w-full"><imgalt={t("dialog.previewAlt", {camera: selectedCamera,diff --git a/web/src/views/recording/RecordingView.tsx b/web/src/views/recording/RecordingView.tsxindex f19a86a17a..b0ba0bc487 100644--- a/web/src/views/recording/RecordingView.tsx+++ b/web/src/views/recording/RecordingView.tsx@@ -95,6 +95,7 @@ type RecordingViewProps = {filter?: ReviewFilter;updateFilter: (newFilter: ReviewFilter) => void;refreshData?: () => void;+ onMotionSearch?: (camera: string) => void;};export function RecordingView({startCamera,@@ -107,6 +108,7 @@ export function RecordingView({filter,updateFilter,refreshData,+ onMotionSearch,}: RecordingViewProps) {const { t } = useTranslation(["views/events", "components/dialog"]);const { data: config } = useSWR<FrigateConfig>("config");@@ -725,6 +727,9 @@ export function RecordingView({setCustomShareTimestamp(initialTimestamp);setShareTimestampOpen(true);}}+ onMotionSearchClick={+ onMotionSearch ? () => onMotionSearch(mainCamera) : undefined+ }onDebugReplayClick={isAdmin? () => {@@ -807,6 +812,9 @@ export function RecordingView({}}}onShareTimestamp={onShareReviewLink}+ onMotionSearch={+ onMotionSearch ? () => onMotionSearch(mainCamera) : undefined+ }onUpdateFilter={updateFilter}setRange={setExportRange}setMode={setExportMode}