mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-01-27 06:28:30 +03:00
Don't use region for state classification models
This commit is contained in:
parent
271f5cf9d5
commit
34008bfd57
@ -229,30 +229,34 @@ class CustomStateClassificationProcessor(RealTimeProcessorApi):
|
|||||||
if not should_run:
|
if not should_run:
|
||||||
return
|
return
|
||||||
|
|
||||||
x, y, x2, y2 = calculate_region(
|
|
||||||
frame.shape,
|
|
||||||
crop[0],
|
|
||||||
crop[1],
|
|
||||||
crop[2],
|
|
||||||
crop[3],
|
|
||||||
224,
|
|
||||||
1.0,
|
|
||||||
)
|
|
||||||
|
|
||||||
rgb = cv2.cvtColor(frame, cv2.COLOR_YUV2RGB_I420)
|
rgb = cv2.cvtColor(frame, cv2.COLOR_YUV2RGB_I420)
|
||||||
frame = rgb[
|
height, width = rgb.shape[:2]
|
||||||
y:y2,
|
|
||||||
x:x2,
|
|
||||||
]
|
|
||||||
|
|
||||||
if frame.shape != (224, 224):
|
# Convert normalized crop coordinates to pixel values
|
||||||
try:
|
x1 = int(camera_config.crop[0] * width)
|
||||||
resized_frame = cv2.resize(frame, (224, 224))
|
y1 = int(camera_config.crop[1] * height)
|
||||||
except Exception:
|
x2 = int(camera_config.crop[2] * width)
|
||||||
logger.warning("Failed to resize image for state classification")
|
y2 = int(camera_config.crop[3] * height)
|
||||||
return
|
|
||||||
else:
|
# Clip coordinates to frame boundaries
|
||||||
resized_frame = frame
|
x1 = max(0, min(x1, width))
|
||||||
|
y1 = max(0, min(y1, height))
|
||||||
|
x2 = max(0, min(x2, width))
|
||||||
|
y2 = max(0, min(y2, height))
|
||||||
|
|
||||||
|
if x2 <= x1 or y2 <= y1:
|
||||||
|
logger.warning(
|
||||||
|
f"Invalid crop coordinates for {camera}: [{x1}, {y1}, {x2}, {y2}]"
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
|
frame = rgb[y1:y2, x1:x2]
|
||||||
|
|
||||||
|
try:
|
||||||
|
resized_frame = cv2.resize(frame, (224, 224))
|
||||||
|
except Exception:
|
||||||
|
logger.warning("Failed to resize image for state classification")
|
||||||
|
return
|
||||||
|
|
||||||
if self.interpreter is None:
|
if self.interpreter is None:
|
||||||
# When interpreter is None, always save (score is 0.0, which is < 1.0)
|
# When interpreter is None, always save (score is 0.0, which is < 1.0)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user