mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
Improve mask error (#11361)
* Don't apply masks / zones that are outside of the detect resolution * formatting
This commit is contained in:
parent
67bff1e79e
commit
b451d0a4f1
@ -157,26 +157,45 @@ def get_relative_coordinates(
|
|||||||
points = m.split(",")
|
points = m.split(",")
|
||||||
|
|
||||||
if any(x > "1.0" for x in points):
|
if any(x > "1.0" for x in points):
|
||||||
relative_masks.append(
|
rel_points = []
|
||||||
",".join(
|
for i in range(0, len(points), 2):
|
||||||
[
|
x = int(points[i])
|
||||||
f"{round(int(points[i]) / frame_shape[1], 3)},{round(int(points[i + 1]) / frame_shape[0], 3)}"
|
y = int(points[i + 1])
|
||||||
for i in range(0, len(points), 2)
|
|
||||||
]
|
if x > frame_shape[1] or y > frame_shape[0]:
|
||||||
|
logger.error(
|
||||||
|
f"Not applying mask due to invalid coordinates. {x},{y} is outside of the detection resolution {frame_shape[1]}x{frame_shape[0]}. Use the editor in the UI to correct the mask."
|
||||||
|
)
|
||||||
|
continue
|
||||||
|
|
||||||
|
rel_points.append(
|
||||||
|
f"{round(x / frame_shape[1], 3)},{round(y / frame_shape[0], 3)}"
|
||||||
)
|
)
|
||||||
)
|
|
||||||
|
relative_masks.append(",".join(rel_points))
|
||||||
else:
|
else:
|
||||||
relative_masks.append(m)
|
relative_masks.append(m)
|
||||||
|
|
||||||
mask = relative_masks
|
mask = relative_masks
|
||||||
elif isinstance(mask, str) and any(x > "1.0" for x in mask.split(",")):
|
elif isinstance(mask, str) and any(x > "1.0" for x in mask.split(",")):
|
||||||
points = mask.split(",")
|
points = mask.split(",")
|
||||||
mask = ",".join(
|
rel_points = []
|
||||||
[
|
|
||||||
f"{round(int(points[i]) / frame_shape[1], 3)},{round(int(points[i + 1]) / frame_shape[0], 3)}"
|
for i in range(0, len(points), 2):
|
||||||
for i in range(0, len(points), 2)
|
x = int(points[i])
|
||||||
]
|
y = int(points[i + 1])
|
||||||
)
|
|
||||||
|
if x > frame_shape[1] or y > frame_shape[0]:
|
||||||
|
logger.error(
|
||||||
|
f"Not applying mask due to invalid coordinates. {x},{y} is outside of the detection resolution {frame_shape[1]}x{frame_shape[0]}. Use the editor in the UI to correct the mask."
|
||||||
|
)
|
||||||
|
return []
|
||||||
|
|
||||||
|
rel_points.append(
|
||||||
|
f"{round(x / frame_shape[1], 3)},{round(y / frame_shape[0], 3)}"
|
||||||
|
)
|
||||||
|
|
||||||
|
mask = ",".join(rel_points)
|
||||||
|
|
||||||
return mask
|
return mask
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user