ocr_template_match.py: error: the following arguments are required: -i/--image, -t/--template

在运行信用卡数字识别的时候,出现以下错误,原因是需要在程序运行前输入规定参数值,才能运行

usage: ocr_template_match.py [-h] -i IMAGE -t TEMPLATE
ocr_template_match.py: error: the following arguments are required: -i/--image, -t/--template

参数设置:

# 设置参数
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--image", required=True,
	help="path to input image")
ap.add_argument("-t", "--template", required=True,
	help="path to template OCR-A image")
args = vars(ap.parse_args())

在这里插入图片描述
点击下拉按钮,选择Edit Configurations…
在这里插入图片描述
蓝框内填入指定参数
信用卡数字识别中填入的参数(多个参数之间用空格隔开):
-i D:\opencvdemo\数字识别\images\credit_card_01.png -t D:\opencvdemo\数字识别\images\ocr_a_reference.png
点击ok,再次程序,又会发现:。。。
注:如果参数是路径的话,像现在这样,一定要把路径写全,这里就要具体到是哪张图片,后缀.png

Traceback (most recent call last):
  File "D:/opencvdemo/数字识别/ocr_template_match.py", line 32, in <module>
    cv_show('img',img)
  File "D:/opencvdemo/数字识别/ocr_template_match.py", line 27, in cv_show
    cv2.imshow(name, img)
cv2.error: OpenCV(4.1.2) D:\Build\OpenCV\opencv-4.1.2\modules\highgui\src\window.cpp:384: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'cv::imshow'

这个报错是因为在路径名当中有中文夹杂,把路径中有中文的地方用英文替换,就不报错,正常运行了。
正常运行,输出框内会出现设置的参数(上面蓝框内输入的参数)

D:\Anaconda\python.exe D:/opencvdemo/idcardidentify/ocr_template_match.py -i D:\opencvdemo\idcardidentify\images\credit_card_01.png -t D:\opencvdemo\idcardidentify\images\ocr_a_reference.png
评论 14
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值