add show option
This commit is contained in:
parent
9d6d1c9bed
commit
4c789e514b
11
main.py
11
main.py
@ -35,16 +35,19 @@ ap.add_argument("-w", "--width", type=float, required=True,
|
||||
help="width of the left-most object in the image (in inches)")
|
||||
ap.add_argument("-n", "--number", type=int, required=False,
|
||||
help="object # to measure (from left to right)")
|
||||
ap.add_argument("-s", "--show", type=bool, required=False,
|
||||
ap.add_argument("-s", "--show", action="store_true",
|
||||
help="show on the screen")
|
||||
args = vars(ap.parse_args())
|
||||
|
||||
args2 = ap.parse_args()
|
||||
selected = 2
|
||||
if type(args["number"]) == type(selected):
|
||||
selected = args["number"]
|
||||
|
||||
# load the image, convert it to grayscale, and blur it slightly
|
||||
image = cv2.imread(args["image"])
|
||||
if args2.show:
|
||||
cv2.imshow("Image", image)
|
||||
cv2.waitKey(0)
|
||||
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
||||
gray = cv2.GaussianBlur(gray, (7, 7), 0)
|
||||
|
||||
@ -54,7 +57,7 @@ gray = cv2.GaussianBlur(gray, (7, 7), 0)
|
||||
edged = cv2.Canny(gray, 50, 100)
|
||||
edged = cv2.dilate(edged, None, iterations=1)
|
||||
edged = cv2.erode(edged, None, iterations=1)
|
||||
if args["show"] == True:
|
||||
if args2.show:
|
||||
cv2.imshow("Image", edged)
|
||||
cv2.waitKey(0)
|
||||
# find contours in the edge map
|
||||
@ -162,7 +165,7 @@ for c in cnts:
|
||||
iteml = sizeVexScrew(iteml)
|
||||
print("Rounded Length: " + str(iteml))
|
||||
# draw the object sizes on the image
|
||||
if args["show"] == True:
|
||||
if args2.show:
|
||||
cv2.putText(orig, "{:.5f}in".format(dimA),
|
||||
(int(tltrX - 15), int(tltrY - 10)), cv2.FONT_HERSHEY_SIMPLEX,
|
||||
0.65, (255, 255, 255), 2)
|
||||
|
Loading…
x
Reference in New Issue
Block a user