diff --git a/main.py b/main.py index 601deab..bf4a622 100644 --- a/main.py +++ b/main.py @@ -52,7 +52,7 @@ if type(args["number"]) == type(selected): image = cv2.imread(args["image"]) image = cv2.resize(image, (image.shape[1]*2, image.shape[0]*2), interpolation = cv2.INTER_NEAREST) if args2.show: - cv2.imshow("Image", image) + cv2.imshow("Screw Length Detection", image) cv2.waitKey(0) gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) gray = cv2.GaussianBlur(gray, (7, 7), 0) @@ -64,7 +64,7 @@ edged = cv2.Canny(gray, 50, 100) edged = cv2.dilate(edged, None, iterations=1) edged = cv2.erode(edged, None, iterations=1) if args2.show: - cv2.imshow("Image", edged) + cv2.imshow("Screw Length Detection", edged) cv2.waitKey(0) # find contours in the edge map cnts = cv2.findContours(edged.copy(), cv2.RETR_EXTERNAL, @@ -160,7 +160,7 @@ for c in cnts: dimA = dA / pixelsPerMetric dimB = dB / pixelsPerMetric - if num == selected: + if num == num: iteml = larger(dimA, dimB) print("Screw Length (RAW): " + str(iteml)) iteml = sizeVexScrew(iteml) @@ -170,12 +170,13 @@ for c in cnts: cv2.putText(orig, "{:.5f}in".format(larger(dimA, dimB)), (int(trbrX + 20), int(trbrY)), cv2.FONT_HERSHEY_SIMPLEX, 0.65, (255, 255, 255), 2) - cv2.putText(orig, "{:.3f}in".format(iteml), # print screw length - (int(trbrX + 20), int(trbrY + 20)), cv2.FONT_HERSHEY_SIMPLEX, - 0.65, (255, 255, 255), 2) + if num > 1: + cv2.putText(orig, "{:.3f}in screw".format(iteml), # print screw length + (int(trbrX + 20), int(trbrY + 20)), cv2.FONT_HERSHEY_SIMPLEX, + 0.65, (255, 255, 255), 2) # show the output image - cv2.imshow("Image", orig) + cv2.imshow("Screw Length Detection", orig) cv2.waitKey(0)