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)
|
exit(12)
|
||||||
|
|
||||||
# Get the absolute path to the current directory
|
# 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
|
# The username of the user being authenticated
|
||||||
user = sys.argv[1]
|
user = sys.argv[1]
|
||||||
# The model file contents
|
# The model file contents
|
||||||
|
|
@ -202,9 +202,11 @@ screen_width = dsp.screen().width_in_pixels
|
||||||
screen_height = dsp.screen().height_in_pixels
|
screen_height = dsp.screen().height_in_pixels
|
||||||
if screen_height > screen_width:
|
if screen_height > screen_width:
|
||||||
landscape = False
|
landscape = False
|
||||||
# Get the height of the image
|
# Get the height of the image (which would be the width if screen is portait oriented)
|
||||||
height = video_capture.internal.get(cv2.CAP_PROP_FRAME_HEIGHT) or 1
|
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
|
# Calculate the amount the image has to shrink
|
||||||
scaling_factor = (max_height / height) or 1
|
scaling_factor = (max_height / height) or 1
|
||||||
|
|
||||||
|
|
@ -286,11 +288,18 @@ while True:
|
||||||
# Apply that factor to the frame
|
# Apply that factor to the frame
|
||||||
frame = cv2.resize(frame, None, fx=scaling_factor, fy=scaling_factor, interpolation=cv2.INTER_AREA)
|
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)
|
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
|
# Get all faces from that frame as encodings
|
||||||
# Upsamples 1 time
|
# Upsamples 1 time
|
||||||
face_locations = face_detector(gsframe, 1)
|
face_locations = face_detector(gsframe, 1)
|
||||||
|
|
||||||
# Loop through each face
|
# Loop through each face
|
||||||
for fl in face_locations:
|
for fl in face_locations:
|
||||||
if use_cnn:
|
if use_cnn:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue