我有以下代码从命令行获取输入。我想在 streamlit 中运行此代码,而不是从命令行获取参数的值,而是将它们设置为一些默认值,例如“-i”,我希望它默认打开相机。我怎样才能做到这一点?
def build_argparser():
parser = ArgumentParser()
general = parser.add_argument_group('General')
general.add_argument('-i', '--input', metavar="PATH", default='0',
help="(optional) Path to the input video " \
"('0' for the camera, default)")
general.add_argument('-o', '--output', metavar="PATH", default="",
help="(optional) Path to save the output video to")
general.add_argument('--no_show', action='store_true',
help="(optional) Do not display output")
general.add_argument('-tl', '--timelapse', action='store_true',
help="(optional) Auto-pause after each frame")
general.add_argument('-cw', '--crop_width', default=0, type=int,
help="(optional) Crop the input stream to this width " \
"(default: no crop). Both -cw and -ch parameters " \
"should be specified to use crop.")
general.add_argument('-ch', '--crop_height', default=0, type=int,
help="(optional) Crop the input stream to this height " \
"(default: no crop). Both -cw and -ch parameters " \
"should be specified to use crop.")
general.add_argument('--match_algo', default='HUNGARIAN', choices=MATCH_ALGO,
help="(optional)algorithm for face matching(default: %(default)s)")