mirror of
https://github.com/boltgolt/howdy.git
synced 2024-09-12 09:41:18 +02:00
removed xlib dependency and installation. Made rotation before face recognition config based
This commit is contained in:
parent
069bd5eed9
commit
a0166ccae3
4 changed files with 38 additions and 19 deletions
19
.vscode/launch.json
vendored
Normal file
19
.vscode/launch.json
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Python: Current File",
|
||||
"type": "python",
|
||||
"request": "launch",
|
||||
"program": "${file}",
|
||||
"console": "integratedTerminal",
|
||||
"args": [
|
||||
"matan"
|
||||
],
|
||||
"sudo": true
|
||||
}
|
||||
]
|
||||
}
|
|
@ -118,11 +118,6 @@ log("Upgrading numpy to the latest version")
|
|||
# Update numpy
|
||||
handleStatus(subprocess.call(["pip3", "install", "--upgrade", "numpy"]))
|
||||
|
||||
log("Installing xlib")
|
||||
|
||||
# Install xlib
|
||||
handleStatus(subprocess.call(["pip3", "install", "--upgrade", "python3-xlib"]))
|
||||
|
||||
log("Downloading and unpacking data files")
|
||||
|
||||
# Run the bash script to download and unpack the .dat files needed
|
||||
|
|
|
@ -22,7 +22,6 @@ import subprocess
|
|||
import snapshot
|
||||
import numpy as np
|
||||
import _thread as thread
|
||||
import Xlib.display as display
|
||||
|
||||
from i18n import _
|
||||
from recorders.video_capture import VideoCapture
|
||||
|
@ -151,6 +150,7 @@ end_report = config.getboolean("debug", "end_report", fallback=False)
|
|||
capture_failed = config.getboolean("snapshots", "capture_failed", fallback=False)
|
||||
capture_successful = config.getboolean("snapshots", "capture_successful", fallback=False)
|
||||
gtk_stdout = config.getboolean("debug", "gtk_stdout", fallback=False)
|
||||
rotate = config.getint("video", "rotate", fallback=0)
|
||||
|
||||
# Send the gtk outupt to the terminal if enabled in the config
|
||||
gtk_pipe = sys.stdout if gtk_stdout else subprocess.DEVNULL
|
||||
|
@ -195,17 +195,9 @@ del lock
|
|||
# Fetch the max frame height
|
||||
max_height = config.getfloat("video", "max_height", fallback=0.0)
|
||||
|
||||
# Get screen orientation
|
||||
landscape = True
|
||||
dsp = display.Display()
|
||||
screen_width = dsp.screen().width_in_pixels
|
||||
screen_height = dsp.screen().height_in_pixels
|
||||
if screen_height > screen_width:
|
||||
landscape = False
|
||||
# Get the height of the image (which would be the width if screen is portrait oriented)
|
||||
if landscape:
|
||||
height = video_capture.internal.get(cv2.CAP_PROP_FRAME_HEIGHT) or 1
|
||||
else:
|
||||
height = video_capture.internal.get(cv2.CAP_PROP_FRAME_HEIGHT) or 1
|
||||
if rotate == 2:
|
||||
height = video_capture.internal.get(cv2.CAP_PROP_FRAME_WIDTH) or 1
|
||||
# Calculate the amount the image has to shrink
|
||||
scaling_factor = (max_height / height) or 1
|
||||
|
@ -288,9 +280,16 @@ while True:
|
|||
# Apply that factor to the frame
|
||||
frame = cv2.resize(frame, None, fx=scaling_factor, fy=scaling_factor, interpolation=cv2.INTER_AREA)
|
||||
gsframe = cv2.resize(gsframe, None, fx=scaling_factor, fy=scaling_factor, interpolation=cv2.INTER_AREA)
|
||||
# If orientation is portrait
|
||||
# Alternate checking photo rotated clockwise and counter clockwise (since we don't know which side portrait is to)
|
||||
if not landscape:
|
||||
# If camera is configured to rotate = 1, check portrait in addition to landscape
|
||||
if rotate == 1:
|
||||
if frames % 3 == 1:
|
||||
frame = cv2.rotate(frame, cv2.ROTATE_90_COUNTERCLOCKWISE)
|
||||
gsframe = cv2.rotate(gsframe, cv2.ROTATE_90_COUNTERCLOCKWISE)
|
||||
if frames % 3 == 2:
|
||||
frame = cv2.rotate(frame, cv2.ROTATE_90_CLOCKWISE)
|
||||
gsframe = cv2.rotate(gsframe, cv2.ROTATE_90_CLOCKWISE)
|
||||
# If camera is configured to rotate = 2, check portrait orientation
|
||||
elif rotate == 2:
|
||||
if frames % 2 == 0:
|
||||
frame = cv2.rotate(frame, cv2.ROTATE_90_COUNTERCLOCKWISE)
|
||||
gsframe = cv2.rotate(gsframe, cv2.ROTATE_90_COUNTERCLOCKWISE)
|
||||
|
|
|
@ -80,6 +80,12 @@ force_mjpeg = false
|
|||
# OPENCV only.
|
||||
exposure = -1
|
||||
|
||||
# Rotate captured frames so faces are upright.
|
||||
# Check landscape orientation only: rotate = 0
|
||||
# Check landscape and portrait orientation: rotate = 1
|
||||
# Check portrait orientation only: rotate = 2
|
||||
rotate = 0
|
||||
|
||||
[snapshots]
|
||||
# Capture snapshots of failed login attempts and save them to disk with metadata
|
||||
# Snapshots are saved to the "snapshots" folder
|
||||
|
|
Loading…
Reference in a new issue