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