Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: pixel_val_threshold on motion detection was being ignored #56

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/framegrab/motion.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ def __init__(self, pct_threshold: float = 1, val_threshold: int = 50) -> bool:
:param pct_threshold: Percent of pixels needed to change before motion is detected
"""
self.unused = True
self.threshold = 50
self.pixel_val_threshold = 50
self.pixel_val_threshold = val_threshold
self.pixel_pct_threshold = pct_threshold
self.log_pixel_percent = True

Expand Down Expand Up @@ -48,8 +47,8 @@ def motion_detected(self, new_img: np.ndarray) -> bool:
if new_img16.shape != self.base_img.shape:
return True

diff1 = np.abs(new_img16 - self.base_img) > self.threshold
diff2 = np.abs(new_img16 - self.base2) > self.threshold
diff1 = np.abs(new_img16 - self.base_img) > self.pixel_val_threshold
diff2 = np.abs(new_img16 - self.base2) > self.pixel_val_threshold

self.base2 = self.base_img
self.base_img = new_img
Expand Down
Loading