Ignore change on state change
This commit is contained in:
@@ -233,21 +233,28 @@ def detect_face(gray):
|
||||
|
||||
|
||||
def detect_motion(gray):
|
||||
if ignore_motion_due_to_light():
|
||||
log.debug("Ignoring motion due to light cooldown")
|
||||
return False
|
||||
light_cooldown = ignore_motion_due_to_light()
|
||||
|
||||
# If no previous frame exists, initialize it
|
||||
if not os.path.exists(PREV_IMG):
|
||||
cv2.imwrite(PREV_IMG, gray)
|
||||
log.debug("Initialized previous frame")
|
||||
return False
|
||||
|
||||
prev = cv2.imread(PREV_IMG, cv2.IMREAD_GRAYSCALE)
|
||||
|
||||
# Always update PREV_IMG so state stays aligned
|
||||
cv2.imwrite(PREV_IMG, gray)
|
||||
|
||||
# If we're in light cooldown, ignore motion but accept the frame
|
||||
if light_cooldown:
|
||||
log.debug("Ignoring motion due to light cooldown (state synced)")
|
||||
return False
|
||||
|
||||
diff = cv2.absdiff(prev, gray)
|
||||
mean_diff = np.mean(diff)
|
||||
|
||||
if mean_diff > 75:
|
||||
if mean_diff > 60:
|
||||
log.debug("Ignoring global brightness change (mean=%.2f)", mean_diff)
|
||||
return False
|
||||
|
||||
|
||||
Reference in New Issue
Block a user