I am doing data extraction from scanned document.I am using the below code for constructing and parsing the arguments:
from PIL import Image
import pytesseract
import argparse
import cv2
import os
import re
import io
import json
import ftfy
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--image", required=True,
help="path to input image to be OCR'd")
ap.add_argument("-p", "--preprocess", type=str, default="thresh",
help="type of preprocessing to be done, choose from blur, linear, cubic or bilateral")
args = vars(ap.parse_args())
The line args = vars(ap.parse_args()) is throwing an error as below:
usage: [-h] -i IMAGE [-p PREPROCESS]
: error: the following arguments are required: -i/--image
An exception has occurred, use %tb to see the full traceback.
SystemExit: 2
C:\Users\Aditya\anaconda\lib\site-packages\IPython\core\interactiveshell.py:3339: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D.
warn("To exit: use 'exit', 'quit', or Ctrl-D.", stacklevel=1)
As I am new on working with images, so need help to solve this error.
ipythonconsole?ipyhonhelp shows:ipython [subcommand] [options] [-c cmd | -m mod | file] [--] [arg] ...The arguments for yourargparseare those[arg]after the--. If instead you are running this in ajupyternotebook, you can't useargparse.