Skip to content

Commit

Permalink
added resize flag to argument parser
Browse files Browse the repository at this point in the history
  • Loading branch information
ShreenidhiBodas committed Apr 17, 2020
1 parent 8124c49 commit 5665010
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions test_grader.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,19 @@

# create argument parser
ap = argparse.ArgumentParser()
ap.add_argument('-i', '--image', help="path to the image")
ap.add_argument('-i', '--image', required=True, help="path to the image")
ap.add_argument('-c', '--crop', type=int, help="whether to crop image 1 if yes 0 if no")
args = vars(ap.parse_args())

#define the answer key
#answer key is a dictionary with zero based indexing fot the question and answers
ANSWER_KEY = { 0:1, 1:4, 2:0, 3:3, 4:1 }

#preprocess the image
image = cv2.imread(args["image"])
if args["crop"] == 1:
image = imutils.resize(cv2.imread(args["image"]), width=700)
else:
image = cv2.imread(args["image"])
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
blurred = cv2.GaussianBlur(gray, (5,5), 0)
edged = cv2.Canny(blurred, 75, 200)
Expand Down

0 comments on commit 5665010

Please sign in to comment.