added prerecorded video support
This commit is contained in:
parent
f345468cbf
commit
880e039d5e
1 changed files with 11 additions and 2 deletions
|
@ -6,6 +6,12 @@ import time
|
|||
import os
|
||||
import datetime
|
||||
|
||||
def dir_path(string):
|
||||
if os.path.exists(string):
|
||||
return string
|
||||
else:
|
||||
raise NotADirectoryError(string)
|
||||
|
||||
def init_argparse() -> argparse.ArgumentParser:
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="FaceDetection",
|
||||
|
@ -22,7 +28,7 @@ def init_argparse() -> argparse.ArgumentParser:
|
|||
"-o", "--output", action='store_true', help="show the resultant directions"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-f", "--file", nargs="?", help="File to scan instead of using the camera. Useful for generating training data"
|
||||
"-f", "--file", type=dir_path, nargs="?", help="File to scan instead of using the camera. Useful for generating training data"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-s", "--no-screen", action='store_true', help="Do not show the successful frames"
|
||||
|
@ -72,6 +78,9 @@ def draw_dashboard(keep_stat_line = False):
|
|||
parser = init_argparse()
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.file:
|
||||
cap = cv2.VideoCapture(args.file)
|
||||
else:
|
||||
cap = cv2.VideoCapture(0, cv2.IMREAD_GRAYSCALE) # instead of grayscale you can also use -1, 0, or 1.
|
||||
faceCascade = cv2.CascadeClassifier(r"./cascades/lbpcascade_frontalface.xml") # CHECK THIS FIRST TROUBLE SHOOTING
|
||||
faceCascade_default = cv2.CascadeClassifier(r"./cascades/haarcascade_frontalface_default.xml")
|
||||
|
|
Loading…
Reference in a new issue