mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-08 20:25:26 +03:00
Ensure that crop is 16:9
This commit is contained in:
parent
781a7500f3
commit
755477a84b
@ -81,6 +81,11 @@ class PendingReviewSegment:
|
||||
region = calculate_16_9_crop(
|
||||
camera_config.frame_shape, min_x, min_y, max_x, max_y
|
||||
)
|
||||
|
||||
# could not find suitable 16:9 region
|
||||
if not region:
|
||||
return
|
||||
|
||||
color_frame = cv2.cvtColor(frame, cv2.COLOR_YUV2BGR_I420)
|
||||
color_frame = color_frame[region[1] : region[3], region[0] : region[2]]
|
||||
width = int(THUMB_HEIGHT * color_frame.shape[1] / color_frame.shape[0])
|
||||
|
||||
@ -231,6 +231,9 @@ def calculate_16_9_crop(frame_shape, xmin, ymin, xmax, ymax, multiplier=1.25):
|
||||
# if 16:9 by height is too small
|
||||
if aspect_y_size < y_size or aspect_y_size > frame_shape[0]:
|
||||
x_size = int((16 / 9) * y_size) // 4 * 4
|
||||
|
||||
if x_size / y_size > 1.8:
|
||||
return None
|
||||
else:
|
||||
y_size = aspect_y_size // 4 * 4
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user