-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
39 lines (37 loc) · 1.48 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# # # import the necessary packages
# # import argparse
# # construct the argument parse and parse the arguments
# ap = argparse.ArgumentParser()
# ap.add_argument("-n", "--name", required=True,
# help="name of the user")
# args = vars(ap.parse_args())
# # display a friendly message to the user
# print("Hi there {}, it's nice to meet you!".format(args["name"]))
# import argparse
# import imutils
# import cv2
# # construct the argument parser and parse the arguments
# ap = argparse.ArgumentParser()
# ap.add_argument("-i", "--input", required=True,
# help="path to input image")
# ap.add_argument("-o", "--output", required=True,
# help="path to output image")
# args = vars(ap.parse_args())
# # load the input image from disk
# image = cv2.imread(args["input"])
# # convert the image to grayscale, blur it, and threshold it
# gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# blurred = cv2.GaussianBlur(gray, (5,5), 0)
# thresh = cv2.threshold(blurred, 60, 255, cv2.THRESH_BINARY)[1]
# cnts = cv2.findContours(thresh.copy(), cv2.RETR_EXTERNAL,
# cv2.CHAIN_APPROX_SIMPLE)
# cnts = imutils.grab_contours(cnts)
# # loop over the contours and draw them on the input image
# for c in cnts:
# cv2.drawContours(image, [c], -1, (0, 0, 255), 2)
# # display the total number of shapes on the image
# text = "I found {} total shapes".format(len(cnts))
# cv2.putText(image, text, (10, 20), cv2.FONT_HERSHEY_SIMPLEX, 0.5,
# (0, 0, 255), 2)
# # write the output image to disk
# cv2.imwrite(args["output"], image)