mirror of
https://github.com/boltgolt/howdy.git
synced 2024-09-12 09:41:18 +02:00
if orientation is portrait, rotate image 90 degrees before scanning for faces
This commit is contained in:
parent
e4faf1c5bf
commit
3f20e05da4
2 changed files with 35 additions and 7 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
|
||||
}
|
||||
]
|
||||
}
|
|
@ -102,8 +102,8 @@ if len(sys.argv) < 2:
|
|||
exit(12)
|
||||
|
||||
# Get the absolute path to the current directory
|
||||
PATH = os.path.abspath(__file__ + "/..")
|
||||
|
||||
#PATH = os.path.abspath(__file__ + "/..")
|
||||
PATH = "/usr/lib/security/howdy"
|
||||
# The username of the user being authenticated
|
||||
user = sys.argv[1]
|
||||
# The model file contents
|
||||
|
@ -202,9 +202,11 @@ 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
|
||||
height = video_capture.internal.get(cv2.CAP_PROP_FRAME_HEIGHT) or 1
|
||||
|
||||
# Get the height of the image (which would be the width if screen is portait 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_WIDTH) or 1
|
||||
# Calculate the amount the image has to shrink
|
||||
scaling_factor = (max_height / height) or 1
|
||||
|
||||
|
@ -286,11 +288,18 @@ 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 orientaion is portrait
|
||||
# Alternate checking photo rotated clockwise and counter clockwise (since we don't know which side portrait is to)
|
||||
if not landscape:
|
||||
if frames % 2 == 0:
|
||||
frame = cv2.rotate(frame, cv2.ROTATE_90_COUNTERCLOCKWISE)
|
||||
gsframe = cv2.rotate(gsframe, cv2.ROTATE_90_COUNTERCLOCKWISE)
|
||||
else:
|
||||
frame = cv2.rotate(frame, cv2.ROTATE_90_CLOCKWISE)
|
||||
gsframe = cv2.rotate(gsframe, cv2.ROTATE_90_CLOCKWISE)
|
||||
# Get all faces from that frame as encodings
|
||||
# Upsamples 1 time
|
||||
face_locations = face_detector(gsframe, 1)
|
||||
|
||||
# Loop through each face
|
||||
for fl in face_locations:
|
||||
if use_cnn:
|
||||
|
|
Loading…
Reference in a new issue