mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-03-27 02:28:22 +03:00
tweaks
This commit is contained in:
parent
7badcbdbeb
commit
4f358c376f
@ -514,7 +514,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"motionMaskLabel": "Motion Mask {{number}}",
|
"motionMaskLabel": "Motion Mask {{number}}",
|
||||||
"objectMaskLabel": "Object Mask {{number}} ({{label}})",
|
"objectMaskLabel": "Object Mask {{number}}",
|
||||||
"form": {
|
"form": {
|
||||||
"zoneName": {
|
"zoneName": {
|
||||||
"error": {
|
"error": {
|
||||||
@ -636,6 +636,7 @@
|
|||||||
},
|
},
|
||||||
"add": "New Motion Mask",
|
"add": "New Motion Mask",
|
||||||
"edit": "Edit Motion Mask",
|
"edit": "Edit Motion Mask",
|
||||||
|
"defaultName": "Motion Mask {{number}}",
|
||||||
"context": {
|
"context": {
|
||||||
"title": "Motion masks are used to prevent unwanted types of motion from triggering detection (example: tree branches, camera timestamps). Motion masks should be used <em>very sparingly</em>, over-masking will make it more difficult for objects to be tracked."
|
"title": "Motion masks are used to prevent unwanted types of motion from triggering detection (example: tree branches, camera timestamps). Motion masks should be used <em>very sparingly</em>, over-masking will make it more difficult for objects to be tracked."
|
||||||
},
|
},
|
||||||
|
|||||||
@ -85,7 +85,7 @@ export default function MotionMaskEditPane({
|
|||||||
const count = polygons.filter((poly) => poly.type == "motion_mask").length;
|
const count = polygons.filter((poly) => poly.type == "motion_mask").length;
|
||||||
|
|
||||||
return t("masksAndZones.motionMasks.defaultName", {
|
return t("masksAndZones.motionMasks.defaultName", {
|
||||||
number: count + 1,
|
number: count,
|
||||||
});
|
});
|
||||||
}, [polygons, t]);
|
}, [polygons, t]);
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ export default function MotionMaskEditPane({
|
|||||||
|
|
||||||
const count = polygons.filter((poly) => poly.type == "motion_mask").length;
|
const count = polygons.filter((poly) => poly.type == "motion_mask").length;
|
||||||
|
|
||||||
return `motion_mask_${count + 1}`;
|
return `motion_mask_${count}`;
|
||||||
}, [polygons]);
|
}, [polygons]);
|
||||||
|
|
||||||
const polygonArea = useMemo(() => {
|
const polygonArea = useMemo(() => {
|
||||||
|
|||||||
@ -90,19 +90,10 @@ export default function ObjectMaskEditPane({
|
|||||||
|
|
||||||
const count = polygons.filter((poly) => poly.type == "object_mask").length;
|
const count = polygons.filter((poly) => poly.type == "object_mask").length;
|
||||||
|
|
||||||
let objectType = "";
|
|
||||||
const objects = polygon?.objects[0];
|
|
||||||
if (objects === undefined) {
|
|
||||||
objectType = t("masksAndZones.zones.allObjects");
|
|
||||||
} else {
|
|
||||||
objectType = getTranslatedLabel(objects);
|
|
||||||
}
|
|
||||||
|
|
||||||
return t("masksAndZones.objectMaskLabel", {
|
return t("masksAndZones.objectMaskLabel", {
|
||||||
number: count + 1,
|
number: count,
|
||||||
label: objectType,
|
|
||||||
});
|
});
|
||||||
}, [polygons, polygon, t]);
|
}, [polygons, t]);
|
||||||
|
|
||||||
const defaultId = useMemo(() => {
|
const defaultId = useMemo(() => {
|
||||||
if (!polygons) {
|
if (!polygons) {
|
||||||
@ -111,7 +102,7 @@ export default function ObjectMaskEditPane({
|
|||||||
|
|
||||||
const count = polygons.filter((poly) => poly.type == "object_mask").length;
|
const count = polygons.filter((poly) => poly.type == "object_mask").length;
|
||||||
|
|
||||||
return `object_mask_${count + 1}`;
|
return `object_mask_${count}`;
|
||||||
}, [polygons]);
|
}, [polygons]);
|
||||||
|
|
||||||
const formSchema = z.object({
|
const formSchema = z.object({
|
||||||
|
|||||||
@ -321,6 +321,7 @@ export function PolygonCanvas({
|
|||||||
isActive={index === activePolygonIndex}
|
isActive={index === activePolygonIndex}
|
||||||
isHovered={index === hoveredPolygonIndex}
|
isHovered={index === hoveredPolygonIndex}
|
||||||
isFinished={polygon.isFinished}
|
isFinished={polygon.isFinished}
|
||||||
|
enabled={polygon.enabled}
|
||||||
color={polygon.color}
|
color={polygon.color}
|
||||||
handlePointDragMove={handlePointDragMove}
|
handlePointDragMove={handlePointDragMove}
|
||||||
handleGroupDragEnd={handleGroupDragEnd}
|
handleGroupDragEnd={handleGroupDragEnd}
|
||||||
@ -350,6 +351,7 @@ export function PolygonCanvas({
|
|||||||
isActive={true}
|
isActive={true}
|
||||||
isHovered={activePolygonIndex === hoveredPolygonIndex}
|
isHovered={activePolygonIndex === hoveredPolygonIndex}
|
||||||
isFinished={polygons[activePolygonIndex].isFinished}
|
isFinished={polygons[activePolygonIndex].isFinished}
|
||||||
|
enabled={polygons[activePolygonIndex].enabled}
|
||||||
color={polygons[activePolygonIndex].color}
|
color={polygons[activePolygonIndex].color}
|
||||||
handlePointDragMove={handlePointDragMove}
|
handlePointDragMove={handlePointDragMove}
|
||||||
handleGroupDragEnd={handleGroupDragEnd}
|
handleGroupDragEnd={handleGroupDragEnd}
|
||||||
|
|||||||
@ -24,6 +24,7 @@ type PolygonDrawerProps = {
|
|||||||
isActive: boolean;
|
isActive: boolean;
|
||||||
isHovered: boolean;
|
isHovered: boolean;
|
||||||
isFinished: boolean;
|
isFinished: boolean;
|
||||||
|
enabled?: boolean;
|
||||||
color: number[];
|
color: number[];
|
||||||
handlePointDragMove: (e: KonvaEventObject<MouseEvent | TouchEvent>) => void;
|
handlePointDragMove: (e: KonvaEventObject<MouseEvent | TouchEvent>) => void;
|
||||||
handleGroupDragEnd: (e: KonvaEventObject<MouseEvent | TouchEvent>) => void;
|
handleGroupDragEnd: (e: KonvaEventObject<MouseEvent | TouchEvent>) => void;
|
||||||
@ -39,6 +40,7 @@ export default function PolygonDrawer({
|
|||||||
isActive,
|
isActive,
|
||||||
isHovered,
|
isHovered,
|
||||||
isFinished,
|
isFinished,
|
||||||
|
enabled = true,
|
||||||
color,
|
color,
|
||||||
handlePointDragMove,
|
handlePointDragMove,
|
||||||
handleGroupDragEnd,
|
handleGroupDragEnd,
|
||||||
@ -53,6 +55,26 @@ export default function PolygonDrawer({
|
|||||||
const groupRef = useRef<Konva.Group>(null);
|
const groupRef = useRef<Konva.Group>(null);
|
||||||
const [cursor, setCursor] = useState("default");
|
const [cursor, setCursor] = useState("default");
|
||||||
|
|
||||||
|
const patternCanvas = useMemo(() => {
|
||||||
|
if (enabled) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
const canvas = document.createElement("canvas");
|
||||||
|
canvas.width = 10;
|
||||||
|
canvas.height = 10;
|
||||||
|
const ctx = canvas.getContext("2d");
|
||||||
|
if (ctx) {
|
||||||
|
ctx.strokeStyle = "rgba(0, 0, 0, 0.3)";
|
||||||
|
ctx.lineWidth = 2;
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(10, 0);
|
||||||
|
ctx.lineTo(0, 10);
|
||||||
|
ctx.stroke();
|
||||||
|
}
|
||||||
|
return canvas as unknown as HTMLImageElement;
|
||||||
|
}, [enabled]);
|
||||||
|
|
||||||
const handleMouseOverPoint = (
|
const handleMouseOverPoint = (
|
||||||
e: KonvaEventObject<MouseEvent | TouchEvent>,
|
e: KonvaEventObject<MouseEvent | TouchEvent>,
|
||||||
) => {
|
) => {
|
||||||
@ -180,6 +202,15 @@ export default function PolygonDrawer({
|
|||||||
: setCursor("default")
|
: setCursor("default")
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
{!enabled && isFinished && (
|
||||||
|
<Line
|
||||||
|
points={flattenedPoints}
|
||||||
|
closed={isFinished}
|
||||||
|
fillPriority="pattern"
|
||||||
|
fillPatternImage={patternCanvas}
|
||||||
|
listening={false}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
{isFinished && isActive && (
|
{isFinished && isActive && (
|
||||||
<Line
|
<Line
|
||||||
name="unfilled-line"
|
name="unfilled-line"
|
||||||
|
|||||||
@ -248,9 +248,7 @@ export default function PolygonItem({
|
|||||||
|
|
||||||
<div
|
<div
|
||||||
key={index}
|
key={index}
|
||||||
className={`transition-background my-1.5 flex flex-row items-center justify-between rounded-lg p-1 duration-100 ${
|
className="transition-background my-1.5 flex flex-row items-center justify-between rounded-lg p-1 duration-100"
|
||||||
polygon.enabled === false ? "opacity-50" : ""
|
|
||||||
}`}
|
|
||||||
data-index={index}
|
data-index={index}
|
||||||
onMouseEnter={() => setHoveredPolygonIndex(index)}
|
onMouseEnter={() => setHoveredPolygonIndex(index)}
|
||||||
onMouseLeave={() => setHoveredPolygonIndex(null)}
|
onMouseLeave={() => setHoveredPolygonIndex(null)}
|
||||||
|
|||||||
@ -454,7 +454,7 @@ export default function ZoneEditPane({
|
|||||||
friendlyNameQuery = `&cameras.${polygon?.camera}.zones.${zoneName}.friendly_name=${encodeURIComponent(friendly_name)}`;
|
friendlyNameQuery = `&cameras.${polygon?.camera}.zones.${zoneName}.friendly_name=${encodeURIComponent(friendly_name)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const enabledQuery = `&cameras.${polygon?.camera}.zones.${zoneName}.enabled=${enabled}`;
|
const enabledQuery = `&cameras.${polygon?.camera}.zones.${zoneName}.enabled=${enabled ? "True" : "False"}`;
|
||||||
|
|
||||||
axios
|
axios
|
||||||
.put(
|
.put(
|
||||||
|
|||||||
@ -169,6 +169,7 @@ export default function MasksAndZonesView({
|
|||||||
objects: [],
|
objects: [],
|
||||||
camera: selectedCamera,
|
camera: selectedCamera,
|
||||||
color: polygonColor,
|
color: polygonColor,
|
||||||
|
enabled: true,
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
@ -242,7 +243,7 @@ export default function MasksAndZonesView({
|
|||||||
distances:
|
distances:
|
||||||
zoneData.distances?.map((distance) => parseFloat(distance)) ?? [],
|
zoneData.distances?.map((distance) => parseFloat(distance)) ?? [],
|
||||||
isFinished: true,
|
isFinished: true,
|
||||||
color: zoneData.enabled ? zoneData.color : [100, 100, 100],
|
color: zoneData.color,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -269,7 +270,7 @@ export default function MasksAndZonesView({
|
|||||||
),
|
),
|
||||||
distances: [],
|
distances: [],
|
||||||
isFinished: true,
|
isFinished: true,
|
||||||
color: maskData.enabled ? [0, 0, 255] : [100, 100, 100],
|
color: [0, 0, 255],
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -292,7 +293,7 @@ export default function MasksAndZonesView({
|
|||||||
),
|
),
|
||||||
distances: [],
|
distances: [],
|
||||||
isFinished: true,
|
isFinished: true,
|
||||||
color: maskData.enabled ? [128, 128, 128] : [80, 80, 80],
|
color: [128, 128, 128],
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -329,7 +330,7 @@ export default function MasksAndZonesView({
|
|||||||
),
|
),
|
||||||
distances: [],
|
distances: [],
|
||||||
isFinished: true,
|
isFinished: true,
|
||||||
color: maskData.enabled ? [128, 128, 128] : [80, 80, 80],
|
color: [128, 128, 128],
|
||||||
};
|
};
|
||||||
objectMaskIndex++;
|
objectMaskIndex++;
|
||||||
return [newMask];
|
return [newMask];
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user