from imutils.video import VideoStream
import argparse
import imutils
import time
import cv2
import os
import sys
ap = argparse.ArgumentParser()
ap.add_argument("-c" "/--
cascade/Haarcascade_frontalface_default.xml",required=True,
help="path to where the face cascade resides")
ap.add_argument("-o" "/--datasets/andrian",
help="path to your output",required=True)
args = vars(ap.parse_args())
detector=cv2.CascadeClassifier(args["C/users/fridah/pycharmprojects/attendance_system/ cascade"])
print("[INFO] starting video stream...")
vs = VideoStream(src=0).start()
time.sleep(2.0)
total = 0
while True:
frame = vs.read()
orig = frame.copy()
frame = imutils.resize(frame, width=400)
rects = detector.detectMultiScale(
cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY), scaleFactor=1.1,
minNeighbors=5, minSize=(30, 30))
# loop over the face detections and draw them on the frame
for (x, y, w, h) in rects:
cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 2)
cv2.imshow("Frame", frame)
key = cv2.waitKey(1) & 0xFF
if key == ord("k"):
p = os.path.sep.join([args["output"], "{}.png".format(
str(total).zfill(5))])
cv2.imwrite(p, orig)
total += 1
elif key == ord("q"):
break
print("[INFO] {} face images stored".format(total))
print("[INFO] cleaning up...")
cv2.destroyAllWindows()
vs.stop()
一旦我尝试运行该程序,它就会给出以下错误:我已经尝试修复,请您帮忙吗?arg解析器每次都会给出错误 数据集.py:错误:需要以下参数:-c /- 级联/Haarcascade_frontalface_default.xml,-o /-datasets / andrian