Skip to content

Commit 25879d2

Browse files
committed
[detectors] Add downscale performance hit #401
1 parent f196a31 commit 25879d2

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

scenedetect/detectors/hash_detector.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,7 @@ def hash_frame(frame_img, hash_size, factor) -> numpy.ndarray:
179179
hash_img = dct_low_freq > med
180180

181181
return hash_img
182+
183+
@property
184+
def downscale_performance_hint(self) -> bool:
185+
return False

scenedetect/scene_detector.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ def event_buffer_length(self) -> int:
131131
"""
132132
return 0
133133

134+
@property
135+
def downscale_performance_hint(self) -> bool:
136+
"""Indicates if the detector's performance is improved by downscaling."""
137+
return True
138+
134139

135140
# TODO(v0.7): Remove this early, no point in keeping it around.
136141
class SparseSceneDetector(SceneDetector):

scenedetect/scene_manager.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1283,7 +1283,9 @@ def detect_scenes(
12831283
1 + min(max_y, frame_height) - min_y,
12841284
)
12851285
# Calculate downscale factor and log effective resolution.
1286-
if self.auto_downscale:
1286+
if self.auto_downscale and all(
1287+
detector.downscale_performance_hint for detector in self._detector_list
1288+
):
12871289
downscale_factor = compute_downscale_factor(max(effective_frame_size))
12881290
else:
12891291
downscale_factor = self.downscale

0 commit comments

Comments
 (0)