From 1ba4502b07db997b2ef8e41975f1bc6ecb7851d8 Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Wed, 17 Apr 2024 21:27:04 -0500 Subject: [PATCH] motion tuner fixes and tweaks --- .../settings/MotionMaskEditPane.tsx | 45 ++--- web/src/components/settings/MotionTuner.tsx | 165 ++++++++++++------ .../settings/ObjectMaskEditPane.tsx | 133 +++++++------- web/src/components/settings/ZoneEditPane.tsx | 26 ++- web/src/components/ui/slider.tsx | 2 +- 5 files changed, 218 insertions(+), 153 deletions(-) diff --git a/web/src/components/settings/MotionMaskEditPane.tsx b/web/src/components/settings/MotionMaskEditPane.tsx index ff7a32a7e..d1a4833d8 100644 --- a/web/src/components/settings/MotionMaskEditPane.tsx +++ b/web/src/components/settings/MotionMaskEditPane.tsx @@ -248,7 +248,10 @@ export default function MotionMaskEditPane({
- + )} /> -
- - +
+
+ + +
diff --git a/web/src/components/settings/MotionTuner.tsx b/web/src/components/settings/MotionTuner.tsx index aa082092f..243a82992 100644 --- a/web/src/components/settings/MotionTuner.tsx +++ b/web/src/components/settings/MotionTuner.tsx @@ -27,6 +27,9 @@ import { Button } from "../ui/button"; import { Switch } from "../ui/switch"; import { Toaster } from "@/components/ui/sonner"; import { toast } from "sonner"; +import { Separator } from "../ui/separator"; +import { Link } from "react-router-dom"; +import { LuExternalLink } from "react-icons/lu"; type MotionTunerProps = { selectedCamera: string; @@ -45,9 +48,6 @@ export default function MotionTuner({ selectedCamera }: MotionTunerProps) { const [isLoading, setIsLoading] = useState(false); const [confirmationDialogOpen, setConfirmationDialogOpen] = useState(false); - // const [selectedCamera, setSelectedCamera] = useState(cameras[0]?.name); - const [nextSelectedCamera, setNextSelectedCamera] = useState(""); - const { send: sendMotionThreshold } = useMotionThreshold(selectedCamera); const { send: sendMotionContourArea } = useMotionContourArea(selectedCamera); const { send: sendImproveContrast } = useImproveContrast(selectedCamera); @@ -58,6 +58,12 @@ export default function MotionTuner({ selectedCamera }: MotionTunerProps) { improve_contrast: undefined, }); + const [origMotionSettings, setOrigMotionSettings] = useState({ + threshold: undefined, + contour_area: undefined, + improve_contrast: undefined, + }); + const cameraConfig = useMemo(() => { if (config && selectedCamera) { return config.cameras[selectedCamera]; @@ -71,6 +77,11 @@ export default function MotionTuner({ selectedCamera }: MotionTunerProps) { contour_area: cameraConfig.motion.contour_area, improve_contrast: cameraConfig.motion.improve_contrast, }); + setOrigMotionSettings({ + threshold: cameraConfig.motion.threshold, + contour_area: cameraConfig.motion.contour_area, + improve_contrast: cameraConfig.motion.improve_contrast, + }); } }, [cameraConfig]); @@ -150,15 +161,16 @@ export default function MotionTuner({ selectedCamera }: MotionTunerProps) { selectedCamera, ]); - const onCancel = useCallback(() => {}, []); + const onCancel = useCallback(() => { + setMotionSettings(origMotionSettings); + setChangedValue(false); + }, [origMotionSettings]); const handleDialog = useCallback( (save: boolean) => { if (save) { saveToConfig(); } - // setSelectedCamera(nextSelectedCamera); - setNextSelectedCamera(""); setConfirmationDialogOpen(false); setChangedValue(false); }, @@ -176,72 +188,117 @@ export default function MotionTuner({ selectedCamera }: MotionTunerProps) { Motion Detection Tuner +
+

+ Frigate uses motion detection as a first line check to see if there + is anything happening in the frame worth checking with object + detection. +

-
-
- { - handleMotionConfigChange({ threshold: value[0] }); - }} - /> - +
+ + Read the Motion Tuning Guide{" "} + +
-
- { - handleMotionConfigChange({ contour_area: value[0] }); - }} - /> - +
+ +
+
+
+ +
+

+ The threshold value dictates how much of a change in a pixel's + luminance is required to be considered motion.{" "} + Default: 30 +

+
+
+
+ { + handleMotionConfigChange({ threshold: value[0] }); + }} + /> +
+ {motionSettings.threshold} +
+
-
+
+
+ +
+

+ The contour area value is used to decide which groups of + changed pixels qualify as motion. Default: 10 +

+
+
+
+ { + handleMotionConfigChange({ contour_area: value[0] }); + }} + /> +
+ {motionSettings.contour_area} +
+
+
+ +
+
+ +
+ Improve contrast for darker scenes. Default: ON +
+
{ handleMotionConfigChange({ improve_contrast: isChecked }); }} /> -
-
-
-
Improve Contrast
-
Improve contrast for darker scenes.
-
-
-
-
-
- +
+
- + /> + ( + + Objects + + + The object type that that applies to this object mask. + + + + )} + /> + ( + + + + )} + /> +
+
+
+ + +
diff --git a/web/src/components/settings/ZoneEditPane.tsx b/web/src/components/settings/ZoneEditPane.tsx index 739a339c5..b5a0fe493 100644 --- a/web/src/components/settings/ZoneEditPane.tsx +++ b/web/src/components/settings/ZoneEditPane.tsx @@ -394,7 +394,7 @@ export default function ZoneEditPane({
- + )} /> -
- -
+ )} /> -
- -
+ )} /> -
- -
+ Objects @@ -490,14 +484,14 @@ export default function ZoneEditPane({ }} /> -
- -
+ + + ( - +
Alerts @@ -509,6 +503,7 @@ export default function ZoneEditPane({ @@ -518,7 +513,7 @@ export default function ZoneEditPane({ control={form.control} name="review_detections" render={({ field }) => ( - +
Detections @@ -530,6 +525,7 @@ export default function ZoneEditPane({ diff --git a/web/src/components/ui/slider.tsx b/web/src/components/ui/slider.tsx index 0f57209d8..8a3e93747 100644 --- a/web/src/components/ui/slider.tsx +++ b/web/src/components/ui/slider.tsx @@ -18,7 +18,7 @@ const Slider = React.forwardRef< - + )); Slider.displayName = SliderPrimitive.Root.displayName;