我正在运行这段代码,但出现错误:
usage: ipykernel_launcher.py [-h] [-v VIDEO] [-a MIN_AREA]
ipykernel_launcher.py: error: unrecognized arguments: -f C:\Users\vivek\AppData\Roaming\jupyter\runtime\kernel-727a64d4-d054-4022-a74a-1046dfef03a6.json
An exception has occurred, use %tb to see the full traceback.
SystemExit: 2
我尝试研究argparse,但无法在代码中正确实现它。
# construct the argument parser and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-v", "--video", help="path to the video file")
ap.add_argument("-a", "--min-area", type=int, default=50, help="minimum
area size")
#default 50
args = vars(ap.parse_args())
HD = 768 , 576
#if the video argument is None, then we are reading from webcam
if args.get("video", None) is None:
camera = cv2.VideoCapture(0)
time.sleep(0.25)
# otherwise, we are reading from a video file
else:
camera = cv2.VideoCapture(args["video"])
tot_f_num = int(camera.get(cv2.CAP_PROP_FRAME_COUNT))
frame_rate_vid = int(camera.get(cv2.CAP_PROP_FPS))