Added vflip
This commit is contained in:
@@ -8,6 +8,7 @@ import time
|
||||
import requests
|
||||
import logging
|
||||
import sys
|
||||
import argparse
|
||||
|
||||
# ==================================================
|
||||
# Logging
|
||||
@@ -27,6 +28,21 @@ logging.basicConfig(
|
||||
|
||||
log = logging.getLogger("desk_presence")
|
||||
|
||||
# ==================================================
|
||||
# Arguments
|
||||
# ==================================================
|
||||
parser = argparse.ArgumentParser(description="Desk presence detection")
|
||||
parser.add_argument(
|
||||
"--vflip",
|
||||
action="store_true",
|
||||
help="Flip captured image vertically before processing",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
VFLIP = args.vflip
|
||||
|
||||
if VFLIP:
|
||||
log.info("Vertical flip enabled")
|
||||
|
||||
# ==================================================
|
||||
# Camera
|
||||
# ==================================================
|
||||
@@ -231,8 +247,8 @@ def detect_motion(gray):
|
||||
diff = cv2.absdiff(prev, gray)
|
||||
mean_diff = np.mean(diff)
|
||||
|
||||
if mean_diff > 18:
|
||||
log.debug("Ignoring global brightness change (mean=%0.2f)", mean_diff)
|
||||
if mean_diff > 75:
|
||||
log.debug("Ignoring global brightness change (mean=%.2f)", mean_diff)
|
||||
return False
|
||||
|
||||
_, thresh = cv2.threshold(diff, 30, 255, cv2.THRESH_BINARY)
|
||||
@@ -267,6 +283,9 @@ def main_loop():
|
||||
time.sleep(30)
|
||||
continue
|
||||
|
||||
if VFLIP:
|
||||
frame = cv2.flip(frame, 0)
|
||||
|
||||
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
|
||||
|
||||
face = detect_face(gray)
|
||||
|
||||
Reference in New Issue
Block a user